Browse Source

Spline: fix t param in SplinePointData

Tom Spira 4 years ago
parent
commit
b8b9836af7
1 changed files with 6 additions and 1 deletions
  1. 6 1
      hrt/prefab/l3d/Spline.hx

+ 6 - 1
hrt/prefab/l3d/Spline.hx

@@ -278,7 +278,7 @@ class Spline extends Object3D {
 
 			// Point found
 			if( hxd.Math.abs(curSegmentLength - step) <= threshold ) {
-				samples.insert(samples.length, { pos : p, tangent : getTangentBetween(t, curP, nextP), prev : curP, next : nextP, t : t });
+				samples.insert(samples.length, { pos : p, tangent : getTangentBetween(t, curP, nextP), prev : curP, next : nextP });
 				sumT = t;
 				maxT = 1.0;
 				minT = sumT;
@@ -315,6 +315,11 @@ class Spline extends Object3D {
 		for( i in 0 ... samples.length - 1 ) {
 			lengthSum += samples[i].pos.distance(samples[i+1].pos);
 		}
+		var l = 0.0;
+		for( i in 0 ... samples.length - 1 ) {
+			samples[i].t = l/lengthSum;
+			l += samples[i].pos.distance(samples[i+1].pos);
+		}
 		sd.length = lengthSum;
 	}