Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Physics::Component::SphereCollider Struct Reference

#include <SphereCollider.hpp>

Public Member Functions

 SphereCollider ()=default
 Default constructor (radius 0.5).
 SphereCollider (float r)
 Construct with radius.
 SphereCollider (float r, const glm::vec3 &localOffset)
 Construct with radius and offset.
float GetDiameter () const
 Get diameter of the sphere.
void SetDiameter (float diameter)
 Set diameter directly (converts to radius).
bool IsValid () const
 Check if collider is valid.

Static Public Member Functions

static SphereCollider Unit ()
 Create a unit sphere (radius 1.0).
static SphereCollider Ball (float r)
 Create a sphere for a ball/projectile.
static SphereCollider AtOffset (float r, const glm::vec3 &localOffset)
 Create a sphere at an offset (useful for compound shapes).

Public Attributes

float radius = 0.5f
 Radius of the sphere in world units.
glm::vec3 offset {0.0f, 0.0f, 0.0f}
 Local offset from entity transform (center of sphere).

Detailed Description

Constructor & Destructor Documentation

◆ SphereCollider() [1/3]

Physics::Component::SphereCollider::SphereCollider ( )
default

Default constructor (radius 0.5).

◆ SphereCollider() [2/3]

Physics::Component::SphereCollider::SphereCollider ( float r)
inlineexplicit

Construct with radius.

Parameters
rSphere radius

◆ SphereCollider() [3/3]

Physics::Component::SphereCollider::SphereCollider ( float r,
const glm::vec3 & localOffset )
inline

Construct with radius and offset.

Parameters
rSphere radius
localOffsetLocal position offset from entity center

Member Function Documentation

◆ AtOffset()

SphereCollider Physics::Component::SphereCollider::AtOffset ( float r,
const glm::vec3 & localOffset )
inlinestatic

Create a sphere at an offset (useful for compound shapes).

Parameters
rRadius
localOffsetPosition offset from entity center
Returns
SphereCollider

◆ Ball()

SphereCollider Physics::Component::SphereCollider::Ball ( float r)
inlinestatic

Create a sphere for a ball/projectile.

Parameters
rRadius of the ball
Returns
SphereCollider

◆ GetDiameter()

float Physics::Component::SphereCollider::GetDiameter ( ) const
inlinenodiscard

Get diameter of the sphere.

Returns
Diameter (2 * radius)

◆ IsValid()

bool Physics::Component::SphereCollider::IsValid ( ) const
inlinenodiscard

Check if collider is valid.

Returns
true if radius > 0

◆ SetDiameter()

void Physics::Component::SphereCollider::SetDiameter ( float diameter)
inline

Set diameter directly (converts to radius).

Parameters
diameterFull diameter of sphere

◆ Unit()

SphereCollider Physics::Component::SphereCollider::Unit ( )
inlinestatic

Create a unit sphere (radius 1.0).

Returns
SphereCollider with radius 1.0

Member Data Documentation

◆ offset

glm::vec3 Physics::Component::SphereCollider::offset {0.0f, 0.0f, 0.0f}

Local offset from entity transform (center of sphere).

◆ radius

float Physics::Component::SphereCollider::radius = 0.5f

Radius of the sphere in world units.

Examples
Basic usage for a sphere with radius 0.5.

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