23 return plSimdBBox(vCenter - vHalfExtents, vCenter + vHalfExtents);
46 m_Min = vCenter - vHalfExtents;
47 m_Max = vCenter + vHalfExtents;
58 return m_Min.IsValid<3>() && m_Max.IsValid<3>() && (m_Min <= m_Max).AllSet<3>();
63 return m_Min.IsNaN<3>() || m_Max.IsNaN<3>();
83 m_Min = m_Min.CompMin(vPoint);
84 m_Max = m_Max.CompMax(vPoint);
89 PL_ASSERT_DEBUG(pPoints !=
nullptr,
"Array may not be nullptr.");
90 PL_ASSERT_DEBUG(uiStride >=
sizeof(
plSimdVec4f),
"Data may not overlap.");
94 for (plUInt32 i = 0; i < uiNumPoints; ++i)
104 m_Min = m_Min.CompMin(rhs.m_Min);
105 m_Max = m_Max.CompMax(rhs.m_Max);
118 return ((vPoint >= m_Min) && (vPoint <= m_Max)).AllSet<3>();
135 return ((m_Max > rhs.m_Min) && (m_Min < rhs.m_Max)).AllSet<3>();
168 plSimdVec4f newHalfExtents = mMat.m_col0.Abs() * halfExtents.x();
169 newHalfExtents += mMat.m_col1.Abs() * halfExtents.y();
170 newHalfExtents += mMat.m_col2.Abs() * halfExtents.z();
177 return vPoint.CompMin(m_Max).CompMax(m_Min);
184 return (vPoint - vClamped).GetLengthSquared<3>();
191 return (vPoint - vClamped).GetLength<3>();
194PL_ALWAYS_INLINE
bool plSimdBBox::operator==(
const plSimdBBox& rhs)
const
196 return ((m_Min == rhs.m_Min) && (m_Max == rhs.m_Max)).AllSet<3>();
199PL_ALWAYS_INLINE
bool plSimdBBox::operator!=(
const plSimdBBox& rhs)
const
201 return ((m_Min != rhs.m_Min) || (m_Max != rhs.m_Max)).AnySet<3>();
static T * AddByteOffset(T *pPtr, std::ptrdiff_t offset)
Returns the address stored in ptr plus the given byte offset iOffset, cast to type T.
void SetFromPoints(const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
Creates a new bounding-box around the given set of points.
Definition SimdBBox_inl.h:50
plSimdVec4f GetExtents() const
Returns the extents of the box along each axis.
Definition SimdBBox_inl.h:71
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 SetInvalid()
Resets the box to an invalid state. ExpandToInclude can then be used to make it into a bounding box f...
Definition SimdBBox_inl.h:38
void SetCenterAndHalfExtents(const plSimdVec4f &vCenter, const plSimdVec4f &vHalfExtents)
Sets the box from a center point and half-extents for each axis.
Definition SimdBBox_inl.h:44
bool Overlaps(const plSimdBBox &rhs) const
Checks whether this box overlaps with the given box.
Definition SimdBBox_inl.h:133
static plSimdBBox MakeZero()
Creates a box that is located at the origin and has zero size. This is a 'valid' box.
Definition SimdBBox_inl.h:11
bool IsNaN() const
Checks whether any component is NaN.
Definition SimdBBox_inl.h:61
static plSimdBBox MakeFromMinMax(const plSimdVec4f &vMin, const plSimdVec4f &vMax)
Creates a box with the given minimum and maximum values.
Definition SimdBBox_inl.h:26
plSimdBBox()
Default constructor does not initialize anything.
plSimdVec4f GetHalfExtents() const
Returns the half extents of the box along each axis.
Definition SimdBBox_inl.h:76
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 SimdBBox_inl.h:108
bool IsValid() const
Checks whether the box is in an invalid state.
Definition SimdBBox_inl.h:56
void Transform(const plSimdTransform &transform)
Transforms the corners of the box and recomputes the aabb of those transformed points.
Definition SimdBBox_inl.h:156
plSimdVec4f GetClampedPoint(const plSimdVec4f &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 SimdBBox_inl.h:175
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 MakeInvalid()
Creates a box that is in an invalid state. ExpandToInclude can then be used to make it into a boundin...
Definition SimdBBox_inl.h:16
plSimdFloat GetDistanceSquaredTo(const plSimdVec4f &vPoint) const
Returns the squared minimum distance from the box's surface to the point. Zero if the point is inside...
Definition SimdBBox_inl.h:180
bool Contains(const plSimdVec4f &vPoint) const
Checks whether the given point is inside the box.
Definition SimdBBox_inl.h:116
void Translate(const plSimdVec4f &vDiff)
Moves the box by the given vector.
Definition SimdBBox_inl.h:150
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
void Grow(const plSimdVec4f &vDiff)
Will increase the size of the box in all directions by the given amount (per axis).
Definition SimdBBox_inl.h:144
plSimdFloat GetDistanceTo(const plSimdVec4f &vPoint) const
Returns the minimum distance from the box's surface to the point. Zero if the point is inside the box...
Definition SimdBBox_inl.h:187
Definition SimdBSphere.h:6
plSimdFloat GetRadius() const
Returns the radius.
Definition SimdBSphere_inl.h:85
bool Contains(const plSimdVec4f &vPoint) const
Returns true if the given point is inside the sphere.
Definition SimdBSphere_inl.h:160
plSimdVec4f GetCenter() const
Returns the center.
Definition SimdBSphere_inl.h:80
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).