Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
MapdataArea.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
MapdataPointInfo
;
10
11
class
MapdataAreaBase {
12
public
:
13
struct
SData
{
14
s8 shape;
15
s8 type;
16
u8 _02[0x03 - 0x02];
17
u8 priority;
18
EGG::Vector3f
position;
19
EGG::Vector3f
rotation;
20
EGG::Vector3f
scale;
21
s16 parameters[2];
22
// Pre Revision 2200: End of structure
23
s8 railId;
24
u8 _2d[0x30 - 0x2d];
25
};
26
27
enum class
Shape {
28
Box = 0,
29
Cylinder = 1,
30
};
31
32
enum class
Type {
33
MovingRoad = 3,
34
};
35
36
MapdataAreaBase(
const
SData *data, s16 index);
37
~MapdataAreaBase() =
default
;
38
void
read(
EGG::Stream
&stream);
39
40
virtual
bool
testImpl(
const
EGG::Vector3f
&pos)
const
= 0;
41
43
[[nodiscard]]
bool
test(
const
EGG::Vector3f
&pos)
const
{
44
return
(m_position - pos).squaredLength() >
m_sqBoundingSphereRadius
? false :
45
testImpl(pos);
46
}
47
48
[[nodiscard]] MapdataPointInfo *getPointInfo()
const
;
49
50
[[nodiscard]] Type type()
const
{
51
return
m_type;
52
}
53
54
[[nodiscard]] u8 priority()
const
{
55
return
m_priority;
56
}
57
58
[[nodiscard]] s16 param(
size_t
i)
const
{
59
ASSERT(i < m_params.size());
60
return
m_params[i];
61
}
62
63
[[nodiscard]] s16 index()
const
{
64
return
m_index;
65
}
66
67
protected
:
68
const
SData
*m_rawData;
69
Type m_type;
70
u8 m_priority;
71
EGG::Vector3f m_position;
72
EGG::Vector3f m_rotation;
73
EGG::Vector3f m_scale;
74
std::array<s16, 2> m_params;
75
s8 m_railId;
76
77
EGG::Vector3f m_right;
78
EGG::Vector3f m_up;
79
EGG::Vector3f m_forward;
80
EGG::Vector3f m_dimensions;
81
f32 m_ellipseRadiusSq;
82
f32 m_ellipseAspectRatio;
83
f32
m_sqBoundingSphereRadius
;
84
s16 m_index;
85
};
86
87
class
MapdataAreaBox :
public
MapdataAreaBase {
88
public
:
89
MapdataAreaBox(
const
SData
*data, s16 index);
90
~MapdataAreaBox() =
default
;
91
92
[[nodiscard]]
bool
testImpl(
const
EGG::Vector3f
&pos)
const override
;
93
};
94
95
class
MapdataAreaCylinder :
public
MapdataAreaBase {
96
public
:
97
MapdataAreaCylinder(
const
SData
*data, s16 index);
98
~MapdataAreaCylinder() =
default
;
99
100
[[nodiscard]]
bool
testImpl(
const
EGG::Vector3f
&pos)
const override
;
101
};
102
103
class
MapdataAreaAccessor :
public
MapdataAccessorBase<MapdataAreaBase, MapdataAreaBase::SData> {
104
public
:
105
MapdataAreaAccessor(
const
MapSectionHeader
*header);
106
~MapdataAreaAccessor()
override
;
107
108
void
init(
const
MapdataAreaBase::SData
*start, u16 count);
109
void
sort();
110
111
[[nodiscard]]
MapdataAreaBase
*getSorted(u16 i)
const
{
112
ASSERT(!m_sortedEntries.empty());
113
return
i < m_entryCount ? m_sortedEntries[i] :
nullptr
;
114
}
115
116
private
:
117
owning_span<MapdataAreaBase *>
m_sortedEntries;
118
};
119
120
}
// namespace Kinoko::System
Kinoko::EGG::Stream
A stream of data, abstracted to allow for continuous seeking.
Definition
Stream.hh:8
Kinoko::System::MapdataAreaBase
Definition
MapdataArea.hh:11
Kinoko::System::MapdataAreaBase::m_sqBoundingSphereRadius
f32 m_sqBoundingSphereRadius
Used to phase out intersection tests early.
Definition
MapdataArea.hh:83
Kinoko::System::MapdataPointInfo
Definition
MapdataPointInfo.hh:12
Kinoko::owning_span
A contiguous storage container that manages the lifecycle of a buffer of a given size.
Definition
Types.hh:31
Kinoko::System
High-level handling for generic system operations, such as input reading, race configuration,...
Definition
CourseMap.cc:5
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:107
Kinoko::System::MapSectionHeader
Definition
MapdataAccessorBase.hh:9
Kinoko::System::MapdataAreaBase::SData
Definition
MapdataArea.hh:13
game
system
map
MapdataArea.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0