Kinoko
v0.6
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
KTestSystem.hh
Go to the documentation of this file.
1
#pragma once
2
3
#include "
host/KSystem.hh
"
4
#include "
host/Option.hh
"
5
6
#include <
egg/core/Allocator.hh
>
7
#include <
egg/core/SceneManager.hh
>
8
#include <
egg/math/Quat.hh
>
9
10
#include <
game/system/RaceConfig.hh
>
11
12
#include <queue>
13
14
namespace
Kinoko
{
15
17
class
KTestSystem
final :
public
KSystem
{
18
public
:
19
void
init
()
override
;
20
void
calc
()
override
;
21
bool
run
()
override
;
22
void
parseOptions
(
int
argc,
char
**argv)
override
;
23
24
static
KTestSystem
*
CreateInstance
();
25
static
void
DestroyInstance
();
26
27
static
KTestSystem
*
Instance
() {
28
return
static_cast<
KTestSystem
*
>
(
s_instance
);
29
}
30
31
private
:
32
struct
TestCase
{
33
std::string
name
;
34
std::string
rkgPath
;
35
std::string
krkgPath
;
36
u16
targetFrame
;
37
};
38
39
struct
TestData
{
40
EGG::Vector3f
pos
;
41
EGG::Quatf
fullRot
;
42
// Added in 0.2
43
EGG::Vector3f
extVel
;
44
// Added in 0.3
45
EGG::Vector3f
intVel
;
46
// Added in 0.4
47
f32
speed
;
48
f32
acceleration
;
49
f32
softSpeedLimit
;
50
// Added in 0.5
51
EGG::Quatf
mainRot
;
52
EGG::Vector3f
angVel2
;
53
// Added in 0.6
54
f32
raceCompletion
;
55
u16
checkpointId
;
56
u8
jugemId
;
57
};
58
59
EGG_NEW_DELETE_FRIEND
60
61
KTestSystem
();
62
~KTestSystem
()
override
;
63
64
KTestSystem
(
const
KTestSystem
&) =
delete
;
65
KTestSystem
(
KTestSystem
&&) =
delete
;
66
67
template
<IntegralType T>
68
void
checkDesync
(
const
T &t0,
const
T &t1,
const
char
*name) {
69
if
(t0 == t1) {
70
return
;
71
}
72
73
if
(
m_sync
) {
74
REPORT
(
"Test Case Failed: %s [%d / %d]"
,
getCurrentTestCase
().name.c_str(),
75
m_currentFrame
,
m_frameCount
);
76
}
77
78
REPORT
(
"DESYNC! Name: %s"
, name);
79
REPORT
(
"Expected: %d"
, t0);
80
REPORT
(
"Observed: %d"
, t1);
81
82
m_sync
=
false
;
83
}
84
85
template
<
typename
T>
86
void
checkDesync
(
const
T &t0,
const
T &t1,
const
char
*name) {
87
if
(t0 == t1) {
88
return
;
89
}
90
91
m_sceneMgr
->
currentScene
()->
heap
()->
enableAllocation
();
92
93
if
(
m_sync
) {
94
REPORT
(
"Test Case Failed: %s [%d / %d]"
,
getCurrentTestCase
().name.c_str(),
95
m_currentFrame
,
m_frameCount
);
96
}
97
98
REPORT
(
"DESYNC! Name: %s"
, name);
99
std::string s0(t0);
100
std::string s1(t1);
101
REPORT
(
"Expected: %s"
, s0.c_str());
102
REPORT
(
"Observed: %s"
, s1.c_str());
103
104
m_sceneMgr
->
currentScene
()->
heap
()->
disableAllocation
();
105
106
m_sync
=
false
;
107
}
108
109
void
checkDesync
(
const
f32
&t0,
const
f32
&t1,
const
char
*name) {
110
if
(t0 == t1) {
111
return
;
112
}
113
114
m_sceneMgr
->
currentScene
()->
heap
()->
enableAllocation
();
115
116
if
(
m_sync
) {
117
REPORT
(
"Test Case Failed: %s [%d / %d]"
,
getCurrentTestCase
().name.c_str(),
118
m_currentFrame
,
m_frameCount
);
119
}
120
121
REPORT
(
"DESYNC! Name: %s"
, name);
122
std::string s0 = std::to_string(t0);
123
std::string s1 = std::to_string(t1);
124
REPORT
(
"Expected: 0x%08X | %s"
, f2u(t0), s0.c_str());
125
REPORT
(
"Observed: 0x%08X | %s"
, f2u(t1), s1.c_str());
126
127
m_sceneMgr
->
currentScene
()->
heap
()->
disableAllocation
();
128
129
m_sync
=
false
;
130
}
131
132
void
initSuite
();
133
134
void
startNextTestCase
();
135
bool
popTestCase
();
136
137
bool
calcTest
();
138
TestData
findCurrentFrameEntry
();
139
void
testFrame
(
const
TestData &data);
140
141
bool
runTest
();
142
void
writeTestOutput
()
const
;
143
144
const
TestCase &
getCurrentTestCase
()
const
;
145
146
static
void
OnInit
(
System::RaceConfig
*config,
void
*arg);
147
148
EGG::SceneManager
*
m_sceneMgr
;
149
EGG::RamStream
m_stream
;
150
std::queue<TestCase, std::deque<TestCase, EGG::Allocator<TestCase>>>
m_testCases
;
151
Host::EOption
m_testMode
;
152
153
u16
m_versionMajor
;
154
u16
m_versionMinor
;
155
u16
m_frameCount
;
156
u16
m_currentFrame
;
157
bool
m_sync
;
158
};
159
160
}
// namespace Kinoko
Allocator.hh
EGG_NEW_DELETE_FRIEND
#define EGG_NEW_DELETE_FRIEND
Grants Kinoko::EGG::egg_new and Kinoko::EGG::egg_delete access to a class' private constructors/destr...
Definition
Heap.hh:186
KSystem.hh
REPORT
#define REPORT(m,...)
Definition
Logger.hh:38
Option.hh
Quat.hh
RaceConfig.hh
SceneManager.hh
Kinoko::EGG::Heap::disableAllocation
void disableAllocation()
Definition
Heap.hh:48
Kinoko::EGG::Heap::enableAllocation
void enableAllocation()
Definition
Heap.hh:52
Kinoko::EGG::RamStream
A stream of data stored in memory.
Definition
Stream.hh:81
Kinoko::EGG::SceneManager
Manages the scene stack and transitions between scenes.
Definition
SceneManager.hh:17
Kinoko::EGG::SceneManager::currentScene
Scene * currentScene() const
Definition
SceneManager.hh:59
Kinoko::EGG::Scene::heap
Heap * heap() const
Definition
Scene.hh:61
Kinoko::KSystem
Base interface for a Kinoko system.
Definition
KSystem.hh:10
Kinoko::KSystem::s_instance
static KSystem * s_instance
Definition
KSystem.hh:33
Kinoko::KTestSystem::initSuite
void initSuite()
Definition
KTestSystem.cc:52
Kinoko::KTestSystem::checkDesync
void checkDesync(const T &t0, const T &t1, const char *name)
Definition
KTestSystem.hh:68
Kinoko::KTestSystem::m_testMode
Host::EOption m_testMode
Differentiates between test suite and ghost+krkg.
Definition
KTestSystem.hh:151
Kinoko::KTestSystem::m_currentFrame
u16 m_currentFrame
Definition
KTestSystem.hh:156
Kinoko::KTestSystem::m_sync
bool m_sync
Definition
KTestSystem.hh:157
Kinoko::KTestSystem::CreateInstance
static KTestSystem * CreateInstance()
Definition
KTestSystem.cc:238
Kinoko::KTestSystem::run
bool run() override
Executes a run.
Definition
KTestSystem.cc:117
Kinoko::KTestSystem::parseOptions
void parseOptions(int argc, char **argv) override
Parses non-generic command line options.
Definition
KTestSystem.cc:140
Kinoko::KTestSystem::OnInit
static void OnInit(System::RaceConfig *config, void *arg)
Initializes the race configuration as needed for test cases.
Definition
KTestSystem.cc:468
Kinoko::KTestSystem::getCurrentTestCase
const TestCase & getCurrentTestCase() const
Gets the current test case.
Definition
KTestSystem.cc:460
Kinoko::KTestSystem::m_sceneMgr
EGG::SceneManager * m_sceneMgr
Definition
KTestSystem.hh:148
Kinoko::KTestSystem::m_frameCount
u16 m_frameCount
Definition
KTestSystem.hh:155
Kinoko::KTestSystem::startNextTestCase
void startNextTestCase()
Starts the next test case.
Definition
KTestSystem.cc:261
Kinoko::KTestSystem::m_stream
EGG::RamStream m_stream
Definition
KTestSystem.hh:149
Kinoko::KTestSystem::writeTestOutput
void writeTestOutput() const
Writes details about the current test to file.
Definition
KTestSystem.cc:449
Kinoko::KTestSystem::DestroyInstance
static void DestroyInstance()
Definition
KTestSystem.cc:244
Kinoko::KTestSystem::KTestSystem
KTestSystem(const KTestSystem &)=delete
Kinoko::KTestSystem::testFrame
void testFrame(const TestData &data)
Tests the frame against the provided test data.
Definition
KTestSystem.cc:388
Kinoko::KTestSystem::calc
void calc() override
Executes a frame.
Definition
KTestSystem.cc:110
Kinoko::KTestSystem::checkDesync
void checkDesync(const f32 &t0, const f32 &t1, const char *name)
Definition
KTestSystem.hh:109
Kinoko::KTestSystem::findCurrentFrameEntry
TestData findCurrentFrameEntry()
Finds the test data of the current frame.
Definition
KTestSystem.cc:327
Kinoko::KTestSystem::m_testCases
std::queue< TestCase, std::deque< TestCase, EGG::Allocator< TestCase > > > m_testCases
Definition
KTestSystem.hh:150
Kinoko::KTestSystem::runTest
bool runTest()
Runs a single test case, and ends when the test is finished or when a desync is found.
Definition
KTestSystem.cc:435
Kinoko::KTestSystem::m_versionMajor
u16 m_versionMajor
Definition
KTestSystem.hh:153
Kinoko::KTestSystem::init
void init() override
Initializes the system.
Definition
KTestSystem.cc:35
Kinoko::KTestSystem::popTestCase
bool popTestCase()
Pops the current test case and frees the KRKG buffer.
Definition
KTestSystem.cc:298
Kinoko::KTestSystem::Instance
static KTestSystem * Instance()
Definition
KTestSystem.hh:27
Kinoko::KTestSystem::KTestSystem
KTestSystem()
Definition
KTestSystem.cc:251
Kinoko::KTestSystem::calcTest
bool calcTest()
Checks one frame in the test.
Definition
KTestSystem.cc:308
Kinoko::KTestSystem::KTestSystem
KTestSystem(KTestSystem &&)=delete
Kinoko::KTestSystem::m_versionMinor
u16 m_versionMinor
Definition
KTestSystem.hh:154
Kinoko::System::RaceConfig
Initializes the player with parameters specified in the provided ghost file.
Definition
RaceConfig.hh:23
Kinoko::Host::EOption
EOption
Definition
Option.hh:9
Kinoko
Definition
abstract/Archive.cc:5
Kinoko::f32
float f32
Definition
Memory.hh:21
Kinoko::u8
uint8_t u8
Definition
Memory.hh:16
Kinoko::u16
uint16_t u16
Definition
Memory.hh:17
Kinoko::EGG::Quatf
A quaternion, used to represent 3D rotation.
Definition
Quat.hh:12
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:108
Kinoko::KTestSystem::TestCase
Definition
KTestSystem.hh:32
Kinoko::KTestSystem::TestCase::krkgPath
std::string krkgPath
Definition
KTestSystem.hh:35
Kinoko::KTestSystem::TestCase::targetFrame
u16 targetFrame
Definition
KTestSystem.hh:36
Kinoko::KTestSystem::TestCase::name
std::string name
Definition
KTestSystem.hh:33
Kinoko::KTestSystem::TestCase::rkgPath
std::string rkgPath
Definition
KTestSystem.hh:34
Kinoko::KTestSystem::TestData
Definition
KTestSystem.hh:39
Kinoko::KTestSystem::TestData::softSpeedLimit
f32 softSpeedLimit
Definition
KTestSystem.hh:49
Kinoko::KTestSystem::TestData::angVel2
EGG::Vector3f angVel2
Definition
KTestSystem.hh:52
Kinoko::KTestSystem::TestData::pos
EGG::Vector3f pos
Definition
KTestSystem.hh:40
Kinoko::KTestSystem::TestData::acceleration
f32 acceleration
Definition
KTestSystem.hh:48
Kinoko::KTestSystem::TestData::speed
f32 speed
Definition
KTestSystem.hh:47
Kinoko::KTestSystem::TestData::extVel
EGG::Vector3f extVel
Definition
KTestSystem.hh:43
Kinoko::KTestSystem::TestData::raceCompletion
f32 raceCompletion
Definition
KTestSystem.hh:54
Kinoko::KTestSystem::TestData::fullRot
EGG::Quatf fullRot
Definition
KTestSystem.hh:41
Kinoko::KTestSystem::TestData::intVel
EGG::Vector3f intVel
Definition
KTestSystem.hh:45
Kinoko::KTestSystem::TestData::checkpointId
u16 checkpointId
Definition
KTestSystem.hh:55
Kinoko::KTestSystem::TestData::jugemId
u8 jugemId
Definition
KTestSystem.hh:56
Kinoko::KTestSystem::TestData::mainRot
EGG::Quatf mainRot
Definition
KTestSystem.hh:51
host
KTestSystem.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.18.0