Selaa lähdekoodia

Object.setTransform(): don't modify input matrix (fixes #571)

trethaller 6 vuotta sitten
vanhempi
commit
e267469ca3
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4 2
      h3d/scene/Object.hx

+ 4 - 2
h3d/scene/Object.hx

@@ -769,6 +769,7 @@ class Object implements hxd.impl.Serializable {
 	/**
 	/**
 		Set the position, scale and rotation of the object relative to its parent based on the specified transform matrix.
 		Set the position, scale and rotation of the object relative to its parent based on the specified transform matrix.
 	**/
 	**/
+	static var tmpMat = new h3d.Matrix();
 	public function setTransform( mat : h3d.Matrix ) {
 	public function setTransform( mat : h3d.Matrix ) {
 		var s = mat.getScale();
 		var s = mat.getScale();
 		this.x = mat.tx;
 		this.x = mat.tx;
@@ -777,8 +778,9 @@ class Object implements hxd.impl.Serializable {
 		this.scaleX = s.x;
 		this.scaleX = s.x;
 		this.scaleY = s.y;
 		this.scaleY = s.y;
 		this.scaleZ = s.z;
 		this.scaleZ = s.z;
-		mat.prependScale(1.0 / s.x, 1.0 / s.y, 1.0 / s.z);
-		qRot.initRotateMatrix(mat);
+		tmpMat.load(mat);
+		tmpMat.prependScale(1.0 / s.x, 1.0 / s.y, 1.0 / s.z);
+		qRot.initRotateMatrix(tmpMat);
 		posChanged = true;
 		posChanged = true;
 	}
 	}