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 {
71 struct KCollisionPrism {
73 KCollisionPrism(f32 height, u16 posIndex, u16 faceNormIndex, u16 edge1NormIndex,
74 u16 edge2NormIndex, u16 edge3NormIndex, u16 attribute);
100 KColData(
const void *file);
103 void narrowScopeLocal(
const EGG::Vector3f &pos, f32 radius, KCLTypeMask mask);
107 [[nodiscard]]
bool checkPointCollision(f32 *distOut,
EGG::Vector3f *fnrmOut, u16 *flagsOut);
108 [[nodiscard]]
bool checkSphereCollision(f32 *distOut,
EGG::Vector3f *fnrmOut, u16 *flagsOut);
110 [[nodiscard]]
bool checkSphereSingle(f32 *distOut,
EGG::Vector3f *fnrmOut, u16 *flagsOut);
114 KCLTypeMask typeMask);
125 [[nodiscard]] u16 prismCache(u32 idx)
const {
126 return m_prismCache[idx];
136 template <CollisionCheckType Type>
140 [[nodiscard]]
bool checkPointCollision(u16 prismIdx, f32 *distOut,
EGG::Vector3f *fnrmOut,
141 u16 *flagsOut,
bool movement);
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;
163 KCLTypeMask m_typeMask;
164 const u16 *m_prismIter;
166 std::array<u16, 256> m_prismCache;
167 u16 *m_prismCacheTop;
168 u16 *m_cachedPrismArray;
void narrowPolygon_EachBlock(const u16 *prismArray)
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.
owning_span< u16 > m_prismAttributes
One-indexed array of each prism's KCL attribute.
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.
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.
owning_span< KCollisionPrismGeometry > m_prismGeometry
One-indexed array of each prism's geometry.
bool checkCollision(u16 prismIdx, f32 *distOut, EGG::Vector3f *fnrmOut, u16 *flagsOut)
This is a combination of the three collision checks in the base game.
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.
u32 m_areaZWidthMask
The z dimension of the octree's bounding box.
u32 m_areaXYBlocksShift
Used to initialize octree navigation.
void preloadPrismGeometry()
Resolves each prism's vertex, height, and normal indices into a contiguous struct.
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.
Stores the vertex, height and normals of a collision prism.
f32 height
The height of the tri.
EGG::Vector3f vtx
The first vertex of the tri.
EGG::Vector3f enrm2
The second edge's normal.
EGG::Vector3f fnrm
The face normal.
EGG::Vector3f enrm1
The first edge's normal.
EGG::Vector3f enrm3
The third edge's normal.