Răsfoiți Sursa

Update Spline : Minor Fix

ShiroSmith 5 ani în urmă
părinte
comite
3b476c2ba3
2 a modificat fișierele cu 22 adăugiri și 5 ștergeri
  1. 1 0
      hide/prefab/SplineEditor.hx
  2. 21 5
      hrt/prefab/l3d/Spline.hx

+ 1 - 0
hide/prefab/SplineEditor.hx

@@ -322,6 +322,7 @@ class SplineEditor {
 		if( spd.tangent != null ) {
 		if( spd.tangent != null ) {
 			var dir = spd.tangent.toVector();
 			var dir = spd.tangent.toVector();
 			dir.transform3x3(invMatrix); // Don't take the translation
 			dir.transform3x3(invMatrix); // Don't take the translation
+			dir.scale3(-1);
 			var rot = h3d.Matrix.lookAtX(dir);
 			var rot = h3d.Matrix.lookAtX(dir);
 			sp.setDirection(rot.front());
 			sp.setDirection(rot.front());
 		}
 		}

+ 21 - 5
hrt/prefab/l3d/Spline.hx

@@ -86,13 +86,29 @@ class Spline extends Object3D {
 	override function save() {
 	override function save() {
 		var obj : Dynamic = super.save();
 		var obj : Dynamic = super.save();
 
 
+		var tmp = new h3d.Matrix();
+		inline function getTransform( o : h3d.scene.Object, m : h3d.Matrix ) : h3d.Matrix {
+			m.identity();
+			@:privateAccess o.qRot.toMatrix(m);
+			m._11 *= o.scaleX;
+			m._12 *= o.scaleX;
+			m._13 *= o.scaleX;
+			m._21 *= o.scaleY;
+			m._22 *= o.scaleY;
+			m._23 *= o.scaleY;
+			m._31 *= o.scaleZ;
+			m._32 *= o.scaleZ;
+			m._33 *= o.scaleZ;
+			m._41 = o.x;
+			m._42 = o.y;
+			m._43 = o.z;
+			return m;
+		}
+
 		if( points != null && points.length > 0 ) {
 		if( points != null && points.length > 0 ) {
-			var parentInv = points[0].parent.getAbsPos().clone();
-			parentInv.initInverse(parentInv);
 			obj.points = [ for(sp in points) {
 			obj.points = [ for(sp in points) {
-								var abs = sp.getAbsPos().clone();
-								abs.multiply(abs, parentInv);
-								[for(f in abs.getFloats()) hxd.Math.fmt(f) ];
+								var m = getTransform(sp, tmp);
+								[for(f in m.getFloats()) hxd.Math.fmt(f) ];
 							} ];
 							} ];
 		}
 		}
 		// Clone support
 		// Clone support