A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectBoble.cc
1#include "ObjectBoble.hh"
2
3namespace Field {
4
6ObjectBoble::ObjectBoble(const System::MapdataGeoObj &params) : ObjectCollidable(params) {}
7
9ObjectBoble::~ObjectBoble() = default;
10
12void ObjectBoble::init() {
13 m_railInterpolator->init(0.0f, 0);
14 m_curTangentDir = m_railInterpolator->curTangentDir();
15 m_railInterpolator->setPerPointVelocities(true);
16 m_flags |= 8;
17 m_scale = EGG::Vector3f(1.0f, 1.0f, 1.0f);
18}
19
21void ObjectBoble::calc() {
22 m_railInterpolator->calc();
23 m_pos = m_railInterpolator->curPos();
24 m_flags |= 1;
25
26 calcTangent();
27}
28
30void ObjectBoble::calcTangent() {
31 m_curTangentDir = Interpolate(0.2f, m_curTangentDir, m_railInterpolator->curTangentDir());
32 m_curTangentDir.normalise();
33
34 EGG::Vector3f axis = m_curTangentDir.cross(EGG::Vector3f::ex);
35 if (axis.normalise() == 0.0f) {
36 axis = m_curTangentDir.cross(EGG::Vector3f::ez);
37 axis.normalise();
38 }
39
40 setMatrixTangentTo(axis.cross(m_curTangentDir), m_curTangentDir);
41}
42
43} // namespace Field
Pertains to collision.
A 3D float vector.
Definition Vector.hh:87
f32 normalise()
Normalizes the vector and returns the original length.
Definition Vector.cc:44