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);
89 void narrowScopeLocal(
const EGG::Vector3f &pos, f32 radius, KCLTypeMask mask);
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);
100 KCLTypeMask typeMask);
111 [[nodiscard]]
u16 prismCache(u32 idx)
const {
112 return m_prismCache[idx];
115 [[nodiscard]] std::span<const KCollisionPrism> prisms()
const {
119 [[nodiscard]] std::span<const EGG::Vector3f> nrms()
const {
120 return m_nrms.view();
123 [[nodiscard]] std::span<const EGG::Vector3f> vertices()
const {
124 return m_vertices.view();
128 [[nodiscard]]
static EGG::Vector3f
GetVertex(f32 height,
const EGG::Vector3f &vertex1,
129 const EGG::Vector3f &fnrm,
const EGG::Vector3f &enrm3,
const EGG::Vector3f &enrm);
136 template <CollisionCheckType Type>
137 [[nodiscard]]
bool checkCollision(
const KCollisionPrism &prism, f32 *distOut,
138 EGG::Vector3f *fnrmOut, u16 *flagsOut);
140 [[nodiscard]]
bool checkPointCollision(
const KCollisionPrism &prism, f32 *distOut,
141 EGG::Vector3f *fnrmOut, u16 *flagsOut,
bool movement);
142 [[nodiscard]]
bool checkSphereMovement(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *attributeOut);
143 [[nodiscard]]
bool checkPointMovement(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *attributeOut);
144 [[nodiscard]]
bool checkPoint(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *attributeOut);
146 const void *m_posData;
147 const void *m_nrmData;
148 const void *m_prismData;
149 const void *m_blockData;
150 f32 m_prismThickness;
151 EGG::Vector3f m_areaMinPos;
163 KCLTypeMask m_typeMask;
164 const u16 *m_prismIter;
166 std::array<u16, 256> m_prismCache;
167 u16 *m_prismCacheTop;
168 u16 *m_cachedPrismArray;
Performs lookups for KCL triangles.
void narrowPolygon_EachBlock(const u16 *prismArray)
owning_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.
u32 m_areaYWidthMask
The y dimension of the octree's bounding box.
const u16 * searchBlock(const EGG::Vector3f &pos)
Finds the data block corresponding to the provided position.
bool checkSphere(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *flagsOut)
Iterates the list of looked-up triangles to see if we are colliding.
u32 m_areaXWidthMask
The x dimension of the octree's bounding box.
void preloadNormals()
Creates a copy of the normals in memory.
bool checkSphereMovement(f32 *distOut, EGG::Vector3f *fnrmOut, u16 *attributeOut)
Iterates the local data block to check for directional collision.
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.
u32 m_areaXBlocksShift
Used to initialize octree navigation.
u32 m_blockWidthShift
Used to initialize octree navigation.
f32 m_sphereRadius
Clamps the sphere we check collision against.
void preloadPrisms()
Creates a copy of the prisms in memory.
void lookupPoint(const EGG::Vector3f &pos, const EGG::Vector3f &prevPos, KCLTypeMask typeMask)
Sets members in preparation of a subsequent point collision check call.
void computeBBox()
Calculates a EGG::BoundBox3f that describes the boundary of the track's KCL.
void preloadVertices()
Creates a copy of the vertices in memory.
u32 m_areaZWidthMask
The z dimension of the octree's bounding box.
u32 m_areaXYBlocksShift
Used to initialize octree navigation.
bool checkCollision(const KCollisionPrism &prism, f32 *distOut, EGG::Vector3f *fnrmOut, u16 *flagsOut)
This is a combination of the three collision checks in the base game.
A contiguous storage container that manages the lifecycle of a buffer of a given size.
A representation of a bounding cuboid.
constexpr Vector3f minimize(const Vector3f &rhs) const
Returns a vector whose elements are the min of the elements of both vectors.
constexpr Vector3f maximize(const Vector3f &rhs) const
Returns a vector whose elements are the max of the elements of both vectors.