kottore / away3d

Automatically exported from code.google.com/p/away3d
0 stars 0 forks source link

Patch - core math - Number3D transform() and rotate() methods #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Small fix, but cost me alot of time.in debugging.  The  transform() method of 
Number3D should grab a copy of the values of the input Number3D in case it's a 
self 
referencing call as such as: 

myVect.transform(myVect, rotMatrix ); 

Problems will occur in the current svn version because since we feed itself as 
v to the method, once the assignement to the x class member is done it is used 
to 
subsequently as v.x to calculate the remaining dimensions causing huge 
displacement. 

/me takes a couple of pills to remove the headache 

Same thing is true for the rotate() method of the same class. 

Thanks! 
Ben 

Index: /Users/bbeausej/Documents/DEV/Away3d/src/away3d/core/math/ 
Number3D.as 
=================================================================== 
--- /Users/bbeausej/Documents/DEV/Away3d/src/away3d/core/math/ 
Number3D.as     (revision 552) 
+++ /Users/bbeausej/Documents/DEV/Away3d/src/away3d/core/math/ 
Number3D.as     (working copy) 
@@ -180,9 +180,13 @@ 
         */ 
         public function rotate(v:Number3D, m:Matrix3D):void 
         { 
-            x = v.x * m.sxx + v.y * m.sxy + v.z * m.sxz; 
-            y = v.x * m.syx + v.y * m.syy + v.z * m.syz; 
-            z = v.x * m.szx + v.y * m.szy + v.z * m.szz; 
+               var vx:Number = v.x; 
+               var vy:Number = v.y; 
+               var vz:Number = v.z; 
+ 
+            x = vx * m.sxx + vy * m.sxy + vz * m.sxz; 
+            y = vx * m.syx + vy * m.syy + vz * m.syz; 
+            z = vx * m.szx + vy * m.szy + vz * m.szz; 
         } 
        /** 
@@ -193,9 +197,14 @@ 
         */ 
         public function transform(v:Number3D, m:Matrix3D):void 
         { 
-            x = v.x * m.sxx + v.y * m.sxy + v.z * m.sxz + m.tx; 
-            y = v.x * m.syx + v.y * m.syy + v.z * m.syz + m.ty; 
-            z = v.x * m.szx + v.y * m.szy + v.z * m.szz + m.tz; 
+               var vx:Number = v.x; 
+               var vy:Number = v.y; 
+               var vz:Number = v.z; 
+ 
+ 
+            x = vx * m.sxx + vy * m.sxy + vz * m.sxz + m.tx; 
+            y = vx * m.syx + vy * m.syy + vz * m.syz + m.ty; 
+            z = vx * m.szx + vy * m.szy + vz * m.szz + m.tz; 
         } 
         /** 

Original issue reported on code.google.com by bbeau...@gmail.com on 5 Jun 2008 at 6:50

GoogleCodeExporter commented 8 years ago
changes made in svn trunk revision 587

Original comment by rob.bate...@gmail.com on 25 Jun 2008 at 11:11