ezEngine  Release 25.03
ezSimdBSphere Class Reference

Public Member Functions

 EZ_DECLARE_POD_TYPE ()
 
 ezSimdBSphere ()
 Default constructor does not initialize any data.
 
 ezSimdBSphere (const ezSimdVec4f &vCenter, const ezSimdFloat &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.
 
ezSimdVec4f GetCenter () const
 Returns the center.
 
ezSimdFloat GetRadius () const
 Returns the radius.
 
void SetFromPoints (const ezSimdVec4f *pPoints, ezUInt32 uiNumPoints, ezUInt32 uiStride=sizeof(ezSimdVec4f))
 Initializes the sphere to be the bounding sphere of all the given points.
 
void ExpandToInclude (const ezSimdVec4f &vPoint)
 Increases the sphere's radius to include this point.
 
void ExpandToInclude (const ezSimdVec4f *pPoints, ezUInt32 uiNumPoints, ezUInt32 uiStride=sizeof(ezSimdVec4f))
 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 ezSimdBSphere &rhs)
 Increases this sphere's radius, such that it encloses the other sphere.
 
void Transform (const ezSimdTransform &t)
 Transforms the sphere in its local space.
 
void Transform (const ezSimdMat4f &mMat)
 Transforms the sphere in its local space.
 
ezSimdFloat GetDistanceTo (const ezSimdVec4f &vPoint) const
 Computes the distance of the point to the sphere's surface. Returns negative values for points inside the sphere.
 
ezSimdFloat GetDistanceTo (const ezSimdBSphere &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 ezSimdVec4f &vPoint) const
 Returns true if the given point is inside the sphere.
 
bool Contains (const ezSimdBSphere &rhs) const
 Returns whether the other sphere is completely inside this sphere.
 
bool Overlaps (const ezSimdBSphere &rhs) const
 Checks whether the two objects overlap.
 
ezSimdVec4f GetClampedPoint (const ezSimdVec4f &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 ezSimdBSphere &rhs) const
 
bool operator!= (const ezSimdBSphere &rhs) const
 

Static Public Member Functions

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

Public Attributes

ezSimdVec4f m_CenterAndRadius
 

Member Function Documentation

◆ MakeFromPoints()

ezSimdBSphere ezSimdBSphere::MakeFromPoints ( const ezSimdVec4f pPoints,
ezUInt32  uiNumPoints,
ezUInt32  uiStride = sizeof(ezSimdVec4f) 
)
inlinestatic

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()

EZ_ALWAYS_INLINE ezSimdBSphere ezSimdBSphere::MakeInvalid ( const ezSimdVec4f vCenter = ezSimdVec4f::MakeZero())
static

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: