public class FrustumIntersection extends Object
matrix.
This class is preferred over the frustum intersection methods in Matrix4fc when many objects need to be culled by the same static frustum.
| Modifier and Type | Field and 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. |
| Constructor and Description |
|---|
FrustumIntersection()
Create a new
FrustumIntersection with undefined frustum planes. |
FrustumIntersection(Matrix4fc m)
Create a new
FrustumIntersection from the given matrix by extracing the matrix's frustum planes. |
FrustumIntersection(Matrix4fc m,
boolean allowTestSpheres)
Create a new
FrustumIntersection from the given matrix by extracing the matrix's frustum planes. |
| Modifier and Type | Method and Description |
|---|---|
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)
|
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 |
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. |
public static final int PLANE_NX
intersectAab()
and its different overloads identifying the plane with equation x=-1 when using the identity frustum.public static final int PLANE_PX
intersectAab()
and its different overloads identifying the plane with equation x=1 when using the identity frustum.public static final int PLANE_NY
intersectAab()
and its different overloads identifying the plane with equation y=-1 when using the identity frustum.public static final int PLANE_PY
intersectAab()
and its different overloads identifying the plane with equation y=1 when using the identity frustum.public static final int PLANE_NZ
intersectAab()
and its different overloads identifying the plane with equation z=-1 when using the identity frustum.public static final int PLANE_PZ
intersectAab()
and its different overloads identifying the plane with equation z=1 when using the identity frustum.public static final int INTERSECT
intersectAab()
and its different overloads indicating that the axis-aligned box intersects the frustum.public static final int INSIDE
intersectAab()
and its different overloads indicating that the axis-aligned box is fully inside of the frustum.public static final int OUTSIDE
intersectSphere(Vector3fc, float) or intersectSphere(float, float, float, float)
indicating that the sphere is completely outside of the frustum.public static final int PLANE_MASK_NX
intersectAab()
that identifies the plane with equation x=-1 when using the identity frustum.public static final int PLANE_MASK_PX
intersectAab()
that identifies the plane with equation x=1 when using the identity frustum.public static final int PLANE_MASK_NY
intersectAab()
that identifies the plane with equation y=-1 when using the identity frustum.public static final int PLANE_MASK_PY
intersectAab()
that identifies the plane with equation y=1 when using the identity frustum.public static final int PLANE_MASK_NZ
intersectAab()
that identifies the plane with equation z=-1 when using the identity frustum.public static final int PLANE_MASK_PZ
intersectAab()
that identifies the plane with equation z=1 when using the identity frustum.public FrustumIntersection()
FrustumIntersection with undefined frustum planes.
Before using any of the frustum culling methods, make sure to define the frustum planes using set(Matrix4fc).
public FrustumIntersection(Matrix4fc m)
FrustumIntersection from the given matrix by extracing the matrix's frustum planes.
In order to update the compute frustum planes later on, call set(Matrix4fc).
m - the Matrix4fc to create the frustum culler fromset(Matrix4fc)public FrustumIntersection(Matrix4fc m, boolean allowTestSpheres)
FrustumIntersection from the given matrix by extracing the matrix's frustum planes.
In order to update the compute frustum planes later on, call set(Matrix4fc).
m - the Matrix4fc to create the frustum culler fromallowTestSpheres - whether the methods testSphere(Vector3fc, float), testSphere(float, float, float, float),
intersectSphere(Vector3fc, float) or intersectSphere(float, float, float, float) will used.
If no spheres need to be tested, then false should be usedset(Matrix4fc)public FrustumIntersection set(Matrix4fc m)
this FrustumIntersection with the given matrix.
Reference: Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix
m - the matrix to update this frustum culler's frustum planes frompublic FrustumIntersection set(Matrix4fc m, boolean allowTestSpheres)
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.
Reference: Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix
m - the matrix to update this frustum culler's frustum planes fromallowTestSpheres - whether the methods testSphere(Vector3fc, float), testSphere(float, float, float, float),
intersectSphere(Vector3fc, float) or intersectSphere(float, float, float, float) will be used.
If no spheres need to be tested, then false should be usedpublic boolean testPoint(Vector3fc point)
this frustum culler.point - the point to testtrue if the given point is inside the frustum; false otherwisepublic boolean testPoint(float x,
float y,
float z)
(x, y, z) is within the frustum defined by this frustum culler.x - the x-coordinate of the pointy - the y-coordinate of the pointz - the z-coordinate of the pointtrue if the given point is inside the frustum; false otherwisepublic boolean testSphere(Vector3fc center, float radius)
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 are actually not visible.
See iquilezles.org for an examination of this problem.
center - the sphere's centerradius - the sphere's radiustrue if the given sphere is partly or completely inside the frustum;
false otherwisepublic boolean testSphere(float x,
float y,
float z,
float r)
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 are actually not visible.
See iquilezles.org for an examination of this problem.
x - the x-coordinate of the sphere's centery - the y-coordinate of the sphere's centerz - the z-coordinate of the sphere's centerr - the sphere's radiustrue if the given sphere is partly or completely inside the frustum;
false otherwisepublic int intersectSphere(Vector3fc center, float radius)
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 are actually not visible.
See iquilezles.org for an examination of this problem.
public int intersectSphere(float x,
float y,
float z,
float r)
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 are actually not visible.
See iquilezles.org for an examination of this problem.
x - the x-coordinate of the sphere's centery - the y-coordinate of the sphere's centerz - the z-coordinate of the sphere's centerr - the sphere's radiusINSIDE 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 frustumpublic boolean testAab(Vector3fc min, Vector3fc max)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
min - the minimum corner coordinates of the axis-aligned boxmax - the maximum corner coordinates of the axis-aligned boxtrue if the axis-aligned box is completely or partly inside of the frustum; false otherwisepublic boolean testAab(float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
Reference: Efficient View Frustum Culling
minX - the x-coordinate of the minimum cornerminY - the y-coordinate of the minimum cornerminZ - the z-coordinate of the minimum cornermaxX - the x-coordinate of the maximum cornermaxY - the y-coordinate of the maximum cornermaxZ - the z-coordinate of the maximum cornertrue if the axis-aligned box is completely or partly inside of the frustum; false otherwisepublic boolean testPlaneXY(Vector2fc min, Vector2fc max)
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 -1 for planes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
min - the minimum corner coordinates of the XY-planemax - the maximum corner coordinates of the XY-planetrue if the XY-plane is completely or partly inside of the frustum; false otherwisepublic boolean testPlaneXY(float minX,
float minY,
float maxX,
float maxY)
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 -1 for planes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
Reference: Efficient View Frustum Culling
minX - the x-coordinate of the minimum cornerminY - the y-coordinate of the minimum cornermaxX - the x-coordinate of the maximum cornermaxY - the y-coordinate of the maximum cornertrue if the XY-plane is completely or partly inside of the frustum; false otherwisepublic boolean testPlaneXZ(float minX,
float minZ,
float maxX,
float maxZ)
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 -1 for planes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
Reference: Efficient View Frustum Culling
minX - the x-coordinate of the minimum cornerminZ - the z-coordinate of the minimum cornermaxX - the x-coordinate of the maximum cornermaxZ - the z-coordinate of the maximum cornertrue if the XZ-plane is completely or partly inside of the frustum; false otherwisepublic int intersectAab(Vector3fc min, Vector3fc max)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
min - the minimum corner coordinates of the axis-aligned boxmax - the maximum corner coordinates of the axis-aligned boxINTERSECT 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_PZpublic int intersectAab(float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
Reference: Efficient View Frustum Culling
minX - the x-coordinate of the minimum cornerminY - the y-coordinate of the minimum cornerminZ - the z-coordinate of the minimum cornermaxX - the x-coordinate of the maximum cornermaxY - the y-coordinate of the maximum cornermaxZ - the z-coordinate of the maximum cornerINTERSECT 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_PZpublic int intersectAab(Vector3fc min, Vector3fc max, int mask)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
min - the minimum corner coordinates of the axis-aligned boxmax - the maximum corner coordinates of the axis-aligned boxmask - 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_PZINTERSECT 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_PZpublic int intersectAab(float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ,
int mask)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
Reference: Efficient View Frustum Culling
minX - the x-coordinate of the minimum cornerminY - the y-coordinate of the minimum cornerminZ - the z-coordinate of the minimum cornermaxX - the x-coordinate of the maximum cornermaxY - the y-coordinate of the maximum cornermaxZ - the z-coordinate of the maximum cornermask - 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_PZINTERSECT 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_PZpublic int intersectAab(Vector3fc min, Vector3fc max, int mask, int startPlane)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
min - the minimum corner coordinates of the axis-aligned boxmax - the maximum corner coordinates of the axis-aligned boxmask - 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_PZstartPlane - 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_PZINTERSECT 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_PZpublic int intersectAab(float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ,
int mask,
int startPlane)
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 -1 for boxes that are actually not visible/do not intersect the frustum.
See iquilezles.org for an examination of this problem.
Reference: Efficient View Frustum Culling
minX - the x-coordinate of the minimum cornerminY - the y-coordinate of the minimum cornerminZ - the z-coordinate of the minimum cornermaxX - the x-coordinate of the maximum cornermaxY - the y-coordinate of the maximum cornermaxZ - the z-coordinate of the maximum cornermask - 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_PZstartPlane - 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_PZINTERSECT 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_PZCopyright © 2015–2019 JOML. All rights reserved.