#include <BoundingSphere.h>
A 3D bounding sphere class. This template represents a 3D bounding sphere, which has a center point and a radius. This type of bounding volume can be used to speedup collision detection or (ray) intersection tests or visibility tests.
◆ BoundingSphere() [1/3]
MCORE_INLINE MCore::BoundingSphere::BoundingSphere |
( |
| ) |
|
|
inline |
Default constructor. Sets the sphere center to (0,0,0) and makes the radius 0.
◆ BoundingSphere() [2/3]
MCORE_INLINE MCore::BoundingSphere::BoundingSphere |
( |
const AZ::Vector3 & |
pos, |
|
|
float |
rad |
|
) |
| |
|
inline |
Constructor which sets the center of the sphere and it's radius. Automatically calculates the squared radius too.
- Parameters
-
pos | The center position of the sphere. |
rad | The radius of the sphere. |
◆ BoundingSphere() [3/3]
MCORE_INLINE MCore::BoundingSphere::BoundingSphere |
( |
const AZ::Vector3 & |
pos, |
|
|
float |
rad, |
|
|
float |
radSq |
|
) |
| |
|
inline |
Constructor which sets the center, radius and squared radius. Use this constructor when the squared radius is already known, so an extra multiplication is eliminated.
- Parameters
-
pos | The center position of the sphere. |
rad | The radius of the sphere. |
radSq | The squared radius of the sphere (rad*rad). |
◆ Contains() [1/2]
MCORE_INLINE bool MCore::BoundingSphere::Contains |
( |
const AZ::Vector3 & |
v | ) |
|
|
inline |
Check if the sphere contains a given 3D point. Note that the border of the sphere is also counted as inside.
- Parameters
-
v | The vector representing the 3D point to perform the test with. |
- Returns
- Returns true when 'v' is inside the spheres volume, otherwise false is returned.
◆ Contains() [2/2]
MCORE_INLINE bool MCore::BoundingSphere::Contains |
( |
const BoundingSphere & |
s | ) |
const |
|
inline |
Check if the sphere COMPLETELY contains a given other sphere. Note that the border of the sphere is also counted as inside.
- Parameters
-
s | The sphere to perform the test with. |
- Returns
- Returns true when 's' is completely inside this sphere. False is returned in any other case.
◆ EncapsulateFast()
MCORE_INLINE void MCore::BoundingSphere::EncapsulateFast |
( |
const AZ::Vector3 & |
v | ) |
|
|
inline |
Encapsulate a 3D point to the sphere. Automatically adjusts the radius of the sphere. Only use this method when the center of the sphere is already known. This is the faster way of encapsulating. But again, only use this method when the center of the sphere is known upfront and won't change. If the center of the sphere should automatically adjust as well, use the Encapsulate method instead (of course that's slower too).
- Parameters
-
v | The vector representing the 3D point to encapsulate (add) to the sphere. |
◆ GetCenter()
MCORE_INLINE const AZ::Vector3 & MCore::BoundingSphere::GetCenter |
( |
| ) |
const |
|
inline |
Get the center of the sphere. So the position of the sphere.
- Returns
- Returns the center position of the sphere.
◆ GetRadius()
MCORE_INLINE float MCore::BoundingSphere::GetRadius |
( |
| ) |
const |
|
inline |
Get the radius of the sphere.
- Returns
- Returns the radius of the sphere.
◆ GetRadiusSquared()
MCORE_INLINE float MCore::BoundingSphere::GetRadiusSquared |
( |
| ) |
const |
|
inline |
Get the squared radius of the sphere.
- Returns
- Returns the squared radius of the sphere (no calculations done for this), since it's already known.
◆ Init()
MCORE_INLINE void MCore::BoundingSphere::Init |
( |
| ) |
|
|
inline |
Initialize the spheres center, radius and square radius. This will set the center position to (0,0,0) and both the radius and squared radius to 0. Call this method when you want to reset the sphere. Note that this is already done by the default constructor.
◆ Intersects()
MCORE_INLINE bool MCore::BoundingSphere::Intersects |
( |
const BoundingSphere & |
s | ) |
const |
|
inline |
Check if a given sphere intersects with this sphere. Note that the border of this sphere is counted as 'inside'. So if only the borders of the spheres intersects, this is seen as intersection.
- Parameters
-
s | The sphere to perform the intersection test with. |
- Returns
- Returns true when 's' intersects this sphere. So if it's partially or completely inside this sphere or if the borders overlap.
◆ SetCenter()
MCORE_INLINE void MCore::BoundingSphere::SetCenter |
( |
const AZ::Vector3 & |
center | ) |
|
|
inline |
Set the center of the sphere.
- Parameters
-
center | The center position of the sphere. |
◆ SetRadius()
MCORE_INLINE void MCore::BoundingSphere::SetRadius |
( |
float |
radius | ) |
|
|
inline |
Set the radius of the sphere. The squared radius will automatically be updated inside this method.
- Parameters
-
radius | The radius of the sphere. |
The documentation for this class was generated from the following file:
- Gems/EMotionFX/Code/MCore/Source/BoundingSphere.h