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

#include <ObjectPylon.hh>

Description

The traffic cones on Daisy Circuit.

Definition at line 8 of file ObjectPylon.hh.

Inheritance diagram for Field::ObjectPylon:

Public Member Functions

 ObjectPylon (const System::MapdataGeoObj &params)
 
void init () override
 
void calc () override
 
u32 loadFlags () const override
 
Kart::Reaction onCollision (Kart::KartObject *kartObj, Kart::Reaction reactionOnKart, Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override
 
- Public Member Functions inherited from Field::ObjectCollidable
 ObjectCollidable (const System::MapdataGeoObj &params)
 
 ObjectCollidable (const char *name, const EGG::Vector3f &pos, const EGG::Vector3f &rot, const EGG::Vector3f &scale)
 
void load () override
 
void calcCollisionTransform () override
 
f32 getCollisionRadius () const override
 Finds the radius that fits fully in a BoxColUnit.
 
virtual void loadAABB (f32 maxSpeed)
 
virtual void loadAABB (f32 radius, f32 maxSpeed)
 
virtual void processKartReactions (Kart::KartObject *kartObj, Kart::Reaction &reactionOnKart, Kart::Reaction &reactionOnObj)
 
virtual void onWallCollision (Kart::KartObject *, const EGG::Vector3f &)
 
virtual void onObjectCollision (Kart::KartObject *)
 
virtual bool checkCollision (ObjectCollisionBase *lhs, EGG::Vector3f &dist)
 
virtual const EGG::Vector3fgetCollisionTranslation () const
 
virtual ObjectCollisionBasecollision () const
 
- Public Member Functions inherited from Field::ObjectBase
 ObjectBase (const System::MapdataGeoObj &params)
 
 ObjectBase (const char *name, const EGG::Vector3f &pos, const EGG::Vector3f &rot, const EGG::Vector3f &scale)
 
virtual void calcModel ()
 
virtual const char * getResources () const
 
virtual void loadGraphics ()
 
virtual void loadAnims ()
 
virtual void loadRail ()
 
virtual const char * getName () const
 
virtual const char * getKclName () const
 
virtual void resize (f32 radius, f32 maxSpeed)
 
virtual void unregisterCollision ()
 
virtual void disableCollision () const
 
virtual void enableCollision () const
 
virtual const BoxColUnitgetUnit () const
 
const RailInterpolatorrailInterpolator () const
 
virtual const EGG::Vector3fgetPosition () const
 
virtual ObjectId id () const
 
const EGG::Vector3fpos () const
 
void setPos (const EGG::Vector3f &pos)
 
void setScale (const EGG::Vector3f &scale)
 
void setTransform (const EGG::Matrix34f &mat)
 
const EGG::Vector3fscale () const
 

Private Types

enum  State {
  Idle = 0 ,
  Moving = 1 ,
  Hide = 2 ,
  ComeBack = 3 ,
  Hiding = 4 ,
  Hit = 5
}
 

Private Member Functions

void checkCollision (const EGG::Vector3f &hitDepth)
 
void startHit (f32 velFactor, EGG::Vector3f &hitDepth)
 
void calcHit ()
 
void calcHiding ()
 
void calcHide ()
 
void calcComeBack ()
 

Private Attributes

State m_state
 
std::array< ObjectPylon *, 2 > m_neighbors
 
const EGG::Vector3f m_initPos
 
const EGG::Vector3f m_initScale
 
const EGG::Vector3f m_initRot
 
u32 m_stateStartFrame
 Frame when pylon entered the current m_state.
 
u32 m_numBounces
 Number of floor collisions while in Hit state.
 
EGG::Vector3f m_vel
 Velocity used in Hit and ComeBack states.
 
EGG::Vector3f m_angVel
 Added to rotation while in Hit state.
 

Static Private Attributes

static constexpr f32 RADIUS = 120.0f
 
static constexpr f32 FALL_VEL = 20.0f
 
static constexpr u32 STATE_COOLDOWN_FRAMES = 5
 Minimum frames before a state change can occur.
 

Additional Inherited Members

- Public Types inherited from Field::ObjectBase
enum class  eFlags {
  Position = 0 ,
  Rotation = 1 ,
  Matrix = 2 ,
  Scale = 3
}
 
typedef EGG::TBitFlag< u16, eFlags > Flags
 
- Protected Member Functions inherited from Field::ObjectCollidable
void createCollision () override
 
virtual const EGG::Vector3fcollisionCenter () const
 
void registerManagedObject ()
 
- Protected Member Functions inherited from Field::ObjectBase
void calcTransform ()
 
void calcRotLock ()
 
void linkAnims (const std::span< const char * > &names, const std::span< Render::AnmType > types)
 
void setMatrixTangentTo (const EGG::Vector3f &up, const EGG::Vector3f &tangent)
 
void setMatrixFromOrthonormalBasisAndPos (const EGG::Vector3f &v)
 
- Static Protected Member Functions inherited from Field::ObjectBase
static f32 CheckPointAgainstLineSegment (const EGG::Vector3f &point, const EGG::Vector3f &a, const EGG::Vector3f &b)
 Calculates on what side of line segment ab point lies.
 
static EGG::Vector3f RotateXZByYaw (f32 angle, const EGG::Vector3f &v)
 Rotates a vector around the Y-axis and returns the XZ-plane portion of the vector.
 
static EGG::Vector3f RotateAxisAngle (f32 angle, const EGG::Vector3f &axis, const EGG::Vector3f &v1)
 
static void SetRotTangentHorizontal (EGG::Matrix34f &mat, const EGG::Vector3f &up, const EGG::Vector3f &tangent)
 
static EGG::Matrix34f OrthonormalBasis (const EGG::Vector3f &v)
 
static EGG::Matrix34f RailOrthonormalBasis (const RailInterpolator &railInterpolator)
 
static EGG::Vector3f AdjustVecForward (f32 sidewaysScalar, f32 forwardScalar, f32 minSpeed, const EGG::Vector3f &src, EGG::Vector3f forward)
 
static f32 CalcParabolicDisplacement (f32 initVel, f32 accel, u32 frame)
 Solves the standard kinematic equation \(y(t) = v_0\, t - \frac{1}{2} a t^{2}\).
 
static EGG::Vector3f Interpolate (f32 t, const EGG::Vector3f &v0, const EGG::Vector3f &v1)
 
- Protected Attributes inherited from Field::ObjectCollidable
ObjectCollisionBasem_collision
 
- Protected Attributes inherited from Field::ObjectBase
Render::DrawMdlm_drawMdl
 
Abstract::g3d::ResFilem_resFile
 
ObjectId m_id
 
RailInterpolatorm_railInterpolator
 
BoxColUnitm_boxColUnit
 
Flags m_flags
 
EGG::Vector3f m_pos
 
EGG::Vector3f m_scale
 
EGG::Vector3f m_rot
 
bool m_rotLock
 
EGG::Matrix34f m_transform
 
const System::MapdataGeoObjm_mapObj
 

Member Enumeration Documentation

◆ State

enum Field::ObjectPylon::State
private

Definition at line 25 of file ObjectPylon.hh.

Constructor & Destructor Documentation

◆ ObjectPylon()

Field::ObjectPylon::ObjectPylon ( const System::MapdataGeoObj & params)
0x8082CAD8

Definition at line 13 of file ObjectPylon.cc.

Member Function Documentation

◆ calc()

void Field::ObjectPylon::calc ( )
overridevirtual0x8082D044

Reimplemented from Field::ObjectBase.

Definition at line 78 of file ObjectPylon.cc.

◆ calcComeBack()

void Field::ObjectPylon::calcComeBack ( )
private

Definition at line 329 of file ObjectPylon.cc.

◆ calcHide()

void Field::ObjectPylon::calcHide ( )
private

Definition at line 316 of file ObjectPylon.cc.

◆ calcHiding()

void Field::ObjectPylon::calcHiding ( )
private

Definition at line 294 of file ObjectPylon.cc.

◆ calcHit()

void Field::ObjectPylon::calcHit ( )
private

Definition at line 230 of file ObjectPylon.cc.

◆ checkCollision()

void Field::ObjectPylon::checkCollision ( const EGG::Vector3f & hitDepth)
private0x8082E100
Warning
This function can cause time trial desyncs. Higher in the callstack is ObjectDirector::checkKartObjectCollision, which iterates over each object in the spatial cache. For each object, it updates the AABB and checks for collision. If there was a collision, it calls OnCollision which will in turn call this function. This function will then update its position if it finds itself to be colliding with any of its neighbors. However, it is not guaranteed that its neighbors have had their AABBs updated yet for this frame, as they may not be processed until a later iteration in checkKartObjectCollision.

Definition at line 171 of file ObjectPylon.cc.

◆ init()

void Field::ObjectPylon::init ( )
overridevirtual0x8082CD60

Reimplemented from Field::ObjectBase.

Definition at line 20 of file ObjectPylon.cc.

◆ loadFlags()

u32 Field::ObjectPylon::loadFlags ( ) const
inlinenodiscardoverridevirtual0x8082E4F8

Reimplemented from Field::ObjectBase.

Definition at line 17 of file ObjectPylon.hh.

◆ onCollision()

Kart::Reaction Field::ObjectPylon::onCollision ( Kart::KartObject * kartObj,
Kart::Reaction reactionOnKart,
Kart::Reaction reactionOnObj,
EGG::Vector3f & hitDepth )
overridevirtual0x8082DBEC

If the player's speed ratio is above 70%, then the pylone nters the "Hit" state where it bounces away. Else, it checks to see the angle of impact between the player and the pylon. If the player's angle falls between 30 and 150 degrees, then the cone will reduce the player's speed down to 82%.

Reimplemented from Field::ObjectCollidable.

Definition at line 107 of file ObjectPylon.cc.

◆ startHit()

void Field::ObjectPylon::startHit ( f32 velFactor,
EGG::Vector3f & hitDepth )
private0x8082E3F0

Definition at line 217 of file ObjectPylon.cc.

Member Data Documentation

◆ FALL_VEL

f32 Field::ObjectPylon::FALL_VEL = 20.0f
staticconstexprprivate

Definition at line 54 of file ObjectPylon.hh.

◆ m_angVel

EGG::Vector3f Field::ObjectPylon::m_angVel
private

Added to rotation while in Hit state.

Definition at line 51 of file ObjectPylon.hh.

◆ m_initPos

const EGG::Vector3f Field::ObjectPylon::m_initPos
private

Definition at line 45 of file ObjectPylon.hh.

◆ m_initRot

const EGG::Vector3f Field::ObjectPylon::m_initRot
private

Definition at line 47 of file ObjectPylon.hh.

◆ m_initScale

const EGG::Vector3f Field::ObjectPylon::m_initScale
private

Definition at line 46 of file ObjectPylon.hh.

◆ m_neighbors

std::array<ObjectPylon *, 2> Field::ObjectPylon::m_neighbors
private

Definition at line 44 of file ObjectPylon.hh.

◆ m_numBounces

u32 Field::ObjectPylon::m_numBounces
private

Number of floor collisions while in Hit state.

Definition at line 49 of file ObjectPylon.hh.

◆ m_state

State Field::ObjectPylon::m_state
private

Definition at line 43 of file ObjectPylon.hh.

◆ m_stateStartFrame

u32 Field::ObjectPylon::m_stateStartFrame
private

Frame when pylon entered the current m_state.

Definition at line 48 of file ObjectPylon.hh.

◆ m_vel

EGG::Vector3f Field::ObjectPylon::m_vel
private

Velocity used in Hit and ComeBack states.

Definition at line 50 of file ObjectPylon.hh.

◆ RADIUS

f32 Field::ObjectPylon::RADIUS = 120.0f
staticconstexprprivate

Definition at line 53 of file ObjectPylon.hh.

◆ STATE_COOLDOWN_FRAMES

u32 Field::ObjectPylon::STATE_COOLDOWN_FRAMES = 5
staticconstexprprivate

Minimum frames before a state change can occur.

Definition at line 57 of file ObjectPylon.hh.