Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Crux::BoundingSphere Struct Reference

Bounding sphere defined by a center point and radius. More...

#include <BoundingVolumes.h>

Public Member Functions

constexpr bool Intersects (const BoundingSphere &other) const
 Tests whether this sphere overlaps another sphere.
constexpr bool Intersects (const AABB &aabb) const
 Tests whether this sphere overlaps an AABB.
constexpr bool Contains (const vec3 &point) const
 Tests whether a point lies inside or on the surface of this sphere.

Static Public Member Functions

static BoundingSphere FromAABB (const AABB &aabb)
 Constructs the smallest bounding sphere enclosing the given AABB.
static constexpr BoundingSphere FromCenterRadius (const vec3 &center, f32 radius)
 Constructs a bounding sphere from an explicit center and radius.

Public Attributes

vec3 Center {0.0f, 0.0f, 0.0f}
f32 Radius {0.0f}

Detailed Description

Bounding sphere defined by a center point and radius.

Member Function Documentation

◆ Contains()

bool Crux::BoundingSphere::Contains ( const vec3 & point) const
inlineconstexpr

Tests whether a point lies inside or on the surface of this sphere.

Parameters
pointThe point to test.
Returns
True if the squared distance from the center to point is within the squared radius.

◆ FromAABB()

BoundingSphere Crux::BoundingSphere::FromAABB ( const AABB & aabb)
inlinestatic

Constructs the smallest bounding sphere enclosing the given AABB.

Parameters
aabbThe AABB to enclose.
Returns
A sphere centered at the AABB center with radius equal to the half-diagonal.

◆ FromCenterRadius()

constexpr BoundingSphere Crux::BoundingSphere::FromCenterRadius ( const vec3 & center,
f32 radius )
inlinestaticconstexpr

Constructs a bounding sphere from an explicit center and radius.

Parameters
centerThe center of the sphere.
radiusThe radius of the sphere.
Returns
A BoundingSphere with the given center and radius.

◆ Intersects() [1/2]

bool Crux::BoundingSphere::Intersects ( const AABB & aabb) const
inlineconstexpr

Tests whether this sphere overlaps an AABB.

Parameters
aabbThe AABB to test against.
Returns
True if the closest point on the AABB to the sphere center is within the radius.

◆ Intersects() [2/2]

bool Crux::BoundingSphere::Intersects ( const BoundingSphere & other) const
inlineconstexpr

Tests whether this sphere overlaps another sphere.

Uses squared distance to avoid a sqrt.

Parameters
otherThe sphere to test against.
Returns
True if the distance between centers is less than or equal to the sum of radii.

Member Data Documentation

◆ Center

vec3 Crux::BoundingSphere::Center {0.0f, 0.0f, 0.0f}

◆ Radius

f32 Crux::BoundingSphere::Radius {0.0f}

The documentation for this struct was generated from the following file: