A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KartPullPath.hh
1#pragma once
2
3#include "game/kart/KartObjectProxy.hh"
4
5#include "game/system/map/MapdataPointInfo.hh"
6
7namespace Kart {
8
9class KartPullPath;
10
14public:
15 enum class Type {
16 Global,
17 Regional,
18 };
19
20 KartPullPathTracker(KartPullPath *handle, Type type);
22
23 void calc();
24
25 void setCurrentIdx(s16 idx) {
26 m_currentIdx = idx;
27 }
28
29 void setPointInfo(System::MapdataPointInfo *info) {
30 m_pointInfo = info;
31 m_currentIdx = 0;
32 }
33
34private:
35 enum class SearchDirection {
36 Current,
37 Next,
38 Previous,
39 };
40
41 void calcTrackerGlobal();
42 void calcTrackerRegional();
43
44 [[nodiscard]] f32 getDistance(const EGG::Vector3f &point, const EGG::Vector3f &dir) const;
45 bool search(SearchDirection searchDirection, s16 &idx, EGG::Vector3f &point,
46 EGG::Vector3f &dir) const;
47
48 Type m_type;
49 s16 m_currentIdx;
50 System::MapdataPointInfo *m_pointInfo;
51 KartPullPath *m_handle;
52};
53
57public:
60
61 void init();
62 void reset();
63 void calc();
64 void changePoint(s16 idx, f32 distance);
65
67 void resetDistance() {
68 m_distance = -1.0f;
69 }
70
71 [[nodiscard]] s16 incomingIdx() const {
72 return m_incomingIdx;
73 }
74
75 [[nodiscard]] const EGG::Vector3f &pullDirection() const {
76 return m_pullDirection;
77 }
78
79 [[nodiscard]] f32 pullSpeed() const {
80 return m_pullSpeed;
81 }
82
83 [[nodiscard]] f32 maxPullSpeed() const {
84 return m_maxPullSpeed;
85 }
86
87 [[nodiscard]] f32 roadSpeedDecay() const {
88 return m_roadSpeedDecay;
89 }
90
91private:
92 bool calcArea();
93 void calcPointChange();
94 void calcTrackers();
95 [[nodiscard]] EGG::Vector3f getPullUnitNormal() const;
96 void setTrackerPointInfo(System::MapdataPointInfo *info);
97
98 f32 m_distance;
99 System::MapdataPointInfo *m_pointInfo;
100 s16 m_incomingIdx;
101 s16 m_currentIdx;
102 EGG::Vector3f m_pullDirection;
103 f32 m_pullSpeed;
104 f32 m_maxPullSpeed;
105 KartPullPathTracker m_globalTracker;
106 KartPullPathTracker m_regionalTracker;
107 f32 m_roadSpeedDecay;
108 s16 m_areaId;
109};
110
111} // namespace Kart
Base class for most kart-related objects.
Tracks the kart's progress along the pull path.
Type m_type
Replaces inheritance for calc.
f32 getDistance(const EGG::Vector3f &point, const EGG::Vector3f &dir) const
Gets the distance from the line formed by the point and direction.
Manages areas pulling the kart along a given path.
EGG::Vector3f getPullUnitNormal() const
Pertains to kart-related functionality.
A 3D float vector.
Definition Vector.hh:88