Kemena3D
Loading...
Searching...
No Matches
kemena::kAABB Struct Reference

Axis-aligned bounding box (min/max in the same space). More...

#include <kdatatype.h>

Public Member Functions

 kAABB ()=default
 Constructs an empty (invalid) bounding box.
 kAABB (kVec3 min, kVec3 max)
 Constructs a bounding box from explicit corners.
kVec3 center () const
 Returns the geometric centre of the box.
kVec3 halfExtents () const
 Returns half the size of the box along each axis.
bool isValid () const
 Returns true if min is component-wise less than or equal to max (i.e. the box is non-degenerate).
void expandBy (const kVec3 &point)
 Grows the box so that it encloses the given point.
void merge (const kAABB &other)
 Grows the box so that it encloses another box.
kAABB expanded (float amount) const
 Returns a copy of the box uniformly expanded outward by the given amount on every side.
bool contains (const kAABB &other) const
 Tests whether this box fully contains another box.
bool overlaps (const kAABB &other) const
 Tests whether this box intersects another box.

Public Attributes

kVec3 min = kVec3( 1e30f)
 Minimum corner; initialised to +inf so the box starts empty/invalid.
kVec3 max = kVec3(-1e30f)
 Maximum corner; initialised to -inf so the box starts empty/invalid.

Detailed Description

Axis-aligned bounding box (min/max in the same space).

Constructor & Destructor Documentation

◆ kAABB() [1/2]

kemena::kAABB::kAABB ( )
default

Constructs an empty (invalid) bounding box.

Here is the caller graph for this function:

◆ kAABB() [2/2]

kemena::kAABB::kAABB ( kVec3 min,
kVec3 max )
inline

Constructs a bounding box from explicit corners.

Parameters
minMinimum corner.
maxMaximum corner.

Member Function Documentation

◆ center()

kVec3 kemena::kAABB::center ( ) const
inline

Returns the geometric centre of the box.

◆ contains()

bool kemena::kAABB::contains ( const kAABB & other) const
inline

Tests whether this box fully contains another box.

Parameters
otherBox to test for containment.
Returns
true if other lies entirely within this box.
Here is the call graph for this function:

◆ expandBy()

void kemena::kAABB::expandBy ( const kVec3 & point)
inline

Grows the box so that it encloses the given point.

Parameters
pointPoint to include.

◆ expanded()

kAABB kemena::kAABB::expanded ( float amount) const
inline

Returns a copy of the box uniformly expanded outward by the given amount on every side.

Parameters
amountDistance to push each face outward.
Returns
Expanded bounding box.
Here is the call graph for this function:

◆ halfExtents()

kVec3 kemena::kAABB::halfExtents ( ) const
inline

Returns half the size of the box along each axis.

◆ isValid()

bool kemena::kAABB::isValid ( ) const
inline

Returns true if min is component-wise less than or equal to max (i.e. the box is non-degenerate).

◆ merge()

void kemena::kAABB::merge ( const kAABB & other)
inline

Grows the box so that it encloses another box.

Parameters
otherBox to merge into this one.
Here is the call graph for this function:

◆ overlaps()

bool kemena::kAABB::overlaps ( const kAABB & other) const
inline

Tests whether this box intersects another box.

Parameters
otherBox to test against.
Returns
true if the two boxes overlap (touching counts as overlap).
Here is the call graph for this function:

Member Data Documentation

◆ max

kVec3 kemena::kAABB::max = kVec3(-1e30f)

Maximum corner; initialised to -inf so the box starts empty/invalid.

◆ min

kVec3 kemena::kAABB::min = kVec3( 1e30f)

Minimum corner; initialised to +inf so the box starts empty/invalid.


The documentation for this struct was generated from the following file: