Added object distributuon calculationg

This commit is contained in:
Misaki
2024-09-22 00:11:03 +09:00
parent 77d16fbffa
commit df0194ff9c
22 changed files with 375 additions and 100 deletions

View File

@@ -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;
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e7afadfcd369f5a4385b23c090665f74
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 315e5886979edba429c781f6a8a0a0cc

View File

@@ -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;
}