A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Kart::CollisionGroup Class Reference

#include <CollisionGroup.hh>

Description

Houses hitbox and collision info for an object (body or wheel).

Definition at line 113 of file CollisionGroup.hh.

Public Member Functions

f32 initHitboxes (const std::array< BSP::Hitbox, 16 > &hitboxes)
 Initializes the hitbox array based on the KartParam's BSP hitboxes.
 
f32 computeCollisionLimits ()
 Sets the bounding radius.
 
void createSingleHitbox (f32 radius, const EGG::Vector3f &relPos)
 Creates a hitbox to represent a tire.
 

Setters

void reset ()
 
void resetCollision ()
 
void setHitboxScale (f32 scale)
 

Getters

f32 boundingRadius () const
 
Hitboxhitbox (u16 hitboxIdx)
 
u16 hitboxCount () const
 
CollisionDatacollisionData ()
 
const CollisionDatacollisionData () const
 

Private Attributes

f32 m_boundingRadius
 
CollisionData m_collisionData
 
std::span< Hitboxm_hitboxes
 
f32 m_hitboxScale
 

Constructor & Destructor Documentation

◆ CollisionGroup()

Kart::CollisionGroup::CollisionGroup ( )
0x805B82BC

Definition at line 81 of file CollisionGroup.cc.

◆ ~CollisionGroup()

Kart::CollisionGroup::~CollisionGroup ( )

Definition at line 85 of file CollisionGroup.cc.

Member Function Documentation

◆ boundingRadius()

f32 Kart::CollisionGroup::boundingRadius ( ) const
inlinenodiscard

Definition at line 129 of file CollisionGroup.hh.

◆ collisionData() [1/2]

CollisionData & Kart::CollisionGroup::collisionData ( )
inlinenodiscard

Definition at line 141 of file CollisionGroup.hh.

◆ collisionData() [2/2]

const CollisionData & Kart::CollisionGroup::collisionData ( ) const
inlinenodiscard

Definition at line 145 of file CollisionGroup.hh.

◆ computeCollisionLimits()

f32 Kart::CollisionGroup::computeCollisionLimits ( )
nodiscard0x805B883C

Sets the bounding radius.

Returns
The furthest point of all the hitboxes' spheres

Definition at line 120 of file CollisionGroup.cc.

◆ createSingleHitbox()

void Kart::CollisionGroup::createSingleHitbox ( f32 radius,
const EGG::Vector3f & relPos )
0x805B875C

Creates a hitbox to represent a tire.

Parameters
radiusThe radius of the tire

Definition at line 152 of file CollisionGroup.cc.

◆ hitbox()

Hitbox & Kart::CollisionGroup::hitbox ( u16 hitboxIdx)
inlinenodiscard

Definition at line 133 of file CollisionGroup.hh.

◆ hitboxCount()

u16 Kart::CollisionGroup::hitboxCount ( ) const
inlinenodiscard

Definition at line 137 of file CollisionGroup.hh.

◆ initHitboxes()

f32 Kart::CollisionGroup::initHitboxes ( const std::array< BSP::Hitbox, 16 > & hitboxes)
nodiscard0x805B84C0

Initializes the hitbox array based on the KartParam's BSP hitboxes.

The BSP always contains 16 hitboxes, but only some of them are valid/enabled. The game iterates the BSP::Hitbox array to see how many are enabled, allocates a Hitbox array of that size, and then sets all the enabled BSP hitboxes.

Parameters
hitboxesThe hitboxes from KartParam.bin
Returns
The furthest point out of the hitboxes' spheres

Definition at line 96 of file CollisionGroup.cc.

◆ reset()

void Kart::CollisionGroup::reset ( )
0x805B8330

Definition at line 169 of file CollisionGroup.cc.

◆ resetCollision()

void Kart::CollisionGroup::resetCollision ( )

Definition at line 178 of file CollisionGroup.cc.

◆ setHitboxScale()

void Kart::CollisionGroup::setHitboxScale ( f32 scale)
0x805B83D8

Definition at line 183 of file CollisionGroup.cc.

Member Data Documentation

◆ m_boundingRadius

f32 Kart::CollisionGroup::m_boundingRadius
private

Definition at line 151 of file CollisionGroup.hh.

◆ m_collisionData

CollisionData Kart::CollisionGroup::m_collisionData
private

Definition at line 152 of file CollisionGroup.hh.

◆ m_hitboxes

std::span<Hitbox> Kart::CollisionGroup::m_hitboxes
private

Definition at line 153 of file CollisionGroup.hh.

◆ m_hitboxScale

f32 Kart::CollisionGroup::m_hitboxScale
private

Definition at line 154 of file CollisionGroup.hh.