Implement RaceSkel, add BETA10 annotations (#1088)

* Implement `RaceSkel`, add BETA10 annotations

* fix formatting

* Fix order

* Address some review comments

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
This commit is contained in:
jonschz
2024-08-21 22:30:27 +02:00
committed by GitHub
parent b649902578
commit 1b46859cf6
15 changed files with 104 additions and 18 deletions

View File

@@ -184,6 +184,7 @@ LegoObjectFactory::LegoObjectFactory()
}
// FUNCTION: LEGO1 0x10009a90
// FUNCTION: BETA10 0x100a1021
MxCore* LegoObjectFactory::Create(const char* p_name)
{
MxCore* object = NULL;
@@ -491,6 +492,10 @@ MxCore* LegoObjectFactory::Create(const char* p_name)
object = MxObjectFactory::Create(p_name);
}
// clang-format off
assert(object!=NULL);
// clang-format on
return object;
}

View File

@@ -541,6 +541,7 @@ void LegoWorld::Remove(MxCore* p_object)
}
// FUNCTION: LEGO1 0x100213a0
// FUNCTION: BETA10 0x100db027
MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
{
if (!strcmp(p_class, "MxControlPresenter")) {

View File

@@ -37,6 +37,7 @@ float LegoAnimActorStruct::GetDuration()
}
// FUNCTION: LEGO1 0x1001c140
// FUNCTION: BETA10 0x1003dfe4
LegoAnimActor::~LegoAnimActor()
{
for (MxS32 i = 0; i < m_animMaps.size(); i++) {
@@ -89,9 +90,12 @@ void LegoAnimActor::VTable0x70(float p_float)
}
// FUNCTION: LEGO1 0x1001c360
// FUNCTION: BETA10 0x1003e2d3
MxResult LegoAnimActor::FUN_1001c360(float p_und, Matrix4& p_transform)
{
if (p_und >= 0) {
assert((m_curAnim >= 0) && (m_curAnim < m_animMaps.size()));
LegoROI** roiMap = m_animMaps[m_curAnim]->m_roiMap;
MxU32 numROIs = m_animMaps[m_curAnim]->m_numROIs;
@@ -108,7 +112,11 @@ MxResult LegoAnimActor::FUN_1001c360(float p_und, Matrix4& p_transform)
}
}
else {
LegoTreeNode* root = m_animMaps[m_curAnim]->m_AnimTreePtr->GetRoot();
// name verified by BETA10 0x1003e407
LegoTreeNode* n = m_animMaps[m_curAnim]->m_AnimTreePtr->GetRoot();
assert(roiMap && n && m_roi && m_boundary);
m_roi->SetVisibility(TRUE);
for (MxU32 i = 0; i < numROIs; i++) {
@@ -119,8 +127,8 @@ MxResult LegoAnimActor::FUN_1001c360(float p_und, Matrix4& p_transform)
}
}
for (MxS32 j = 0; j < root->GetNumChildren(); j++) {
LegoROI::FUN_100a8e80(root->GetChild(j), p_transform, p_und, roiMap);
for (MxS32 j = 0; j < n->GetNumChildren(); j++) {
LegoROI::FUN_100a8e80(n->GetChild(j), p_transform, p_und, roiMap);
}
if (m_cameraFlag) {
@@ -192,6 +200,7 @@ void LegoAnimActor::SetWorldSpeed(MxFloat p_worldSpeed)
}
// FUNCTION: LEGO1 0x1001c920
// FUNCTION: BETA10 0x1003e914
void LegoAnimActor::ParseAction(char* p_extra)
{
LegoPathActor::ParseAction(p_extra);
@@ -201,17 +210,20 @@ void LegoAnimActor::ParseAction(char* p_extra)
if (world) {
if (KeyValueStringParse(value, g_strANIMATION, p_extra)) {
// name verified by BETA10 0x1003ea46
char* token = strtok(value, g_parseExtraTokens);
while (token) {
LegoLocomotionAnimPresenter* presenter =
(LegoLocomotionAnimPresenter*) world->Find("LegoAnimPresenter", token);
// name verified by BETA10 0x1003e9f5
LegoLocomotionAnimPresenter* p = (LegoLocomotionAnimPresenter*) world->Find("LegoAnimPresenter", token);
if (presenter != NULL) {
assert(p);
if (p != NULL) {
token = strtok(NULL, g_parseExtraTokens);
if (token) {
presenter->FUN_1006d680(this, atof(token));
p->FUN_1006d680(this, atof(token));
}
}

View File

@@ -7,7 +7,7 @@ DECOMP_SIZE_ASSERT(CarRace, 0x154)
// FUNCTION: LEGO1 0x10016a90
CarRace::CarRace()
{
this->m_unk0x150 = 0;
this->m_skeleton = NULL;
this->m_unk0x130 = MxRect32(0x16c, 0x154, 0x1ec, 0x15e);
}

View File

@@ -304,11 +304,10 @@ MxU32 LegoRaceCar::HandleSkeletonKicks(float p_param1)
{
const SkeletonKickPhase* current = g_skeletonKickPhases;
// TODO: Type is guesswork so far
CarRace* r = (CarRace*) CurrentWorld(); // called `r` in BETA10
assert(r);
RaceSkel* s = (RaceSkel*) r->GetUnk0x150(); // called `s` in BETA10
RaceSkel* s = r->GetSkeleton(); // called `s` in BETA10
assert(s);
float skeletonCurAnimPosition;

View File

@@ -1,13 +1,53 @@
#include "raceskel.h"
#include "carrace.h"
#include "legoworld.h"
#include "misc.h"
#include <assert.h>
DECOMP_SIZE_ASSERT(RaceSkel, 0x178)
// STUB: LEGO1 0x100719b0
// FUNCTION: LEGO1 0x100719b0
// FUNCTION: BETA10 0x100f1240
RaceSkel::RaceSkel()
{
// TODO
m_animPosition = 0.0f;
}
// FUNCTION: LEGO1 0x10071ad0
RaceSkel::~RaceSkel()
{
}
// FUNCTION: LEGO1 0x10071b50
// FUNCTION: BETA10 0x100f13cf
MxResult RaceSkel::FUN_1001c360(float p_und, Matrix4& p_transform)
{
p_transform[3][0] = -630.0f;
p_transform[3][1] = -4.688f;
p_transform[3][2] = 323.0f;
m_animPosition = p_und;
return LegoAnimActor::FUN_1001c360(p_und, p_transform);
}
// FUNCTION: LEGO1 0x10071b90
// FUNCTION: BETA10 0x100f1444
void RaceSkel::ParseAction(char* p_extra)
{
LegoAnimActor::ParseAction(p_extra);
// name verified by BETA10 0x100f147d
CarRace* w = (CarRace*) CurrentWorld();
assert(w);
w->SetSkeleton(this);
assert(m_roi);
BoundingSphere sphere = m_roi->GetBoundingSphere();
sphere.Radius() *= 100.0f;
m_roi->SetBoundingSphere(sphere);
}
// FUNCTION: LEGO1 0x10071cb0