Plasma Engine  2.0
Loading...
Searching...
No Matches
BoundingBoxSphere.h
1#pragma once
2
3#include <Foundation/Math/Mat4.h>
4#include <Foundation/Math/Vec4.h>
5
9
10template <typename Type>
12{
13public:
14 // Means this object can be copied using memcpy instead of copy construction.
15 PL_DECLARE_POD_TYPE();
16
17 using ComponentType = Type;
18
19public:
21 plBoundingBoxSphereTemplate(); // [tested]
22
24
25 void operator=(const plBoundingBoxSphereTemplate& rhs);
26
29
32
34 [[nodiscard]] static plBoundingBoxSphereTemplate<Type> MakeZero();
35
38
40 [[nodiscard]] static plBoundingBoxSphereTemplate<Type> MakeFromCenterExtents(const plVec3Template<Type>& vCenter, const plVec3Template<Type>& vBoxHalfExtents, Type fSphereRadius);
41
43 [[nodiscard]] static plBoundingBoxSphereTemplate<Type> MakeFromPoints(const plVec3Template<Type>* pPoints, plUInt32 uiNumPoints, plUInt32 uiStride = sizeof(plVec3Template<Type>));
44
47
50
53
54
55#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
56 void AssertNotNaN() const
57 {
58 PL_ASSERT_ALWAYS(!IsNaN(), "This object contains NaN values. This can happen when you forgot to initialize it before using it. Please check that "
59 "all code-paths properly initialize this object.");
60 }
61#endif
62
64 bool IsValid() const; // [tested]
65
67 bool IsNaN() const; // [tested]
68
70 const plBoundingBoxTemplate<Type> GetBox() const; // [tested]
71
73 const plBoundingSphereTemplate<Type> GetSphere() const; // [tested]
74
76 void ExpandToInclude(const plBoundingBoxSphereTemplate& rhs); // [tested]
77
79 void Transform(const plMat4Template<Type>& mTransform); // [tested]
80
81public:
82 plVec3Template<Type> m_vCenter;
83 Type m_fSphereRadius;
84 plVec3Template<Type> m_vBoxHalfExtends;
85};
86
88template <typename Type>
89bool operator==(const plBoundingBoxSphereTemplate<Type>& lhs, const plBoundingBoxSphereTemplate<Type>& rhs); // [tested]
90
92template <typename Type>
93bool operator!=(const plBoundingBoxSphereTemplate<Type>& lhs, const plBoundingBoxSphereTemplate<Type>& rhs); // [tested]
94
95
96#include <Foundation/Math/Implementation/BoundingBoxSphere_inl.h>
A combination of a bounding box and a bounding sphere with the same center.
Definition BoundingBoxSphere.h:12
plBoundingBoxSphereTemplate()
Default constructor does not initialize anything.
Definition BoundingBoxSphere_inl.h:4
bool IsNaN() const
Checks whether any component is NaN.
Definition BoundingBoxSphere_inl.h:130
bool IsValid() const
Checks whether the bounds is in an invalid state.
Definition BoundingBoxSphere_inl.h:124
static plBoundingBoxSphereTemplate< Type > MakeZero()
Creates an object with all zero values. These are valid bounds around the origin with no volume.
Definition BoundingBoxSphere_inl.h:48
static plBoundingBoxSphereTemplate< Type > MakeInvalid()
Creates an 'invalid' object, ie one with negative extents/radius. Invalid objects can be made valid t...
Definition BoundingBoxSphere_inl.h:58
void ExpandToInclude(const plBoundingBoxSphereTemplate &rhs)
Expands the bounds such that the given bounds are inside it.
Definition BoundingBoxSphere_inl.h:148
const plBoundingSphereTemplate< Type > GetSphere() const
Returns the bounding sphere.
Definition BoundingBoxSphere_inl.h:142
static plBoundingBoxSphereTemplate< Type > MakeFromSphere(const plBoundingSphereTemplate< Type > &sphere)
Creates an object from another bounding sphere.
Definition BoundingBoxSphere_inl.h:104
static plBoundingBoxSphereTemplate< Type > MakeFromCenterExtents(const plVec3Template< Type > &vCenter, const plVec3Template< Type > &vBoxHalfExtents, Type fSphereRadius)
Creates an object from the given center point and extents.
Definition BoundingBoxSphere_inl.h:68
const plBoundingBoxTemplate< Type > GetBox() const
Returns the bounding box.
Definition BoundingBoxSphere_inl.h:136
static plBoundingBoxSphereTemplate< Type > MakeFromBox(const plBoundingBoxTemplate< Type > &box)
Creates an object from another bounding box.
Definition BoundingBoxSphere_inl.h:94
static plBoundingBoxSphereTemplate< Type > MakeFromPoints(const plVec3Template< Type > *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plVec3Template< Type >))
Creates an object that contains all the provided points.
Definition BoundingBoxSphere_inl.h:78
static plBoundingBoxSphereTemplate< Type > MakeFromBoxAndSphere(const plBoundingBoxTemplate< Type > &box, const plBoundingSphereTemplate< Type > &sphere)
Creates an object from another bounding box and a sphere.
Definition BoundingBoxSphere_inl.h:114
void Transform(const plMat4Template< Type > &mTransform)
Transforms the bounds in its local space.
Definition BoundingBoxSphere_inl.h:166
An axis-aligned bounding box implementation.
Definition BoundingBox.h:12
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