Browse Source

Splines: fix splines transform

lviguier 1 year ago
parent
commit
f07219437c
1 changed files with 14 additions and 4 deletions
  1. 14 4
      hrt/prefab/l3d/Spline.hx

+ 14 - 4
hrt/prefab/l3d/Spline.hx

@@ -68,6 +68,7 @@ class SplinePoint extends Object3D {
 	public var offset : h3d.Matrix;
 	public var offset : h3d.Matrix;
 
 
 	static var tmpMat : h3d.Matrix = new h3d.Matrix();
 	static var tmpMat : h3d.Matrix = new h3d.Matrix();
+	static var tmpMatBis : h3d.Matrix = new h3d.Matrix();
 
 
 	function get_spline() {
 	function get_spline() {
 		return parent.to(Spline);
 		return parent.to(Spline);
@@ -179,12 +180,21 @@ class SplinePoint extends Object3D {
 	#end
 	#end
 
 
 	override public function getAbsPos( followRefs : Bool = false ) {
 	override public function getAbsPos( followRefs : Bool = false ) {
-		var result = null;
+		var result = tmpMatBis;
+
 		if (obj != null)
 		if (obj != null)
 			result = obj.getAbsPos();
 			result = obj.getAbsPos();
-		else {
-			result = this.getTransform(@:privateAccess SplinePoint.tmpMat);
-			result.multiply(result, spline.local3d.getAbsPos());
+		else @:privateAccess {
+			result.load(this.getTransform(tmpMat));
+
+			var p = Std.downcast(this.parent, Object3D);
+			while (p != null)  {
+				p.getTransform(tmpMat);
+				tmpMat.multiply(result, tmpMat);
+				result.load(tmpMat);
+
+				p = Std.downcast(p.parent, Object3D);
+			}
 		}
 		}
 
 
 		if (offset != null) result.multiply(result, offset);
 		if (offset != null) result.multiply(result, offset);