From 85b96a891bb81776faf0a6dd1783443a045f74fb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 12 Jun 2013 12:15:55 +0200 Subject: VectorUtil, Quaternion: Use 'final' qualifier if possible --- .../classes/com/jogamp/opengl/math/Quaternion.java | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/math/Quaternion.java') diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index 409176101..d5ffe2da4 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -55,8 +55,8 @@ public class Quaternion { * @param vector2 */ public Quaternion(float[] vector1, float[] vector2) { - float theta = FloatUtil.acos(VectorUtil.dot(vector1, vector2)); - float[] cross = VectorUtil.cross(vector1, vector2); + final float theta = FloatUtil.acos(VectorUtil.dot(vector1, vector2)); + final float[] cross = VectorUtil.cross(vector1, vector2); fromAxis(cross, theta); } @@ -77,9 +77,9 @@ public class Quaternion { * @param angle rotation angle (rads) */ public void fromAxis(float[] vector, float angle) { - float halfangle = angle * 0.5f; - float sin = FloatUtil.sin(halfangle); - float[] nv = VectorUtil.normalize(vector); + final float halfangle = angle * 0.5f; + final float sin = FloatUtil.sin(halfangle); + final float[] nv = VectorUtil.normalize(vector); x = (nv[0] * sin); y = (nv[1] * sin); z = (nv[2] * sin); @@ -92,8 +92,8 @@ public class Quaternion { * @return new float[4] with ,theta,Rx,Ry,Rz */ public float[] toAxis() { - float[] vec = new float[4]; - float scale = FloatUtil.sqrt(x * x + y * y + z * z); + final float[] vec = new float[4]; + final float scale = FloatUtil.sqrt(x * x + y * y + z * z); vec[0] = FloatUtil.acos(w) * 2.0f; vec[1] = x / scale; vec[2] = y / scale; @@ -172,11 +172,11 @@ public class Quaternion { * @param q a quaternion to multiply with */ public void mult(Quaternion q) { - float w1 = w * q.w - x * q.x - y * q.y - z * q.z; + final float w1 = w * q.w - x * q.x - y * q.y - z * q.z; - float x1 = w * q.x + x * q.w + y * q.z - z * q.y; - float y1 = w * q.y - x * q.z + y * q.w + z * q.x; - float z1 = w * q.z + x * q.y - y * q.x + z * q.w; + final float x1 = w * q.x + x * q.w + y * q.z - z * q.y; + final float y1 = w * q.y - x * q.z + y * q.w + z * q.x; + final float z1 = w * q.z + x * q.y - y * q.x + z * q.w; w = w1; x = x1; @@ -202,11 +202,11 @@ public class Quaternion { * @return rotated vector */ public float[] mult(float[] vector) { - // TODO : optimalize - float[] res = new float[3]; - Quaternion a = new Quaternion(vector[0], vector[1], vector[2], 0.0f); - Quaternion b = new Quaternion(this); - Quaternion c = new Quaternion(this); + // TODO : optimize + final float[] res = new float[3]; + final Quaternion a = new Quaternion(vector[0], vector[1], vector[2], 0.0f); + final Quaternion b = new Quaternion(this); + final Quaternion c = new Quaternion(this); b.inverse(); a.mult(b); c.mult(a); @@ -220,11 +220,11 @@ public class Quaternion { * Normalize a quaternion required if to be used as a rotational quaternion */ public void normalize() { - float norme = (float) FloatUtil.sqrt(w * w + x * x + y * y + z * z); + final float norme = (float) FloatUtil.sqrt(w * w + x * x + y * y + z * z); if (norme == 0.0f) { setIdentity(); } else { - float recip = 1.0f / norme; + final float recip = 1.0f / norme; w *= recip; x *= recip; @@ -237,9 +237,9 @@ public class Quaternion { * Invert the quaternion If rotational, will produce a the inverse rotation */ public void inverse() { - float norm = w * w + x * x + y * y + z * z; + final float norm = w * w + x * x + y * y + z * z; - float recip = 1.0f / norm; + final float recip = 1.0f / norm; w *= recip; x = -1 * x * recip; @@ -254,7 +254,7 @@ public class Quaternion { * @return new float[16] column matrix 4x4 */ public float[] toMatrix() { - float[] matrix = new float[16]; + final float[] matrix = new float[16]; matrix[0] = 1.0f - 2 * y * y - 2 * z * z; matrix[1] = 2 * x * y + 2 * w * z; matrix[2] = 2 * x * z - 2 * w * y; @@ -365,28 +365,28 @@ public class Quaternion { * @param m 3x3 column matrix */ public void setFromMatrix(float[] m) { - float T = m[0] + m[4] + m[8] + 1; + final float T = m[0] + m[4] + m[8] + 1; if (T > 0) { - float S = 0.5f / (float) FloatUtil.sqrt(T); + final float S = 0.5f / (float) FloatUtil.sqrt(T); w = 0.25f / S; x = (m[5] - m[7]) * S; y = (m[6] - m[2]) * S; z = (m[1] - m[3]) * S; } else { if ((m[0] > m[4]) & (m[0] > m[8])) { - float S = FloatUtil.sqrt(1.0f + m[0] - m[4] - m[8]) * 2f; // S=4*qx + final float S = FloatUtil.sqrt(1.0f + m[0] - m[4] - m[8]) * 2f; // S=4*qx w = (m[7] - m[5]) / S; x = 0.25f * S; y = (m[3] + m[1]) / S; z = (m[6] + m[2]) / S; } else if (m[4] > m[8]) { - float S = FloatUtil.sqrt(1.0f + m[4] - m[0] - m[8]) * 2f; // S=4*qy + final float S = FloatUtil.sqrt(1.0f + m[4] - m[0] - m[8]) * 2f; // S=4*qy w = (m[6] - m[2]) / S; x = (m[3] + m[1]) / S; y = 0.25f * S; z = (m[7] + m[5]) / S; } else { - float S = FloatUtil.sqrt(1.0f + m[8] - m[0] - m[4]) * 2f; // S=4*qz + final float S = FloatUtil.sqrt(1.0f + m[8] - m[0] - m[4]) * 2f; // S=4*qz w = (m[3] - m[1]) / S; x = (m[6] + m[2]) / S; y = (m[7] + m[5]) / S; @@ -403,7 +403,7 @@ public class Quaternion { * @return true if representing a rotational matrix, false otherwise */ public boolean isRotationMatrix(float[] m) { - double epsilon = 0.01; // margin to allow for rounding errors + final double epsilon = 0.01; // margin to allow for rounding errors if (FloatUtil.abs(m[0] * m[3] + m[3] * m[4] + m[6] * m[7]) > epsilon) return false; if (FloatUtil.abs(m[0] * m[2] + m[3] * m[5] + m[6] * m[8]) > epsilon) -- cgit v1.2.3 From 95d3c4020f9871f3520e29d314c8ae6b3b42f9eb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 03:47:43 +0200 Subject: Quaternion: Fix float type - double epsilon slipped through review, where we like to compare float values - remove 64bit conversion. --- src/jogl/classes/com/jogamp/opengl/math/Quaternion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/math/Quaternion.java') diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index d5ffe2da4..f1a3f8be2 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -403,7 +403,7 @@ public class Quaternion { * @return true if representing a rotational matrix, false otherwise */ public boolean isRotationMatrix(float[] m) { - final double epsilon = 0.01; // margin to allow for rounding errors + final float epsilon = 0.01f; // margin to allow for rounding errors if (FloatUtil.abs(m[0] * m[3] + m[3] * m[4] + m[6] * m[7]) > epsilon) return false; if (FloatUtil.abs(m[0] * m[2] + m[3] * m[5] + m[6] * m[8]) > epsilon) @@ -421,6 +421,6 @@ public class Quaternion { private float determinant(float[] m) { return m[0] * m[4] * m[8] + m[3] * m[7] * m[2] + m[6] * m[1] * m[5] - - m[0] * m[7] * m[5] - m[3] * m[1] * m[8] - m[6] * m[4] * m[2]; + - m[0] * m[7] * m[5] - m[3] * m[1] * m[8] - m[6] * m[4] * m[2]; } } -- cgit v1.2.3 From 98ab29dded5d8f8e482b02a8782f1dc87bb3a1a5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 01:41:15 +0200 Subject: Remove deprecated methods. - Quaternion.isEmpty() - Texture.dispose(GL) - GLContext.getGLVersionMajor() / ..Minor() - GLContextImpl.bindPbufferToTexture() / releasePbufferFromTexture() - MouseEvent.getWheelRotation() - --- .../classes/com/jogamp/opengl/math/Quaternion.java | 16 ++----------- .../com/jogamp/opengl/util/texture/Texture.java | 6 ----- src/jogl/classes/javax/media/opengl/GLContext.java | 4 ---- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 20 ++-------------- .../classes/com/jogamp/newt/event/MouseEvent.java | 27 ---------------------- .../junit/graph/demos/GPUUISceneGLListener0A.java | 4 +++- .../jogl/demos/es2/TextureSequenceCubeES2.java | 6 +++-- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 6 +++-- 8 files changed, 15 insertions(+), 74 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/math/Quaternion.java') diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index f1a3f8be2..c6bf44f6d 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -330,20 +330,8 @@ public class Quaternion { } /** - * Check if this quaternion is empty, ie (0,0,0,1) - * - * @return true if empty, false otherwise - * @deprecated use {@link #isIdentity()} instead - */ - @Deprecated - public boolean isEmpty() { - if (w == 1 && x == 0 && y == 0 && z == 0) - return true; - return false; - } - - /** - * Check if this quaternion represents an identity matrix, for rotation. + * Check if this quaternion represents an identity matrix for rotation, + * , ie (0,0,0,1). * * @return true if it is an identity rep., false otherwise */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index d6a8090fb..c52999224 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -289,12 +289,6 @@ public class Texture { gl.glBindTexture(target, texID); } - /** - * @deprecated use {@link #destroy(GL)} - */ - public final void dispose(GL gl) throws GLException { - destroy(gl); - } /** * Destroys the native resources used by this texture object. * diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 84d371ac6..684d0de65 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -671,10 +671,6 @@ public abstract class GLContext { return ctxVersionString; } - /** @deprecated Use {@link #getGLVersionNumber()} */ - public final int getGLVersionMajor() { return ctxVersion.getMajor(); } - /** @deprecated Use {@link #getGLVersionNumber()} */ - public final int getGLVersionMinor() { return ctxVersion.getMinor(); } /** * Returns this context OpenGL version. * @see #getGLSLVersionNumber() diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 8671b045d..f896c95ee 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1098,22 +1098,6 @@ public abstract class GLContextImpl extends GLContext { */ public abstract ProcAddressTable getPlatformExtProcAddressTable(); - /** - * Pbuffer support; given that this is a GLContext associated with a - * pbuffer, binds this pbuffer to its texture target. - * @throws GLException if not implemented (default) - * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer - */ - public void bindPbufferToTexture() { throw new GLException("not implemented"); } - - /** - * Pbuffer support; given that this is a GLContext associated with a - * pbuffer, releases this pbuffer from its texture target. - * @throws GLException if not implemented (default) - * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer - */ - public void releasePbufferFromTexture() { throw new GLException("not implemented"); } - public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); /** Maps the given "platform-independent" function name to a real function @@ -1515,8 +1499,8 @@ public abstract class GLContextImpl extends GLContext { int i = 0; final String MesaSP = "Mesa "; - final String MesaRendererAMDsp = " AMD "; - final String MesaRendererIntelsp = "Intel(R)"; + // final String MesaRendererAMDsp = " AMD "; + // final String MesaRendererIntelsp = "Intel(R)"; final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium "); diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 18c8285f7..93bbcc0b9 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -251,33 +251,6 @@ public class MouseEvent extends InputEvent return normalized ? pressure[index] / maxPressure : pressure[index]; } - /** - * Usually a wheel rotation of > 0.0f is up, - * and < 0.0f is down. - *

- * Usually a wheel rotations is considered a vertical scroll.
- * If {@link #isShiftDown()}, a wheel rotations is - * considered a horizontal scroll, where shift-up = left = > 0.0f, - * and shift-down = right = < 0.0f. - *

- *

- * However, on some OS this might be flipped due to the OS default behavior. - * The latter is true for OS X 10.7 (Lion) for example. - *

- *

- * The events will be send usually in steps of one, ie. -1.0f and 1.0f. - * Higher values may result due to fast scrolling. - * Fractional values may result due to slow scrolling with high resolution devices. - *

- *

- * The button number refers to the wheel number. - *

- * @deprecated Use {@link #getRotation()} - */ - public float getWheelRotation() { - return isShiftDown() ? rotationXYZ[0] : rotationXYZ[1] ; - } - /** * Returns a 3-component float array filled with the values of the rotational axis * in the following order: horizontal-, vertical- and z-axis. diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index f43a933e4..2e8ad02d8 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -428,7 +428,9 @@ public class GPUUISceneGLListener0A implements GLEventListener { @Override public void mouseWheelMoved(MouseEvent e) { - zoom += 2f*e.getWheelRotation(); + if( !e.isShiftDown() ) { + zoom += 2f*e.getRotation()[0]; + } } } } \ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 25f8740d4..d8e3df5c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -133,8 +133,10 @@ public class TextureSequenceCubeES2 implements GLEventListener { } } public void mouseWheelMoved(MouseEvent e) { - zoom += e.getWheelRotation()/10f; - System.err.println("zoom: "+zoom); + if( !e.isShiftDown() ) { + zoom += e.getRotation()[0]/10f; + System.err.println("zoom: "+zoom); + } } }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index e17c9e88b..6b618bd5b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -140,8 +140,10 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { // prevMouseY = y; } public void mouseWheelMoved(MouseEvent e) { - zoom += e.getWheelRotation()/10f; - System.err.println("zoom: "+zoom); + if( !e.isShiftDown() ) { + zoom += e.getRotation()[0]/10f; + System.err.println("zoom: "+zoom); + } } }; -- cgit v1.2.3