Added object distributuon calculationg
This commit is contained in:
@@ -6,6 +6,8 @@ namespace Misaki.ArtTool
|
||||
[ExecuteInEditMode]
|
||||
public class LinearField : FieldBase
|
||||
{
|
||||
public RemappingSetting remappingSetting = new();
|
||||
|
||||
public float length = 1.0f;
|
||||
|
||||
private float3 fieldForward;
|
||||
@@ -17,13 +19,13 @@ namespace Misaki.ArtTool
|
||||
fieldPosition = transform.position;
|
||||
}
|
||||
|
||||
public override float Operate(float3 position)
|
||||
public override float Operate(float3 position, float weight)
|
||||
{
|
||||
var plane = new Unity.Mathematics.Geometry.Plane(fieldForward, fieldPosition);
|
||||
var distance = plane.SignedDistanceToPoint(position) / length;
|
||||
var weight = math.saturate(distance / 2.0f + 0.5f);
|
||||
|
||||
weight = Remapping(weight);
|
||||
weight = math.saturate(distance / 2.0f + 0.5f);
|
||||
weight = FieldHelper.ApplyRemapping(weight, ref remappingSetting);
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
8
Runtime/Cloner/Fields/ModifierLayer.meta
Normal file
8
Runtime/Cloner/Fields/ModifierLayer.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7afadfcd369f5a4385b23c090665f74
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Runtime/Cloner/Fields/ModifierLayer/Clamp.cs
Normal file
14
Runtime/Cloner/Fields/ModifierLayer/Clamp.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace Misaki.ArtTool
|
||||
{
|
||||
public class Clamp : FieldBase
|
||||
{
|
||||
public float2 minMax;
|
||||
|
||||
public override float Operate(float3 position, float weight)
|
||||
{
|
||||
return math.clamp(weight, minMax.x, minMax.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Cloner/Fields/ModifierLayer/Clamp.cs.meta
Normal file
2
Runtime/Cloner/Fields/ModifierLayer/Clamp.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 315e5886979edba429c781f6a8a0a0cc
|
||||
@@ -5,6 +5,8 @@ namespace Misaki.ArtTool
|
||||
{
|
||||
public class SphereField : FieldBase
|
||||
{
|
||||
public RemappingSetting remappingSetting = new();
|
||||
|
||||
public float radius = 1.0f;
|
||||
|
||||
private float3 fieldPosition;
|
||||
@@ -14,10 +16,10 @@ namespace Misaki.ArtTool
|
||||
fieldPosition = transform.position;
|
||||
}
|
||||
|
||||
public override float Operate(float3 position)
|
||||
public override float Operate(float3 position, float weight)
|
||||
{
|
||||
var weight = ShapeHelper.Linear01DistanceToSphereCenter(position, fieldPosition, radius);
|
||||
weight = Remapping(weight);
|
||||
weight = ShapeHelper.Linear01DistanceToSphereCenter(position, fieldPosition, radius);
|
||||
weight = FieldHelper.ApplyRemapping(weight, ref remappingSetting);
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user