From 8e36d7213307833f73db78999145057557447520 Mon Sep 17 00:00:00 2001 From: Josh4359 <77248236+Josh4359@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:59:55 -0700 Subject: [PATCH] Update SplinePlus.cs --- Runtime/SplinePlus.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Runtime/SplinePlus.cs b/Runtime/SplinePlus.cs index 4c19500..e53edc6 100644 --- a/Runtime/SplinePlus.cs +++ b/Runtime/SplinePlus.cs @@ -82,18 +82,18 @@ public class SplinePlus : MonoBehaviour { int resolutionScale = Mathf.CeilToInt(splineContainer.Splines[splineIndex].GetLength()) * resolution; - position = EvaluatePoint(splineIndex, t, out float3 upVector); + position = EvaluatePoint(splineIndex, t); float t1 = Mathf.Clamp(t, 0, 1 - (1 / (float)resolutionScale)); - Vector3 position0 = EvaluatePoint(splineIndex, t1, out _); + Vector3 position0 = EvaluatePoint(splineIndex, t1); - Vector3 position1 = EvaluatePoint(splineIndex, t1 + (1 / (float)resolutionScale), out _); + Vector3 position1 = EvaluatePoint(splineIndex, t1 + (1 / (float)resolutionScale)); Vector3 difference = position1 - position0; - rotation = Vector3.Dot(difference, upVector) > 0 - ? Quaternion.LookRotation(difference, upVector) + rotation = Vector3.Dot(difference, Vector3.up) > 0 + ? Quaternion.LookRotation(difference, Vector3.up) : Quaternion.FromToRotation(Vector3.forward, difference); } @@ -101,24 +101,24 @@ public class SplinePlus : MonoBehaviour { int resolutionScale = Mathf.CeilToInt(splineContainer.CalculateLength()) * resolution; - position = EvaluatePoint(t, out float3 upVector); + position = EvaluatePoint(t); float t1 = Mathf.Clamp(t, 0, 1 - (1 / (float)resolutionScale)); - Vector3 position0 = EvaluatePoint(t1, out _); + Vector3 position0 = EvaluatePoint(t1); - Vector3 position1 = EvaluatePoint(t1 + (1 / (float)resolutionScale), out _); + Vector3 position1 = EvaluatePoint(t1 + (1 / (float)resolutionScale)); Vector3 difference = position1 - position0; - rotation = Vector3.Dot(difference, upVector) > 0 - ? Quaternion.LookRotation(difference, upVector) + rotation = Vector3.Dot(difference, Vector3.up) > 0 + ? Quaternion.LookRotation(difference, Vector3.up) : Quaternion.FromToRotation(Vector3.forward, difference); } - Vector3 EvaluatePoint(int splineIndex, float t, out float3 upVector) + Vector3 EvaluatePoint(int splineIndex, float t) { - ScaledEvaluate(splineContainer, splineIndex, t, out float3 position, out _, out upVector); + ScaledEvaluate(splineContainer, splineIndex, t, out float3 position, out _, out _); ScaledEvaluate(deformContainer, 0, position.x / deformContainer.Spline.GetLength(), out float3 deformPosition, out float3 deformTangent, out float3 deformUpVector); @@ -132,9 +132,9 @@ public class SplinePlus : MonoBehaviour return deformPosition + (deformMatrix.c0 * position.z) + (deformMatrix.c1 * position.y); } - Vector3 EvaluatePoint(float t, out float3 upVector) + Vector3 EvaluatePoint(float t) { - splineContainer.Evaluate(t, out float3 position, out _, out upVector); + splineContainer.Evaluate(t, out float3 position, out _, out _); ScaledEvaluate(deformContainer, 0, position.x / deformContainer.Spline.GetLength(), out float3 deformPosition, out float3 deformTangent, out float3 deformUpVector);