Pārlūkot izejas kodu

- 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
dan..om 12 gadi atpakaļ
vecāks
revīzija
eea91e0b20
1 mainītis faili ar 12 papildinājumiem un 0 dzēšanām
  1. 12 0
      engine/src/core/com/jme3/math/FastMath.java

+ 12 - 0
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;