Browse Source

Spline: set t value for last point

Tom SPIRA 4 years ago
parent
commit
ef114cc1e3
1 changed files with 2 additions and 1 deletions
  1. 2 1
      hrt/prefab/l3d/Spline.hx

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

@@ -380,7 +380,7 @@ class Spline extends Object3D {
 				t += 1./step;
 			}
 			if (nextP.getPoint().distance(samples[samples.length - 1].pos) >= 1./step)
-				samples.insert(samples.length, { pos : nextP.getPoint(), tangent : nextP.getTangent(), prev : curP, next : nextP, t : 1.0 });
+				samples.insert(samples.length, { pos : nextP.getPoint(), tangent : nextP.getTangent(), prev : curP, next : nextP });
 			curP = points[i];
 			nextP = points[(i + 1) % points.length];
 
@@ -397,6 +397,7 @@ class Spline extends Object3D {
 			samples[i].t = l/lengthSum;
 			l += samples[i].pos.distance(samples[i+1].pos);
 		}
+		samples[samples.length - 1].t = 1;
 		sd.length = lengthSum;
 	}