Update SplinePlus.cs
This commit is contained in:
parent
dbde4a40c1
commit
8e36d72133
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user