A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectCarA.hh
1#pragma once
2
3#include "game/field/StateManager.hh"
4#include "game/field/obj/ObjectCollidable.hh"
5
6namespace Field {
7
8class ObjectCarA : public ObjectCollidable, public StateManager {
9public:
10 ObjectCarA(const System::MapdataGeoObj &params);
11 ~ObjectCarA() override;
12
13 void init() override;
14 void calc() override;
15
17 [[nodiscard]] u32 loadFlags() const override {
18 return 1;
19 }
20
21 void createCollision() override;
22 void calcCollisionTransform() override;
23
24 Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
25 Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override;
26
27private:
28 // Trapezoidal motion profile
29 enum class MotionState {
30 Accelerating = 0,
31 Cruising = 1,
32 Decelerating = 2,
33 };
34
35 void calcPos();
36
37 void enterStop();
38 void enterAccel() {}
39 void enterCruising();
40
41 void calcStop();
42 void calcAccel();
43 void calcCruising();
44
45 const f32 m_finalVel;
46 const f32 m_accel;
47 const u32 m_stopTime;
51 f32 m_currVel;
52 MotionState m_motionState;
53 bool m_changingDir;
54
55 static constexpr std::array<StateManagerEntry, 3> STATE_ENTRIES = {{
56 {StateEntry<ObjectCarA, &ObjectCarA::enterStop, &ObjectCarA::calcStop>(0)},
57 {StateEntry<ObjectCarA, &ObjectCarA::enterAccel, &ObjectCarA::calcAccel>(1)},
58 {StateEntry<ObjectCarA, &ObjectCarA::enterCruising, &ObjectCarA::calcCruising>(2)},
59 }};
60};
61
62} // namespace Field
EGG::Vector3f m_currTangent
It's EGG::Vector3f::ey unless it flies up in the air.
Definition ObjectCarA.hh:49
f32 m_cruiseTime
How long to spend at cruising speed before decelerating.
Definition ObjectCarA.hh:48
EGG::Vector3f m_currUp
It's EGG::Vector3f::ey unless it flies up in the air.
Definition ObjectCarA.hh:50
Base class that represents different "states" for an object.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88