A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
SphereLink.hh
1#pragma once
2
3#include <egg/math/Vector.hh>
4
5namespace Field {
6
8class SphereLink {
9public:
10 SphereLink();
12
13 void initLinkLen(f32 length);
14 void init();
15 void calcStiffness();
16 void calc();
17 void calcConstraints(f32 scale);
18 void checkCollision();
19 void calcPos();
20
21 [[nodiscard]] bool isLeader() const {
22 return !m_prev;
23 }
24
26 void setPrev(SphereLink *prev) {
27 m_prev = prev;
28 }
29
30 void setNext(SphereLink *next) {
31 m_next = next;
32 }
33
34 void setPos(const EGG::Vector3f &pos) {
35 m_pos = pos;
36 }
37
38 void setVel(const EGG::Vector3f &vel) {
39 m_vel = vel;
40 }
41
42 void addSpringForce(const EGG::Vector3f &force) {
43 m_springForce += force;
44 }
46
48 [[nodiscard]] f32 linkLen() const {
49 return m_linkLen;
50 }
51
52 [[nodiscard]] const EGG::Vector3f &pos() const {
53 return m_pos;
54 }
55
56 [[nodiscard]] const EGG::Vector3f &up() const {
57 return m_up;
58 }
59
60 [[nodiscard]] static constexpr const EGG::Vector3f &Gravity() {
61 return GRAVITY;
62 }
64
65private:
66 void calcSpring();
67
68 SphereLink *m_prev;
69 SphereLink *m_next;
71 EGG::Vector3f m_pos;
72 EGG::Vector3f m_vel;
74 EGG::Vector3f m_up;
75 bool m_touchingGround;
76
77 static constexpr EGG::Vector3f GRAVITY = EGG::Vector3f(0.0f, 2.5f, 0.0f);
78};
79
80} // namespace Field
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88