diff options
author | Sven Gothel <[email protected]> | 2013-12-10 21:20:13 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-12-10 21:20:13 +0100 |
commit | ab9076c83cc3b2e7800eaf0a19febe786458146d (patch) | |
tree | d659890823695b9424ff672f34b3cec4aaa964b7 /src/jogl/classes/com/jogamp/opengl/math | |
parent | e2b74932a334b4a0bb9fedc12b0bc51095d35d6a (diff) |
Bug 747: VectorUtil: Make scale(..) creating new float[] deprecated, adding 'in place' variant w/ passing result float[] ; TODO: Replace all variations with 'in place' version to be more memory efficient.
Make scale(..) creating new float[] deprecated, adding 'in place' variant w/ passing result float[]
TODO: Replace all variations with 'in place' version to be more memory efficient.
See Bug747: Validate memory footprint and usage / General performance
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/math')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java index 508f1aafd..e1e797088 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java @@ -70,21 +70,49 @@ public class VectorUtil { return newVector; } - /** Scales a vector by param + /** Scales a vector by param creating a new float[] for the result! * @param vector input vector * @param scale constant to scale by - * @return scaled vector + * @return new scaled vector + * @deprecated Use {@link #scale(float[], float[], float)} */ public static float[] scale(float[] vector, float scale) { final float[] newVector = new float[3]; - newVector[0] = vector[0]*scale; - newVector[1] = vector[1]*scale; - newVector[2] = vector[2]*scale; + newVector[0] = vector[0] * scale; + newVector[1] = vector[1] * scale; + newVector[2] = vector[2] * scale; return newVector; } + /** Scales a vector by param using given result float[] + * @param result vector for the result + * @param vector input vector + * @param scale single scale constant for all vector components + */ + public static float[] scale(float[] result, float[] vector, float scale) + { + result[0] = vector[0] * scale; + result[1] = vector[1] * scale; + result[2] = vector[2] * scale; + return result; + } + + /** Scales a vector by param using given result float[] + * @param result vector for the result + * @param vector input vector + * @param scale 3 component scale constant for each vector component + * @return given result vector + */ + public static float[] scale(float[] result, float[] vector, float[] scale) + { + result[0] = vector[0] * scale[0]; + result[1] = vector[1] * scale[1]; + result[2] = vector[2] * scale[2]; + return result; + } + /** Adds to vectors * @param v1 vector 1 * @param v2 vector 2 |