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

#include <KartState.hh>

Description

Houses various flags and other variables to preserve the kart's state.

Most notably, this class is the direct observer of the input state, and sets the appropriate flags for KartMove to act upon the input state. This class also is responsible for managing calculations of the start boost duration.

Definition at line 13 of file KartState.hh.

Inheritance diagram for Kart::KartState:

Public Member Functions

void init ()
 
void reset ()
 
void calcInput ()
 Each frame, read input and save related bit flags. Also handles start boosts.
 
void calc ()
 Every frame, resets the input state and saves collision-related bit flags.
 
void resetFlags ()
 
void calcCollisions ()
 Each frame, checks for collision and saves relevant bit flags.
 
void calcStartBoost ()
 STAGE 1 - Each frame, calculates the start boost charge.
 
void calcHandleStartBoost ()
 On countdown end, calculates and applies our start boost charge.
 
void handleStartBoost (size_t idx)
 Applies the relevant start boost duration.
 
void resetEjection ()
 Resets certain bitfields pertaining to ejections (reject road, half pipe zippers, etc.)
 

Static Public Attributes

static constexpr std::array< StartBoostEntry, 6 > START_BOOST_ENTRIES
 

Setters

void setCannonPointId (u16 val)
 
void setBoostRampType (s32 val)
 
void setJumpPadVariant (s32 val)
 
void setHalfPipeInvisibilityTimer (s16 val)
 
void setTrickableTimer (s16 val)
 

Getters

bool isDrifting () const
 
u16 cannonPointId () const
 
s32 boostRampType () const
 
s32 jumpPadVariant () const
 
f32 stickX () const
 
f32 stickY () const
 
u32 airtime () const
 
const EGG::Vector3ftop () const
 
const EGG::Vector3fsoftWallSpeed () const
 
f32 startBoostCharge () const
 
s16 wallBonkTimer () const
 
s16 trickableTimer () const
 
Statusstatus ()
 
const Statusstatus () const
 

Private Attributes

Status m_status
 
u32 m_airtime
 
EGG::Vector3f m_top
 
EGG::Vector3f m_softWallSpeed
 
s32 m_hwgTimer
 
u16 m_cannonPointId
 
s32 m_boostRampType
 
s32 m_jumpPadVariant
 
s16 m_halfPipeInvisibilityTimer
 
f32 m_stickX
 One of 15 discrete stick values from [-1.0, 1.0].
 
f32 m_stickY
 One of 15 discrete stick values from [-1.0, 1.0].
 
f32 m_startBoostCharge
 0-1 representation of start boost charge. Burnout if >0.95f.
 
size_t m_startBoostIdx
 Used to map m_startBoostCharge to a start boost duration.
 
s16 m_wallBonkTimer
 2f counter that stunts your speed after hitting a wall.
 
s16 m_trickableTimer
 

Additional Inherited Members

- Private Member Functions inherited from Kart::KartObjectProxy
void setPos (const EGG::Vector3f &pos)
 
void setRot (const EGG::Quatf &q)
 
void setInertiaScale (const EGG::Vector3f &scale)
 
KartActionaction ()
 
const KartActionaction () const
 
KartBodybody ()
 
const KartBodybody () const
 
KartCollidecollide ()
 
const KartCollidecollide () const
 
CollisionGroupcollisionGroup ()
 
const CollisionGroupcollisionGroup () const
 
KartMovemove ()
 
const KartMovemove () const
 
KartHalfPipehalfPipe ()
 
const KartHalfPipehalfPipe () const
 
KartScalekartScale ()
 
const KartScalekartScale () const
 
KartJumpjump ()
 
const KartJumpjump () const
 
KartParamparam ()
 
const KartParamparam () const
 
const BSPbsp () const
 
KartPhysicsphysics ()
 
const KartPhysicsphysics () const
 
KartDynamicsdynamics ()
 
const KartDynamicsdynamics () const
 
KartStatestate ()
 
const KartStatestate () const
 
KartSubsub ()
 
const KartSubsub () const
 
KartSuspensionsuspension (u16 suspIdx)
 
const KartSuspensionsuspension (u16 suspIdx) const
 
KartSuspensionPhysicssuspensionPhysics (u16 suspIdx)
 
const KartSuspensionPhysicssuspensionPhysics (u16 suspIdx) const
 
KartTiretire (u16 tireIdx)
 
const KartTiretire (u16 tireIdx) const
 
WheelPhysicstirePhysics (u16 tireIdx)
 
const WheelPhysicstirePhysics (u16 tireIdx) const
 
CollisionDatacollisionData ()
 
const CollisionDatacollisionData () const
 
CollisionDatacollisionData (u16 tireIdx)
 
const CollisionDatacollisionData (u16 tireIdx) const
 
const System::KPadinputs () const
 
Render::KartModelmodel ()
 
const Render::KartModelmodel () const
 
Field::ObjectCollisionKartobjectCollisionKart ()
 
const Field::ObjectCollisionKartobjectCollisionKart () const
 
