Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
SphereLink.hh
1
#pragma once
2
3
#include <egg/math/Vector.hh>
4
5
namespace
Kinoko::Field
{
6
8
class
SphereLink {
9
public
:
10
SphereLink();
11
~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
65
private
:
66
void
calcSpring();
67
68
SphereLink *m_prev;
69
SphereLink *m_next;
70
f32
m_linkLen
;
71
EGG::Vector3f
m_pos;
72
EGG::Vector3f
m_vel;
73
EGG::Vector3f
m_springForce
;
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 Kinoko::Field
Kinoko::Field::SphereLink::m_springForce
EGG::Vector3f m_springForce
Prevents links from stretching past their m_linkLen.
Definition
SphereLink.hh:73
Kinoko::Field::SphereLink::m_linkLen
f32 m_linkLen
The maximum distance between this link and the previous (forward) link.
Definition
SphereLink.hh:70
Kinoko::Field
Pertains to collision.
Definition
BoxColManager.cc:10
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:107
game
field
SphereLink.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0