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() = default;
10
12void ObjectShip64::init() {
13 m_railInterpolator->init(0, 0);
14
15 m_tangent = m_railInterpolator->curTangentDir();
16 m_railInterpolator->setPerPointVelocities(true);
17
18 calc();
19 calcModel();
20}
21
23void ObjectShip64::calc() {
24 m_railInterpolator->calc();
25
26 setPos(m_railInterpolator->curPos());
27
28 m_tangent = Interpolate(0.2f, m_tangent, m_railInterpolator->curTangentDir());
29 m_tangent.normalise();
30
31 setMatrixFromOrthonormalBasisAndPos(m_tangent);
32}
33
35void ObjectShip64::createCollision() {
36 constexpr f32 RADIUS = 1500.0f;
37 constexpr f32 HEIGHT = 3500.0f;
38
39 ObjectCollidable::createCollision();
40 m_auxCollision = new ObjectCollisionCylinder(RADIUS, HEIGHT, EGG::Vector3f::zero);
41}
42
44void ObjectShip64::calcCollisionTransform() {
45 ObjectCollidable::calcCollisionTransform();
46 calcTransform();
47
49 v = m_transform.base(0);
50 v.normalise();
51
52 m_transform.setAxisRotation(F_PI / 2.0f, v);
53
54 m_transform.setBase(3, v);
55
56 m_auxCollision->transform(m_transform, m_scale);
57}
58
60bool ObjectShip64::checkCollision(ObjectCollisionBase *lhs, EGG::Vector3f &dist) {
61 EGG::Vector3f colDist = EGG::Vector3f::zero;
62 EGG::Vector3f auxDist = EGG::Vector3f::zero;
63
64 bool has_col = lhs->check(*m_collision, colDist) || lhs->check(*m_auxCollision, auxDist);
65 dist = colDist + auxDist;
66
67 return has_col;
68}
69
70} // 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