Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
MapdataCheckPoint.hh
1
#pragma once
2
3
#include "game/system/map/MapdataAccessorBase.hh"
4
5
#include <egg/math/Vector.hh>
6
7
namespace
Kinoko::System
{
8
9
class
MapdataCheckPoint
;
10
class
MapdataCheckPointAccessor
;
11
12
struct
LinkedCheckpoint
{
13
MapdataCheckPoint
*checkpoint;
14
EGG::Vector2f
p0diff;
15
EGG::Vector2f
p1diff;
16
f32 distance;
17
};
18
19
class
MapdataCheckPoint {
20
public
:
21
struct
SData
{
22
EGG::Vector2f
left;
23
EGG::Vector2f
right;
24
s8 jugemIndex;
25
s8 checkArea;
26
u8 prevPt;
27
u8 nextPt;
28
};
29
STATIC_ASSERT(
sizeof
(
SData
) == 0x14);
30
31
enum class
SectorOccupancy
{
32
InsideSector
,
33
OutsideSector
,
34
BetweenSides
,
36
};
37
38
MapdataCheckPoint
(
const
SData *data);
39
void
read(
EGG::Stream
&stream);
40
void
initCheckpointLinks
(
MapdataCheckPointAccessor
&accessor,
int
id
);
41
[[nodiscard]]
SectorOccupancy
checkSectorAndDistanceRatio(
const
EGG::Vector3f
&pos,
42
f32 &distanceRatio)
const
;
43
44
[[nodiscard]] u16
getEntryOffsetMs
(
const
EGG::Vector2f
&prevPos,
45
const
EGG::Vector2f
&pos)
const
;
46
[[nodiscard]] f32
getEntryOffsetExact
(
const
EGG::Vector2f
&prevPos,
47
const
EGG::Vector2f
&pos)
const
;
48
49
[[nodiscard]]
bool
isNormalCheckpoint()
const
{
50
return
static_cast<
CheckArea
>
(
m_checkArea
) ==
CheckArea::NormalCheckpoint
;
51
}
52
53
[[nodiscard]]
bool
isFinishLine()
const
{
54
return
static_cast<
CheckArea
>
(
m_checkArea
) ==
CheckArea::FinishLine
;
55
}
56
58
void
setSearched() {
59
m_searched =
true
;
60
}
61
62
void
clearSearched() {
63
m_searched =
false
;
64
}
66
68
[[nodiscard]]
bool
searched()
const
{
69
return
m_searched;
70
}
71
72
[[nodiscard]] s8 jugemIndex()
const
{
73
return
m_jugemIndex
;
74
}
75
76
[[nodiscard]] s8 checkArea()
const
{
77
return
m_checkArea
;
78
}
79
80
[[nodiscard]] u16 nextCount()
const
{
81
return
m_nextCount;
82
}
83
84
[[nodiscard]] u16 prevCount()
const
{
85
return
m_prevCount;
86
}
87
88
[[nodiscard]]
const
EGG::Vector2f &dir()
const
{
89
return
m_dir;
90
}
91
92
[[nodiscard]] u16 id()
const
{
93
return
m_id;
94
}
95
96
[[nodiscard]] MapdataCheckPoint *prevPoint(
size_t
i)
const
{
97
ASSERT(i < m_prevPoints.size());
98
return
m_prevPoints[i];
99
}
100
101
[[nodiscard]] MapdataCheckPoint *nextPoint(
size_t
i)
const
{
102
ASSERT(i < m_nextPoints.size());
103
return
m_nextPoints[i].checkpoint;
104
}
106
107
enum class
CheckArea
{
108
NormalCheckpoint
= -1,
109
FinishLine
= 0,
110
};
111
112
private
:
113
[[nodiscard]]
SectorOccupancy
checkSectorAndDistanceRatio(
const
LinkedCheckpoint
&next,
114
const
EGG::Vector2f
&p0,
const
EGG::Vector2f
&p1, f32 &distanceRatio)
const
;
115
[[nodiscard]]
bool
checkSector
(
const
LinkedCheckpoint
&next,
const
EGG::Vector2f
&p0,
116
const
EGG::Vector2f
&p1)
const
;
117
[[nodiscard]]
bool
checkDistanceRatio
(
const
LinkedCheckpoint
&next,
const
EGG::Vector2f
&p0,
118
const
EGG::Vector2f
&p1, f32 &distanceRatio)
const
;
119
120
static
constexpr
size_t
MAX_NEIGHBORS = 6;
121
122
[[maybe_unused]]
const
SData *m_rawData;
123
EGG::Vector2f
m_left;
124
EGG::Vector2f
m_right;
125
s8
m_jugemIndex
;
133
s8
m_checkArea
;
134
u8 m_prevPt;
135
u8 m_nextPt;
136
u16 m_nextCount;
137
u16 m_prevCount;
138
EGG::Vector2f
m_midpoint;
139
EGG::Vector2f
m_dir;
140
bool
m_searched;
141
u16 m_id;
142
std::array<MapdataCheckPoint *, MAX_NEIGHBORS> m_prevPoints;
143
std::array<LinkedCheckpoint, MAX_NEIGHBORS> m_nextPoints;
144
};
145
146
class
MapdataCheckPointAccessor
147
:
public
MapdataAccessorBase<MapdataCheckPoint, MapdataCheckPoint::SData> {
148
public
:
149
MapdataCheckPointAccessor(
const
MapSectionHeader
*header);
150
~MapdataCheckPointAccessor()
override
;
151
152
[[nodiscard]] s8 lastKcpType()
const
{
153
return
m_lastKcpType;
154
}
155
156
private
:
157
void
init
();
158
159
s8 m_lastKcpType;
160
u16 m_finishLineCheckpointId;
161
};
162
163
}
// namespace Kinoko::System
Kinoko::EGG::Stream
A stream of data, abstracted to allow for continuous seeking.
Definition
Stream.hh:8
Kinoko::System::MapdataCheckPointAccessor
Definition
MapdataCheckPoint.hh:147
Kinoko::System::MapdataCheckPointAccessor::init
void init()
Initializes all checkpoint links, and finds the finish line and last key checkpoint.
Definition
MapdataCheckPoint.cc:224
Kinoko::System::MapdataCheckPoint
Definition
MapdataCheckPoint.hh:19
Kinoko::System::MapdataCheckPoint::initCheckpointLinks
void initCheckpointLinks(MapdataCheckPointAccessor &accessor, int id)
Calculates m_nextPoints and m_prevPoints from m_nextPt and m_prevPt.
Definition
MapdataCheckPoint.cc:33
Kinoko::System::MapdataCheckPoint::m_jugemIndex
s8 m_jugemIndex
Definition
MapdataCheckPoint.hh:125
Kinoko::System::MapdataCheckPoint::checkDistanceRatio
bool checkDistanceRatio(const LinkedCheckpoint &next, const EGG::Vector2f &p0, const EGG::Vector2f &p1, f32 &distanceRatio) const
Sets the distance ratio, which is the progress of traversal through the checkpoint quad.
Definition
MapdataCheckPoint.cc:204
Kinoko::System::MapdataCheckPoint::SectorOccupancy
SectorOccupancy
Definition
MapdataCheckPoint.hh:31
Kinoko::System::MapdataCheckPoint::SectorOccupancy::BetweenSides
@ BetweenSides
Definition
MapdataCheckPoint.hh:34
Kinoko::System::MapdataCheckPoint::SectorOccupancy::OutsideSector
@ OutsideSector
Player is outside the given checkpoint group.
Definition
MapdataCheckPoint.hh:33
Kinoko::System::MapdataCheckPoint::SectorOccupancy::InsideSector
@ InsideSector
Player is inside the given checkpoint group.
Definition
MapdataCheckPoint.hh:32
Kinoko::System::MapdataCheckPoint::checkSector
bool checkSector(const LinkedCheckpoint &next, const EGG::Vector2f &p0, const EGG::Vector2f &p1) const
Definition
MapdataCheckPoint.cc:187
Kinoko::System::MapdataCheckPoint::CheckArea
CheckArea
Definition
MapdataCheckPoint.hh:107
Kinoko::System::MapdataCheckPoint::CheckArea::FinishLine
@ FinishLine
Triggers a lap change.
Definition
MapdataCheckPoint.hh:109
Kinoko::System::MapdataCheckPoint::CheckArea::NormalCheckpoint
@ NormalCheckpoint
Only used for picking respawn position.
Definition
MapdataCheckPoint.hh:108
Kinoko::System::MapdataCheckPoint::getEntryOffsetMs
u16 getEntryOffsetMs(const EGG::Vector2f &prevPos, const EGG::Vector2f &pos) const
Finds the offset between the two positions that enter the checkpoint.
Definition
MapdataCheckPoint.cc:129
Kinoko::System::MapdataCheckPoint::m_checkArea
s8 m_checkArea
Definition
MapdataCheckPoint.hh:133
Kinoko::System::MapdataCheckPoint::getEntryOffsetExact
f32 getEntryOffsetExact(const EGG::Vector2f &prevPos, const EGG::Vector2f &pos) const
Finds the offset between the two positions that enter the checkpoint.
Definition
MapdataCheckPoint.cc:155
Kinoko::System
High-level handling for generic system operations, such as input reading, race configuration,...
Definition
CourseMap.cc:5
Kinoko::EGG::Vector2f
A 2D float vector.
Definition
Vector.hh:12
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:107
Kinoko::System::LinkedCheckpoint
Definition
MapdataCheckPoint.hh:12
Kinoko::System::MapSectionHeader
Definition
MapdataAccessorBase.hh:9
Kinoko::System::MapdataCheckPoint::SData
Definition
MapdataCheckPoint.hh:21
game
system
map
MapdataCheckPoint.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0