A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KartObjectProxy.hh
1#pragma once
2
3#include "game/system/KPadController.hh"
4
5#include <egg/math/Matrix.hh>
6
7#include <list>
8#include <vector>
9
10namespace Field {
11
12class BoxColUnit;
13class ObjectCollisionKart;
14
15} // namespace Field
16
17namespace Render {
18
19class KartModel;
20
21} // namespace Render
22
23namespace Kart {
24
25class CollisionGroup;
26struct CollisionData;
27class KartAction;
28class KartBody;
29class KartCollide;
30class KartDynamics;
31class KartHalfPipe;
32class KartJump;
33class KartMove;
34class KartParam;
35struct BSP;
36class KartPhysics;
37class KartState;
38class KartSub;
39class KartSuspension;
40class KartSuspensionPhysics;
41class KartTire;
42class WheelPhysics;
43
46 KartParam *param;
47 KartBody *body;
48 Render::KartModel *model;
49 KartSub *sub;
50 KartMove *move;
51 KartAction *action;
52 KartCollide *collide;
53 Field::ObjectCollisionKart *objectCollisionKart;
54 KartState *state;
55
56 std::vector<KartSuspension *> suspensions;
57 std::vector<KartTire *> tires;
58
59 Field::BoxColUnit *boxColUnit;
60};
61
65 friend class KartObject;
66
67public:
70
72 void setPos(const EGG::Vector3f &pos);
73 void setRot(const EGG::Quatf &q);
74 void setInertiaScale(const EGG::Vector3f &scale);
76
78 [[nodiscard]] KartAction *action();
79 [[nodiscard]] const KartAction *action() const;
80 [[nodiscard]] KartBody *body();
81 [[nodiscard]] const KartBody *body() const;
82 [[nodiscard]] KartCollide *collide();
83 [[nodiscard]] const KartCollide *collide() const;
84 [[nodiscard]] CollisionGroup *collisionGroup();
85 [[nodiscard]] const CollisionGroup *collisionGroup() const;
86 [[nodiscard]] KartMove *move();
87 [[nodiscard]] const KartMove *move() const;
88 [[nodiscard]] KartHalfPipe *halfPipe();
89 [[nodiscard]] const KartHalfPipe *halfPipe() const;
90 [[nodiscard]] KartJump *jump();
91 [[nodiscard]] const KartJump *jump() const;
92 [[nodiscard]] KartParam *param();
93 [[nodiscard]] const KartParam *param() const;
94 [[nodiscard]] const BSP &bsp() const;
95 [[nodiscard]] KartPhysics *physics();
96 [[nodiscard]] const KartPhysics *physics() const;
97 [[nodiscard]] KartDynamics *dynamics();
98 [[nodiscard]] const KartDynamics *dynamics() const;
99 [[nodiscard]] KartState *state();
100 [[nodiscard]] const KartState *state() const;
101 [[nodiscard]] KartSub *sub();
102 [[nodiscard]] const KartSub *sub() const;
103 [[nodiscard]] KartSuspension *suspension(u16 suspIdx);
104 [[nodiscard]] const KartSuspension *suspension(u16 suspIdx) const;
105 [[nodiscard]] KartSuspensionPhysics *suspensionPhysics(u16 suspIdx);
106 [[nodiscard]] const KartSuspensionPhysics *suspensionPhysics(u16 suspIdx) const;
107 [[nodiscard]] KartTire *tire(u16 tireIdx);
108 [[nodiscard]] const KartTire *tire(u16 tireIdx) const;
109 [[nodiscard]] WheelPhysics *tirePhysics(u16 tireIdx);
110 [[nodiscard]] const WheelPhysics *tirePhysics(u16 tireIdx) const;
111 [[nodiscard]] CollisionData &collisionData();
112 [[nodiscard]] const CollisionData &collisionData() const;
113 [[nodiscard]] CollisionData &collisionData(u16 tireIdx);
114 [[nodiscard]] const CollisionData &collisionData(u16 tireIdx) const;
115 [[nodiscard]] const System::KPad *inputs() const;
116 [[nodiscard]] Render::KartModel *model();
117 [[nodiscard]] const Render::KartModel *model() const;
118 [[nodiscard]] Field::ObjectCollisionKart *objectCollisionKart();
119 [[nodiscard]] const Field::ObjectCollisionKart *objectCollisionKart() const;
120 [[nodiscard]] Field::BoxColUnit *boxColUnit();
121 [[nodiscard]] const Field::BoxColUnit *boxColUnit() const;
122
123 [[nodiscard]] const EGG::Vector3f &scale() const;
124 [[nodiscard]] const EGG::Matrix34f &pose() const;
125 [[nodiscard]] EGG::Vector3f bodyFront() const;
126 [[nodiscard]] EGG::Vector3f bodyForward() const;
127 [[nodiscard]] EGG::Vector3f bodyUp() const;
128
129 [[nodiscard]] const EGG::Vector3f &componentXAxis() const;
130 [[nodiscard]] const EGG::Vector3f &componentYAxis() const;
131 [[nodiscard]] const EGG::Vector3f &componentZAxis() const;
132
133 [[nodiscard]] const EGG::Vector3f &pos() const;
134 [[nodiscard]] const EGG::Vector3f &prevPos() const;
135 [[nodiscard]] const EGG::Quatf &fullRot() const;
136 [[nodiscard]] const EGG::Vector3f &extVel() const;
137 [[nodiscard]] const EGG::Vector3f &intVel() const;
138 [[nodiscard]] const EGG::Vector3f &velocity() const;
139 [[nodiscard]] f32 speed() const;
140 [[nodiscard]] f32 acceleration() const;
141 [[nodiscard]] f32 softSpeedLimit() const;
142 [[nodiscard]] const EGG::Quatf &mainRot() const;
143 [[nodiscard]] const EGG::Vector3f &angVel2() const;
144 [[nodiscard]] bool isBike() const;
145 [[nodiscard]] u16 suspCount() const;
146 [[nodiscard]] u16 tireCount() const;
147 [[nodiscard]] bool hasFloorCollision(const WheelPhysics *wheelPhysics) const;
148 [[nodiscard]] std::pair<EGG::Vector3f, EGG::Vector3f> getCannonPosRot();
149 [[nodiscard]] f32 speedRatio() const;
150 [[nodiscard]] f32 speedRatioCapped() const;
151 [[nodiscard]] bool isInRespawn() const;
152
153 [[nodiscard]] static std::list<KartObjectProxy *> &proxyList() {
154 return s_proxyList;
155 }
157
158protected:
159 void apply(size_t idx);
160
161private:
162 static void ApplyAll(const KartAccessor *pointers);
163
164 const KartAccessor *m_accessor;
165
166 static std::list<KartObjectProxy *> s_proxyList;
167};
168
169} // namespace Kart
A 3 x 4 matrix.
Definition Matrix.hh:8
Relates a KartObject with its convex hull representation.
Houses hitbox and collision info for an object (body or wheel).
Manages body+wheel collision and its influence on position/velocity/etc.
State management for most components of a kart's physics.
Handles the physics and boosts associated with zippers.
Manages trick inputs and state.
Definition KartJump.hh:30
Responsible for reacting to player inputs and moving the kart.
Definition KartMove.hh:18
Base class for most kart-related objects.
EGG::Vector3f bodyUp() const
Returns the second column of the rotation matrix, which is the "up" direction.
static void ApplyAll(const KartAccessor *pointers)
For all proxies in the static list, synchronizes all pointers to the KartAccessor.
EGG::Vector3f bodyForward() const
Returns the first column of the rotation matrix, which is the "right" direction.
static std::list< KartObjectProxy * > s_proxyList
List of all KartObjectProxy children.
EGG::Vector3f bodyFront() const
Returns the third column of the rotation matrix, which is the facing vector.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Houses stats regarding a given character/vehicle combo.
Definition KartParam.hh:51
Manages the lifecycle of KartDynamics, handles moving floors and trick rotation.
Houses various flags and other variables to preserve the kart's state.
Definition KartState.hh:12
Hosts a few classes and the high level per-frame calc functions.
Definition KartSub.hh:11
Physics for a single wheel's suspension.
Doesn't do much besides hold a pointer to KartSuspensionPhysics.
A holder for a wheel's physics data.
Definition KartTire.hh:9
Manages wheel physics and collision checks.
Included in Kinoko because it mysteriously sets an angle member variable in KartBody.
Definition KartModel.hh:9
Pertains to collision.
Pertains to kart-related functionality.
Pertains to rendering the kart model.
A quaternion, used to represent 3D rotation.
Definition Quat.hh:12
A 3D float vector.
Definition Vector.hh:83
A representation of the boundaries of an entity that has dynamic collision.
Houses hitbox and wheel positions, radii, and suspension info.
Definition KartParam.hh:8
Information about the current collision and its properties.
Shared between classes who inherit KartObjectProxy so they can access one another.