Field::BoxColUnitboxColUnit ()
 
const Field::BoxColUnitboxColUnit () const
 
const EGG::Vector3fscale () const
 
const EGG::Matrix34fpose () const
 
EGG::Vector3f bodyFront () const
 Returns the third column of the rotation matrix, which is the facing vector.
 
EGG::Vector3f bodyForward () const
 Returns the first column of the rotation matrix, which is the "right" direction.
 
EGG::Vector3f bodyUp () const
 Returns the second column of the rotation matrix, which is the "up" direction.
 
const EGG::Vector3fcomponentXAxis () const
 
const EGG::Vector3fcomponentYAxis () const
 
const EGG::Vector3fcomponentZAxis () const
 
const EGG::Vector3fpos () const
 
const EGG::Vector3fprevPos () const
 
const EGG::QuatffullRot () const
 
const EGG::Vector3fextVel () const
 
const EGG::Vector3fintVel () const
 
const EGG::Vector3fvelocity () const
 
f32 speed () const
 
f32 acceleration () const
 
f32 softSpeedLimit () const
 
const EGG::QuatfmainRot () const
 
const EGG::Vector3fangVel2 () const
 
bool isBike () const
 
u16 suspCount () const
 
u16 tireCount () const
 
bool hasFloorCollision (const WheelPhysics *wheelPhysics) const
 
std::pair< EGG::Vector3f, EGG::Vector3fgetCannonPosRot ()
 
f32 speedRatio () const
 
f32 speedRatioCapped () const
 
bool isInRespawn () const
 
Field::KCLTypeMask wallKclType () const
 
u32 wallKclVariant () const
 
Statusstatus ()
 
const Statusstatus () const
 
void apply (size_t idx)
 
- Static Private Member Functions inherited from Kart::KartObjectProxy
static std::list< KartObjectProxy * > & proxyList ()
 

Constructor & Destructor Documentation

◆ KartState()

Kart::KartState::KartState ( )
0x805943B4

Definition at line 30 of file KartState.cc.

Member Function Documentation

◆ airtime()

u32 Kart::KartState::airtime ( ) const
inlinenodiscard

Definition at line 76 of file KartState.hh.

◆ boostRampType()

s32 Kart::KartState::boostRampType ( ) const
inlinenodiscard

Definition at line 60 of file KartState.hh.

◆ calc()

void Kart::KartState::calc ( )
0x8059474C

Every frame, resets the input state and saves collision-related bit flags.

Stage: All

Definition at line 115 of file KartState.cc.

◆ calcCollisions()

void Kart::KartState::calcCollisions ( )
0x80594BD4

Each frame, checks for collision and saves relevant bit flags.

Stage: All

Iterates each tire to check for collision. If any tire is colliding with the floor, the "Any Wheel Collision" bit is set. If all tires are colliding with the floor, the "All Wheels Collision" bit is set. Tracks airtime and computes the appropriate top vector, given the floor normals of all colliding floor KCLs.

Definition at line 143 of file KartState.cc.

◆ calcHandleStartBoost()

void Kart::KartState::calcHandleStartBoost ( )
0x805959D4

On countdown end, calculates and applies our start boost charge.

Stage: 1

Definition at line 370 of file KartState.cc.

◆ calcInput()

void Kart::KartState::calcInput ( )
0x8059487C

Each frame, read input and save related bit flags. Also handles start boosts.

Stage: 1+

Definition at line 66 of file KartState.cc.

◆ calcStartBoost()

void Kart::KartState::calcStartBoost ( )
0x80595918

STAGE 1 - Each frame, calculates the start boost charge.

If the player is holding accelerate, the start boost charge increases using exponential decay. If the player is not holding accelerate, the start boost charge decays by 4% each frame.

Definition at line 352 of file KartState.cc.

◆ cannonPointId()

u16 Kart::KartState::cannonPointId ( ) const
inlinenodiscard

Definition at line 56 of file KartState.hh.

◆ handleStartBoost()

void Kart::KartState::handleStartBoost ( size_t idx)
0x80595AF8

Applies the relevant start boost duration.

Parameters
idxThe index into the start boost entries array.

Definition at line 401 of file KartState.cc.

◆ init()

void Kart::KartState::init ( )
0x8059455C

Definition at line 41 of file KartState.cc.

◆ isDrifting()

bool Kart::KartState::isDrifting ( ) const
inlinenodiscard

Definition at line 52 of file KartState.hh.

◆ jumpPadVariant()

s32 Kart::KartState::jumpPadVariant ( ) const
inlinenodiscard

Definition at line 64 of file KartState.hh.

◆ reset()

void Kart::KartState::reset ( )
0x80594594

Definition at line 46 of file KartState.cc.

◆ resetEjection()

void Kart::KartState::resetEjection ( )
0x805958F0

Resets certain bitfields pertaining to ejections (reject road, half pipe zippers, etc.)

Definition at line 411 of file KartState.cc.

◆ resetFlags()

