3#include <Foundation/Math/Vec3.h>
10template <
typename Type>
15 PL_DECLARE_POD_TYPE();
17 using ComponentType = Type;
26#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
27 void AssertNotNaN()
const
29 PL_ASSERT_ALWAYS(!
IsNaN(),
"This object contains NaN values. This can happen when you forgot to initialize it before using it. Please check that "
30 "all code-paths properly initialize this object.");
163template <
typename Type>
167template <
typename Type>
171#include <Foundation/Math/Implementation/BoundingBox_inl.h>
An axis-aligned bounding box implementation.
Definition BoundingBox.h:12
void Translate(const plVec3Template< Type > &vDiff)
Moves the box by the given vector.
Definition BoundingBox_inl.h:263
Type GetDistanceSquaredTo(const plVec3Template< Type > &vPoint) const
Returns the squared minimum distance from the box's surface to the point. Zero if the point is inside...
Definition BoundingBox_inl.h:332
const plVec3Template< Type > GetCenter() const
Returns the center position of the box.
Definition BoundingBox_inl.h:78
void ExpandToCube()
If the box is not cubic all extents are set to the value of the maximum extent, such that the box bec...
Definition BoundingBox_inl.h:139
const plVec3Template< Type > GetExtents() const
Returns the extents of the box along each axis.
Definition BoundingBox_inl.h:84
void ExpandToInclude(const plVec3Template< Type > &vPoint)
Expands the box such that the given point is inside it.
Definition BoundingBox_inl.h:108
bool IsNaN() const
Checks whether any component is NaN.
Definition BoundingBox_inl.h:102
Type GetDistanceTo(const plVec3Template< Type > &vPoint) const
Returns the minimum distance from the box's surface to the point. Zero if the point is inside the box...
Definition BoundingBox_inl.h:324
void TransformFromCenter(const plMat4Template< Type > &mTransform)
Transforms the corners of the box in its local space. The center of the box does not change,...
Definition BoundingBox_inl.h:293
static plBoundingBoxTemplate< Type > MakeFromPoints(const plVec3Template< Type > *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plVec3Template< Type >))
Creates a box around the given set of points. If uiNumPoints is zero, the returned box is invalid (sa...
Definition BoundingBox_inl.h:54
void GetCorners(plVec3Template< Type > *out_pCorners) const
Writes the 8 different corners of the box to the given array.
Definition BoundingBox_inl.h:62
plBoundingBoxTemplate()
Default constructor does not initialize anything.
bool IsValid() const
Checks whether the box is in an invalid state.
Definition BoundingBox_inl.h:96
void ScaleFromCenter(const plVec3Template< Type > &vScale)
Scales the box along each axis, but keeps its center constant.
Definition BoundingBox_inl.h:270
static plBoundingBoxTemplate< Type > MakeFromMinMax(const plVec3Template< Type > &vMin, const plVec3Template< Type > &vMax)
Creates a box with the given minimum and maximum values.
Definition BoundingBox_inl.h:42
void TransformFromOrigin(const plMat4Template< Type > &mTransform)
Transforms the corners of the box and recomputes the AABB of those transformed points....
Definition BoundingBox_inl.h:306
const plVec3Template< Type > GetClampedPoint(const plVec3Template< Type > &vPoint) const
The given point is clamped to the volume of the box, i.e. it will be either inside the box or on its ...
Definition BoundingBox_inl.h:318
bool IsEqual(const plBoundingBoxTemplate &rhs, Type fEpsilon=plMath::DefaultEpsilon< Type >()) const
Checks whether this box and the other box are equal within some threshold.
Definition BoundingBox_inl.h:245
const plVec3Template< Type > GetHalfExtents() const
Returns the half extents of the box along each axis.
Definition BoundingBox_inl.h:90
static plBoundingBoxTemplate< Type > MakeZero()
Creates a box that is located at the origin and has zero size. This is a 'valid' box.
Definition BoundingBox_inl.h:15
bool Contains(const plVec3Template< Type > &vPoint) const
Checks whether the given point is inside the box.
Definition BoundingBox_inl.h:162
bool Overlaps(const plBoundingBoxTemplate &rhs) const
Checks whether this box overlaps with the given box.
Definition BoundingBox_inl.h:197
void Grow(const plVec3Template< Type > &vDiff)
Will increase the size of the box in all directions by the given amount (per axis).
Definition BoundingBox_inl.h:151
static plBoundingBoxTemplate< Type > MakeInvalid()
Creates a box that is in an invalid state. ExpandToInclude can then be used to make it into a boundin...
Definition BoundingBox_inl.h:24
bool GetRayIntersection(const plVec3Template< Type > &vStartPos, const plVec3Template< Type > &vRayDir, Type *out_pIntersectionDistance=nullptr, plVec3Template< Type > *out_pIntersection=nullptr) const
Returns whether the given ray intersects the box. Optionally returns the intersection distance and po...
Definition BoundingBox_inl.h:392
const plBoundingSphereTemplate< Type > GetBoundingSphere() const
Returns a bounding sphere that encloses this box.
Definition AllClasses_inl.h:29
void ScaleFromOrigin(const plVec3Template< Type > &vScale)
Scales the box's corners by the given factors, thus also moves the box around.
Definition BoundingBox_inl.h:282
bool IsIdentical(const plBoundingBoxTemplate &rhs) const
Checks whether this box and the other box are exactly identical.
Definition BoundingBox_inl.h:239
bool GetLineSegmentIntersection(const plVec3Template< Type > &vStartPos, const plVec3Template< Type > &vEndPos, Type *out_pLineFraction=nullptr, plVec3Template< Type > *out_pIntersection=nullptr) const
Checks whether the line segment intersects the box. Optionally returns the intersection point and the...
Definition BoundingBox_inl.h:485
static plBoundingBoxTemplate< Type > MakeFromCenterAndHalfExtents(const plVec3Template< Type > &vCenter, const plVec3Template< Type > &vHalfExtents)
Creates a box from a center point and half-extents for each axis.
Definition BoundingBox_inl.h:33
An implementation of a bounding sphere.
Definition BoundingSphere.h:11
A 4x4 component matrix class.
Definition Mat4.h:11
A 3-component vector class.
Definition Vec3.h:9