Fix error amd Update features.
Changed Span<PointData> to ReadOnlySpan<PointData> on method Operate in EffectorBase.cs Changed the return type of method Operate in EffectorBase.cs from void to PointDate Added FieldHelper and BlendField function to make the blending work.
This commit is contained in:
@@ -21,21 +21,21 @@ namespace Misaki.ArtTool
|
||||
public float3 scale;
|
||||
public float uniformScale;
|
||||
|
||||
public override void Operate(int index, float4x4 nodeWorldMatrix, Span<PointData> points)
|
||||
public override PointData Operate(int index, float4x4 nodeWorldMatrix, ReadOnlySpan<PointData> points)
|
||||
{
|
||||
var currentPoint = points[index];
|
||||
if (!isEnablePosition && !isEnableRotation && !isEnableScale)
|
||||
{
|
||||
return;
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
var currentPoint = points[index];
|
||||
|
||||
MatrixHelper.DecomposeMatrix(currentPoint.matrix, out var position, out var rotation, out var scale);
|
||||
|
||||
var weight = CalculateFieldsWeight(position);
|
||||
if (weight == 0)
|
||||
{
|
||||
return;
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
if (isEnablePosition)
|
||||
@@ -96,7 +96,7 @@ namespace Misaki.ArtTool
|
||||
|
||||
currentPoint.matrix = float4x4.TRS(position, rotation, scale);
|
||||
|
||||
points[index] = currentPoint;
|
||||
return currentPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,39 +10,37 @@ namespace Misaki.ArtTool
|
||||
public bool isHideMode = false;
|
||||
|
||||
// TODO: Average the push direction and distance of each point for more consistence result
|
||||
public override void Operate(int index, float4x4 nodeWorldMatrix, Span<PointData> points)
|
||||
public override PointData Operate(int index, float4x4 nodeWorldMatrix, ReadOnlySpan<PointData> points)
|
||||
{
|
||||
var currentPoint = points[index];
|
||||
|
||||
var weight = CalculateFieldsWeight(currentPoint.matrix.c3.xyz);
|
||||
if (weight == 0)
|
||||
if (weight > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < iteration; i++)
|
||||
{
|
||||
for (var p = 0; p < points.Length; p++)
|
||||
for (var i = 0; i < iteration; i++)
|
||||
{
|
||||
if (index == p)
|
||||
for (var p = 0; p < points.Length; p++)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (index == p)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var targetPoint = points[p];
|
||||
var targetPoint = points[p];
|
||||
|
||||
var distance = math.distance(currentPoint.matrix.c3.xyz, targetPoint.matrix.c3.xyz);
|
||||
if (distance < radius)
|
||||
{
|
||||
var direction = math.normalizesafe(currentPoint.matrix.c3.xyz - targetPoint.matrix.c3.xyz);
|
||||
currentPoint.matrix.c3.xyz += (radius - distance) * weight * direction;
|
||||
var distance = math.distance(currentPoint.matrix.c3.xyz, targetPoint.matrix.c3.xyz);
|
||||
if (distance < radius)
|
||||
{
|
||||
var direction = math.normalizesafe(currentPoint.matrix.c3.xyz - targetPoint.matrix.c3.xyz);
|
||||
currentPoint.matrix.c3.xyz += (radius - distance) * weight * direction;
|
||||
|
||||
//Debug.Log($"Push at index {index} with distance {radius - distance} and direction {direction}");
|
||||
//Debug.Log($"Push at index {index} with distance {radius - distance} and direction {direction}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
points[index] = currentPoint;
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,15 +26,15 @@ namespace Misaki.ArtTool
|
||||
public float3 scaleMinMax;
|
||||
public float uniformScaleMinMax;
|
||||
|
||||
public override void Operate(int index, float4x4 nodeWorldMatrix, Span<PointData> points)
|
||||
public override PointData Operate(int index, float4x4 nodeWorldMatrix, ReadOnlySpan<PointData> points)
|
||||
{
|
||||
var currentPoint = points[index];
|
||||
|
||||
if (!isEnablePosition && !isEnableRotation && !isEnableScale)
|
||||
{
|
||||
return;
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
var currentPoint = points[index];
|
||||
|
||||
Random random;
|
||||
if (synchronized)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace Misaki.ArtTool
|
||||
var weight = CalculateFieldsWeight(position);
|
||||
if (weight == 0)
|
||||
{
|
||||
return;
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
if (isEnablePosition)
|
||||
@@ -121,7 +121,7 @@ namespace Misaki.ArtTool
|
||||
|
||||
currentPoint.matrix = float4x4.TRS(position, rotation, scale);
|
||||
|
||||
points[index] = currentPoint;
|
||||
return currentPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user