1#include "CollisionGroup.hh"
6void CollisionData::reset() {
13 roadVelocity.setZero();
21 colPerpendicularity = 0.0f;
25 bInvisibleWall =
false;
29 bInvisibleWallOnly =
false;
35 bWallAtLeftCloser =
false;
36 bWallAtRightCloser =
false;
41Hitbox::Hitbox() : m_bspHitbox(nullptr), m_ownsBSP(false) {}
55 if (scale.y < totalScale) {
56 fVar1 = (totalScale - scale.y) * m_bspHitbox->radius;
60 scaledPos.y = (m_bspHitbox->position.y + sinkDepth) * scale.y + fVar1;
63 m_worldPos = m_relPos + pos;
75 f32 yScaleFactor = scale.y;
77 scaledPos.x *= scale.x;
78 scaledPos.z *= scale.z;
80 if (scale.y != scale.z && scale.y < 1.0f) {
81 scaledPos.y += (1.0f - scale.y) * m_radius;
82 yScaleFactor = scale.z;
85 scaledPos.y *= yScaleFactor;
90CollisionGroup::CollisionGroup() : m_hitboxScale(1.0f) {
91 m_collisionData.reset();
94CollisionGroup::~CollisionGroup() {
95 delete[] m_hitboxes.data();
106 u16 bspHitboxCount = 0;
108 for (
const auto &hitbox : hitboxes) {
109 if (parse<u16>(hitbox.enable)) {
114 m_hitboxes = std::span<Hitbox>(
new Hitbox[bspHitboxCount], bspHitboxCount);
117 for (
const auto &bspHitbox : hitboxes) {
118 if (parse<u16>(bspHitbox.enable)) {
119 m_hitboxes[hitboxIdx++].setBspHitbox(&bspHitbox);
132 for (
const auto &hitbox : m_hitboxes) {
135 if (bspHitbox->
enable == 0) {
143 f32 maxComponent = max.z;
145 if (max.x <= max.y) {
147 maxComponent = max.y;
149 }
else if (max.z < max.x) {
150 maxComponent = max.x;
153 m_boundingRadius = maxComponent;
162 m_hitboxes = std::span<Hitbox>(
new Hitbox[1], 1);
166 for (
auto &hitbox : m_hitboxes) {
169 hitbox.setBspHitbox(bspHitbox,
true);
171 bspHitbox->radius = radius;
172 hitbox.setRadius(radius);
174 m_boundingRadius = radius;
178void CollisionGroup::reset() {
179 m_collisionData.reset();
181 for (
auto &hitbox : m_hitboxes) {
183 hitbox.setRadius(hitbox.bspHitbox()->radius * m_hitboxScale);
187void CollisionGroup::resetCollision() {
188 m_collisionData.reset();
192void CollisionGroup::setHitboxScale(f32 scale) {
193 m_hitboxScale = scale;
195 for (
auto &hitbox : m_hitboxes) {
196 hitbox.setRadius(hitbox.bspHitbox()->radius * m_hitboxScale);
Vector3f ps_multVector(const Vector3f &vec) const
Paired-singles impl. of multVector.
void createSingleHitbox(f32 radius, const EGG::Vector3f &relPos)
Creates a hitbox to represent a tire.
f32 computeCollisionLimits()
Sets the bounding radius.
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.
Pertains to kart-related functionality.
A quaternion, used to represent 3D rotation.
Vector3f rotateVector(const Vector3f &vec) const
Rotates a vector based on the quat.
Vector3f abs() const
Returns the absolute value of each element of the vector.
Vector3f maximize(const Vector3f &rhs) const
Returns a vector whose elements are the max of the elements of both vectors.
Represents one of the many hitboxes that make up a vehicle.
u16 enable
Specifies if this is an active hitbox (since BSP always has 16).
EGG::Vector3f position
The relative position of the hitbox.
Field::KCLTypeMask closestWallFlags
The colliding wall KCL flag's KColType.
bool bMovingWaterVertical
KC last turn vertical water.
u32 closestFloorSettings
The colliding floor KCL flag's "variant".
bool bMovingWaterMomentum
Player will maintain speed for a bit after leaving KCL.
bool bMovingWaterDecaySpeed
Player speed will drop if not in mushroom.
bool bFloor
Set if colliding with KCL which satisfies KCL_TYPE_FLOOR.
bool bMovingWaterDisableAccel
KC last turn prevents mini-turbo acceleration.
bool bWall3
Set if colliding with COL_TYPE_WALL_2.
bool bWall
Set if colliding with KCL which satisfies KCL_TYPE_WALL.
Field::KCLTypeMask closestFloorFlags
The colliding floor KCL flag's KColType.
bool bMovingWaterStickyRoad
KC pipe vertical water section.
s32 intensity
The KCL flag's "wheel depth".