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 Kinoko::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
25 friend class Host::Context;
26
27public:
29 virtual ~ObjectCollisionBase();
30
31 virtual void transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale) = 0;
32 virtual void transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale,
33 const EGG::Vector3f &speed) = 0;
34 virtual const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const = 0;
35 virtual f32 getBoundingRadius() const = 0;
36
37 bool check(ObjectCollisionBase &rhs, EGG::Vector3f &distance);
38
40 [[nodiscard]] const EGG::Vector3f &translation() const {
41 return m_translation;
42 }
43
44protected:
45 EGG::Vector3f m_translation;
46
47private:
48 bool enclosesOrigin(const GJKState &state, u32 idx) const;
49 void FUN_808350e4(GJKState &state, EGG::Vector3f &v) const;
50 bool getNearestSimplex(GJKState &state, EGG::Vector3f &v) const;
51 void getNearestPoint(GJKState &state, u32 idx, EGG::Vector3f &v0, EGG::Vector3f &v1) const;
52 bool FUN_808357e4(const GJKState &state, u32 idx) const;
53 bool inSimplex(const GJKState &state, const EGG::Vector3f &v) const;
54 void getNearestPoint(const GJKState &state, u32 idx, EGG::Vector3f &v) const;
55 void calcSimplex(GJKState &state) const;
56
57 EGG::Vector3f m_00;
58
59 static std::array<std::array<f32, 4>, 4> s_dotProductCache;
60};
61
62} // namespace Kinoko::Field
A 3 x 4 matrix.
Definition Matrix.hh:10
The base class that all objects' collision inherits from.
Contexts can be used to restore a previous memory state for the current session.
Definition Context.hh:70
Pertains to collision.
A 3D float vector.
Definition Vector.hh:107
Houses the state of an object in terms of the Gilbert–Johnson–Keerthi (GJK) algorithm.