Package org.joml

Class FrustumIntersection


  • public class FrustumIntersection
    extends java.lang.Object
    Efficiently performs frustum intersection tests by caching the frustum planes of an arbitrary transformation matrix.

    This class is preferred over the frustum intersection methods in Matrix4fc when many objects need to be culled by the same static frustum.

    Author:
    Kai Burjack
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int INSIDE
      Return value of intersectAab() and its different overloads indicating that the axis-aligned box is fully inside of the frustum.
      static int INTERSECT
      Return value of intersectAab() and its different overloads indicating that the axis-aligned box intersects the frustum.
      static int OUTSIDE
      Return value of intersectSphere(Vector3fc, float) or intersectSphere(float, float, float, float) indicating that the sphere is completely outside of the frustum.
      static int PLANE_MASK_NX
      The value in a bitmask for intersectAab() that identifies the plane with equation x=-1 when using the identity frustum.
      static int PLANE_MASK_NY
      The value in a bitmask for intersectAab() that identifies the plane with equation y=-1 when using the identity frustum.
      static int PLANE_MASK_NZ
      The value in a bitmask for intersectAab() that identifies the plane with equation z=-1 when using the identity frustum.
      static int PLANE_MASK_PX
      The value in a bitmask for intersectAab() that identifies the plane with equation x=1 when using the identity frustum.
      static int PLANE_MASK_PY
      The value in a bitmask for intersectAab() that identifies the plane with equation y=1 when using the identity frustum.
      static int PLANE_MASK_PZ
      The value in a bitmask for intersectAab() that identifies the plane with equation z=1 when using the identity frustum.
      static int PLANE_NX
      Return value of intersectAab() and its different overloads identifying the plane with equation x=-1 when using the identity frustum.
      static int PLANE_NY
      Return value of intersectAab() and its different overloads identifying the plane with equation y=-1 when using the identity frustum.
      static int PLANE_NZ
      Return value of intersectAab() and its different overloads identifying the plane with equation z=-1 when using the identity frustum.
      static int PLANE_PX
      Return value of intersectAab() and its different overloads identifying the plane with equation x=1 when using the identity frustum.
      static int PLANE_PY
      Return value of intersectAab() and its different overloads identifying the plane with equation y=1 when using the identity frustum.
      static int PLANE_PZ
      Return value of intersectAab() and its different overloads identifying the plane with equation z=1 when using the identity frustum.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float distanceToPlane​(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int plane)
      Compute the signed distance from the given axis-aligned box to the plane.
      int intersectAab​(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
      Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it.
      int intersectAab​(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int mask)
      Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it.
      int intersectAab​(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int mask, int startPlane)
      Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it.
      int intersectAab​(Vector3fc min, Vector3fc max)
      Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it.
      int intersectAab​(Vector3fc min, Vector3fc max, int mask)
      Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it.
      int intersectAab​(Vector3fc min, Vector3fc max, int mask, int startPlane)
      Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it.
      int intersectSphere​(float x, float y, float z, float r)
      Determine whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
      int intersectSphere​(Vector3fc center, float radius)
      Determine whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
      FrustumIntersection set​(Matrix4fc m)
      Update the stored frustum planes of this FrustumIntersection with the given matrix.
      FrustumIntersection set​(Matrix4fc m, boolean allowTestSpheres)
      Update the stored frustum planes of this FrustumIntersection with the given matrix and allow to optimize the frustum plane extraction in the case when no intersection test is needed for spheres.
      boolean testAab​(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
      Test whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler.
      boolean testAab​(Vector3fc min, Vector3fc max)
      Test whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler.
      boolean testLineSegment​(float aX, float aY, float aZ, float bX, float bY, float bZ)
      Test whether the given line segment, defined by the end points (aX, aY, aZ) and (bX, bY, bZ), is partly or completely within the frustum defined by this frustum culler.
      boolean testLineSegment​(Vector3fc a, Vector3fc b)
      Test whether the given line segment, defined by the end points a and b, is partly or completely within the frustum defined by this frustum culler.
      boolean testPlaneXY​(float minX, float minY, float maxX, float maxY)
      Test whether the given XY-plane (at Z = 0) is partly or completely within or outside of the frustum defined by this frustum culler.
      boolean testPlaneXY​(Vector2fc min, Vector2fc max)
      Test whether the given XY-plane (at Z = 0) is partly or completely within or outside of the frustum defined by this frustum culler.
      boolean testPlaneXZ​(float minX, float minZ, float maxX, float maxZ)
      Test whether the given XZ-plane (at Y = 0) is partly or completely within or outside of the frustum defined by this frustum culler.
      boolean testPoint​(float x, float y, float z)
      Test whether the given point (x, y, z) is within the frustum defined by this frustum culler.
      boolean testPoint​(Vector3fc point)
      Test whether the given point is within the frustum defined by this frustum culler.
      boolean testSphere​(float x, float y, float z, float r)
      Test whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
      boolean testSphere​(Vector3fc center, float radius)
      Test whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PLANE_NX

        public static final int PLANE_NX
        Return value of intersectAab() and its different overloads identifying the plane with equation x=-1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_PX

        public static final int PLANE_PX
        Return value of intersectAab() and its different overloads identifying the plane with equation x=1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_NY

        public static final int PLANE_NY
        Return value of intersectAab() and its different overloads identifying the plane with equation y=-1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_PY

        public static final int PLANE_PY
        Return value of intersectAab() and its different overloads identifying the plane with equation y=1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_NZ

        public static final int PLANE_NZ
        Return value of intersectAab() and its different overloads identifying the plane with equation z=-1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_PZ

        public static final int PLANE_PZ
        Return value of intersectAab() and its different overloads identifying the plane with equation z=1 when using the identity frustum.
        See Also:
        Constant Field Values
      • INTERSECT

        public static final int INTERSECT
        Return value of intersectAab() and its different overloads indicating that the axis-aligned box intersects the frustum.
        See Also:
        Constant Field Values
      • INSIDE

        public static final int INSIDE
        Return value of intersectAab() and its different overloads indicating that the axis-aligned box is fully inside of the frustum.
        See Also:
        Constant Field Values
      • PLANE_MASK_NX

        public static final int PLANE_MASK_NX
        The value in a bitmask for intersectAab() that identifies the plane with equation x=-1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_MASK_PX

        public static final int PLANE_MASK_PX
        The value in a bitmask for intersectAab() that identifies the plane with equation x=1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_MASK_NY

        public static final int PLANE_MASK_NY
        The value in a bitmask for intersectAab() that identifies the plane with equation y=-1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_MASK_PY

        public static final int PLANE_MASK_PY
        The value in a bitmask for intersectAab() that identifies the plane with equation y=1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_MASK_NZ

        public static final int PLANE_MASK_NZ
        The value in a bitmask for intersectAab() that identifies the plane with equation z=-1 when using the identity frustum.
        See Also:
        Constant Field Values
      • PLANE_MASK_PZ

        public static final int PLANE_MASK_PZ
        The value in a bitmask for intersectAab() that identifies the plane with equation z=1 when using the identity frustum.
        See Also:
        Constant Field Values
    • Method Detail

      • testPoint

        public boolean testPoint​(Vector3fc point)
        Test whether the given point is within the frustum defined by this frustum culler.
        Parameters:
        point - the point to test
        Returns:
        true if the given point is inside the frustum; false otherwise
      • testPoint

        public boolean testPoint​(float x,
                                 float y,
                                 float z)
        Test whether the given point (x, y, z) is within the frustum defined by this frustum culler.
        Parameters:
        x - the x-coordinate of the point
        y - the y-coordinate of the point
        z - the z-coordinate of the point
        Returns:
        true if the given point is inside the frustum; false otherwise
      • testSphere

        public boolean testSphere​(Vector3fc center,
                                  float radius)
        Test whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for spheres that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        center - the sphere's center
        radius - the sphere's radius
        Returns:
        true if the given sphere is partly or completely inside the frustum; false otherwise
      • testSphere

        public boolean testSphere​(float x,
                                  float y,
                                  float z,
                                  float r)
        Test whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for spheres that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        x - the x-coordinate of the sphere's center
        y - the y-coordinate of the sphere's center
        z - the z-coordinate of the sphere's center
        r - the sphere's radius
        Returns:
        true if the given sphere is partly or completely inside the frustum; false otherwise
      • intersectSphere

        public int intersectSphere​(Vector3fc center,
                                   float radius)
        Determine whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for spheres that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        center - the sphere's center
        radius - the sphere's radius
        Returns:
        INSIDE if the given sphere is completely inside the frustum, or INTERSECT if the sphere intersects the frustum, or OUTSIDE if the sphere is outside of the frustum
      • intersectSphere

        public int intersectSphere​(float x,
                                   float y,
                                   float z,
                                   float r)
        Determine whether the given sphere is partly or completely within or outside of the frustum defined by this frustum culler.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for spheres that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        x - the x-coordinate of the sphere's center
        y - the y-coordinate of the sphere's center
        z - the z-coordinate of the sphere's center
        r - the sphere's radius
        Returns:
        INSIDE if the given sphere is completely inside the frustum, or INTERSECT if the sphere intersects the frustum, or OUTSIDE if the sphere is outside of the frustum
      • testAab

        public boolean testAab​(Vector3fc min,
                               Vector3fc max)
        Test whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler. The box is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        min - the minimum corner coordinates of the axis-aligned box
        max - the maximum corner coordinates of the axis-aligned box
        Returns:
        true if the axis-aligned box is completely or partly inside of the frustum; false otherwise
      • testAab

        public boolean testAab​(float minX,
                               float minY,
                               float minZ,
                               float maxX,
                               float maxY,
                               float maxZ)
        Test whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler. The box is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Reference: Efficient View Frustum Culling

        Parameters:
        minX - the x-coordinate of the minimum corner
        minY - the y-coordinate of the minimum corner
        minZ - the z-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxY - the y-coordinate of the maximum corner
        maxZ - the z-coordinate of the maximum corner
        Returns:
        true if the axis-aligned box is completely or partly inside of the frustum; false otherwise
      • testPlaneXY

        public boolean testPlaneXY​(Vector2fc min,
                                   Vector2fc max)
        Test whether the given XY-plane (at Z = 0) is partly or completely within or outside of the frustum defined by this frustum culler. The plane is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for planes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        min - the minimum corner coordinates of the XY-plane
        max - the maximum corner coordinates of the XY-plane
        Returns:
        true if the XY-plane is completely or partly inside of the frustum; false otherwise
      • testPlaneXY

        public boolean testPlaneXY​(float minX,
                                   float minY,
                                   float maxX,
                                   float maxY)
        Test whether the given XY-plane (at Z = 0) is partly or completely within or outside of the frustum defined by this frustum culler. The plane is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for planes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Reference: Efficient View Frustum Culling

        Parameters:
        minX - the x-coordinate of the minimum corner
        minY - the y-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxY - the y-coordinate of the maximum corner
        Returns:
        true if the XY-plane is completely or partly inside of the frustum; false otherwise
      • testPlaneXZ

        public boolean testPlaneXZ​(float minX,
                                   float minZ,
                                   float maxX,
                                   float maxZ)
        Test whether the given XZ-plane (at Y = 0) is partly or completely within or outside of the frustum defined by this frustum culler. The plane is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns true for planes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Reference: Efficient View Frustum Culling

        Parameters:
        minX - the x-coordinate of the minimum corner
        minZ - the z-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxZ - the z-coordinate of the maximum corner
        Returns:
        true if the XZ-plane is completely or partly inside of the frustum; false otherwise
      • intersectAab

        public int intersectAab​(Vector3fc min,
                                Vector3fc max)
        Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it. The box is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        min - the minimum corner coordinates of the axis-aligned box
        max - the maximum corner coordinates of the axis-aligned box
        Returns:
        the index of the first plane that culled the box, if the box does not intersect the frustum; or INTERSECT if the box intersects the frustum, or INSIDE if the box is fully inside of the frustum. The plane index is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
      • intersectAab

        public int intersectAab​(float minX,
                                float minY,
                                float minZ,
                                float maxX,
                                float maxY,
                                float maxZ)
        Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it. The box is specified via its min and max corner coordinates.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Reference: Efficient View Frustum Culling

        Parameters:
        minX - the x-coordinate of the minimum corner
        minY - the y-coordinate of the minimum corner
        minZ - the z-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxY - the y-coordinate of the maximum corner
        maxZ - the z-coordinate of the maximum corner
        Returns:
        the index of the first plane that culled the box, if the box does not intersect the frustum, or INTERSECT if the box intersects the frustum, or INSIDE if the box is fully inside of the frustum. The plane index is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
      • distanceToPlane

        public float distanceToPlane​(float minX,
                                     float minY,
                                     float minZ,
                                     float maxX,
                                     float maxY,
                                     float maxZ,
                                     int plane)
        Compute the signed distance from the given axis-aligned box to the plane.
        Parameters:
        minX - the x-coordinate of the minimum corner
        minY - the y-coordinate of the minimum corner
        minZ - the z-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxY - the y-coordinate of the maximum corner
        maxZ - the z-coordinate of the maximum corner
        plane - one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
        Returns:
        the signed distance of the axis-aligned box to the plane
      • intersectAab

        public int intersectAab​(Vector3fc min,
                                Vector3fc max,
                                int mask)
        Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it. The box is specified via its min and max corner coordinates.

        This method differs from intersectAab(Vector3fc, Vector3fc) in that it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the left frustum plane, use a mask of PLANE_MASK_NX. Or in order to test all planes except the left plane, use a mask of (~0 ^ PLANE_MASK_NX).

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        min - the minimum corner coordinates of the axis-aligned box
        max - the maximum corner coordinates of the axis-aligned box
        mask - contains as bitset all the planes that should be tested. This value can be any combination of PLANE_MASK_NX, PLANE_MASK_PX, PLANE_MASK_NY, PLANE_MASK_PY, PLANE_MASK_NZ and PLANE_MASK_PZ
        Returns:
        the index of the first plane that culled the box, if the box does not intersect the frustum, or INTERSECT if the box intersects the frustum, or INSIDE if the box is fully inside of the frustum. The plane index is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
      • intersectAab

        public int intersectAab​(float minX,
                                float minY,
                                float minZ,
                                float maxX,
                                float maxY,
                                float maxZ,
                                int mask)
        Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it. The box is specified via its min and max corner coordinates.

        This method differs from intersectAab(float, float, float, float, float, float) in that it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the left frustum plane, use a mask of PLANE_MASK_NX. Or in order to test all planes except the left plane, use a mask of (~0 ^ PLANE_MASK_NX).

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Reference: Efficient View Frustum Culling

        Parameters:
        minX - the x-coordinate of the minimum corner
        minY - the y-coordinate of the minimum corner
        minZ - the z-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxY - the y-coordinate of the maximum corner
        maxZ - the z-coordinate of the maximum corner
        mask - contains as bitset all the planes that should be tested. This value can be any combination of PLANE_MASK_NX, PLANE_MASK_PX, PLANE_MASK_NY, PLANE_MASK_PY, PLANE_MASK_NZ and PLANE_MASK_PZ
        Returns:
        the index of the first plane that culled the box, if the box does not intersect the frustum, or INTERSECT if the box intersects the frustum, or INSIDE if the box is fully inside of the frustum. The plane index is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
      • intersectAab

        public int intersectAab​(Vector3fc min,
                                Vector3fc max,
                                int mask,
                                int startPlane)
        Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it. The box is specified via its min and max corner coordinates.

        This method differs from intersectAab(Vector3fc, Vector3fc) in that it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the left frustum plane, use a mask of PLANE_MASK_NX. Or in order to test all planes except the left plane, use a mask of (~0 ^ PLANE_MASK_NX).

        In addition, the startPlane denotes the first frustum plane to test the box against. To use this effectively means to store the plane that previously culled an axis-aligned box (as returned by intersectAab()) and in the next frame use the return value as the argument to the startPlane parameter of this method. The assumption is that the plane that culled the object previously will also cull it now (temporal coherency) and the culling computation is likely reduced in that case.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Parameters:
        min - the minimum corner coordinates of the axis-aligned box
        max - the maximum corner coordinates of the axis-aligned box
        mask - contains as bitset all the planes that should be tested. This value can be any combination of PLANE_MASK_NX, PLANE_MASK_PX, PLANE_MASK_NY, PLANE_MASK_PY, PLANE_MASK_NZ and PLANE_MASK_PZ
        startPlane - the first frustum plane to test the axis-aligned box against. It is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
        Returns:
        the index of the first plane that culled the box, if the box does not intersect the frustum, or INTERSECT if the box intersects the frustum, or INSIDE if the box is fully inside of the frustum. The plane index is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
      • intersectAab

        public int intersectAab​(float minX,
                                float minY,
                                float minZ,
                                float maxX,
                                float maxY,
                                float maxZ,
                                int mask,
                                int startPlane)
        Determine whether the given axis-aligned box is partly or completely within or outside of the frustum defined by this frustum culler and, if the box is not inside this frustum, return the index of the plane that culled it. The box is specified via its min and max corner coordinates.

        This method differs from intersectAab(float, float, float, float, float, float) in that it allows to mask-off planes that should not be calculated. For example, in order to only test a box against the left frustum plane, use a mask of PLANE_MASK_NX. Or in order to test all planes except the left plane, use a mask of (~0 ^ PLANE_MASK_NX).

        In addition, the startPlane denotes the first frustum plane to test the box against. To use this effectively means to store the plane that previously culled an axis-aligned box (as returned by intersectAab()) and in the next frame use the return value as the argument to the startPlane parameter of this method. The assumption is that the plane that culled the object previously will also cull it now (temporal coherency) and the culling computation is likely reduced in that case.

        The algorithm implemented by this method is conservative. This means that in certain circumstances a false positive can occur, when the method returns INTERSECT for boxes that do not intersect the frustum. See iquilezles.org for an examination of this problem.

        Reference: Efficient View Frustum Culling

        Parameters:
        minX - the x-coordinate of the minimum corner
        minY - the y-coordinate of the minimum corner
        minZ - the z-coordinate of the minimum corner
        maxX - the x-coordinate of the maximum corner
        maxY - the y-coordinate of the maximum corner
        maxZ - the z-coordinate of the maximum corner
        mask - contains as bitset all the planes that should be tested. This value can be any combination of PLANE_MASK_NX, PLANE_MASK_PX, PLANE_MASK_NY, PLANE_MASK_PY, PLANE_MASK_NZ and PLANE_MASK_PZ
        startPlane - the first frustum plane to test the axis-aligned box against. It is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
        Returns:
        the index of the first plane that culled the box, if the box does not intersect the frustum, or INTERSECT if the box intersects the frustum, or INSIDE if the box is fully inside of the frustum. The plane index is one of PLANE_NX, PLANE_PX, PLANE_NY, PLANE_PY, PLANE_NZ and PLANE_PZ
      • testLineSegment

        public boolean testLineSegment​(Vector3fc a,
                                       Vector3fc b)
        Test whether the given line segment, defined by the end points a and b, is partly or completely within the frustum defined by this frustum culler.
        Parameters:
        a - the line segment's first end point
        b - the line segment's second end point
        Returns:
        true if the given line segment is partly or completely inside the frustum; false otherwise
      • testLineSegment

        public boolean testLineSegment​(float aX,
                                       float aY,
                                       float aZ,
                                       float bX,
                                       float bY,
                                       float bZ)
        Test whether the given line segment, defined by the end points (aX, aY, aZ) and (bX, bY, bZ), is partly or completely within the frustum defined by this frustum culler.
        Parameters:
        aX - the x coordinate of the line segment's first end point
        aY - the y coordinate of the line segment's first end point
        aZ - the z coordinate of the line segment's first end point
        bX - the x coordinate of the line segment's second end point
        bY - the y coordinate of the line segment's second end point
        bZ - the z coordinate of the line segment's second end point
        Returns:
        true if the given line segment is partly or completely inside the frustum; false otherwise