LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: [UPDATE] MatrixStack improvements, new Ray/AAB-intersection test  (Read 932 times)

Kai

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 899

MatrixStack improvements
The MatrixStackf (formerly MatrixStack) as well as the new MatrixStackd classes now inherit from Matrix4f and Matrix4d, respectively.

Thanks to @theagentd for this proposal.

Due to subtyping this of course now enables a MatrixStack to be used in all cases where a Matrix can be used. The current (i.e. top) matrix of the MatrixStack is always the 16 matrix elements inherited from class Matrix itself.
Another great benefit is that the subclassing now always keeps the operations of MatrixStack in sync with the Matrix.

Equals relations:
- a Matrix is equal to a MatrixStack iff the 16 matrix elements of the Matrix are equal to the 16 matrix elements of the MatrixStack (inherited from Matrix).
- a MatrixStack is equal to a Matrix iff the 16 matrix elements of the MatrixStack (inherited from Matrix) are equal to the 16 matrix elements of the Matrix.
- a MatrixStack is equal to a MatrixStack iff the 16 matrix elements of both MatrixStacks (inherited from Matrix) are equal and the current depth (i.e. stack pointer) of both stacks are equal and all matrices between and including the bottom of both stacks and the current/top matrix of boths stacks are equal.

RayAabIntersection
The new class RayAabIntersection which currently only resides in the "intersection" branch of JOML enables very fast ray vs. axis-aligned box intersection tests.
It is an implementation of the 2008 Fast Ray/Axis-Aligned Bounding Box Overlap Tests using Ray Slopes paper.
That method about 20% faster than the "slab method" using precomputation of a given ray for faster intersection tests of many axis-aligned boxes with that same ray.
It is suitable for building software raytracers when using a spatial acceleration structure that makes use of axis-aligned bounding boxes; or when implementing picking in a game (engine). A test for ray/triangle intersection is soon to come.
Logged