6 : m_CenterAndRadius(vCenter)
7 , m_BoxHalfExtents(vBoxHalfExtents)
9 m_CenterAndRadius.SetW(fSphereRadius);
18 : m_CenterAndRadius(box.GetCenter())
19 , m_BoxHalfExtents(m_CenterAndRadius - box.m_Min)
21 m_CenterAndRadius.SetW(m_BoxHalfExtents.GetLength<3>());
25 : m_CenterAndRadius(sphere.m_CenterAndRadius)
41 res.m_CenterAndRadius.Set(0.0f, 0.0f, 0.0f, -plMath::SmallEpsilon<float>());
49 res.m_CenterAndRadius = vCenter;
50 res.m_BoxHalfExtents = vBoxHalfExtents;
51 res.m_CenterAndRadius.SetW(fSphereRadius);
62 res.m_BoxHalfExtents = res.m_CenterAndRadius - box.m_Min;
67 res.m_CenterAndRadius.SetW(sphere.
GetRadius());
86 res.m_BoxHalfExtents = res.m_CenterAndRadius - box.m_Min;
87 res.m_CenterAndRadius.SetW(res.m_BoxHalfExtents.GetLength<3>().Min((sphere.
GetCenter() - res.m_CenterAndRadius).GetLength<3>() + sphere.
GetRadius()));
93 m_CenterAndRadius.Set(0.0f, 0.0f, 0.0f, -plMath::SmallEpsilon<float>());
99 return m_CenterAndRadius.IsValid<4>() && m_CenterAndRadius.w() >=
plSimdFloat::MakeZero() && m_BoxHalfExtents.IsValid<3>() &&
105 return m_CenterAndRadius.IsNaN<4>() || m_BoxHalfExtents.IsNaN<3>();
121 sphere.m_CenterAndRadius = m_CenterAndRadius;
132 plSimdFloat tmpRadius = boxHalfExtents.GetLength<3>();
134 const plSimdFloat fSphereRadiusA = (m_CenterAndRadius - center).GetLength<3>() + m_CenterAndRadius.w();
135 const plSimdFloat fSphereRadiusB = (rhs.m_CenterAndRadius - center).GetLength<3>() + rhs.m_CenterAndRadius.w();
137 m_CenterAndRadius = center;
138 m_CenterAndRadius.SetW(tmpRadius.Min(fSphereRadiusA.Max(fSphereRadiusB)));
139 m_BoxHalfExtents = boxHalfExtents;
152 plSimdFloat maxRadius = mMat.m_col0.Dot<3>(mMat.m_col0);
153 maxRadius = maxRadius.Max(mMat.m_col1.Dot<3>(mMat.m_col1));
154 maxRadius = maxRadius.Max(mMat.m_col2.Dot<3>(mMat.m_col2));
155 radius *= maxRadius.GetSqrt();
157 m_CenterAndRadius.SetW(radius);
159 plSimdVec4f newHalfExtents = mMat.m_col0.Abs() * m_BoxHalfExtents.x();
160 newHalfExtents += mMat.m_col1.Abs() * m_BoxHalfExtents.y();
161 newHalfExtents += mMat.m_col2.Abs() * m_BoxHalfExtents.z();
163 m_BoxHalfExtents = newHalfExtents.CompMin(
plSimdVec4f(radius));
166PL_ALWAYS_INLINE
bool plSimdBBoxSphere::operator==(
const plSimdBBoxSphere& rhs)
const
168 return (m_CenterAndRadius == rhs.m_CenterAndRadius).AllSet<4>() && (m_BoxHalfExtents == rhs.m_BoxHalfExtents).AllSet<3>();
171PL_ALWAYS_INLINE
bool plSimdBBoxSphere::operator!=(
const plSimdBBoxSphere& rhs)
const
173 return !(*
this == rhs);
static plSimdBBox MakeFromPoints(const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
Creates a box around the given set of points. If uiNumPoints is zero, the returned box is invalid (sa...
Definition SimdBBox_inl.h:31
void ExpandToInclude(const plSimdVec4f &vPoint)
Expands the box such that the given point is inside it.
Definition SimdBBox_inl.h:81
plSimdVec4f GetCenter() const
Returns the center position of the box.
Definition SimdBBox_inl.h:66
static plSimdBBox MakeFromCenterAndHalfExtents(const plSimdVec4f &vCenter, const plSimdVec4f &vHalfExtents)
Creates a box from a center point and half-extents for each axis.
Definition SimdBBox_inl.h:21
Definition SimdBBoxSphere.h:6
plSimdBSphere GetSphere() const
Returns the bounding sphere.
Definition SimdBBoxSphere_inl.h:118
static plSimdBBoxSphere MakeFromPoints(const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
Creates an object that contains all the provided points.
Definition SimdBBoxSphere_inl.h:55
static plSimdBBoxSphere MakeZero()
Creates an object with all zero values. These are valid bounds around the origin with no volume.
Definition SimdBBoxSphere_inl.h:30
plSimdBBoxSphere()
Default constructor does not initialize anything.
void SetInvalid()
Resets the bounds to an invalid state.
Definition SimdBBoxSphere_inl.h:91
void Transform(const plSimdTransform &t)
Transforms the bounds in its local space.
Definition SimdBBoxSphere_inl.h:142
void ExpandToInclude(const plSimdBBoxSphere &rhs)
Expands the bounds such that the given bounds are inside it.
Definition SimdBBoxSphere_inl.h:125
bool IsNaN() const
Checks whether any component is NaN.
Definition SimdBBoxSphere_inl.h:103
void SetFromPoints(const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
Calculates the bounds from given set of points.
Definition SimdBBoxSphere_inl.h:108
static plSimdBBoxSphere MakeFromBox(const plSimdBBox &box)
Creates an object from another bounding box.
Definition SimdBBoxSphere_inl.h:72
static plSimdBBoxSphere MakeFromBoxAndSphere(const plSimdBBox &box, const plSimdBSphere &sphere)
Creates an object from another bounding box and a sphere.
Definition SimdBBoxSphere_inl.h:82
static plSimdBBoxSphere MakeFromSphere(const plSimdBSphere &sphere)
Creates an object from another bounding sphere.
Definition SimdBBoxSphere_inl.h:77
plSimdBBox GetBox() const
Returns the bounding box.
Definition SimdBBoxSphere_inl.h:113
static plSimdBBoxSphere MakeFromCenterExtents(const plSimdVec4f &vCenter, const plSimdVec4f &vBoxHalfExtents, const plSimdFloat &fSphereRadius)
Creates an object from the given center point and extents.
Definition SimdBBoxSphere_inl.h:46
static plSimdBBoxSphere MakeInvalid()
Creates an 'invalid' object, ie one with negative extents/radius. Invalid objects can be made valid t...
Definition SimdBBoxSphere_inl.h:38
bool IsValid() const
Checks whether the bounds is in an invalid state.
Definition SimdBBoxSphere_inl.h:97
Definition SimdBSphere.h:6
plSimdFloat GetRadius() const
Returns the radius.
Definition SimdBSphere_inl.h:85
void ExpandToInclude(const plSimdVec4f &vPoint)
Increases the sphere's radius to include this point.
Definition SimdBSphere_inl.h:95
plSimdVec4f GetCenter() const
Returns the center.
Definition SimdBSphere_inl.h:80
static plSimdFloat MakeZero()
Creates an plSimdFloat that is initialized to zero.
Definition FPUFloat_inl.h:36
A 4x4 matrix class.
Definition SimdMat4f.h:7
plSimdVec4f TransformPosition(const plSimdVec4f &v) const
Matrix-vector multiplication, assuming the 4th component of the vector is one (default behavior).
Definition SimdMat4f_inl.h:141
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
static plSimdVec4f MakeZero()
Creates an plSimdVec4f that is initialized to zero.
Definition SimdVec4f_inl.h:8
constexpr TYPE MaxValue()
Returns the largest possible positive value (that is not infinity).