From b06cdfc77c0b9fddc18d7b7d7988639394ab12a0 Mon Sep 17 00:00:00 2001 From: phr00t Date: Tue, 4 Feb 2014 19:28:02 +0000 Subject: [PATCH] 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 --- engine/src/core/com/jme3/math/Quaternion.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/src/core/com/jme3/math/Quaternion.java b/engine/src/core/com/jme3/math/Quaternion.java index 1591a13a0..1ee1305d2 100644 --- a/engine/src/core/com/jme3/math/Quaternion.java +++ b/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; }