Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
KartSuspensionPhysics.hh
1
#pragma once
2
3
#include "game/kart/CollisionGroup.hh"
4
#include "game/kart/KartObjectProxy.hh"
5
#include "game/kart/KartParam.hh"
6
7
#include <egg/math/Matrix.hh>
8
9
namespace
Kinoko::Kart
{
10
13
class
WheelPhysics : KartObjectProxy {
14
public
:
15
WheelPhysics(u16 wheelIdx, u16 bspWheelIdx);
16
~WheelPhysics();
17
18
void
init();
19
void
initBsp();
20
void
reset();
21
22
void
realign(
const
EGG::Vector3f
&bottom,
const
EGG::Vector3f
&vehicleMovement);
23
24
void
updateCollision(
const
EGG::Vector3f
&bottom,
const
EGG::Vector3f
&topmostPos);
25
void
calcSuspension(
const
EGG::Vector3f
&forward);
26
28
void
setSuspTravel(f32 suspTravel) {
29
m_suspTravel = suspTravel;
30
}
31
32
void
setPos(
const
EGG::Vector3f
&pos) {
33
m_pos = pos;
34
}
35
36
void
setLastPos(
const
EGG::Vector3f
&pos) {
37
m_lastPos = pos;
38
}
39
40
void
setLastPosDiff(
const
EGG::Vector3f
&pos) {
41
m_lastPosDiff = pos;
42
}
43
44
void
setWheelEdgePos(
const
EGG::Vector3f
&pos) {
45
m_wheelEdgePos = pos;
46
}
47
48
void
setColVel(
const
EGG::Vector3f
&vec) {
49
m_colVel = vec;
50
}
52
54
[[nodiscard]]
const
EGG::Vector3f
&pos()
const
{
55
return
m_pos;
56
}
57
58
[[nodiscard]]
const
EGG::Vector3f
&lastPosDiff()
const
{
59
return
m_lastPosDiff;
60
}
61
62
[[nodiscard]] f32 suspTravel() {
63
return
m_suspTravel;
64
}
65
66
[[nodiscard]]
const
EGG::Vector3f
&topmostPos()
const
{
67
return
m_topmostPos;
68
}
69
70
[[nodiscard]]
CollisionGroup
*hitboxGroup() {
71
return
m_hitboxGroup;
72
}
73
74
[[nodiscard]]
const
CollisionGroup
*hitboxGroup()
const
{
75
return
m_hitboxGroup;
76
}
77
78
[[nodiscard]]
const
EGG::Vector3f
&speed()
const
{
79
return
m_speed;
80
}
81
82
[[nodiscard]]
const
EGG::Vector3f
&wheelEdgePos()
const
{
83
return
m_wheelEdgePos;
84
}
85
86
[[nodiscard]] f32 effectiveRadius()
const
{
87
return
m_effectiveRadius;
88
}
89
90
[[nodiscard]] f32 _74()
const
{
91
return
m_74;
92
}
94
95
private
:
96
u16 m_wheelIdx;
97
u16 m_bspWheelIdx;
98
const
BSP::Wheel
*m_bspWheel;
99
CollisionGroup
*m_hitboxGroup;
100
EGG::Vector3f
m_pos;
101
EGG::Vector3f
m_lastPos;
102
EGG::Vector3f
m_lastPosDiff;
103
f32 m_suspTravel;
104
EGG::Vector3f
m_colVel;
105
EGG::Vector3f
m_speed;
106
EGG::Vector3f
m_wheelEdgePos;
107
f32 m_effectiveRadius;
108
f32 m_targetEffectiveRadius;
109
f32 m_74;
110
EGG::Vector3f
m_topmostPos;
111
};
112
114
class
KartSuspensionPhysics : KartObjectProxy {
115
public
:
117
enum class
TireType
{
118
Kart
,
119
KartReflected,
120
Bike,
121
};
122
123
KartSuspensionPhysics
(u16 wheelIdx, TireType TireType, u16 bspWheelIdx);
124
~KartSuspensionPhysics
();
125
126
void
init();
127
void
reset();
128
129
void
setInitialState();
130
131
void
calcCollision(f32 dt,
const
EGG::Vector3f
&gravity,
const
EGG::Matrix34f
&mat);
132
void
calcSuspension
(
const
EGG::Vector3f
&forward,
const
EGG::Vector3f
&vehicleMovement);
133
134
private
:
135
const
BSP::Wheel
*m_bspWheel;
136
WheelPhysics
*m_tirePhysics;
137
TireType m_tireType;
138
u16 m_bspWheelIdx;
139
u16 m_wheelIdx;
140
EGG::Vector3f
m_topmostPos;
141
f32 m_maxTravelScaled;
142
EGG::Vector3f
m_bottomDir;
143
};
144
145
}
// namespace Kinoko::Kart
Kinoko::EGG::Matrix34f
A 3 x 4 matrix.
Definition
Matrix.hh:10
Kinoko::Kart::CollisionGroup
Houses hitbox and collision info for an object (body or wheel).
Definition
CollisionGroup.hh:122
Kinoko::Kart::KartSuspensionPhysics
Physics for a single wheel's suspension.
Definition
KartSuspensionPhysics.hh:114
Kinoko::Kart::KartSuspensionPhysics::calcSuspension
void calcSuspension(const EGG::Vector3f &forward, const EGG::Vector3f &vehicleMovement)
Calculates linear force and rotation from the kart's suspension.
Definition
KartSuspensionPhysics.cc:202
Kinoko::Kart::KartSuspensionPhysics::TireType
TireType
Every other kart tire is a mirror of the first. Bikes do not leverage this.
Definition
KartSuspensionPhysics.hh:117
Kinoko::Kart::WheelPhysics
Manages wheel physics and collision checks.
Definition
KartSuspensionPhysics.hh:13
Kinoko::Kart
Pertains to kart-related functionality.
Definition
BoxColManager.hh:14
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:107
Kinoko::Kart::BSP::Wheel
Info pertaining to the suspension, position, etc. of a wheel.
Definition
KartParam.hh:20
game
kart
KartSuspensionPhysics.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0