Upload project files
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user