Skip to content

Commit

Permalink
Match LegoPathActor::VTable0x8c (#1303)
Browse files Browse the repository at this point in the history
* Match `LegoPathActor::VTable0x8c`

* Fix
  • Loading branch information
foxtacles authored Dec 29, 2024
1 parent d97ce96 commit 795d6e1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions LEGO1/lego/legoomni/include/legopathactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class LegoPathActor : public LegoActor {
float p_srcScale,
LegoUnknown100db7f4& p_destEdge,
float p_destScale
); // vtable+0x88
virtual MxS32 VTable0x8c(float p_time, Matrix4& p_transform); // vtable+0x8c
); // vtable+0x88
virtual MxS32 VTable0x8c(float p_time, MxMatrix& p_transform); // vtable+0x8c

// FUNCTION: LEGO1 0x10002d40
virtual MxU32 VTable0x90(float, Matrix4&) { return FALSE; } // vtable+0x90
Expand Down
44 changes: 30 additions & 14 deletions LEGO1/lego/legoomni/src/paths/legopathactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mxutilities.h"
#include "mxvariabletable.h"

#include <mxdebug.h>
#include <vec.h>

DECOMP_SIZE_ASSERT(LegoPathActor, 0x154)
Expand Down Expand Up @@ -233,7 +234,7 @@ MxResult LegoPathActor::VTable0x84(

// FUNCTION: LEGO1 0x1002e100
// FUNCTION: BETA10 0x100b0520
MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
MxS32 LegoPathActor::VTable0x8c(float p_time, MxMatrix& p_transform)
{
if (m_userNavFlag && m_actorState == c_initial) {
m_lastTime = p_time;
Expand All @@ -243,22 +244,27 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
p4 = Vector3(m_roi->GetWorldPosition());

LegoNavController* nav = NavController();
assert(nav);

m_worldSpeed = nav->GetLinearVel();

if (nav->CalculateNewPosDir(p4, p5, p2, p1, m_boundary->GetUnknown0x14())) {
Mx3DPointFloat p6;
p6 = p2;
MxS32 result = 0;

m_unk0xe9 = m_boundary->Intersect(m_roi->GetWorldBoundingSphere().Radius(), p4, p2, p3, m_destEdge);
if (m_unk0xe9 == -1) {
MxTrace("Intersect returned -1\n");
return -1;
}

if (m_unk0xe9 != 0) {
p2 = p3;
else {
if (m_unk0xe9 != 0) {
p2 = p3;
}
}

MxS32 result = VTable0x68(p4, p2, p3);
result = VTable0x68(p4, p2, p3);

if (result > 0) {
p2 = p4;
Expand Down Expand Up @@ -309,11 +315,17 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
dir = p1;
up = *m_boundary->GetUnknown0x14();
right.EqualsCross(up, dir);
right.Unitize();

MxS32 res = right.Unitize();
assert(res == 0);

dir.EqualsCross(right, up);
pos = p2;
return result;
}
else {
return -1;
}
}
else if (p_time >= 0 && m_worldSpeed > 0) {
float f = (m_BADuration - m_unk0x7c) / m_worldSpeed + m_lastTime;
Expand All @@ -332,13 +344,16 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
m_lastTime = f;
p_transform.SetIdentity();

LegoResult r;
if (m_userNavFlag) {
m_unk0x8c.FUN_1009a1e0(m_unk0x7c / m_BADuration, p_transform, *m_boundary->GetUnknown0x14(), 0);
r = m_unk0x8c.FUN_1009a1e0(m_unk0x7c / m_BADuration, p_transform, *m_boundary->GetUnknown0x14(), 0);
}
else {
m_unk0x8c.FUN_1009a1e0(m_unk0x7c / m_BADuration, p_transform, *m_boundary->GetUnknown0x14(), 1);
r = m_unk0x8c.FUN_1009a1e0(m_unk0x7c / m_BADuration, p_transform, *m_boundary->GetUnknown0x14(), 1);
}

assert(r == 0); // SUCCESS

Vector3 pos1(p_transform[3]);
Vector3 pos2(m_unk0xec[3]);
Mx3DPointFloat p1;
Expand All @@ -350,16 +365,17 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform)
else {
m_boundary->FUN_100575b0(pos2, pos1, this);
pos2 = pos1;
}

if (m_unk0xe9 != 0) {
VTable0x9c();
}

return 0;
if (m_unk0xe9 != 0) {
VTable0x9c();
}
}
else {
return -1;
}

return -1;
return 0;
}

// FUNCTION: LEGO1 0x1002e740
Expand Down
4 changes: 3 additions & 1 deletion LEGO1/lego/sources/misc/legounknown.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "legounknown.h"

#include "mxgeometry/mxmatrix.h"

DECOMP_SIZE_ASSERT(LegoUnknown, 0x50)

// FUNCTION: LEGO1 0x1009a0f0
Expand Down Expand Up @@ -29,7 +31,7 @@ void LegoUnknown::FUN_1009a140(const Vector3& p_point1, Vector3& p_point2, Vecto

// FUNCTION: LEGO1 0x1009a1e0
// FUNCTION: BETA10 0x10182d61
LegoResult LegoUnknown::FUN_1009a1e0(float p_f1, Matrix4& p_mat, Vector3& p_v, LegoU32 p_und)
LegoResult LegoUnknown::FUN_1009a1e0(float p_f1, MxMatrix& p_mat, Vector3& p_v, LegoU32 p_und)
{
Vector3 v1(p_mat[3]);
Vector3 v2(p_mat[0]);
Expand Down
4 changes: 2 additions & 2 deletions LEGO1/lego/sources/misc/legounknown.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "legotypes.h"
#include "mxgeometry/mxgeometry3d.h"

class Matrix4;
class MxMatrix;

// SIZE 0x50
class LegoUnknown {
Expand All @@ -13,7 +13,7 @@ class LegoUnknown {
~LegoUnknown();

void FUN_1009a140(const Vector3& p_point1, Vector3& p_point2, Vector3& p_point3, Vector3& p_point4);
LegoResult FUN_1009a1e0(float p_f1, Matrix4& p_mat, Vector3& p_v, LegoU32 p_und);
LegoResult FUN_1009a1e0(float p_f1, MxMatrix& p_mat, Vector3& p_v, LegoU32 p_und);

private:
Mx3DPointFloat m_unk0x00[4]; // 0x00
Expand Down

0 comments on commit 795d6e1

Please sign in to comment.