Progress on Helicopter::FUN_100042a0 (#1242)

* Implement `LegoCameraController::FUN_100123b0`

* Improve `UnknownMx4DPointFloat::Unknown7` match, add BETA10

* Add draft for `FUN_100042a0`

* Improve match

* Match

* Use better naming

* Remove comments

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
jonschz 2024-12-20 01:27:14 +01:00 committed by GitHub
parent a8729dfef6
commit 7ed2ac9ccc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 99 additions and 35 deletions

View File

@ -48,6 +48,7 @@ public:
};
// VTABLE: LEGO1 0x100d40f8
// VTABLE: BETA10 0x101b9880
// SIZE 0x230
class Helicopter : public IslePathActor {
public:
@ -55,6 +56,7 @@ public:
~Helicopter() override; // vtable+0x00
// FUNCTION: LEGO1 0x10003070
// FUNCTION: BETA10 0x1002b300
const char* ClassName() const override // vtable+0x0c
{
// STRING: LEGO1 0x100f0130
@ -62,6 +64,7 @@ public:
}
// FUNCTION: LEGO1 0x10003080
// FUNCTION: BETA10 0x1002b330
MxBool IsA(const char* p_name) const override // vtable+0x10
{
return !strcmp(p_name, Helicopter::ClassName()) || IslePathActor::IsA(p_name);

View File

@ -38,6 +38,7 @@ public:
void SetWorldTransform(const Vector3& p_at, const Vector3& p_dir, const Vector3& p_up);
void FUN_10012290(float p_angle);
void FUN_10012320(float p_angle);
MxResult FUN_100123b0(Matrix4& p_matrix);
void FUN_100123e0(const Matrix4& p_transform, MxU32 p_und);
Mx3DPointFloat GetWorldUp();
Mx3DPointFloat GetWorldLocation();

View File

@ -14,6 +14,8 @@
#include "legoworld.h"
#include "misc.h"
#include "mxdebug.h"
#include "mxmisc.h"
#include "mxtimer.h"
#include "mxtransitionmanager.h"
#include "scripts.h"
@ -405,7 +407,7 @@ void Helicopter::Animate(float p_time)
Vector3 v2(m_unk0x1a8[3]);
float* loc = m_unk0x1a8[3];
mat.SetIdentity();
m_unk0x1f4.Unknown6(mat, f2);
m_unk0x1f4.BETA_1004aaa0(mat, f2);
v2.SetVector(loc);
v2 -= v;
v2 *= f2;
@ -425,10 +427,47 @@ void Helicopter::Animate(float p_time)
}
}
// STUB: LEGO1 0x100042a0
// FUNCTION: LEGO1 0x100042a0
void Helicopter::FUN_100042a0(const Matrix4& p_matrix)
{
// TODO
MxMatrix local48;
MxMatrix local90;
Vector3 vec1(local48[3]); // local98 // esp+0x30
Vector3 vec2(local90[3]); // localac // esp+0x1c
Vector3 vec3(m_unk0x1a8[0]); // locala8 // esp+0x20
Vector3 vec4(m_unk0x1a8[1]); // localb8 // esp+0x10
Vector3 vec5(m_unk0x1a8[2]); // EDI
Vector3 vec6(m_unk0x1a8[3]); // locala0 // esp+0x28
m_world->GetCamera()->FUN_100123b0(local48);
m_unk0x1a8.SetIdentity();
local90 = p_matrix;
vec2[1] += 20.0f;
vec4 = vec2;
vec4 -= vec1;
vec4.Unitize();
vec5[0] = vec5[2] = 0.0f;
vec5[1] = -1.0f;
vec3.EqualsCross(&vec4, &vec5);
vec3.Unitize();
vec4.EqualsCross(&vec5, &vec3);
vec6 = vec2;
local90 = m_unk0x1a8;
m_unk0x160 = local48;
vec1.Clear();
vec2.Clear();
m_unk0x1f0 = Timer()->GetTime();
m_unk0x1f4.BETA_1004a9f0(local48);
m_unk0x1f4.FUN_10004620(local90);
m_unk0x1f4.FUN_10004520();
}
// FUNCTION: LEGO1 0x10004640

View File

@ -358,7 +358,7 @@ void LegoCarBuild::VTable0x70()
m_unk0x2a0 = sqrt((MxDouble) DISTSQRD2(m_unk0x290, m_unk0x298));
m_unk0x25c.Unknown1(m_unk0x178, m_unk0x208);
m_unk0x25c.BETA_1004a9b0(m_unk0x178, m_unk0x208);
}
// FUNCTION: LEGO1 0x10023130
@ -406,7 +406,7 @@ void LegoCarBuild::FUN_10023130(MxLong p_x, MxLong p_y)
MxFloat local1c = sqrt((double) (NORMSQRD2(local20))) / m_unk0x2a0;
m_unk0x25c.Unknown6(local78, local1c);
m_unk0x25c.BETA_1004aaa0(local78, local1c);
local78[3][0] = m_unk0x178[3][0] + local18[0];
local78[3][1] = m_unk0x178[3][1] + local18[1];

View File

