A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
CollisionGroup.hh
Go to the documentation of this file.
1#pragma once
2
4
6
7#include <egg/math/Matrix.hh>
8
9#include <array>
10#include <span>
11
13namespace Kinoko::Kart {
14
53
57class Hitbox {
58public:
59 Hitbox();
60 ~Hitbox();
61
62 void calc(f32 totalScale, f32 sinkDepth, const EGG::Vector3f &scale, const EGG::Quatf &rot,
63 const EGG::Vector3f &pos);
64
66 void reset();
67
70 }
71
72 void setBspHitbox(const BSP::Hitbox *hitbox, bool owns = false) {
73 m_ownsBSP = owns;
74 m_bspHitbox = hitbox;
75 }
76
77 void setWorldPos(const EGG::Vector3f &pos) {
78 m_worldPos = pos;
79 }
80
81 void setLastPos(const EGG::Vector3f &pos) {
82 m_lastPos = pos;
83 }
84
85 void setLastPos(const EGG::Vector3f &scale, const EGG::Matrix34f &pose);
87
89 [[nodiscard]] const BSP::Hitbox *bspHitbox() const {
90 return m_bspHitbox;
91 }
92
93 [[nodiscard]] const EGG::Vector3f &worldPos() const {
94 return m_worldPos;
95 }
96
97 [[nodiscard]] const EGG::Vector3f &lastPos() const {
98 return m_lastPos;
99 }
100
101 [[nodiscard]] const EGG::Vector3f &relPos() const {
102 return m_relPos;
103 }
104
105 [[nodiscard]] f32 radius() const {
106 return m_radius;
107 }
108
110
111private:
117
119};
120
124public:
127
128 [[nodiscard]] f32 initHitboxes(const std::array<BSP::Hitbox, 16> &hitboxes);
129 [[nodiscard]] f32 computeCollisionLimits();
130 void createSingleHitbox(f32 radius, const EGG::Vector3f &relPos);
131
133 void reset();
134 void resetCollision();
135 void setHitboxScale(f32 scale);
137
139 [[nodiscard]] f32 boundingRadius() const {
140 return m_boundingRadius;
141 }
142
143 [[nodiscard]] Hitbox &hitbox(u16 hitboxIdx) {
144 return m_hitboxes[hitboxIdx];
145 }
146
147 [[nodiscard]] u16 hitboxCount() const {
148 return m_hitboxes.size();
149 }
150
151 [[nodiscard]] CollisionData &collisionData() {
152 return m_collisionData;
153 }
154
155 [[nodiscard]] const CollisionData &collisionData() const {
156 return m_collisionData;
157 }
158
160
161private:
166};
167
168} // namespace Kinoko::Kart
A 3 x 4 matrix.
Definition Matrix.hh:10
const CollisionData & collisionData() const
void createSingleHitbox(f32 radius, const EGG::Vector3f &relPos)
Creates a hitbox to represent a tire.
Hitbox & hitbox(u16 hitboxIdx)
f32 computeCollisionLimits()
Sets the bounding radius.
owning_span< Hitbox > m_hitboxes
f32 initHitboxes(const std::array< BSP::Hitbox, 16 > &hitboxes)
Initializes the hitbox array based on the KartParam's BSP hitboxes.
Represents a hitbox for the kart body or a wheel.
void setWorldPos(const EGG::Vector3f &pos)
void setRadius(f32 radius)
void calc(f32 totalScale, f32 sinkDepth, const EGG::Vector3f &scale, const EGG::Quatf &rot, const EGG::Vector3f &pos)
Calculates the position of a given hitbox, both relative to the player and world.
const BSP::Hitbox * m_bspHitbox
void setLastPos(const EGG::Vector3f &pos)
const EGG::Vector3f & worldPos() const
const EGG::Vector3f & lastPos() const
const EGG::Vector3f & relPos() const
void setBspHitbox(const BSP::Hitbox *hitbox, bool owns=false)
const BSP::Hitbox * bspHitbox() const
A contiguous storage container that manages the lifecycle of a buffer of a given size.
Definition Types.hh:32
Pertains to kart-related functionality.
float f32
Definition Memory.hh:21
uint16_t u16
Definition Memory.hh:17
int32_t s32
Definition Memory.hh:13
uint32_t u32
Definition Memory.hh:18
A quaternion, used to represent 3D rotation.
Definition Quat.hh:12
A 3D float vector.
Definition Vector.hh:108
Represents one of the many hitboxes that make up a vehicle.
Definition KartParam.hh:10
Information about the current collision and its properties.
bool bMovingWaterDecaySpeed
Player speed will drop if not in mushroom.
u32 closestFloorSettings
The colliding floor KCL flag's "variant".
Field::KCLTypeMask closestFloorFlags
The colliding floor KCL flag's KColType.
bool bMovingWaterDisableAccel
KC last turn prevents mini-turbo acceleration.
u32 closestWallSettings
The colliding wall KCL flag's "variant".
bool bWall3
Set if colliding with COL_TYPE_WALL_2.
bool bMovingWaterStickyRoad
KC pipe vertical water section.
bool bWall
Set if colliding with KCL which satisfies KCL_TYPE_WALL.
s32 intensity
The KCL flag's "wheel depth".
bool bMovingWaterMomentum
Player will maintain speed for a bit after leaving KCL.
Field::KCLTypeMask closestWallFlags
The colliding wall KCL flag's KColType.
bool bFloor
Set if colliding with KCL which satisfies KCL_TYPE_FLOOR.
bool bMovingWaterVertical
KC last turn vertical water.