diff options
author | Sven Gothel <[email protected]> | 2012-11-12 07:13:45 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-11-12 07:13:45 +0100 |
commit | 92406ae9a2153c1b6a74c29d9939a021d898dcf1 (patch) | |
tree | 4b4e55169333f15ed7d2f548510cd39ebb0a729e /src | |
parent | 3859f4577524bd3302631272579183adbc92f5c2 (diff) |
Frustum: Cleanup / update; PMVMatrix: Fix mulPMV
Frustum: Cleanup / update
- Remove ctor w/ PMV, use update(..) instead - avoid API explosion
- Add update(Plane[]) to copy existing Frustum planes
- Mention world-coordinates in update(PMV)
PMVMatrix: Fix mulPMV
- P*Mv in column major order is correct for Frustum
Diffstat (limited to 'src')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java | 35 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java | 2 |
2 files changed, 24 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java index fd370dfba..c18740b66 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java @@ -57,6 +57,11 @@ public class Frustum { /** * Creates an undefined instance w/o calculating the frustum. + * <p> + * Use one of the <code>update(..)</code> methods to set the {@link #getPlanes() planes}. + * </p> + * @see #update(Plane[]) + * @see #update(float[], int) */ public Frustum() { for (int i = 0; i < 6; ++i) { @@ -64,17 +69,6 @@ public class Frustum { } } - /** - * Creates a defined instance w/ calculating the frustum - * using the passed float[16] as premultiplied P*MV (column major order) - */ - public Frustum(float[] pmv, int pmv_off) { - for (int i = 0; i < 6; ++i) { - planes[i] = new Plane(); - } - update(pmv, pmv_off); - } - /** Plane equation := dot(n, x - p) = 0 -> ax + bc + cx + d == 0 */ public static class Plane { /** Normal of the plane */ @@ -142,7 +136,24 @@ public class Frustum { public final Plane[] getPlanes() { return planes; } /** - * Re-calculate the frustum + * Copy the given <code>src</code> planes into this this instance's planes. + * @param src the 6 source planes + */ + public final void update(Plane[] src) { + for (int i = 0; i < 6; ++i) { + final Plane p0 = planes[i]; + final float[] p0_n = p0.n; + final Plane p1 = src[i]; + final float[] p1_n = p1.n; + p0_n[0] = p1_n[0]; + p0_n[1] = p1_n[1]; + p0_n[2] = p1_n[2]; + p0.d = p1.d; + } + } + + /** + * Calculate the frustum planes in world coordinates * using the passed float[16] as premultiplied P*MV (column major order). */ public void update(float[] pmv, int pmv_off) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 19d877bab..18129ba09 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -1042,7 +1042,7 @@ public class PMVMatrix implements GLMatrixFunc { frustum = new Frustum(); mulPMV = new float[16]; } - FloatUtil.multMatrixf(matrixMv, matrixP, mulPMV, 0); + FloatUtil.multMatrixf(matrixP, matrixMv, mulPMV, 0); frustum.update(mulPMV, 0); dirtyBits &= ~DIRTY_FRUSTUM; mod = true; |