Added object distributuon calculationg
This commit is contained in:
@@ -7,8 +7,40 @@ namespace Misaki.ArtTool
|
||||
{
|
||||
public MeshData meshData;
|
||||
public ObjectDistributionMode mode;
|
||||
public int count;
|
||||
public uint count;
|
||||
public uint seed;
|
||||
public bool alignNormal;
|
||||
|
||||
public int DistributionCount
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = 0;
|
||||
switch (mode)
|
||||
{
|
||||
case ObjectDistributionMode.Surface:
|
||||
case ObjectDistributionMode.Volume:
|
||||
result = (int)count;
|
||||
break;
|
||||
|
||||
case ObjectDistributionMode.Vertex:
|
||||
result = meshData.vertexCount;
|
||||
break;
|
||||
|
||||
case ObjectDistributionMode.Edge:
|
||||
result = meshData.edges.Length;
|
||||
break;
|
||||
|
||||
case ObjectDistributionMode.PolygonCenter:
|
||||
result = meshData.triangles.Length / 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@ namespace Misaki.ArtTool
|
||||
public bool enable = true;
|
||||
public EffectorBase effector;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,33 @@ namespace Misaki.ArtTool
|
||||
public struct MeshData : IDisposable
|
||||
{
|
||||
public Bounds bounds;
|
||||
|
||||
[ReadOnly]
|
||||
public NativeArray<int> triangles;
|
||||
public NativeArray<float4> tangents;
|
||||
[ReadOnly]
|
||||
public NativeArray<float3> normals;
|
||||
[ReadOnly]
|
||||
public NativeArray<float3> vertices;
|
||||
[ReadOnly]
|
||||
public NativeList<int2> edges;
|
||||
|
||||
public int vertexCount;
|
||||
|
||||
public float4x4 worldMatrix;
|
||||
|
||||
public MeshData(Allocator allocator)
|
||||
{
|
||||
bounds = default;
|
||||
|
||||
triangles = new(0, allocator);
|
||||
normals = new(0, allocator);
|
||||
vertices = new(0, allocator);
|
||||
edges = new(0, allocator);
|
||||
|
||||
vertexCount = 0;
|
||||
worldMatrix = float4x4.identity;
|
||||
}
|
||||
|
||||
public MeshData(MeshFilter meshFilter, Allocator allocator)
|
||||
{
|
||||
var mesh = meshFilter.sharedMesh;
|
||||
@@ -28,10 +47,10 @@ namespace Misaki.ArtTool
|
||||
triangles[i] = mesh.triangles[i];
|
||||
}
|
||||
|
||||
tangents = new(mesh.tangents.Length, allocator);
|
||||
for (var i = 0; i < tangents.Length; i++)
|
||||
normals = new(mesh.tangents.Length, allocator);
|
||||
for (var i = 0; i < normals.Length; i++)
|
||||
{
|
||||
tangents[i] = mesh.tangents[i];
|
||||
normals[i] = mesh.normals[i];
|
||||
}
|
||||
|
||||
vertices = new(mesh.vertices.Length, allocator);
|
||||
@@ -68,7 +87,7 @@ namespace Misaki.ArtTool
|
||||
public void Dispose()
|
||||
{
|
||||
triangles.Dispose();
|
||||
tangents.Dispose();
|
||||
normals.Dispose();
|
||||
vertices.Dispose();
|
||||
edges.Dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user