Lysa  0.0
Lysa 3D Engine
AABB Struct Reference

Detailed Description

Lightweight structure representing a 3D axis-aligned bounding box in the engine's right-handed coordinate system.

Public Member Functions

 AABB () = default
 
 AABB (const float3 &min, const float3 &max)
 
 AABB (const AABB &aabb)
 
float3 center () const
 
AABB toGlobal (const float4x4 &transform) const
 
bool intersectsRay (const float3 &origin, const float3 &invDir, float tMax, float &tMin) const
 

Public Attributes

float3 min {}
 
float3 max {}
 

Constructor & Destructor Documentation

AABB ( )
default

Default-construct an empty/invalid AABB with zeroed corners. The box becomes valid once min/max are assigned meaningful values.

AABB ( const float3 &  min,
const float3 &  max 
)
inline

Construct a bounding box from its minimum and maximum corners.

Parameters
minMinimum corner (x/y/z individually less-or-equal to max).
maxMaximum corner (x/y/z individually greater-or-equal to min).
AABB ( const AABB &  aabb)
inline

Member Function Documentation

float3 center ( ) const
inline

Compute the volumetric center of the box.

Returns
The midpoint between the minimum and maximum corners.
bool intersectsRay ( const float3 &  origin,
const float3 &  invDir,
float  tMax,
float &  tMin 
) const

Ray vs AABB intersection

Parameters
originWorld-space ray origin.
invDirInverse direction vector
tMaxMaximum ray distance; hits beyond this are ignored.
tMin[out] Distance to the near intersection (valid only on hit).
Returns
True if the ray intersects the box within [0, tMax].
AABB toGlobal ( const float4x4 &  transform) const

Compute the world-space AABB that encloses this box transformed by the given matrix.

Member Data Documentation

float3 max {}

Maximum corner of the box (component-wise). Typically corresponds to the right/top/front corner: {max.x, max.y, max.z}.

float3 min {}

Minimum corner of the box (component-wise). Typically corresponds to the left/bottom/back corner: {min.x, min.y, min.z}.