From 5cca51e32999a882e2a5f00cb45ecafc824ffd86 Mon Sep 17 00:00:00 2001 From: Sven Göthel Date: Fri, 19 Jan 2024 06:11:46 +0100 Subject: Frustum: Revise code and its Plane definition to support Cube->Frustum as well as to extract planes for float[] vec4-shader uniforms. commit 1040bed4ecc6f4598ea459f1073a9240583fc3c3 added AABBox -> Cube -> Frustum mapping (incomplete) and requires Frustum.Plane.set(..) by normal and point-on-plane for distance. Frustum.isOutside(Cube) has been added, testing all its 8-points similar to AABBox. Further all 6 Frustum.Plane shall be extracted to Vec4f and float[], the latter to pass the whole float[4*6] as a vec4[6] uniform array to the shader. +++ Constructor, setter and getter have been adjusted accordingly. Most of the loops have been unrolled. +++ Method names to query Frustum, i.e. 'is*Outside()' have been reduced to 'isOutside()' where uniquely indenticates the purpose. Hence only 'isSphereOutside()' is left over. --- src/jogl/classes/com/jogamp/math/Matrix4f.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/jogl/classes/com/jogamp/math/Matrix4f.java') diff --git a/src/jogl/classes/com/jogamp/math/Matrix4f.java b/src/jogl/classes/com/jogamp/math/Matrix4f.java index beb7b666c..b82f92727 100644 --- a/src/jogl/classes/com/jogamp/math/Matrix4f.java +++ b/src/jogl/classes/com/jogamp/math/Matrix4f.java @@ -1334,13 +1334,11 @@ public class Matrix4f { * using this premultiplied P*MV (column major order) matrix. *

* Frustum plane's normals will point to the inside of the viewing frustum, - * as required by this class. - *

- *

- * Usually called by {@link Frustum#updateFrustumPlanes(Matrix4f)}. + * as required by the {@link Frustum} class. *

+ * @see Frustum#updateFrustumPlanes(Matrix4f) */ - public void updateFrustumPlanes(final Frustum frustum) { + public Frustum updateFrustumPlanes(final Frustum frustum) { // Left: a = m41 + m11, b = m42 + m12, c = m43 + m13, d = m44 + m14 - [1..4] column-major // Left: a = m30 + m00, b = m31 + m01, c = m32 + m02, d = m33 + m03 - [0..3] column-major { @@ -1415,6 +1413,7 @@ public class Matrix4f { p_n.scale(invLen); p.d *= invLen; } + return frustum; } /** -- cgit v1.2.3