void Kart::KartState::resetFlags ( )
0x80594704

Definition at line 125 of file KartState.cc.

◆ setBoostRampType()

void Kart::KartState::setBoostRampType ( s32 val)
inline

Definition at line 34 of file KartState.hh.

◆ setCannonPointId()

void Kart::KartState::setCannonPointId ( u16 val)
inline

Definition at line 30 of file KartState.hh.

◆ setHalfPipeInvisibilityTimer()

void Kart::KartState::setHalfPipeInvisibilityTimer ( s16 val)
inline

Definition at line 42 of file KartState.hh.

◆ setJumpPadVariant()

void Kart::KartState::setJumpPadVariant ( s32 val)
inline

Definition at line 38 of file KartState.hh.

◆ setTrickableTimer()

void Kart::KartState::setTrickableTimer ( s16 val)
inline

Definition at line 46 of file KartState.hh.

◆ softWallSpeed()

const EGG::Vector3f & Kart::KartState::softWallSpeed ( ) const
inlinenodiscard

Definition at line 84 of file KartState.hh.

◆ startBoostCharge()

f32 Kart::KartState::startBoostCharge ( ) const
inlinenodiscard

Definition at line 88 of file KartState.hh.

◆ status() [1/2]

Status & Kart::KartState::status ( )
inlinenodiscard

Definition at line 100 of file KartState.hh.

◆ status() [2/2]

const Status & Kart::KartState::status ( ) const
inlinenodiscard

Definition at line 104 of file KartState.hh.

◆ stickX()

f32 Kart::KartState::stickX ( ) const
inlinenodiscard

Definition at line 68 of file KartState.hh.

◆ stickY()

f32 Kart::KartState::stickY ( ) const
inlinenodiscard

Definition at line 72 of file KartState.hh.

◆ top()

const EGG::Vector3f & Kart::KartState::top ( ) const
inlinenodiscard

Definition at line 80 of file KartState.hh.

◆ trickableTimer()

s16 Kart::KartState::trickableTimer ( ) const
inlinenodiscard

Definition at line 96 of file KartState.hh.

◆ wallBonkTimer()

s16 Kart::KartState::wallBonkTimer ( ) const
inlinenodiscard

Definition at line 92 of file KartState.hh.

Member Data Documentation

◆ m_airtime

u32 Kart::KartState::m_airtime
private

Definition at line 112 of file KartState.hh.

◆ m_boostRampType

s32 Kart::KartState::m_boostRampType
private

Definition at line 117 of file KartState.hh.

◆ m_cannonPointId

u16 Kart::KartState::m_cannonPointId
private

Definition at line 116 of file KartState.hh.

◆ m_halfPipeInvisibilityTimer

s16 Kart::KartState::m_halfPipeInvisibilityTimer
private

Definition at line 119 of file KartState.hh.

◆ m_hwgTimer

s32 Kart::KartState::m_hwgTimer
private

Definition at line 115 of file KartState.hh.

◆ m_jumpPadVariant

s32 Kart::KartState::m_jumpPadVariant
private

Definition at line 118 of file KartState.hh.

◆ m_softWallSpeed

EGG::Vector3f Kart::KartState::m_softWallSpeed
private

Definition at line 114 of file KartState.hh.

◆ m_startBoostCharge

f32 Kart::KartState::m_startBoostCharge
private

0-1 representation of start boost charge. Burnout if >0.95f.

Definition at line 122 of file KartState.hh.

◆ m_startBoostIdx

size_t Kart::KartState::m_startBoostIdx
private

Used to map m_startBoostCharge to a start boost duration.

Definition at line 123 of file KartState.hh.

◆ m_status

Status Kart::KartState::m_status
private

Definition at line 111 of file KartState.hh.

◆ m_stickX

f32 Kart::KartState::m_stickX
private

One of 15 discrete stick values from [-1.0, 1.0].

Definition at line 120 of file KartState.hh.

◆ m_stickY

f32 Kart::KartState::m_stickY
private

One of 15 discrete stick values from [-1.0, 1.0].

Definition at line 121 of file KartState.hh.

◆ m_top

EGG::Vector3f Kart::KartState::m_top
private

Definition at line 113 of file KartState.hh.

◆ m_trickableTimer

s16 Kart::KartState::m_trickableTimer
private

Definition at line 125 of file KartState.hh.

◆ m_wallBonkTimer

s16 Kart::KartState::m_wallBonkTimer
private

2f counter that stunts your speed after hitting a wall.

Note
This object is labeled as having a poor name. It should be renamed to better represent its purpose.

Definition at line 124 of file KartState.hh.

◆ START_BOOST_ENTRIES

std::array<StartBoostEntry, 6> START_BOOST_ENTRIES
staticconstexpr0x808B64F8
Initial value:
= {{
{0.85f, 0},
{0.88f, 10},
{0.905f, 20},
{0.925f, 30},
{0.94f, 45},
{0.95f, 70},
}}

Definition at line 20 of file KartState.cc.