Forráskód Böngészése

use temp variables instead of creating new ones to improve memory usage

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11012 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
phr00t 11 éve
szülő
commit
b06cdfc77c
1 módosított fájl, 7 hozzáadás és 1 törlés
  1. 7 1
      engine/src/core/com/jme3/math/Quaternion.java

+ 7 - 1
engine/src/core/com/jme3/math/Quaternion.java

@@ -462,7 +462,10 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
      * @return the rotation matrix representation of this quaternion.
      */
     public Matrix4f toRotationMatrix(Matrix4f result) {
-        Vector3f originalScale = result.toScaleVector();
+        TempVars tempv = TempVars.get();
+        Vector3f originalScale = tempv.vect1;
+        
+        result.toScaleVector(originalScale);
         result.setScale(1, 1, 1);
         float norm = norm();
         // we explicitly test norm against one here, saving a division
@@ -496,6 +499,9 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
         result.m22 = 1 - (xx + yy);
 
         result.setScale(originalScale);
+        
+        tempv.release();
+        
         return result;
     }