5#include <egg/math/BoundBox.hh>
6#include <egg/math/Matrix.hh>
18 bbox.min = bbox.min.
minimize(offset);
19 bbox.max = bbox.max.
maximize(offset);
35 if (dist > floorDist) {
42 if (dist > wallDist) {
50 movingFloorDist = -std::numeric_limits<f32>::min();
51 wallDist = -std::numeric_limits<f32>::min();
52 floorDist = -std::numeric_limits<f32>::min();
53 perpendicularity = 0.0f;
57 u32 kclAttributeTypeBit);
65 enum class CollisionCheckType {
74 u16 edge2NormIndex,
u16 edge3NormIndex,
u16 attribute);
93 [[nodiscard]]
bool checkPointCollision(f32 *distOut,
EGG::Vector3f *fnrmOut,
u16 *flagsOut);
94 [[nodiscard]]
bool checkSphereCollision(f32 *distOut,
EGG::Vector3f *fnrmOut,
u16 *flagsOut);
96 [[nodiscard]]
bool checkSphereSingle(f32 *distOut,
EGG::Vector3f *fnrmOut,
u16 *flagsOut);
111 [[nodiscard]]
u16 prismCache(u32 idx)
const {
112 return m_prismCache[idx];
124 [[nodiscard]]
bool checkCollision(
const KCollisionPrism &prism, f32 *distOut,
126 [[nodiscard]]
bool checkPointCollision(
const KCollisionPrism &prism, f32 *distOut,
129 [[nodiscard]]
bool checkPointMovement(f32 *distOut,
EGG::Vector3f *fnrmOut,
u16 *attributeOut);
130 [[nodiscard]]
bool checkPoint(f32 *distOut,
EGG::Vector3f *fnrmOut,
u16 *attributeOut);
132 const void *m_posData;
133 const void *m_nrmData;
134 const void *m_prismData;
135 const void *m_blockData;
136 f32 m_prismThickness;
150 const u16 *m_prismIter;
152 std::array<u16, 256> m_prismCache;
153 u16 *m_prismCacheTop;
154 u16 *m_cachedPrismArray;
161 std::span<EGG::Vector3f> m_nrms;
162 std::span<EGG::Vector3f> m_vertices;
Performs lookups for KCL triangles.
void preloadNormals()
Creates a copy of the normals in memory.
void preloadVertices()
Creates a copy of the vertices in memory.
bool checkSphereMovement(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *attributeOut)
Iterates the local data block to check for directional collision.
u32 m_areaYWidthMask
The y dimension of the octree's bounding box.
u32 m_areaZWidthMask
The z dimension of the octree's bounding box.
f32 m_sphereRadius
Clamps the sphere we check collision against.
static EGG::Vector3f GetVertex(f32 height, const EGG::Vector3f &vertex1, const EGG::Vector3f &fnrm, const EGG::Vector3f &enrm3, const EGG::Vector3f &enrm)
Computes a prism vertex based off of the triangle's normal vectors.
void preloadPrisms()
Creates a copy of the prisms in memory.
bool checkSphere(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *flagsOut)
Iterates the list of looked-up triangles to see if we are colliding.
void computeBBox()
Calculates a EGG::BoundBox3f that describes the boundary of the track's KCL.
void lookupPoint(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos, KCLTypeMask typeMask)
Sets members in preparation of a subsequent point collision check call.
u32 m_areaXWidthMask
The x dimension of the octree's bounding box.
const u16 * searchBlock(const EGG::Vector3f &pos)
Finds the data block corresponding to the provided position.
u32 m_blockWidthShift
Used to initialize octree navigation.
u32 m_areaXYBlocksShift
Used to initialize octree navigation.
void narrowPolygon_EachBlock(const u16 *prismArray)
u32 m_areaXBlocksShift
Used to initialize octree navigation.
std::span< KCollisionPrism > m_prisms
Optimizes for time by avoiding unnecessary byteswapping. The Wii doesn't have this problem because bi...
void lookupSphere(f32 radius, const EGG::Vector3f &pos, const EGG::Vector3f &prevPos, KCLTypeMask typeMask)
Sets members in preparation of a subsequent sphere collision check call.
bool checkCollision(const KCollisionPrism &prism, f32 *distOut, EGG::Vector3f *fnrmOut, u16 *flagsOut, CollisionCheckType type)
This is a combination of the three collision checks in the base game.
A representation of a bounding cuboid.
Vector3f maximize(const Vector3f &rhs) const
Returns a vector whose elements are the max of the elements of both vectors.
Vector3f minimize(const Vector3f &rhs) const
Returns a vector whose elements are the min of the elements of both vectors.