Upload project files
This commit is contained in:
8
Runtime/Cloner/Contracts/Effector.meta
Normal file
8
Runtime/Cloner/Contracts/Effector.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 107650ad99360724989708b1799990a5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
84
Runtime/Cloner/Contracts/Effector/EffectorBase.cs
Normal file
84
Runtime/Cloner/Contracts/Effector/EffectorBase.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public abstract class EffectorBase : MonoBehaviour
|
||||
{
|
||||
public float strength = 1.0f;
|
||||
|
||||
public List<FieldData> fieldDataList = new();
|
||||
|
||||
public EventHandler propertyChanged;
|
||||
|
||||
protected float4x4 effectorMatrix;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
foreach (var item in fieldDataList)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
item.field.propertyChanged += OnPropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
foreach (var item in fieldDataList)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
item.field.propertyChanged -= OnPropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(object sender, EventArgs e)
|
||||
{
|
||||
propertyChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
for (var i = 0; i < fieldDataList.Count; i++)
|
||||
{
|
||||
fieldDataList[i].field.Initialize();
|
||||
}
|
||||
|
||||
effectorMatrix = transform.localToWorldMatrix;
|
||||
}
|
||||
|
||||
public virtual void Operate(int index, float4x4 nodeWorldMatrix, ReadOnlySpan<PointData> points, ref float4x4 pointWorldMatrix, ref bool isValid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected float CalculateFieldsWeight(float3 worldPosition)
|
||||
{
|
||||
var weight = 1.0f;
|
||||
var fieldCount = fieldDataList.Count;
|
||||
for (var i = 0; i < fieldCount; i++)
|
||||
{
|
||||
var fieldData = fieldDataList[i];
|
||||
if (!fieldData.enable || fieldData.opacity <= 0.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
weight = math.lerp(weight, fieldData.field.Operate(worldPosition), fieldData.opacity);
|
||||
}
|
||||
|
||||
weight *= strength;
|
||||
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Cloner/Contracts/Effector/EffectorBase.cs.meta
Normal file
2
Runtime/Cloner/Contracts/Effector/EffectorBase.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7ccd97731dd96b4fa2c848321321710
|
||||
6
Runtime/Cloner/Contracts/Effector/IterateEffectorBase.cs
Normal file
6
Runtime/Cloner/Contracts/Effector/IterateEffectorBase.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public class IterateEffectorBase : EffectorBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5144695703dc3434c93bc038017a3ac3
|
||||
8
Runtime/Cloner/Contracts/Field.meta
Normal file
8
Runtime/Cloner/Contracts/Field.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8ea1a2aeb0489a4babf1d34f2ff07c2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
42
Runtime/Cloner/Contracts/Field/FieldBase.cs
Normal file
42
Runtime/Cloner/Contracts/Field/FieldBase.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public abstract class FieldBase : MonoBehaviour
|
||||
{
|
||||
public RemappingSetting remappingSetting = new();
|
||||
|
||||
public EventHandler propertyChanged;
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract float Operate(float3 position);
|
||||
|
||||
protected float Remapping(float weight)
|
||||
{
|
||||
if (!remappingSetting.enable)
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
weight = math.saturate(weight / (1.0f - remappingSetting.innerOffset));
|
||||
weight = math.lerp(remappingSetting.min, remappingSetting.max, weight);
|
||||
weight = remappingSetting.invert ? 1.0f - weight : weight;
|
||||
weight *= remappingSetting.strength;
|
||||
return weight;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (transform.hasChanged)
|
||||
{
|
||||
propertyChanged.Invoke(this, null);
|
||||
transform.hasChanged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Cloner/Contracts/Field/FieldBase.cs.meta
Normal file
2
Runtime/Cloner/Contracts/Field/FieldBase.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c07d37f0b7524644aab721afc849c508
|
||||
Reference in New Issue
Block a user