Math::BoundingBox struct

A pair of two Vector3 that define the boundaries of an object (the minimum point and the maximum point in the space).

The two vectors are the lower (minumum) bound and the upper (maximum) bound.

Constructors, destructors, conversion operators

BoundingBox()
BoundingBox(const Vector3& lower, const Vector3& upper)

Public functions

auto ApplyTransform(const Transform& transform) -> void
Recalculates the bounding box after having applied the given transform.
auto GetCenter() const -> Vector3
Returns the center of this bounding box.
auto Contains(const Vector3& point) const -> bool
Tells whether this bounding box contains the given point.
auto Intersect(const BoundingBox& other, BoundingBox& dst = BoundingBox()) const -> bool
Finds the intersection between two bounding boxes.

Public variables

Vector3 lower
Vector3 upper

Function documentation

void Math::BoundingBox::ApplyTransform(const Transform& transform)

Recalculates the bounding box after having applied the given transform.

Parameters
transform The transformation to apply to the bounding box.

bool Math::BoundingBox::Contains(const Vector3& point) const

Tells whether this bounding box contains the given point.

Parameters
point

bool Math::BoundingBox::Intersect(const BoundingBox& other, BoundingBox& dst = BoundingBox()) const

Finds the intersection between two bounding boxes.

Parameters
other The other bounding box to intersect with.
dst out [Optional] Where the intersection will be written. Points inside this bbox are contained in both bbox.
Returns true if the bounding boxes intersect, false otherwise.

The return value will indicate whether this bbox and the other intersect anywhere (true) or not (false); optionally, you can pass another bounding box where the intersection will be written.

The method will return true if the resulting intersection box is degenerate, that is, has volume 0; this means taht bounding boxes that only intersect in one point, line or plane return false.