A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectCollisionBase.hh
1#pragma once
2
3#include <egg/math/Matrix.hh>
4
5namespace Field {
6
8struct GJKState {
9 GJKState() : m_flags(0), m_idx(0), m_mask(0), m_00c(0), m_scales{{}} {}
10
11 u32 m_flags;
12 u32 m_idx;
13 u32 m_mask;
14 s32 m_00c;
15 std::array<EGG::Vector3f, 4> m_s;
16 std::array<EGG::Vector3f, 4> m_support1;
17 std::array<EGG::Vector3f, 4> m_support2;
18 std::array<std::array<f32, 4>, 16> m_scales;
19};
20
25public:
27 virtual ~ObjectCollisionBase();
28
29 virtual void transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale,
30 const EGG::Vector3f &speed) = 0;
31 virtual const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const = 0;
32 virtual f32 getBoundingRadius() const = 0;
33
34 bool check(ObjectCollisionBase &rhs, EGG::Vector3f &distance);
35
37 [[nodiscard]] const EGG::Vector3f &translation() const {
38 return m_translation;
39 }
40
41protected:
42 EGG::Vector3f m_translation;
43
44private:
45 bool enclosesOrigin(const GJKState &state, u32 idx) const;
46 void FUN_808350e4(GJKState &state, EGG::Vector3f &v) const;
47 bool getNearestSimplex(GJKState &state, EGG::Vector3f &v) const;
48 void getNearestPoint(GJKState &state, u32 idx, EGG::Vector3f &v0, EGG::Vector3f &v1) const;
49 bool FUN_808357e4(const GJKState &state, u32 idx) const;
50 bool inSimplex(const GJKState &state, const EGG::Vector3f &v) const;
51 void getNearestPoint(const GJKState &state, u32 idx, EGG::Vector3f &v) const;
52 void calcSimplex(GJKState &state) const;
53
54 EGG::Vector3f m_00;
55
56 static std::array<std::array<f32, 4>, 4> s_dotProductCache;
57};
58
59} // namespace Field
A 3 x 4 matrix.
Definition Matrix.hh:8
The base class that all objects' collision inherits from.
Pertains to collision.
A 3D float vector.
Definition Vector.hh:87
Houses the state of an object in terms of the Gilbert–Johnson–Keerthi (GJK) algorithm.