绳子修改

This commit is contained in:
Bob.Song
2025-11-05 18:00:02 +08:00
parent 3e739facde
commit 4059c207c0
9 changed files with 309 additions and 466 deletions

View File

@@ -9,7 +9,7 @@ namespace NBF
public static class PointsExtensions
{
// Curve length
public static float GetLengthOfCurve(this NativeArray<float3> curve, ref float4x4 transform, bool isLoop = false)
public static float GetLengthOfCurve(this NativeArray<float3> curve, ref float4x4 transform)
{
if (curve == null || curve.Length == 0)
{
@@ -24,31 +24,28 @@ namespace NBF
sum += math.distance(lastPoint, point);
lastPoint = point;
}
if (isLoop)
{
sum += math.distance(lastPoint, firstPoint);
}
return sum;
}
public static float GetLengthOfCurve(this NativeArray<float3> curve, bool isLoop = false)
public static float GetLengthOfCurve(this NativeArray<float3> curve)
{
var transform = float4x4.identity;
return curve.GetLengthOfCurve(ref transform, isLoop);
return curve.GetLengthOfCurve(ref transform);
}
public static float GetLengthOfCurve(this IEnumerable<float3> curve, ref float4x4 transform, bool isLoop = false)
public static float GetLengthOfCurve(this IEnumerable<float3> curve, ref float4x4 transform)
{
var array = new NativeArray<float3>(curve.ToArray(), Allocator.Temp);
var sum = array.GetLengthOfCurve(ref transform, isLoop);
var sum = array.GetLengthOfCurve(ref transform);
array.Dispose();
return sum;
}
public static float GetLengthOfCurve(this IEnumerable<float3> curve, bool isLoop = false)
public static float GetLengthOfCurve(this IEnumerable<float3> curve)
{
var transform = float4x4.identity;
return curve.GetLengthOfCurve(ref transform, isLoop);
return curve.GetLengthOfCurve(ref transform);
}
// Curve points