A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectShip64.cc
1#include "ObjectShip64.hh"
2
3namespace Field {
4
6ObjectShip64::ObjectShip64(const System::MapdataGeoObj &params) : ObjectCollidable(params) {}
7
9ObjectShip64::~ObjectShip64() {
10 delete m_auxCollision;
11}
12
14void ObjectShip64::init() {
15 m_railInterpolator->init(0, 0);
16
17 m_tangent = m_railInterpolator->curTangentDir();
18 m_railInterpolator->setPerPointVelocities(true);
19
20 calc();
21 calcModel();
22}
23
25void ObjectShip64::calc() {
26 m_railInterpolator->calc();
27
28 setPos(m_railInterpolator->curPos());
29
30 m_tangent = Interpolate(0.2f, m_tangent, m_railInterpolator->curTangentDir());
31 m_tangent.normalise();
32
33 setMatrixFromOrthonormalBasisAndPos(m_tangent);
34}
35
37void ObjectShip64::createCollision() {
38 constexpr f32 RADIUS = 1500.0f;
39 constexpr f32 HEIGHT = 3500.0f;
40
41 ObjectCollidable::createCollision();
42 m_auxCollision = new ObjectCollisionCylinder(RADIUS, HEIGHT, EGG::Vector3f::zero);
43}
44
46void ObjectShip64::calcCollisionTransform() {
47 ObjectCollidable::calcCollisionTransform();
48 calcTransform();
49
51 v = m_transform.base(0);
52 v.normalise();
53
54 m_transform.setAxisRotation(F_PI / 2.0f, v);
55
56 m_transform.setBase(3, v);
57
58 m_auxCollision->transform(m_transform, m_scale);
59}
60
62bool ObjectShip64::checkCollision(ObjectCollisionBase *lhs, EGG::Vector3f &dist) {
63 EGG::Vector3f colDist = EGG::Vector3f::zero;
64 EGG::Vector3f auxDist = EGG::Vector3f::zero;
65
66 bool has_col = lhs->check(*m_collision, colDist) || lhs->check(*m_auxCollision, auxDist);
67 dist = colDist + auxDist;
68
69 return has_col;
70}
71
72} // namespace Field
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88
f32 normalise()
Normalizes the vector and returns the original length.
Definition Vector.cc:52