Fixed GetNearestPoint
Fixed GetNearestPoint when the spline extends beyond the deform spline in either direction
This commit is contained in:
parent
51d9f90227
commit
b126b282bd
@ -53,22 +53,18 @@ namespace FrameJosh.SplineImporter
|
||||
math.dot(difference, matrix.c1),
|
||||
-math.dot(difference, matrix.c0));
|
||||
|
||||
point = new float3(t1 * deformContainer.Spline.GetLength(), 0, 0) + offset;
|
||||
float distance = math.clamp(t1, 0, 1) * deformContainer.Spline.GetLength();
|
||||
|
||||
point = new float3(distance, 0, 0) + offset;
|
||||
|
||||
SplineUtility.GetNearestPoint(splineContainer.Splines[splineIndex], point, out position, out t);
|
||||
|
||||
position = EvaluatePoint(deformContainer.Spline, position);
|
||||
|
||||
float3 point1 = new float3((t1 * deformContainer.Spline.GetLength()) + (1 / resolution), 0, 0) + offset;
|
||||
|
||||
SplineUtility.GetNearestPoint(splineContainer.Splines[splineIndex], point1, out float3 position1, out _);
|
||||
|
||||
position1 = EvaluatePoint(deformContainer.Spline, position1);
|
||||
|
||||
rotation = quaternion.LookRotationSafe(position1 - position, Vector3.up);
|
||||
DeformSpline(splineContainer.Spline, deformContainer.Spline, t, resolution, out position, out rotation);
|
||||
}
|
||||
else
|
||||
SplineUtility.GetNearestPoint(splineContainer.Splines[splineIndex], point, out position, out t);
|
||||
|
||||
t = math.clamp(t, 0, 1);
|
||||
}
|
||||
|
||||
public void GetNearestPoint(int splineIndex, Vector3 point, out Vector3 position, out Quaternion rotation, out float t)
|
||||
@ -127,7 +123,12 @@ namespace FrameJosh.SplineImporter
|
||||
|
||||
float3 up = math.normalize(deformUpVector);
|
||||
|
||||
return deformPosition + (right * point.z) + (up * point.y);
|
||||
float3 forward = math.normalize(deformTangent);
|
||||
|
||||
return deformPosition
|
||||
+ (forward * (math.max(point.x - deform.GetLength(), 0) + math.min(point.x, 0)))
|
||||
+ (right * point.z)
|
||||
+ (up * point.y);
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
|
@ -413,7 +413,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 304474437}
|
||||
m_LocalRotation: {x: 0, y: 0.905946, z: 0, w: -0.42339322}
|
||||
m_LocalRotation: {x: 0, y: 0.90936726, z: 0, w: -0.41599432}
|
||||
m_LocalPosition: {x: 2.3040967, y: 0, z: -2.9640856}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -911,7 +911,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
splineContainer: {fileID: 52903582}
|
||||
deformContainer: {fileID: 1024458827}
|
||||
resolution: 1
|
||||
resolution: 4
|
||||
--- !u!4 &1797524874
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user