XII Release 0.1.0
Loading...
Searching...
No Matches
xiiSimdBSphere Class Reference

Public Member Functions

 XII_DECLARE_POD_TYPE ()
 
 xiiSimdBSphere ()
 Default constructor does not initialize any data.
 
 xiiSimdBSphere (const xiiSimdVec4f &vCenter, const xiiSimdFloat &fRadius)
 Creates a sphere with the given radius around the given center.
 
bool IsValid () const
 Returns whether the sphere has valid values.
 
bool IsNaN () const
 Returns whether any value is NaN.
 
xiiSimdVec4f GetCenter () const
 Returns the center.
 
xiiSimdFloat GetRadius () const
 Returns the radius.
 
void ExpandToInclude (const xiiSimdVec4f &vPoint)
 Increases the sphere's radius to include this point.
 
void ExpandToInclude (const xiiSimdVec4f *pPoints, xiiUInt32 uiNumPoints, xiiUInt32 uiStride=sizeof(xiiSimdVec4f))
 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 xiiSimdBSphere &rhs)
 Increases this sphere's radius, such that it encloses the other sphere.
 
void Transform (const xiiSimdTransform &t)
 Transforms the sphere in its local space.
 
void Transform (const xiiSimdMat4f &mMat)
 Transforms the sphere in its local space.
 
xiiSimdFloat GetDistanceTo (const xiiSimdVec4f &vPoint) const
 Computes the distance of the point to the sphere's surface. Returns negative values for points inside the sphere.
 
xiiSimdFloat GetDistanceTo (const xiiSimdBSphere &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 xiiSimdVec4f &vPoint) const
 Returns true if the given point is inside the sphere.
 
bool Contains (const xiiSimdBSphere &rhs) const
 Returns whether the other sphere is completely inside this sphere.
 
bool Overlaps (const xiiSimdBSphere &rhs) const
 Checks whether the two objects overlap.
 
xiiSimdVec4f GetClampedPoint (const xiiSimdVec4f &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 xiiSimdBSphere &rhs) const
 
bool operator!= (const xiiSimdBSphere &rhs) const
 

Static Public Member Functions

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

Public Attributes

xiiSimdVec4f m_CenterAndRadius
 

Member Function Documentation

◆ MakeFromPoints()

xiiSimdBSphere xiiSimdBSphere::MakeFromPoints ( const xiiSimdVec4f * pPoints,
xiiUInt32 uiNumPoints,
xiiUInt32 uiStride = sizeof(xiiSimdVec4f) )
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()

XII_ALWAYS_INLINE xiiSimdBSphere xiiSimdBSphere::MakeInvalid ( const xiiSimdVec4f & vCenter = xiiSimdVec4f::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: