From eea91e0b200c5d1fe377a9ec5322379091f60ee9 Mon Sep 17 00:00:00 2001 From: "dan..om" Date: Mon, 26 Nov 2012 13:12:44 +0000 Subject: [PATCH] - Fix to sphericalToCartesian and related methods that checks if store is null. If it is, store is created internally. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10007 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/math/FastMath.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/engine/src/core/com/jme3/math/FastMath.java b/engine/src/core/com/jme3/math/FastMath.java index db66553b7..fe267bcaa 100644 --- a/engine/src/core/com/jme3/math/FastMath.java +++ b/engine/src/core/com/jme3/math/FastMath.java @@ -815,6 +815,9 @@ final public class FastMath { */ public static Vector3f sphericalToCartesian(Vector3f sphereCoords, Vector3f store) { + if (store == null) { + store = new Vector3f(); + } store.y = sphereCoords.x * FastMath.sin(sphereCoords.z); float a = sphereCoords.x * FastMath.cos(sphereCoords.z); store.x = a * FastMath.cos(sphereCoords.y); @@ -830,6 +833,9 @@ final public class FastMath { */ public static Vector3f cartesianToSpherical(Vector3f cartCoords, Vector3f store) { + if (store == null) { + store = new Vector3f(); + } float x = cartCoords.x; if (x == 0) { x = FastMath.FLT_EPSILON; @@ -851,6 +857,9 @@ final public class FastMath { */ public static Vector3f sphericalToCartesianZ(Vector3f sphereCoords, Vector3f store) { + if (store == null) { + store = new Vector3f(); + } store.z = sphereCoords.x * FastMath.sin(sphereCoords.z); float a = sphereCoords.x * FastMath.cos(sphereCoords.z); store.x = a * FastMath.cos(sphereCoords.y); @@ -866,6 +875,9 @@ final public class FastMath { */ public static Vector3f cartesianZToSpherical(Vector3f cartCoords, Vector3f store) { + if (store == null) { + store = new Vector3f(); + } float x = cartCoords.x; if (x == 0) { x = FastMath.FLT_EPSILON;