@ -2793,8 +2793,8 @@ void LegoAnimationManager::FUN_100648f0(LegoTranInfo* p_tranInfo, MxLong p_unk0x
LegoLocation* location = NavController()->GetLocation(p_tranInfo->m_location);
if (location != NULL) {
CalcLocalTransform(location->m_position, location->m_direction, location->m_up, m_unk0x484);
m_unk0x4cc.Unknown1(m_unk0x43c, m_unk0x484);
m_unk0x4cc.Unknown7();
m_unk0x4cc.BETA_1004a9b0(m_unk0x43c, m_unk0x484);
m_unk0x4cc.FUN_10004520();
}
else {
p_tranInfo->m_flags &= ~LegoTranInfo::c_bit1;
@ -2828,7 +2828,7 @@ void LegoAnimationManager::FUN_10064b50(MxLong p_time)
sub[1] = (m_unk0x484[3][1] - m_unk0x43c[3][1]) * und;
sub[2] = (m_unk0x484[3][2] - m_unk0x43c[3][2]) * und;
m_unk0x4cc.Unknown6(mat, (float) (p_time - m_unk0x434) / 1000.0f);
m_unk0x4cc.BETA_1004aaa0(mat, (float) (p_time - m_unk0x434) / 1000.0f);
VPV3(mat[3], m_unk0x43c[3], sub);
mat[3][3] = 1.0f;

View File

@ -140,6 +140,20 @@ void LegoCameraController::FUN_10012320(float p_angle)
m_matrix1.RotateY(p_angle);
}
// FUNCTION: LEGO1 0x100123b0
MxResult LegoCameraController::FUN_100123b0(Matrix4& p_matrix)
{
if (m_lego3DView) {
ViewROI* pov = m_lego3DView->GetPointOfView();
if (pov) {
p_matrix = pov->GetLocal2World();
return SUCCESS;
}
}
return FAILURE;
}
// FUNCTION: LEGO1 0x100123e0
// FUNCTION: BETA10 0x10068cb2
void LegoCameraController::FUN_100123e0(const Matrix4& p_transform, MxU32 p_und)

View File

@ -878,9 +878,9 @@ inline void LegoAnimNodeData::GetTranslation(
c[3] = p_rotationKeys[i + 1].GetAngle();
}
b.Unknown4(a);
b.Unknown5(c);
b.Unknown6(
b.BETA_10180b80(a);
b.BETA_10180bc0(c);
b.BETA_1004aaa0(
p_matrix,
(p_time - p_rotationKeys[i].GetTime()) / (p_rotationKeys[i + 1].GetTime() - p_rotationKeys[i].GetTime())
);

View File

@ -105,35 +105,36 @@ public:
UnknownMx4DPointFloat() : m_unk0x30(0) {}
// FUNCTION: BETA10 0x1004a9b0
void Unknown1(Matrix4& p_m1, Matrix4& p_m2)
void BETA_1004a9b0(Matrix4& p_m1, Matrix4& p_m2)
{
Unknown2(p_m1);
Unknown3(p_m2);
BETA_1004a9f0(p_m1);
FUN_10004620(p_m2);
}
// FUNCTION: BETA10 0x1004a9f0
void Unknown2(Matrix4& p_m)
void BETA_1004a9f0(Matrix4& p_m)
{
p_m.ToQuaternion(m_unk0x00);
m_unk0x30 |= c_bit1;
}
// FUNCTION: LEGO1 0x10004620
// FUNCTION: BETA10 0x1004aa30
void Unknown3(Matrix4& p_m)
void FUN_10004620(Matrix4& p_m)
{
p_m.ToQuaternion(m_unk0x18);
m_unk0x30 |= c_bit2;
}
// FUNCTION: BETA10 0x10180b80
void Unknown4(Vector4& p_v)
void BETA_10180b80(Vector4& p_v)
{
m_unk0x00 = p_v;
m_unk0x30 |= c_bit1;
}
// FUNCTION: BETA10 0x10180bc0
void Unknown5(Vector4& p_v)
void BETA_10180bc0(Vector4& p_v)
{
m_unk0x18 = p_v;
m_unk0x30 |= c_bit2;
@ -143,8 +144,8 @@ public:
const Vector4& GetUnknown0x18() const { return m_unk0x18; }
undefined4 GetUnknown0x30() const { return m_unk0x30; }
inline int Unknown6(Matrix4& p_matrix, float p_f);
inline void Unknown7();
inline int BETA_1004aaa0(Matrix4& p_matrix, float p_f);
inline long FUN_10004520();
private:
inline int FUN_100040a0(Vector4& p_v, float p_f);
@ -155,7 +156,7 @@ private:
};
// FUNCTION: BETA10 0x1004aaa0
int UnknownMx4DPointFloat::Unknown6(Matrix4& p_matrix, float p_f)
int UnknownMx4DPointFloat::BETA_1004aaa0(Matrix4& p_matrix, float p_f)
{
float data[4];
Vector4 v(data);
@ -168,22 +169,27 @@ int UnknownMx4DPointFloat::Unknown6(Matrix4& p_matrix, float p_f)
}
}
inline void UnknownMx4DPointFloat::Unknown7()
// FUNCTION: LEGO1 0x10004520
inline long UnknownMx4DPointFloat::FUN_10004520()
{
if (m_unk0x30) {
Mx4DPointFloat v1;
Mx4DPointFloat v2;
v1 = m_unk0x00;
v1 += m_unk0x18;
v2 = m_unk0x00;
v2 -= m_unk0x18;
if (v1.Dot(&v1, &v1) < v2.Dot(&v2, &v2)) {
m_unk0x18 *= -1.0f;
}
if (!m_unk0x30) {
return -1;
}
Mx4DPointFloat v1;
Mx4DPointFloat v2;
v1 = m_unk0x00;
v1 += m_unk0x18;
v2 = m_unk0x00;
v2 -= m_unk0x18;
if (v1.Dot(&v1, &v1) < v2.Dot(&v2, &v2)) {
m_unk0x18 *= -1.0f;
}
return 0;
}
// FUNCTION: LEGO1 0x100040a0

View File

@ -31,5 +31,6 @@ targets:
- LegoWorld
ignore-functions:
# strcpy, strlen, ... (arguments are imported incorrectly)
- 0x100f8ad0
- 0x100fa200
- 0x100f9780