浏览代码

Fix matrix get/set position (#399)

Valentin Lemière 7 年之前
父节点
当前提交
38f4cf4f05
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      h3d/Matrix.hx

+ 8 - 6
h3d/Matrix.hx

@@ -187,14 +187,16 @@ class Matrix {
 	}
 
 	public inline function getPosition( ?v : Vector ) {
-		return new h3d.Vector(_41,_42,_43,_44);
+		if( v == null ) v = new Vector();
+		v.set(_41,_42,_43,_44);
+		return v;
 	}
 
 	public inline function setPosition( v : Vector ) {
-		v.x = _41;
-		v.y = _42;
-		v.z = _43;
-		v.w = _44;
+		_41 = v.x;
+		_42 = v.y;
+		_43 = v.z;
+		_44 = v.w;
 	}
 
 	public function prependTranslation( x = 0., y = 0., z = 0. ) {
@@ -770,4 +772,4 @@ class Matrix {
 		m._44 = 1;
 		return m;
 	}
-}
+}