Plasma Engine  2.0
Loading...
Searching...
No Matches
plSimdBSphere Class Reference

Public Member Functions

 PL_DECLARE_POD_TYPE ()
 
 plSimdBSphere ()
 Default constructor does not initialize any data.
 
 plSimdBSphere (const plSimdVec4f &vCenter, const plSimdFloat &fRadius)
 Creates a sphere with the given radius around the given center.
 
void SetInvalid ()
 Sets the bounding sphere to invalid values.
 
bool IsValid () const
 Returns whether the sphere has valid values.
 
bool IsNaN () const
 Returns whether any value is NaN.
 
plSimdVec4f GetCenter () const
 Returns the center.
 
plSimdFloat GetRadius () const
 Returns the radius.
 
void SetFromPoints (const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
 Initializes the sphere to be the bounding sphere of all the given points.
 
void ExpandToInclude (const plSimdVec4f &vPoint)
 Increases the sphere's radius to include this point.
 
void ExpandToInclude (const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
 Increases the sphere's radius to include all given points. Does NOT change its position, thus the resulting sphere might be not a very tight fit. More efficient than calling this for every point individually.
 
void ExpandToInclude (const plSimdBSphere &rhs)
 Increases this sphere's radius, such that it encloses the other sphere.
 
void Transform (const plSimdTransform &t)
 Transforms the sphere in its local space.
 
void Transform (const plSimdMat4f &mMat)
 Transforms the sphere in its local space.
 
plSimdFloat GetDistanceTo (const plSimdVec4f &vPoint) const
 Computes the distance of the point to the sphere's surface. Returns negative values for points inside the sphere.
 
plSimdFloat GetDistanceTo (const plSimdBSphere &rhs) const
 Returns the distance between the two spheres. Zero for spheres that are exactly touching each other, negative values for overlapping spheres.
 
bool Contains (const plSimdVec4f &vPoint) const
 Returns true if the given point is inside the sphere.
 
bool Contains (const plSimdBSphere &rhs) const
 Returns whether the other sphere is completely inside this sphere.
 
bool Overlaps (const plSimdBSphere &rhs) const
 Checks whether the two objects overlap.
 
plSimdVec4f GetClampedPoint (const plSimdVec4f &vPoint)
 Clamps the given position to the volume of the sphere. The resulting point will always be inside the sphere, but have the closest distance to the original point.
 
bool operator== (const plSimdBSphere &rhs) const
 
bool operator!= (const plSimdBSphere &rhs) const
 

Static Public Member Functions

static plSimdBSphere MakeZero ()
 Creates a sphere at the origin with radius zero.
 
static plSimdBSphere MakeInvalid (const plSimdVec4f &vCenter=plSimdVec4f::MakeZero())
 Creates an 'invalid' sphere, with its center at the given position and a negative radius.
 
static plSimdBSphere MakeFromCenterAndRadius (const plSimdVec4f &vCenter, const plSimdFloat &fRadius)
 Creates a sphere with the provided center and radius.
 
static plSimdBSphere MakeFromPoints (const plSimdVec4f *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plSimdVec4f))
 Creates a bounding sphere around the provided points.
 

Public Attributes

plSimdVec4f m_CenterAndRadius
 

Member Function Documentation

◆ MakeFromPoints()

plSimdBSphere plSimdBSphere::MakeFromPoints ( const plSimdVec4f * pPoints,
plUInt32 uiNumPoints,
plUInt32 uiStride = sizeof(plSimdVec4f) )
inlinestaticnodiscard

Creates a bounding sphere around the provided points.

The center of the sphere will be at the 'center of mass' of all the points, and the radius will be the distance to the farthest point from there.

◆ MakeInvalid()

PL_ALWAYS_INLINE plSimdBSphere plSimdBSphere::MakeInvalid ( const plSimdVec4f & vCenter = plSimdVec4f::MakeZero())
staticnodiscard

Creates an 'invalid' sphere, with its center at the given position and a negative radius.

Such a sphere can be made 'valid' through ExpandToInclude(), but be aware that the originally provided center position will always be part of the sphere.


The documentation for this class was generated from the following files: