Switch points generation from managed thread to unmanaged thread; Change Spline to NativeSpline; Add converter for DistributionMode and update cloner editor ui; Add MeshData type for object distribution calculation; Add ObjectDistributionSetting and ObjectDistributionCalculation(Vertex and Edge Mode);

This commit is contained in:
Misaki
2024-09-17 18:27:35 +09:00
parent 1c39403cbf
commit 0ae44d6139
23 changed files with 559 additions and 148 deletions

View File

@@ -8,7 +8,7 @@ namespace Misaki.ArtTool
{
var random = Random.CreateFromIndex((uint)index);
var localPosition = GetCubePosition(index, setting.count) * setting.spacing;
var localPosition = ShapeHelper.GetCubePosition(index, setting.count) * setting.spacing;
switch (setting.shape)
{
@@ -17,13 +17,13 @@ namespace Misaki.ArtTool
break;
case GridShape.Sphere:
var isInsideSphere = ShapeHelper.IsInsideSphere(localPosition, 0.0f, setting.count * setting.spacing);
var isInsideSphere = ShapeHelper.IsPointInsideSphere(localPosition, 0.0f, setting.count * setting.spacing);
isValid = isInsideSphere;
break;
case GridShape.Cylinder:
var isInsideCylinder = ShapeHelper.IsInsideCylinder(localPosition, 0.0f, setting.count * setting.spacing);
var isInsideCylinder = ShapeHelper.IsPointInsideCylinder(localPosition, 0.0f, setting.count * setting.spacing);
isValid = isInsideCylinder;
break;
default:
@@ -38,18 +38,5 @@ namespace Misaki.ArtTool
localMatrix = float4x4.TRS(localPosition, quaternion.identity, new float3(1.0f));
}
private static float3 GetCubePosition(int index, int3 size)
{
float3 localPosition;
var yIndex = index / (size.x * size.z);
var remain = index % (size.x * size.z);
var zIndex = remain / size.x;
var xIndex = remain % size.x;
localPosition = new float3(xIndex, yIndex, zIndex);
localPosition -= (float3)(size - 1) * 0.5f;
return localPosition;
}
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using Unity.Mathematics;
namespace Misaki.ArtTool
{
public static partial class Distribution
{
public static void ObjectDistribution(int index, ObjectDistributionSetting setting, out float4x4 localMatrix, out bool isValid)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0bed43825cb2cca49b6b7adfe693a5e2

View File

@@ -17,7 +17,6 @@ namespace Misaki.ArtTool
return;
}
var spline = setting.spline;
float t;
if (setting.isSpacingMode)
@@ -29,7 +28,7 @@ namespace Misaki.ArtTool
t = pointIndex / (float)(pointSize - 1);
}
if (SplineUtility.Evaluate(spline.Spline, t, out var position, out var normal, out var upVector))
if (SplineUtility.Evaluate(setting.nativeSpline, t, out var position, out var normal, out var upVector))
{
var localRotation = quaternion.LookRotationSafe(normal, upVector);