-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
219 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <egg/math/Quat.hh> | ||
|
||
namespace Test { | ||
|
||
struct TestHeader { | ||
u32 signature; | ||
u16 byteOrderMark; | ||
u16 frameCount; | ||
u16 versionMajor; | ||
u16 versionMinor; | ||
u32 dataOffset; | ||
}; | ||
|
||
struct TestData { | ||
EGG::Vector3f pos; | ||
EGG::Quatf fullRot; | ||
}; | ||
|
||
} // namespace Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "TestDirector.hh" | ||
|
||
#include <game/kart/KartObjectManager.hh> | ||
|
||
#include <abstract/File.hh> | ||
|
||
#include <cstddef> | ||
|
||
namespace Test { | ||
|
||
TestDirector::TestDirector() { | ||
size_t size; | ||
u8 *file = Abstract::File::Load("Test/rmc3-rta-1-17-843.krkg", size); | ||
m_file = file; | ||
m_stream = EGG::RamStream(file, static_cast<u32>(size)); | ||
m_currentFrame = -1; | ||
m_sync = true; | ||
|
||
// Initialize endianness for the RAM stream | ||
u16 mark = *reinterpret_cast<u16 *>(file + offsetof(TestHeader, byteOrderMark)); | ||
std::endian endian = parse<u16>(mark) == 0xfeff ? std::endian::big : std::endian::little; | ||
m_stream.setEndian(endian); | ||
|
||
readHeader(); | ||
} | ||
|
||
TestDirector::~TestDirector() = default; | ||
|
||
bool TestDirector::init() { | ||
assert(m_stream.read_u32() == m_stream.index()); | ||
return calc(); | ||
} | ||
|
||
bool TestDirector::calc() { | ||
// Check if we're out of frames | ||
constexpr u16 TARGET_FRAME = 1; | ||
assert(TARGET_FRAME <= m_frameCount); | ||
if (++m_currentFrame > TARGET_FRAME) { | ||
return false; | ||
} | ||
|
||
// Test the current frame | ||
TestData data = findNextEntry(); | ||
m_sync = test(data); | ||
return m_sync; | ||
} | ||
|
||
bool TestDirector::test(const TestData &data) { | ||
auto logVectorDesync = [this](const EGG::Vector3f &v0, const EGG::Vector3f v1, | ||
const char *name) { | ||
K_LOG("DESYNC! Frame: %d; Name: %s", m_currentFrame, name); | ||
K_LOG("Expected [%f, %f, %f], got [%f, %f, %f]", v0.x, v0.y, v0.z, v1.x, v1.y, v1.z); | ||
}; | ||
|
||
auto logQuatDesync = [this](const EGG::Quatf &q0, const EGG::Quatf q1, const char *name) { | ||
K_LOG("DESYNC! Frame: %d; Name: %s", m_currentFrame, name); | ||
K_LOG("Expected [%f, %f, %f, %f], got [%f, %f, %f, %f]", q0.v.x, q0.v.y, q0.v.z, q0.w, | ||
q1.v.x, q1.v.y, q1.v.z, q1.w); | ||
}; | ||
|
||
auto *object = Kart::KartObjectManager::Instance()->object(0); | ||
const auto &pos = object->pos(); | ||
const auto &fullRot = object->fullRot(); | ||
|
||
if (data.pos != pos) { | ||
logVectorDesync(data.pos, pos, "pos"); | ||
return false; | ||
} | ||
if (data.fullRot != fullRot) { | ||
logQuatDesync(data.fullRot, fullRot, "fullRot"); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
TestData TestDirector::findNextEntry() { | ||
EGG::Vector3f pos; | ||
EGG::Quatf fullRot; | ||
pos.read(m_stream); | ||
fullRot.read(m_stream); | ||
|
||
TestData data; | ||
data.pos = pos; | ||
data.fullRot = fullRot; | ||
return data; | ||
} | ||
|
||
bool TestDirector::sync() const { | ||
return m_sync; | ||
} | ||
|
||
void TestDirector::readHeader() { | ||
assert(m_stream.read_u32() == 0x4b524b47); // 'KRKG' | ||
m_stream.skip(2); | ||
m_frameCount = m_stream.read_u16(); | ||
m_versionMajor = m_stream.read_u16(); | ||
m_versionMinor = m_stream.read_u16(); | ||
} | ||
|
||
} // namespace Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include "test/Test.hh" | ||
|
||
#include <egg/util/Stream.hh> | ||
|
||
namespace Test { | ||
|
||
class TestDirector { | ||
public: | ||
TestDirector(); | ||
~TestDirector(); | ||
|
||
bool init(); | ||
bool calc(); | ||
bool test(const TestData &data); | ||
|
||
TestData findNextEntry(); | ||
|
||
bool sync() const; | ||
|
||
private: | ||
void readHeader(); | ||
|
||
void *m_file; | ||
EGG::RamStream m_stream; | ||
|
||
u16 m_versionMajor; | ||
u16 m_versionMinor; | ||
u16 m_frameCount; | ||
u16 m_currentFrame; | ||
bool m_sync; | ||
}; | ||
|
||
} // namespace Test |