aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/gl2
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-27 18:16:43 +0200
committerSven Gothel <[email protected]>2014-06-27 18:16:43 +0200
commit0bded476868c5fdfe44502bfd55957469d0d72bb (patch)
tree8f3baefe8c7267a11dffacc4ba1814478c4b2123 /src/jogl/classes/jogamp/opengl/gl2
parent21b84da775fae5806481ecc658a207bf603126d5 (diff)
Enhance FloatUtil: Merge ProjectFloat features while adding optimized variations; PMVMatrix: Remove NIO buffer path, use backing-array only and FloatUtil direct.
- FloatUtil pptimized variants: - mapObjToWinCoords (gluProject) passing 'P x Mv' for batch operations - mapWinToObjCoords (gluUnProject) passing 'Inv(P x Mv)' for batch operations - mapWinToObjCoords (gluUnProject) passing 'Inv(P x Mv)' and two winz values for two ray picking resulting in two obj positions. (-> mapWinToRay) - PMVMatrix - dropped low performance NIO mode - simply use common backing-array and fixed offsets directly - drop ProjectFloat usage in favor of FloatUtil - reduce number of temporary arrays
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/gl2')
-rw-r--r--src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java55
1 files changed, 5 insertions, 50 deletions
diff --git a/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java b/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java
index a4aa1c7c5..e0ec0f401 100644
--- a/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java
+++ b/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java
@@ -114,10 +114,11 @@
*/
package jogamp.opengl.gl2;
-import java.nio.*;
+import java.nio.DoubleBuffer;
+import java.nio.IntBuffer;
+
+import javax.media.opengl.GL2;
-import javax.media.opengl.*;
-import jogamp.opengl.*;
import com.jogamp.common.nio.Buffers;
/**
@@ -152,12 +153,7 @@ public class ProjectDouble {
private final double[] in = new double[4];
private final double[] out = new double[4];
- private final double[] forward = new double[3];
- private final double[] side = new double[3];
- private final double[] up = new double[3];
-
// Buffer-based implementation
- private DoubleBuffer locbuf;
private final DoubleBuffer matrixBuf;
private final DoubleBuffer tempMatrixBuf;
@@ -174,7 +170,7 @@ public class ProjectDouble {
// Slice up one big buffer because some NIO implementations
// allocate a huge amount of memory to back even the smallest of
// buffers.
- DoubleBuffer locbuf = Buffers.newDirectDoubleBuffer(128);
+ final DoubleBuffer locbuf = Buffers.newDirectDoubleBuffer(128);
int pos = 0;
int sz = 16;
matrixBuf = slice(locbuf, pos, sz);
@@ -194,13 +190,6 @@ public class ProjectDouble {
upBuf = slice(locbuf, pos, sz);
}
- public void destroy() {
- if(locbuf!=null) {
- locbuf.clear();
- locbuf=null;
- }
- }
-
private static DoubleBuffer slice(DoubleBuffer buf, int pos, int len) {
buf.position(pos);
buf.limit(pos + len);
@@ -451,27 +440,6 @@ public class ProjectDouble {
*
* @param v
*/
- private static void normalize(double[] v) {
- double r;
-
- r = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
- if ( r == 0.0 )
- return;
-
- r = 1.0 / r;
-
- v[0] *= r;
- v[1] *= r;
- v[2] *= r;
-
- return;
- }
-
- /**
- * Normalize vector
- *
- * @param v
- */
private static void normalize(DoubleBuffer v) {
double r;
@@ -500,19 +468,6 @@ public class ProjectDouble {
* @param v2
* @param result
*/
- private static void cross(double[] v1, double[] v2, double[] result) {
- result[0] = v1[1] * v2[2] - v1[2] * v2[1];
- result[1] = v1[2] * v2[0] - v1[0] * v2[2];
- result[2] = v1[0] * v2[1] - v1[1] * v2[0];
- }
-
- /**
- * Calculate cross-product
- *
- * @param v1
- * @param v2
- * @param result
- */
private static void cross(DoubleBuffer v1, DoubleBuffer v2, DoubleBuffer result) {
int v1Pos = v1.position();
int v2Pos = v2.position();