Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Frustum Class Referencefinal

A frustum class that can be used for efficient primitive intersection tests. More...

#include <Frustum.h>

Public Types

enum  PlaneId {
  Near , Far , Left , Right ,
  Top , Bottom , MAX
}
 
enum class  ReverseDepth { True , False }
 
enum  CornerIndices {
  NearTopLeft , NearTopRight , NearBottomLeft , NearBottomRight ,
  FarTopLeft , FarTopRight , FarBottomLeft , FarBottomRight ,
  Count
}
 
using CornerVertexArray = AZStd::array< AZ::Vector3, CornerIndices::Count >
 

Public Member Functions

 AZ_TYPE_INFO (Frustum, "{AE7D2ADA-0266-494A-98C4-699F099171C2}")
 
 Frustum ()
 Default constructor, leaves members uninitialized for speed.
 
 Frustum (const ViewFrustumAttributes &viewFrustumAttributes)
 
 Frustum (const Plane &nearPlane, const Plane &farPlane, const Plane &leftPlane, const Plane &rightPlane, const Plane &topPlane, const Plane &bottomPlane)
 
Plane GetPlane (PlaneId planeId) const
 
void SetPlane (PlaneId planeId, const Plane &plane)
 
void Set (const Frustum &frustum)
 
IntersectResult IntersectSphere (const Vector3 &center, float radius) const
 
IntersectResult IntersectSphere (const Sphere &sphere) const
 
IntersectResult IntersectAabb (const Vector3 &minimum, const Vector3 &maximum) const
 
IntersectResult IntersectAabb (const Aabb &aabb) const
 
bool IsClose (const Frustum &rhs, float tolerance=Constants::Tolerance) const
 
bool GetCorners (CornerVertexArray &corners) const
 
ViewFrustumAttributes CalculateViewFrustumAttributes () const
 Returns the corresponding view volume attributes for the frustum.
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static Frustum CreateFromMatrixRowMajor (const Matrix4x4 &matrix, ReverseDepth reverseDepth=ReverseDepth::False)
 
static Frustum CreateFromMatrixColumnMajor (const Matrix4x4 &matrix, ReverseDepth reverseDepth=ReverseDepth::False)
 
static Frustum CreateFromMatrixRowMajorSymmetricZ (const Matrix4x4 &matrix, ReverseDepth reverseDepth=ReverseDepth::False)
 
static Frustum CreateFromMatrixColumnMajorSymmetricZ (const Matrix4x4 &matrix, ReverseDepth reverseDepth=ReverseDepth::False)
 

Detailed Description

A frustum class that can be used for efficient primitive intersection tests.

Constructor & Destructor Documentation

◆ Frustum()

AZ::Frustum::Frustum ( const ViewFrustumAttributes viewFrustumAttributes)
explicit

Construct a view frustum from ViewFrustumAttributes.

Parameters
viewFrustumAttributesAttributes to build a Frustum from a view volume.

Member Function Documentation

◆ CreateFromMatrixRowMajor()

static Frustum AZ::Frustum::CreateFromMatrixRowMajor ( const Matrix4x4 matrix,
ReverseDepth  reverseDepth = ReverseDepth::False 
)
static

Extract frustum from matrix. Matrix Usage and Z conventions form the matrix of use cases. Symmetric-z (OpenGL convention) implies -w <= z <= w Non-symmetric (DirectX convention) implies 0 <= z <= w RowMajor implies x*M convention ColumnMajor implies M*x convention

◆ GetCorners()

bool AZ::Frustum::GetCorners ( CornerVertexArray corners) const

Fills an array with corner vertices and returns true for valid Frustums.

Parameters
cornersThe array of corner vertices to fill.

◆ GetPlane()

AZ_MATH_INLINE Plane AZ::Frustum::GetPlane ( PlaneId  planeId) const

Returns the requested plane.

Parameters
planeIdthe index of the plane to retrieve

◆ IntersectAabb() [1/2]

AZ_MATH_INLINE IntersectResult AZ::Frustum::IntersectAabb ( const Aabb aabb) const

Intersects an axis-aligned bounding box.

Parameters
aabbthe axis-aligned bounding box to test against
Returns
the intersection result of the Aabb against the frustum

◆ IntersectAabb() [2/2]

AZ_MATH_INLINE IntersectResult AZ::Frustum::IntersectAabb ( const Vector3 minimum,
const Vector3 maximum 
) const

Intersects an axis-aligned bounding box.

Parameters
minimumthe smallest extents of the bounding volume to test against
maximumthe largest extents of the bounding volume to test against
Returns
the intersection result of the Aabb against the frustum

◆ IntersectSphere() [1/2]

AZ_MATH_INLINE IntersectResult AZ::Frustum::IntersectSphere ( const Sphere sphere) const

Intersects a sphere against the frustum.

Parameters
spherethe sphere to test against
Returns
the intersection result of the sphere against the frustum

◆ IntersectSphere() [2/2]

AZ_MATH_INLINE IntersectResult AZ::Frustum::IntersectSphere ( const Vector3 center,
float  radius 
) const

Intersects a sphere against the frustum.

Parameters
centerthe center of the sphere to test against
radiusthe radius of the sphere to test against
Returns
the intersection result of the sphere against the frustum

◆ IsClose()

AZ_MATH_INLINE bool AZ::Frustum::IsClose ( const Frustum rhs,
float  tolerance = Constants::Tolerance 
) const

Returns true if the current frustum and provided frustum are close to identical.

Parameters
rhsthe frustum to compare against for closeness

◆ Reflect()

static void AZ::Frustum::Reflect ( ReflectContext context)
static

AzCore Reflection.

Parameters
contextreflection context

◆ Set()

void AZ::Frustum::Set ( const Frustum frustum)

Clones the provided frustum.

Parameters
frustumthe frustum instance to clone

◆ SetPlane()

AZ_MATH_INLINE void AZ::Frustum::SetPlane ( PlaneId  planeId,
const Plane plane 
)

Sets the requested plane.

Parameters
planeIdthe index of the plane to set
planethe new plane value to set to

The documentation for this class was generated from the following files: