1#include "CollisionGroup.hh"
6void CollisionData::reset() {
18 colPerpendicularity = 0.0f;
22 bInvisibleWall =
false;
24 bInvisibleWallOnly =
false;
27 bWallAtLeftCloser =
false;
28 bWallAtRightCloser =
false;
32Hitbox::Hitbox() : m_bspHitbox(nullptr), m_ownsBSP(false) {}
46 if (scale.y < totalScale) {
47 fVar1 = (totalScale - scale.y) * m_bspHitbox->radius;
51 scaledPos.y = (m_bspHitbox->position.y + sinkDepth) * scale.y + fVar1;
54 m_worldPos = m_relPos + pos;
66 f32 yScaleFactor = scale.y;
68 scaledPos.x *= scale.x;
69 scaledPos.z *= scale.z;
71 if (scale.y != scale.z && scale.y < 1.0f) {
72 scaledPos.y += (1.0f - scale.y) * m_radius;
73 yScaleFactor = scale.z;
76 scaledPos.y *= yScaleFactor;
81CollisionGroup::CollisionGroup() : m_hitboxScale(1.0f) {
82 m_collisionData.reset();
85CollisionGroup::~CollisionGroup() {
86 delete[] m_hitboxes.data();
97 u16 bspHitboxCount = 0;
99 for (
const auto &hitbox : hitboxes) {
100 if (parse<u16>(hitbox.enable)) {
105 m_hitboxes = std::span<Hitbox>(
new Hitbox[bspHitboxCount], bspHitboxCount);
108 for (
const auto &bspHitbox : hitboxes) {
109 if (parse<u16>(bspHitbox.enable)) {
110 m_hitboxes[hitboxIdx++].setBspHitbox(&bspHitbox);
123 for (
const auto &hitbox : m_hitboxes) {
126 if (bspHitbox->
enable == 0) {
134 f32 maxComponent = max.z;
136 if (max.x <= max.y) {
138 maxComponent = max.y;
140 }
else if (max.z < max.x) {
141 maxComponent = max.x;
144 m_boundingRadius = maxComponent;
153 m_hitboxes = std::span<Hitbox>(
new Hitbox[1], 1);
157 for (
auto &hitbox : m_hitboxes) {
160 hitbox.setBspHitbox(bspHitbox,
true);
162 bspHitbox->radius = radius;
163 hitbox.setRadius(radius);
165 m_boundingRadius = radius;
169void CollisionGroup::reset() {
170 m_collisionData.reset();
172 for (
auto &hitbox : m_hitboxes) {
174 hitbox.setRadius(hitbox.bspHitbox()->radius * m_hitboxScale);
178void CollisionGroup::resetCollision() {
179 m_collisionData.reset();
183void CollisionGroup::setHitboxScale(f32 scale) {
184 m_hitboxScale = scale;
186 for (
auto &hitbox : m_hitboxes) {
187 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.
u32 closestFloorSettings
The KCL flag's "variant".
bool bFloor
Set if colliding with KCL which satisfies KCL_TYPE_FLOOR.
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 KCL flag's KColType.
s32 intensity
The KCL flag's "wheel depth".