Order functions in binary up to the end of Helicopter; refactor vector/matrix classes ()

* Order experimentation

* Revert IslePathActor

* Fix order

* Fix inlining

* Fixes

* WIP

* WIP

* Refactor

* Refactor

* Fix operators

* Remove obsolete inline keyword

* Fix ctors

* Refactor

* Rename files

* Refactor

* Remove empty line
This commit is contained in:
Christian Semmler 2025-01-04 15:07:04 -07:00 committed by GitHub
parent b8f1364ac7
commit c54805fde8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 1245 additions and 1030 deletions

View file

@ -10,6 +10,7 @@ class Act3Brickster;
class Act3Cop;
class Act3Shark;
class Helicopter;
class MxQuaternionTransformer;
// Macros confirmed by BETA10
#define MAX_PIZZAS 20
@ -152,7 +153,7 @@ protected:
const Matrix4& p_destination,
const Matrix4& p_startPosition,
const Matrix4& p_endPosition,
const UnknownMx4DPointFloat& p_unk0x1f4
const MxQuaternionTransformer& p_unk0x1f4
);
Act3State* m_state; // 0xf8

View file

@ -3,7 +3,7 @@
#include "islepathactor.h"
#include "legostate.h"
#include "realtime/matrix.h"
#include "mxgeometry/mxquaternion.h"
class Act3;
@ -88,12 +88,12 @@ public:
protected:
void FUN_100042a0(const Matrix4& p_matrix);
MxMatrix m_unk0x160; // 0x160
MxMatrix m_unk0x1a8; // 0x1a8
float m_unk0x1f0; // 0x1f0
UnknownMx4DPointFloat m_unk0x1f4; // 0x1f4
HelicopterState* m_state; // 0x228
MxAtomId m_script; // 0x22c
MxMatrix m_unk0x160; // 0x160
MxMatrix m_unk0x1a8; // 0x1a8
float m_unk0x1f0; // 0x1f0
MxQuaternionTransformer m_unk0x1f4; // 0x1f4
HelicopterState* m_state; // 0x228
MxAtomId m_script; // 0x22c
};
#endif // HELICOPTER_H

View file

@ -86,6 +86,26 @@ public:
IslePathActor();
// FUNCTION: LEGO1 0x10002e70
virtual MxLong HandleClick() { return 0; } // vtable+0xcc
// FUNCTION: LEGO1 0x10002df0
virtual MxLong HandleNotification0() { return 0; } // vtable+0xd0
// FUNCTION: LEGO1 0x10002e80
virtual MxLong HandleControl(LegoControlManagerNotificationParam&) { return 0; } // vtable+0xd4
// FUNCTION: LEGO1 0x10002e90
virtual MxLong HandleEndAnim(LegoEndAnimNotificationParam&) { return 0; } // vtable+0xd8
// FUNCTION: LEGO1 0x10002e00
virtual MxLong HandlePathStruct(LegoPathStructNotificationParam&) { return 0; } // vtable+0xdc
virtual void Enter(); // vtable+0xe0
virtual void Exit(); // vtable+0xe4
virtual void SpawnPlayer(LegoGameState::Area p_area, MxBool p_enter, MxU8 p_flags); // vtable+0xe8
virtual void VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundary, MxBool p_reset); // vtable+0xec
// FUNCTION: LEGO1 0x10002e10
~IslePathActor() override { IslePathActor::Destroy(TRUE); }
@ -108,29 +128,6 @@ public:
MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18
void Destroy(MxBool p_fromDestructor) override; // vtable+0x1c
// FUNCTION: LEGO1 0x10002e70
virtual MxLong HandleClick() { return 0; } // vtable+0xcc
// FUNCTION: LEGO1 0x10002df0
virtual MxLong HandleNotification0() { return 0; } // vtable+0xd0
// FUNCTION: LEGO1 0x10002e80
virtual MxLong HandleControl(LegoControlManagerNotificationParam&) { return 0; } // vtable+0xd4
// FUNCTION: LEGO1 0x10002e90
virtual MxLong HandleEndAnim(LegoEndAnimNotificationParam&) { return 0; } // vtable+0xd8
// FUNCTION: LEGO1 0x10002e00
virtual MxLong HandlePathStruct(LegoPathStructNotificationParam&) { return 0; } // vtable+0xdc
virtual void Enter(); // vtable+0xe0
virtual void Exit(); // vtable+0xe4
virtual void SpawnPlayer(LegoGameState::Area p_area, MxBool p_enter, MxU8 p_flags); // vtable+0xe8
virtual void VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundary, MxBool p_reset); // vtable+0xec
// SYNTHETIC: LEGO1 0x10002ff0
// IslePathActor::`scalar deleting destructor'
void FUN_1001b660();
void Reset()
@ -143,6 +140,9 @@ public:
static void RegisterSpawnLocations();
// SYNTHETIC: LEGO1 0x10002ff0
// IslePathActor::`scalar deleting destructor'
protected:
LegoWorld* m_world; // 0x154
LegoPathActor* m_previousActor; // 0x158

View file

@ -3,6 +3,7 @@
#include "decomp.h"
#include "legoentity.h"
#include "mxgeometry/mxmatrix.h"
class LegoCacheSound;

View file

@ -7,7 +7,7 @@
#include "legostate.h"
#include "legotraninfolist.h"
#include "mxcore.h"
#include "mxgeometry/mxgeometry3d.h"
#include "mxgeometry/mxquaternion.h"
class LegoAnimPresenter;
class LegoEntity;
@ -258,46 +258,46 @@ private:
void FUN_100648f0(LegoTranInfo* p_tranInfo, MxLong p_unk0x404);
void FUN_10064b50(MxLong p_time);
LegoOmni::World m_worldId; // 0x08
MxU16 m_animCount; // 0x0c
MxU16 m_unk0x0e; // 0x0e
MxU16 m_unk0x10; // 0x10
AnimInfo* m_anims; // 0x14
undefined2 m_unk0x18; // 0x18
MxBool m_unk0x1a; // 0x1a
MxU32 m_unk0x1c; // 0x1c
LegoTranInfoList* m_tranInfoList; // 0x20
LegoTranInfoList* m_tranInfoList2; // 0x24
MxPresenter* m_unk0x28[2]; // 0x28
MxLong m_unk0x30[2]; // 0x30
MxBool m_unk0x38; // 0x38
MxBool m_animRunning; // 0x39
MxBool m_enableCamAnims; // 0x3a
Extra m_extras[40]; // 0x3c
MxU32 m_lastExtraCharacterId; // 0x3fc
MxBool m_unk0x400; // 0x400
MxBool m_unk0x401; // 0x401
MxBool m_unk0x402; // 0x402
MxLong m_unk0x404; // 0x404
MxLong m_unk0x408; // 0x408
MxLong m_unk0x40c; // 0x40c
MxLong m_unk0x410; // 0x410
MxU32 m_unk0x414; // 0x414
MxU32 m_numAllowedExtras; // 0x418
undefined4 m_unk0x41c; // 0x41c
AnimState* m_animState; // 0x420
LegoROIList* m_unk0x424; // 0x424
MxBool m_suspendedEnableCamAnims; // 0x428
MxBool m_unk0x429; // 0x429
MxBool m_unk0x42a; // 0x42a
MxBool m_suspended; // 0x42b
LegoTranInfo* m_unk0x42c; // 0x42c
MxBool m_unk0x430; // 0x430
MxLong m_unk0x434; // 0x434
MxLong m_unk0x438; // 0x438
MxMatrix m_unk0x43c; // 0x43c
MxMatrix m_unk0x484; // 0x484
UnknownMx4DPointFloat m_unk0x4cc; // 0x4cc
LegoOmni::World m_worldId; // 0x08
MxU16 m_animCount; // 0x0c
MxU16 m_unk0x0e; // 0x0e
MxU16 m_unk0x10; // 0x10
AnimInfo* m_anims; // 0x14
undefined2 m_unk0x18; // 0x18
MxBool m_unk0x1a; // 0x1a
MxU32 m_unk0x1c; // 0x1c
LegoTranInfoList* m_tranInfoList; // 0x20
LegoTranInfoList* m_tranInfoList2; // 0x24
MxPresenter* m_unk0x28[2]; // 0x28
MxLong m_unk0x30[2]; // 0x30
MxBool m_unk0x38; // 0x38
MxBool m_animRunning; // 0x39
MxBool m_enableCamAnims; // 0x3a
Extra m_extras[40]; // 0x3c
MxU32 m_lastExtraCharacterId; // 0x3fc
MxBool m_unk0x400; // 0x400
MxBool m_unk0x401; // 0x401
MxBool m_unk0x402; // 0x402
MxLong m_unk0x404; // 0x404
MxLong m_unk0x408; // 0x408
MxLong m_unk0x40c; // 0x40c
MxLong m_unk0x410; // 0x410
MxU32 m_unk0x414; // 0x414
MxU32 m_numAllowedExtras; // 0x418
undefined4 m_unk0x41c; // 0x41c
AnimState* m_animState; // 0x420
LegoROIList* m_unk0x424; // 0x424
MxBool m_suspendedEnableCamAnims; // 0x428
MxBool m_unk0x429; // 0x429
MxBool m_unk0x42a; // 0x42a
MxBool m_suspended; // 0x42b
LegoTranInfo* m_unk0x42c; // 0x42c
MxBool m_unk0x430; // 0x430
MxLong m_unk0x434; // 0x434
MxLong m_unk0x438; // 0x438
MxMatrix m_unk0x43c; // 0x43c
MxMatrix m_unk0x484; // 0x484
MxQuaternionTransformer m_unk0x4cc; // 0x4cc
};
// TEMPLATE: LEGO1 0x10061750

View file

@ -4,6 +4,7 @@
#include "legogamestate.h"
#include "legostate.h"
#include "legoworld.h"
#include "mxgeometry/mxquaternion.h"
class LegoCarBuildAnimPresenter;
class LegoControlManagerNotificationParam;
@ -189,7 +190,7 @@ private:
MxS32 m_unk0x250[2]; // 0x250
LegoCarBuildAnimPresenter* m_unk0x258; // 0x258
UnknownMx4DPointFloat m_unk0x25c; // 0x25c
MxQuaternionTransformer m_unk0x25c; // 0x25c
// These two are likely locations in pixel space
MxS32 m_unk0x290[2]; // 0x290

View file

@ -3,7 +3,6 @@
#include "legoactor.h"
#include "misc/legounknown.h"
#include "mxgeometry/mxmatrix.h"
#include "mxtypes.h"
struct LegoEdge;

View file

@ -419,7 +419,7 @@ void Helicopter::Animate(float p_time)
Vector3 v3(m_unk0x1a8[3]);
mat.SetIdentity();
m_unk0x1f4.BETA_1004aaa0(mat, f2);
m_unk0x1f4.InterpolateToMatrix(mat, f2);
v2 = v3;
v2 -= v1;
@ -482,8 +482,8 @@ void Helicopter::FUN_100042a0(const Matrix4& p_matrix)
m_unk0x1f0 = Timer()->GetTime();
m_unk0x1f4.BETA_1004a9b0(local48, local90);
m_unk0x1f4.FUN_10004520();
m_unk0x1f4.SetStartEnd(local48, local90);
m_unk0x1f4.NormalizeDirection();
}
// FUNCTION: LEGO1 0x10004640

View file

@ -358,7 +358,7 @@ void LegoCarBuild::VTable0x70()
m_unk0x2a0 = sqrt((MxDouble) DISTSQRD2(m_unk0x290, m_unk0x298));
m_unk0x25c.BETA_1004a9b0(m_unk0x178, m_unk0x208);
m_unk0x25c.SetStartEnd(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.BETA_1004aaa0(local78, local1c);
m_unk0x25c.InterpolateToMatrix(local78, local1c);
local78[3][0] = m_unk0x178[3][0] + local18[0];
local78[3][1] = m_unk0x178[3][1] + local18[1];

View file

@ -2797,8 +2797,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.BETA_1004a9b0(m_unk0x43c, m_unk0x484);
m_unk0x4cc.FUN_10004520();
m_unk0x4cc.SetStartEnd(m_unk0x43c, m_unk0x484);
m_unk0x4cc.NormalizeDirection();
}
else {
p_tranInfo->m_flags &= ~LegoTranInfo::c_bit1;
@ -2832,7 +2832,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.BETA_1004aaa0(mat, (float) (p_time - m_unk0x434) / 1000.0f);
m_unk0x4cc.InterpolateToMatrix(mat, (float) (p_time - m_unk0x434) / 1000.0f);
VPV3(mat[3], m_unk0x43c[3], sub);
mat[3][3] = 1.0f;

View file

@ -8,12 +8,12 @@
#include "mxdirectx/mxdirect3d.h"
#include "mxdirectx/mxstopwatch.h"
#include "mxdisplaysurface.h"
#include "mxgeometry/mxmatrix.h"
#include "mxmisc.h"
#include "mxpalette.h"
#include "mxregion.h"
#include "mxtimer.h"
#include "mxtransitionmanager.h"
#include "realtime/matrix.h"
#include "realtime/realtime.h"
#include "roi/legoroi.h"
#include "tgl/d3drm/impl.h"

View file

@ -799,7 +799,7 @@ void Act3::DebugCopter(
const Matrix4& p_destination,
const Matrix4& p_startPosition,
const Matrix4& p_endPosition,
const UnknownMx4DPointFloat& p_unk0x1f4
const MxQuaternionTransformer& p_unk0x1f4
)
{
DebugPrintf("Copter matrix...\n\n");
@ -831,10 +831,10 @@ void Act3::DebugCopter(
Mx4DPointFloat unk0x00, unk0x18;
if (p_unk0x1f4.GetUnknown0x30() != 0) {
if (p_unk0x1f4.GetFlags() != 0) {
// TODO: Match
unk0x00 = p_unk0x1f4.GetUnknown0x00();
unk0x18 = p_unk0x1f4.GetUnknown0x18();
unk0x00 = p_unk0x1f4.GetStartQuat();
unk0x18 = p_unk0x1f4.GetEndQuat();
DebugPrintf("Source quaternion...");
// STRING: LEGO1 0x100f7864

View file

@ -1,6 +1,7 @@
#include "legoanim.h"
#include "mxgeometry/mxmatrix.h"
#include "mxgeometry/mxquaternion.h"
#include <limits.h>
@ -851,7 +852,7 @@ inline void LegoAnimNodeData::GetTranslation(
break;
case 2:
Mx4DPointFloat a;
UnknownMx4DPointFloat b;
MxQuaternionTransformer b;
if (p_rotationKeys[i].TestBit1() || p_rotationKeys[i + 1].TestBit1()) {
a[0] = p_rotationKeys[i].GetX();
@ -878,9 +879,9 @@ inline void LegoAnimNodeData::GetTranslation(
c[3] = p_rotationKeys[i + 1].GetAngle();
}
b.BETA_10180b80(a);
b.BETA_10180bc0(c);
b.BETA_1004aaa0(
b.SetStart(a);
b.SetEnd(c);
b.InterpolateToMatrix(
p_matrix,
(p_time - p_rotationKeys[i].GetTime()) / (p_rotationKeys[i + 1].GetTime() - p_rotationKeys[i].GetTime())
);

View file

@ -4,6 +4,7 @@
#include "decomp.h"
#include "legoweedge.h"
#include "mxgeometry/mxgeometry3d.h"
#include "mxgeometry/mxgeometry4d.h"
class LegoPathStruct;

View file

@ -4,6 +4,7 @@
#include "legolod.h"
#include "misc/legocontainer.h"
#include "misc/legostorage.h"
#include "mxgeometry/mxgeometry4d.h"
#include "realtime/realtime.h"
#include "shape/legobox.h"
#include "shape/legosphere.h"

View file

@ -2,8 +2,7 @@
#define MXGEOMETRY3D_H
#include "decomp.h"
#include "realtime/matrix.h"
#include "realtime/vector.h"
#include "realtime/vector3d.inl.h"
// VTABLE: LEGO1 0x100d4488
// VTABLE: BETA10 0x101b84d0
@ -53,199 +52,4 @@ private:
float m_elements[3]; // 0x08
};
// VTABLE: LEGO1 0x100d41e8
// VTABLE: BETA10 0x101bab78
// SIZE 0x18
class Mx4DPointFloat : public Vector4 {
public:
// FUNCTION: LEGO1 0x10048290
// FUNCTION: BETA10 0x100484c0
Mx4DPointFloat() : Vector4(m_elements) {}
// FUNCTION: BETA10 0x10073bb0
Mx4DPointFloat(float p_x, float p_y, float p_z, float p_a) : Vector4(m_elements)
{
m_elements[0] = p_x;
m_elements[1] = p_y;
m_elements[2] = p_z;
m_elements[3] = p_a;
}
Mx4DPointFloat(const Mx4DPointFloat& p_other) : Vector4(m_elements) { EqualsImpl(p_other.m_data); }
// FUNCTION: LEGO1 0x10003200
virtual void operator=(const Vector4& p_impl) { EqualsImpl(p_impl.m_data); } // vtable+0x98
// FUNCTION: BETA10 0x1004af10
float& operator[](int idx) { return m_data[idx]; }
// According to the PDB, BETA10 will not link this one if it is never used
// const float& operator[](int idx) const { return m_data[idx]; }
// only used by a couple of BETA10 functions for some unknown reason
// FUNCTION: BETA10 0x1001c950
float& index_operator(int idx) { return m_data[idx]; }
// SYNTHETIC: LEGO1 0x10064b20
// SYNTHETIC: BETA10 0x10070420
// ??4Mx4DPointFloat@@QAEAAV0@ABV0@@Z
private:
float m_elements[4]; // 0x08
};
// SIZE 0x34
class UnknownMx4DPointFloat {
public:
enum {
c_bit1 = 0x01,
c_bit2 = 0x02
};
UnknownMx4DPointFloat() : m_unk0x30(0) {}
// FUNCTION: BETA10 0x1004a9b0
void BETA_1004a9b0(Matrix4& p_m1, Matrix4& p_m2)
{
BETA_1004a9f0(p_m1);
FUN_10004620(p_m2);
}
// FUNCTION: BETA10 0x1004a9f0
void BETA_1004a9f0(Matrix4& p_m)
{
p_m.ToQuaternion(m_unk0x00);
m_unk0x30 |= c_bit1;
}
// FUNCTION: LEGO1 0x10004620
// FUNCTION: BETA10 0x1004aa30
void FUN_10004620(Matrix4& p_m)
{
p_m.ToQuaternion(m_unk0x18);
m_unk0x30 |= c_bit2;
}
// FUNCTION: BETA10 0x10180b80
void BETA_10180b80(Vector4& p_v)
{
m_unk0x00 = p_v;
m_unk0x30 |= c_bit1;
}
// FUNCTION: BETA10 0x10180bc0
void BETA_10180bc0(Vector4& p_v)
{
m_unk0x18 = p_v;
m_unk0x30 |= c_bit2;
}
const Vector4& GetUnknown0x00() const { return m_unk0x00; }
const Vector4& GetUnknown0x18() const { return m_unk0x18; }
undefined4 GetUnknown0x30() const { return m_unk0x30; }
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);
Mx4DPointFloat m_unk0x00; // 0x00
Mx4DPointFloat m_unk0x18; // 0x18
undefined4 m_unk0x30; // 0x30
};
// FUNCTION: BETA10 0x1004aaa0
inline int UnknownMx4DPointFloat::BETA_1004aaa0(Matrix4& p_matrix, float p_f)
{
float data[4];
Vector4 v(data);
if (FUN_100040a0(v, p_f) == 0) {
return p_matrix.FromQuaternion(v);
}
return -1;
}
// FUNCTION: LEGO1 0x10004520
inline long UnknownMx4DPointFloat::FUN_10004520()
{
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
// FUNCTION: BETA10 0x1004ab10
inline int UnknownMx4DPointFloat::FUN_100040a0(Vector4& p_v, float p_f)
{
if (m_unk0x30 == c_bit1) {
p_v = m_unk0x00;
p_v[3] = (float) ((1.0 - p_f) * acos((double) p_v[3]) * 2.0);
return p_v.NormalizeQuaternion();
}
if (m_unk0x30 == c_bit2) {
p_v = m_unk0x18;
p_v[3] = (float) (p_f * acos((double) p_v[3]) * 2.0);
return p_v.NormalizeQuaternion();
}
if (m_unk0x30 == (c_bit1 | c_bit2)) {
int i;
double d1 = p_v.Dot(m_unk0x00, m_unk0x18);
double a;
double b;
if (d1 + 1.0 > 0.00001) {
if (1.0 - d1 > 0.00001) {
double d2 = acos(d1);
double denominator = sin(d2);
a = sin((1.0 - p_f) * d2) / denominator;
b = sin(p_f * d2) / denominator;
}
else {
a = 1.0 - p_f;
b = p_f;
}
for (i = 0; i < 4; i++) {
p_v[i] = (float) (m_unk0x00[i] * a + m_unk0x18[i] * b);
}
}
else {
p_v[0] = -m_unk0x00[1];
p_v[1] = m_unk0x00[0];
p_v[2] = -m_unk0x00[3];
p_v[3] = m_unk0x00[2];
a = sin((1.0 - p_f) * 1.570796326794895);
b = sin(p_f * 1.570796326794895);
for (i = 0; i < 3; i++) {
p_v[i] = (float) (m_unk0x00[i] * a + p_v[i] * b);
}
}
return 0;
}
return -1;
}
#endif // MXGEOMETRY3D_H

View file

@ -0,0 +1,48 @@
#ifndef MXGEOMETRY4D_H
#define MXGEOMETRY4D_H
#include "decomp.h"
#include "realtime/vector4d.inl.h"
// VTABLE: LEGO1 0x100d41e8
// VTABLE: BETA10 0x101bab78
// SIZE 0x18
class Mx4DPointFloat : public Vector4 {
public:
// FUNCTION: LEGO1 0x10048290
// FUNCTION: BETA10 0x100484c0
Mx4DPointFloat() : Vector4(m_elements) {}
// FUNCTION: BETA10 0x10073bb0
Mx4DPointFloat(float p_x, float p_y, float p_z, float p_a) : Vector4(m_elements)
{
m_elements[0] = p_x;
m_elements[1] = p_y;
m_elements[2] = p_z;
m_elements[3] = p_a;
}
Mx4DPointFloat(const Mx4DPointFloat& p_other) : Vector4(m_elements) { EqualsImpl(p_other.m_data); }
// FUNCTION: LEGO1 0x10003200
virtual void operator=(const Vector4& p_impl) { EqualsImpl(p_impl.m_data); } // vtable+0x98
// FUNCTION: BETA10 0x1004af10
float& operator[](int idx) { return m_data[idx]; }
// According to the PDB, BETA10 will not link this one if it is never used
// const float& operator[](int idx) const { return m_data[idx]; }
// only used by a couple of BETA10 functions for some unknown reason
// FUNCTION: BETA10 0x1001c950
float& index_operator(int idx) { return m_data[idx]; }
// SYNTHETIC: LEGO1 0x10064b20
// SYNTHETIC: BETA10 0x10070420
// ??4Mx4DPointFloat@@QAEAAV0@ABV0@@Z
private:
float m_elements[4]; // 0x08
};
#endif // MXGEOMETRY4D_H

View file

@ -1,7 +1,7 @@
#ifndef MXMATRIX_H
#define MXMATRIX_H
#include "realtime/matrix.h"
#include "realtime/matrix4d.inl.h"
// VTABLE: LEGO1 0x100d4300
// VTABLE: BETA10 0x101b82e0
@ -35,4 +35,9 @@ private:
float m_elements[4][4]; // 0x08
};
// Must be included here (not before MxMatrix) for correct ordering in binary.
// FromQuaternion and ToQuaternion in Matrix4 depend on Vector4.
// There's a chance they included mxgeometry4d.h after including this somewhere.
#include "realtime/vector4d.inl.h"
#endif // MXMATRIX_H

View file

@ -0,0 +1,165 @@
#ifndef MXQUATERNION_H
#define MXQUATERNION_H
#include "mxgeometry4d.h"
// SIZE 0x34
class MxQuaternionTransformer {
public:
enum {
c_startSet = 0x01,
c_endSet = 0x02
};
MxQuaternionTransformer() : m_flags(0) {}
inline long NormalizeDirection();
inline void SetStartEnd(Matrix4& p_m1, Matrix4& p_m2);
inline void SetStart(Matrix4& p_m);
inline void SetEnd(Matrix4& p_m);
inline void SetStart(Vector4& p_v);
inline void SetEnd(Vector4& p_v);
inline int InterpolateToMatrix(Matrix4& p_matrix, float p_f);
const Vector4& GetStartQuat() const { return m_startQuat; }
const Vector4& GetEndQuat() const { return m_endQuat; }
undefined4 GetFlags() const { return m_flags; }
private:
inline int Interpolate(Vector4& p_v, float p_f);
Mx4DPointFloat m_startQuat; // 0x00
Mx4DPointFloat m_endQuat; // 0x18
MxU32 m_flags; // 0x30
};
// FUNCTION: LEGO1 0x10004520
long MxQuaternionTransformer::NormalizeDirection()
{
if (!m_flags) {
return -1;
}
Mx4DPointFloat v1;
Mx4DPointFloat v2;
v1 = m_startQuat;
v1 += m_endQuat;
v2 = m_startQuat;
v2 -= m_endQuat;
if (v1.Dot(v1, v1) < v2.Dot(v2, v2)) {
m_endQuat *= -1.0f;
}
return 0;
}
// FUNCTION: BETA10 0x1004a9b0
void MxQuaternionTransformer::SetStartEnd(Matrix4& p_m1, Matrix4& p_m2)
{
SetStart(p_m1);
SetEnd(p_m2);
}
// FUNCTION: BETA10 0x1004a9f0
void MxQuaternionTransformer::SetStart(Matrix4& p_m)
{
p_m.ToQuaternion(m_startQuat);
m_flags |= c_startSet;
}
// FUNCTION: LEGO1 0x10004620
// FUNCTION: BETA10 0x1004aa30
void MxQuaternionTransformer::SetEnd(Matrix4& p_m)
{
p_m.ToQuaternion(m_endQuat);
m_flags |= c_endSet;
}
// FUNCTION: BETA10 0x10180b80
void MxQuaternionTransformer::SetStart(Vector4& p_v)
{
m_startQuat = p_v;
m_flags |= c_startSet;
}
// FUNCTION: BETA10 0x10180bc0
void MxQuaternionTransformer::SetEnd(Vector4& p_v)
{
m_endQuat = p_v;
m_flags |= c_endSet;
}
// FUNCTION: BETA10 0x1004aaa0
int MxQuaternionTransformer::InterpolateToMatrix(Matrix4& p_matrix, float p_f)
{
float data[4];
Vector4 v(data);
if (Interpolate(v, p_f) == 0) {
return p_matrix.FromQuaternion(v);
}
return -1;
}
// FUNCTION: LEGO1 0x100040a0
// FUNCTION: BETA10 0x1004ab10
int MxQuaternionTransformer::Interpolate(Vector4& p_v, float p_f)
{
if (m_flags == c_startSet) {
p_v = m_startQuat;
p_v[3] = (float) ((1.0 - p_f) * acos((double) p_v[3]) * 2.0);
return p_v.NormalizeQuaternion();
}
if (m_flags == c_endSet) {
p_v = m_endQuat;
p_v[3] = (float) (p_f * acos((double) p_v[3]) * 2.0);
return p_v.NormalizeQuaternion();
}
if (m_flags == (c_startSet | c_endSet)) {
int i;
double d1 = p_v.Dot(m_startQuat, m_endQuat);
double a;
double b;
if (d1 + 1.0 > 0.00001) {
if (1.0 - d1 > 0.00001) {
double d2 = acos(d1);
double denominator = sin(d2);
a = sin((1.0 - p_f) * d2) / denominator;
b = sin(p_f * d2) / denominator;
}
else {
a = 1.0 - p_f;
b = p_f;
}
for (i = 0; i < 4; i++) {
p_v[i] = (float) (m_startQuat[i] * a + m_endQuat[i] * b);
}
}
else {
p_v[0] = -m_startQuat[1];
p_v[1] = m_startQuat[0];
p_v[2] = -m_startQuat[3];
p_v[3] = m_startQuat[2];
a = sin((1.0 - p_f) * 1.570796326794895);
b = sin(p_f * 1.570796326794895);
for (i = 0; i < 3; i++) {
p_v[i] = (float) (m_startQuat[i] * a + p_v[i] * b);
}
}
return 0;
}
return -1;
}
#endif // MXQUATERNION_H

View file

@ -3,358 +3,53 @@
#include "vector.h"
#include <memory.h>
// Note: virtual function overloads appear in the virtual table
// in reverse order of appearance.
struct UnknownMatrixType {
float m_data[4][4];
};
// Note: Many functions most likely take const references/pointers instead of non-const.
// The class needs to undergo a very careful refactoring to fix that (no matches should break).
// VTABLE: LEGO1 0x100d4350
// VTABLE: BETA10 0x101b8340
// SIZE 0x08
class Matrix4 {
protected:
float (*m_data)[4];
public:
// FUNCTION: LEGO1 0x10004500
// FUNCTION: BETA10 0x1000fc70
Matrix4(float (*p_data)[4]) { SetData(p_data); }
// Note: virtual function overloads appear in the virtual table
// in reverse order of appearance.
// FUNCTION: LEGO1 0x10002320
// FUNCTION: BETA10 0x1000fcb0
virtual void Equals(float (*p_data)[4]) { memcpy(m_data, p_data, sizeof(float) * 4 * 4); } // vtable+0x04
// FUNCTION: LEGO1 0x10002340
// FUNCTION: BETA10 0x1000fcf0
virtual void Equals(const Matrix4& p_matrix)
{
memcpy(m_data, p_matrix.m_data, sizeof(float) * 4 * 4);
} // vtable+0x00
// FUNCTION: LEGO1 0x10002360
// FUNCTION: BETA10 0x1000fd30
virtual void SetData(float (*p_data)[4]) { m_data = p_data; } // vtable+0x0c
// FUNCTION: LEGO1 0x10002370
// FUNCTION: BETA10 0x1000fd60
virtual void SetData(UnknownMatrixType& p_matrix) { m_data = p_matrix.m_data; } // vtable+0x08
// FUNCTION: LEGO1 0x10002380
// FUNCTION: BETA10 0x1000fd90
virtual float (*GetData())[4] { return m_data; } // vtable+0x14
// FUNCTION: LEGO1 0x10002390
// FUNCTION: BETA10 0x1000fdc0
virtual float (*GetData() const)[4] { return m_data; } // vtable+0x10
// FUNCTION: LEGO1 0x100023a0
// FUNCTION: BETA10 0x1000fdf0
virtual float* Element(int p_row, int p_col) { return &m_data[p_row][p_col]; } // vtable+0x1c
// FUNCTION: LEGO1 0x100023c0
// FUNCTION: BETA10 0x1000fe30
virtual const float* Element(int p_row, int p_col) const { return &m_data[p_row][p_col]; } // vtable+0x18
// FUNCTION: LEGO1 0x100023e0
// FUNCTION: BETA10 0x1000fe70
virtual void Clear() { memset(m_data, 0, 16 * sizeof(float)); } // vtable+0x20
// FUNCTION: LEGO1 0x100023f0
// FUNCTION: BETA10 0x1000feb0
virtual void SetIdentity()
{
Clear();
m_data[0][0] = 1.0f;
m_data[1][1] = 1.0f;
m_data[2][2] = 1.0f;
m_data[3][3] = 1.0f;
} // vtable+0x24
// FUNCTION: LEGO1 0x10002420
// FUNCTION: BETA10 0x1000ff20
virtual void operator=(const Matrix4& p_matrix) { Equals(p_matrix); } // vtable+0x28
// FUNCTION: LEGO1 0x10002430
// FUNCTION: BETA10 0x1000ff50
virtual Matrix4& operator+=(float (*p_data)[4])
{
for (int i = 0; i < 16; i++) {
((float*) m_data)[i] += ((float*) p_data)[i];
}
return *this;
} // vtable+0x2c
// FUNCTION: LEGO1 0x10002460
// FUNCTION: BETA10 0x1000ffc0
virtual void TranslateBy(const float& p_x, const float& p_y, const float& p_z)
{
m_data[3][0] += p_x;
m_data[3][1] += p_y;
m_data[3][2] += p_z;
} // vtable+0x30
// FUNCTION: LEGO1 0x100024a0
// FUNCTION: BETA10 0x10010040
virtual void SetTranslation(const float& p_x, const float& p_y, const float& p_z)
{
m_data[3][0] = p_x;
m_data[3][1] = p_y;
m_data[3][2] = p_z;
} // vtable+0x34
// FUNCTION: LEGO1 0x100024d0
// FUNCTION: BETA10 0x100100a0
virtual void Product(float (*p_a)[4], float (*p_b)[4])
{
float* cur = (float*) m_data;
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 4; col++) {
*cur = 0.0f;
for (int k = 0; k < 4; k++) {
*cur += p_a[row][k] * p_b[k][col];
}
cur++;
}
}
} // vtable+0x3c
// FUNCTION: LEGO1 0x10002530
// FUNCTION: BETA10 0x10010180
virtual void Product(const Matrix4& p_a, const Matrix4& p_b) { Product(p_a.m_data, p_b.m_data); } // vtable+0x38
inline virtual void ToQuaternion(Vector4& p_resultQuat); // vtable+0x40
inline virtual int FromQuaternion(const Vector4& p_vec); // vtable+0x44
// FUNCTION: LEGO1 0x100a0ff0
// FUNCTION: BETA10 0x1001fe60
void Scale(const float& p_x, const float& p_y, const float& p_z)
{
for (int i = 0; i < 4; i++) {
m_data[i][0] *= p_x;
m_data[i][1] *= p_y;
m_data[i][2] *= p_z;
}
}
// FUNCTION: BETA10 0x1001c6a0
void RotateX(const float& p_angle)
{
float s = sin(p_angle);
float c = cos(p_angle);
float matrix[4][4];
memcpy(matrix, m_data, sizeof(float) * 16);
for (int i = 0; i < 4; i++) {
m_data[i][1] = matrix[i][1] * c - matrix[i][2] * s;
m_data[i][2] = matrix[i][2] * c + matrix[i][1] * s;
}
}
// FUNCTION: BETA10 0x1001fd60
void RotateY(const float& p_angle)
{
float s = sin(p_angle);
float c = cos(p_angle);
float matrix[4][4];
memcpy(matrix, m_data, sizeof(float) * 16);
for (int i = 0; i < 4; i++) {
m_data[i][0] = matrix[i][0] * c + matrix[i][2] * s;
m_data[i][2] = matrix[i][2] * c - matrix[i][0] * s;
}
}
// FUNCTION: BETA10 0x1006ab10
void RotateZ(const float& p_angle)
{
float s = sin(p_angle);
float c = cos(p_angle);
float matrix[4][4];
memcpy(matrix, m_data, sizeof(float) * 16);
for (int i = 0; i < 4; i++) {
m_data[i][0] = matrix[i][0] * c - matrix[i][1] * s;
m_data[i][1] = matrix[i][1] * c + matrix[i][0] * s;
}
}
inline virtual void Equals(float (*p_data)[4]); // vtable+0x04
inline virtual void Equals(const Matrix4& p_matrix); // vtable+0x00
inline virtual void SetData(float (*p_data)[4]); // vtable+0x0c
inline virtual void SetData(UnknownMatrixType& p_matrix); // vtable+0x08
inline virtual float (*GetData())[4]; // vtable+0x14
inline virtual float (*GetData() const)[4]; // vtable+0x10
inline virtual float* Element(int p_row, int p_col); // vtable+0x1c
inline virtual const float* Element(int p_row, int p_col) const; // vtable+0x18
inline virtual void Clear(); // vtable+0x20
inline virtual void SetIdentity(); // vtable+0x24
inline virtual void operator=(const Matrix4& p_matrix); // vtable+0x28
inline virtual Matrix4& operator+=(float (*p_data)[4]); // vtable+0x2c
inline virtual void TranslateBy(const float& p_x, const float& p_y, const float& p_z); // vtable+0x30
inline virtual void SetTranslation(const float& p_x, const float& p_y, const float& p_z); // vtable+0x34
inline virtual void Product(float (*p_a)[4], float (*p_b)[4]); // vtable+0x3c
inline virtual void Product(const Matrix4& p_a, const Matrix4& p_b); // vtable+0x38
inline virtual void ToQuaternion(Vector4& p_resultQuat); // vtable+0x40
inline virtual int FromQuaternion(const Vector4& p_vec); // vtable+0x44
inline void Scale(const float& p_x, const float& p_y, const float& p_z);
inline void RotateX(const float& p_angle);
inline void RotateY(const float& p_angle);
inline void RotateZ(const float& p_angle);
inline int BETA_1005a590(Matrix4& p_mat);
// FUNCTION: LEGO1 0x1006b500
void Swap(int p_d1, int p_d2)
{
for (int i = 0; i < 4; i++) {
float e = m_data[p_d1][i];
m_data[p_d1][i] = m_data[p_d2][i];
m_data[p_d2][i] = e;
}
}
inline void Swap(int p_d1, int p_d2);
float* operator[](int idx) { return m_data[idx]; }
const float* operator[](int idx) const { return m_data[idx]; }
protected:
float (*m_data)[4];
};
// FUNCTION: LEGO1 0x10002550
// FUNCTION: BETA10 0x100101c0
inline void Matrix4::ToQuaternion(Vector4& p_outQuat)
{
float trace;
float localc = m_data[0][0] + m_data[1][1] + m_data[2][2];
if (localc > 0) {
trace = (float) sqrt(localc + 1.0);
p_outQuat[3] = trace * 0.5f;
trace = 0.5f / trace;
p_outQuat[0] = (m_data[2][1] - m_data[1][2]) * trace;
p_outQuat[1] = (m_data[0][2] - m_data[2][0]) * trace;
p_outQuat[2] = (m_data[1][0] - m_data[0][1]) * trace;
}
else {
// GLOBAL: LEGO1 0x100d4090
static int rotateIndex[] = {1, 2, 0};
// Largest element along the trace
int largest = 0;
if (m_data[0][0] < m_data[1][1]) {
largest = 1;
}
if (*Element(largest, largest) < m_data[2][2]) {
largest = 2;
}
int next = rotateIndex[largest];
int nextNext = rotateIndex[next];
trace = (float) sqrt(*Element(largest, largest) - (*Element(nextNext, nextNext) + *Element(next, next)) + 1.0);
p_outQuat[largest] = trace * 0.5f;
trace = 0.5f / trace;
p_outQuat[3] = (*Element(nextNext, next) - *Element(next, nextNext)) * trace;
p_outQuat[next] = (*Element(largest, next) + *Element(next, largest)) * trace;
p_outQuat[nextNext] = (*Element(largest, nextNext) + *Element(nextNext, largest)) * trace;
}
}
// FUNCTION: LEGO1 0x10002710
// FUNCTION: BETA10 0x10010550
inline int Matrix4::FromQuaternion(const Vector4& p_vec)
{
float local14 = p_vec.LenSquared();
if (local14 > 0.0f) {
local14 = 2.0f / local14;
float local24 = p_vec[0] * local14;
float local34 = p_vec[1] * local14;
float local10 = p_vec[2] * local14;
float local28 = p_vec[3] * local24;
float local2c = p_vec[3] * local34;
float local30 = p_vec[3] * local10;
float local38 = p_vec[0] * local24;
float local8 = p_vec[0] * local34;
float localc = p_vec[0] * local10;
float local18 = p_vec[1] * local34;
float local1c = p_vec[1] * local10;
float local20 = p_vec[2] * local10;
m_data[0][0] = 1.0f - (local18 + local20);
m_data[1][0] = local8 + local30;
m_data[2][0] = localc - local2c;
m_data[0][1] = local8 - local30;
m_data[1][1] = 1.0f - (local38 + local20);
m_data[2][1] = local1c + local28;
m_data[0][2] = local2c + localc;
m_data[1][2] = local1c - local28;
m_data[2][2] = 1.0f - (local18 + local38);
m_data[3][0] = 0.0f;
m_data[3][1] = 0.0f;
m_data[3][2] = 0.0f;
m_data[3][3] = 1.0f;
m_data[0][3] = 0.0f;
m_data[1][3] = 0.0f;
m_data[2][3] = 0.0f;
return 0;
}
else {
return -1;
}
}
// FUNCTION: BETA10 0x1005a590
inline int Matrix4::BETA_1005a590(Matrix4& p_mat)
{
float local5c[4][4];
Matrix4 localc(local5c);
((Matrix4&) localc) = *this;
p_mat.SetIdentity();
for (int i = 0; i < 4; i++) {
int local1c = i;
int local10;
for (local10 = i + 1; local10 < 4; local10++) {
if (fabs(localc[local1c][i]) < fabs(localc[local10][i])) {
local1c = local10;
}
}
if (local1c != i) {
localc.Swap(local1c, i);
p_mat.Swap(local1c, i);
}
if (localc[i][i] < 0.001f && localc[i][i] > -0.001f) {
return -1;
}
float local60 = localc[i][i];
int local18;
for (local18 = 0; local18 < 4; local18++) {
p_mat[i][local18] /= local60;
}
for (local18 = 0; local18 < 4; local18++) {
localc[i][local18] /= local60;
}
for (local10 = 0; local10 < 4; local10++) {
if (i != local10) {
float afStack70[4];
for (local18 = 0; local18 < 4; local18++) {
afStack70[local18] = p_mat[i][local18] * localc[local10][i];
}
for (local18 = 0; local18 < 4; local18++) {
p_mat[local10][local18] -= afStack70[local18];
}
for (local18 = 0; local18 < 4; local18++) {
afStack70[local18] = localc[i][local18] * localc[local10][i];
}
for (local18 = 0; local18 < 4; local18++) {
localc[local10][local18] -= afStack70[local18];
}
}
}
}
return 0;
}
#endif // MATRIX_H

View file

@ -0,0 +1,365 @@
#ifndef MATRIX4D_H
#define MATRIX4D_H
#include "matrix.h"
#include <math.h>
#include <memory.h>
// FUNCTION: LEGO1 0x10002320
// FUNCTION: BETA10 0x1000fcb0
void Matrix4::Equals(float (*p_data)[4])
{
memcpy(m_data, p_data, sizeof(float) * 4 * 4);
}
// FUNCTION: LEGO1 0x10002340
// FUNCTION: BETA10 0x1000fcf0
void Matrix4::Equals(const Matrix4& p_matrix)
{
memcpy(m_data, p_matrix.m_data, sizeof(float) * 4 * 4);
}
// FUNCTION: LEGO1 0x10002360
// FUNCTION: BETA10 0x1000fd30
void Matrix4::SetData(float (*p_data)[4])
{
m_data = p_data;
}
// FUNCTION: LEGO1 0x10002370
// FUNCTION: BETA10 0x1000fd60
void Matrix4::SetData(UnknownMatrixType& p_matrix)
{
m_data = p_matrix.m_data;
}
// FUNCTION: LEGO1 0x10002380
// FUNCTION: BETA10 0x1000fd90
float (*Matrix4::GetData())[4]
{
return m_data;
}
// FUNCTION: LEGO1 0x10002390
// FUNCTION: BETA10 0x1000fdc0
float (*Matrix4::GetData() const)[4]
{
return m_data;
}
// FUNCTION: LEGO1 0x100023a0
// FUNCTION: BETA10 0x1000fdf0
float* Matrix4::Element(int p_row, int p_col)
{
return &m_data[p_row][p_col];
}
// FUNCTION: LEGO1 0x100023c0
// FUNCTION: BETA10 0x1000fe30
const float* Matrix4::Element(int p_row, int p_col) const
{
return &m_data[p_row][p_col];
}
// FUNCTION: LEGO1 0x100023e0
// FUNCTION: BETA10 0x1000fe70
void Matrix4::Clear()
{
memset(m_data, 0, 16 * sizeof(float));
}
// FUNCTION: LEGO1 0x100023f0
// FUNCTION: BETA10 0x1000feb0
void Matrix4::SetIdentity()
{
Clear();
m_data[0][0] = 1.0f;
m_data[1][1] = 1.0f;
m_data[2][2] = 1.0f;
m_data[3][3] = 1.0f;
}
// FUNCTION: LEGO1 0x10002420
// FUNCTION: BETA10 0x1000ff20
void Matrix4::operator=(const Matrix4& p_matrix)
{
Equals(p_matrix);
}
// FUNCTION: LEGO1 0x10002430
// FUNCTION: BETA10 0x1000ff50
Matrix4& Matrix4::operator+=(float (*p_data)[4])
{
for (int i = 0; i < 16; i++) {
((float*) m_data)[i] += ((float*) p_data)[i];
}
return *this;
}
// FUNCTION: LEGO1 0x10002460
// FUNCTION: BETA10 0x1000ffc0
void Matrix4::TranslateBy(const float& p_x, const float& p_y, const float& p_z)
{
m_data[3][0] += p_x;
m_data[3][1] += p_y;
m_data[3][2] += p_z;
}
// FUNCTION: LEGO1 0x100024a0
// FUNCTION: BETA10 0x10010040
void Matrix4::SetTranslation(const float& p_x, const float& p_y, const float& p_z)
{
m_data[3][0] = p_x;
m_data[3][1] = p_y;
m_data[3][2] = p_z;
}
// FUNCTION: LEGO1 0x100024d0
// FUNCTION: BETA10 0x100100a0
void Matrix4::Product(float (*p_a)[4], float (*p_b)[4])
{
float* cur = (float*) m_data;
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 4; col++) {
*cur = 0.0f;
for (int k = 0; k < 4; k++) {
*cur += p_a[row][k] * p_b[k][col];
}
cur++;
}
}
}
// FUNCTION: LEGO1 0x10002530
// FUNCTION: BETA10 0x10010180
void Matrix4::Product(const Matrix4& p_a, const Matrix4& p_b)
{
Product(p_a.m_data, p_b.m_data);
}
// FUNCTION: LEGO1 0x10002550
// FUNCTION: BETA10 0x100101c0
void Matrix4::ToQuaternion(Vector4& p_outQuat)
{
float trace;
float localc = m_data[0][0] + m_data[1][1] + m_data[2][2];
if (localc > 0) {
trace = (float) sqrt(localc + 1.0);
p_outQuat[3] = trace * 0.5f;
trace = 0.5f / trace;
p_outQuat[0] = (m_data[2][1] - m_data[1][2]) * trace;
p_outQuat[1] = (m_data[0][2] - m_data[2][0]) * trace;
p_outQuat[2] = (m_data[1][0] - m_data[0][1]) * trace;
}
else {
// GLOBAL: LEGO1 0x100d4090
static int rotateIndex[] = {1, 2, 0};
// Largest element along the trace
int largest = 0;
if (m_data[0][0] < m_data[1][1]) {
largest = 1;
}
if (*Element(largest, largest) < m_data[2][2]) {
largest = 2;
}
int next = rotateIndex[largest];
int nextNext = rotateIndex[next];
trace = (float) sqrt(*Element(largest, largest) - (*Element(nextNext, nextNext) + *Element(next, next)) + 1.0);
p_outQuat[largest] = trace * 0.5f;
trace = 0.5f / trace;
p_outQuat[3] = (*Element(nextNext, next) - *Element(next, nextNext)) * trace;
p_outQuat[next] = (*Element(largest, next) + *Element(next, largest)) * trace;
p_outQuat[nextNext] = (*Element(largest, nextNext) + *Element(nextNext, largest)) * trace;
}
}
// FUNCTION: LEGO1 0x10002710
// FUNCTION: BETA10 0x10010550
int Matrix4::FromQuaternion(const Vector4& p_vec)
{
float local14 = p_vec.LenSquared();
if (local14 > 0.0f) {
local14 = 2.0f / local14;
float local24 = p_vec[0] * local14;
float local34 = p_vec[1] * local14;
float local10 = p_vec[2] * local14;
float local28 = p_vec[3] * local24;
float local2c = p_vec[3] * local34;
float local30 = p_vec[3] * local10;
float local38 = p_vec[0] * local24;
float local8 = p_vec[0] * local34;
float localc = p_vec[0] * local10;
float local18 = p_vec[1] * local34;
float local1c = p_vec[1] * local10;
float local20 = p_vec[2] * local10;
m_data[0][0] = 1.0f - (local18 + local20);
m_data[1][0] = local8 + local30;
m_data[2][0] = localc - local2c;
m_data[0][1] = local8 - local30;
m_data[1][1] = 1.0f - (local38 + local20);
m_data[2][1] = local1c + local28;
m_data[0][2] = local2c + localc;
m_data[1][2] = local1c - local28;
m_data[2][2] = 1.0f - (local18 + local38);
m_data[3][0] = 0.0f;
m_data[3][1] = 0.0f;
m_data[3][2] = 0.0f;
m_data[3][3] = 1.0f;
m_data[0][3] = 0.0f;
m_data[1][3] = 0.0f;
m_data[2][3] = 0.0f;
return 0;
}
else {
return -1;
}
}
// FUNCTION: LEGO1 0x100a0ff0
// FUNCTION: BETA10 0x1001fe60
void Matrix4::Scale(const float& p_x, const float& p_y, const float& p_z)
{
for (int i = 0; i < 4; i++) {
m_data[i][0] *= p_x;
m_data[i][1] *= p_y;
m_data[i][2] *= p_z;
}
}
// FUNCTION: BETA10 0x1001c6a0
void Matrix4::RotateX(const float& p_angle)
{
float s = sin(p_angle);
float c = cos(p_angle);
float matrix[4][4];
memcpy(matrix, m_data, sizeof(float) * 16);
for (int i = 0; i < 4; i++) {
m_data[i][1] = matrix[i][1] * c - matrix[i][2] * s;
m_data[i][2] = matrix[i][2] * c + matrix[i][1] * s;
}
}
// FUNCTION: BETA10 0x1001fd60
void Matrix4::RotateY(const float& p_angle)
{
float s = sin(p_angle);
float c = cos(p_angle);
float matrix[4][4];
memcpy(matrix, m_data, sizeof(float) * 16);
for (int i = 0; i < 4; i++) {
m_data[i][0] = matrix[i][0] * c + matrix[i][2] * s;
m_data[i][2] = matrix[i][2] * c - matrix[i][0] * s;
}
}
// FUNCTION: BETA10 0x1006ab10
void Matrix4::RotateZ(const float& p_angle)
{
float s = sin(p_angle);
float c = cos(p_angle);
float matrix[4][4];
memcpy(matrix, m_data, sizeof(float) * 16);
for (int i = 0; i < 4; i++) {
m_data[i][0] = matrix[i][0] * c - matrix[i][1] * s;
m_data[i][1] = matrix[i][1] * c + matrix[i][0] * s;
}
}
// FUNCTION: BETA10 0x1005a590
int Matrix4::BETA_1005a590(Matrix4& p_mat)
{
float local5c[4][4];
Matrix4 localc(local5c);
((Matrix4&) localc) = *this;
p_mat.SetIdentity();
for (int i = 0; i < 4; i++) {
int local1c = i;
int local10;
for (local10 = i + 1; local10 < 4; local10++) {
if (fabs(localc[local1c][i]) < fabs(localc[local10][i])) {
local1c = local10;
}
}
if (local1c != i) {
localc.Swap(local1c, i);
p_mat.Swap(local1c, i);
}
if (localc[i][i] < 0.001f && localc[i][i] > -0.001f) {
return -1;
}
float local60 = localc[i][i];
int local18;
for (local18 = 0; local18 < 4; local18++) {
p_mat[i][local18] /= local60;
}
for (local18 = 0; local18 < 4; local18++) {
localc[i][local18] /= local60;
}
for (local10 = 0; local10 < 4; local10++) {
if (i != local10) {
float afStack70[4];
for (local18 = 0; local18 < 4; local18++) {
afStack70[local18] = p_mat[i][local18] * localc[local10][i];
}
for (local18 = 0; local18 < 4; local18++) {
p_mat[local10][local18] -= afStack70[local18];
}
for (local18 = 0; local18 < 4; local18++) {
afStack70[local18] = localc[i][local18] * localc[local10][i];
}
for (local18 = 0; local18 < 4; local18++) {
localc[local10][local18] -= afStack70[local18];
}
}
}
}
return 0;
}
// FUNCTION: LEGO1 0x1006b500
void Matrix4::Swap(int p_d1, int p_d2)
{
for (int i = 0; i < 4; i++) {
float e = m_data[p_d1][i];
m_data[p_d1][i] = m_data[p_d2][i];
m_data[p_d2][i] = e;
}
}
#endif // MATRIX4D_H

View file

@ -3,173 +3,54 @@
#include "compat.h"
#include <math.h>
#include <memory.h>
// Note: Many functions most likely take const references/pointers instead of non-const.
// The class needs to undergo a very careful refactoring to fix that (no matches should break).
// Note: virtual function overloads appear in the virtual table
// in reverse order of appearance.
// VTABLE: LEGO1 0x100d4288
// VTABLE: BETA10 0x101b8440
// SIZE 0x08
class Vector2 {
protected:
inline virtual void AddImpl(const float* p_value); // vtable+0x04
inline virtual void AddImpl(float p_value); // vtable+0x00
inline virtual void SubImpl(const float* p_value); // vtable+0x08
inline virtual void MulImpl(const float* p_value); // vtable+0x10
inline virtual void MulImpl(const float& p_value); // vtable+0x0c
inline virtual void DivImpl(const float& p_value); // vtable+0x14
inline virtual float DotImpl(const float* p_a, const float* p_b) const; // vtable+0x18
inline virtual void SetData(float* p_data); // vtable+0x1c
inline virtual void EqualsImpl(const float* p_data); // vtable+0x20
float* m_data; // 0x04
public:
// FUNCTION: LEGO1 0x1000c0f0
// FUNCTION: BETA10 0x100116a0
Vector2(float* p_data) { SetData(p_data); }
// Note: virtual function overloads appear in the virtual table
// in reverse order of appearance.
// FUNCTION: BETA10 0x100109e0
Vector2(const float* p_data) { m_data = (float*) p_data; }
// FUNCTION: LEGO1 0x10001f80
virtual void AddImpl(const float* p_value)
{
m_data[0] += p_value[0];
m_data[1] += p_value[1];
} // vtable+0x04
// FUNCTION: LEGO1 0x10001fa0
virtual void AddImpl(float p_value)
{
m_data[0] += p_value;
m_data[1] += p_value;
} // vtable+0x00
// FUNCTION: LEGO1 0x10001fc0
virtual void SubImpl(const float* p_value)
{
m_data[0] -= p_value[0];
m_data[1] -= p_value[1];
} // vtable+0x08
// FUNCTION: LEGO1 0x10001fe0
virtual void MulImpl(const float* p_value)
{
m_data[0] *= p_value[0];
m_data[1] *= p_value[1];
} // vtable+0x10
// FUNCTION: LEGO1 0x10002000
virtual void MulImpl(const float& p_value)
{
m_data[0] *= p_value;
m_data[1] *= p_value;
} // vtable+0x0c
// FUNCTION: LEGO1 0x10002020
virtual void DivImpl(const float& p_value)
{
m_data[0] /= p_value;
m_data[1] /= p_value;
} // vtable+0x14
// FUNCTION: LEGO1 0x10002040
virtual float DotImpl(const float* p_a, const float* p_b) const
{
return p_b[0] * p_a[0] + p_b[1] * p_a[1];
} // vtable+0x18
// FUNCTION: LEGO1 0x10002060
// FUNCTION: BETA10 0x10010c90
virtual void SetData(float* p_data) { m_data = p_data; } // vtable+0x1c
// FUNCTION: LEGO1 0x10002070
virtual void EqualsImpl(const float* p_data) { memcpy(m_data, p_data, sizeof(float) * 2); } // vtable+0x20
// FUNCTION: LEGO1 0x10002090
virtual float* GetData() { return m_data; } // vtable+0x28
// FUNCTION: LEGO1 0x100020a0
virtual const float* GetData() const { return m_data; } // vtable+0x24
// FUNCTION: LEGO1 0x100020b0
virtual void Clear() { memset(m_data, 0, sizeof(float) * 2); } // vtable+0x2c
// FUNCTION: LEGO1 0x100020d0
virtual float Dot(const float* p_a, const float* p_b) const { return DotImpl(p_a, p_b); } // vtable+0x3c
// FUNCTION: LEGO1 0x100020f0
// FUNCTION: BETA10 0x100108c0
virtual float Dot(const Vector2& p_a, const Vector2& p_b) const
{
return DotImpl(p_a.m_data, p_b.m_data);
} // vtable+0x38
// FUNCTION: LEGO1 0x10002110
virtual float Dot(const float* p_a, const Vector2& p_b) const { return DotImpl(p_a, p_b.m_data); } // vtable+0x34
// FUNCTION: LEGO1 0x10002130
virtual float Dot(const Vector2& p_a, const float* p_b) const { return DotImpl(p_a.m_data, p_b); } // vtable+0x30
// FUNCTION: LEGO1 0x10002150
virtual float LenSquared() const { return m_data[0] * m_data[0] + m_data[1] * m_data[1]; } // vtable+0x40
// FUNCTION: LEGO1 0x10002160
// FUNCTION: BETA10 0x10010900
virtual int Unitize()
{
float sq = LenSquared();
if (sq > 0.0f) {
float root = sqrt(sq);
if (root > 0.0f) {
DivImpl(root);
return 0;
}
}
return -1;
} // vtable+0x44
// FUNCTION: LEGO1 0x100021c0
virtual void operator+=(float p_value) { AddImpl(p_value); } // vtable+0x50
// FUNCTION: LEGO1 0x100021d0
virtual void operator+=(const float* p_other) { AddImpl(p_other); } // vtable+0x4c
// FUNCTION: LEGO1 0x100021e0
virtual void operator+=(const Vector2& p_other) { AddImpl(p_other.m_data); } // vtable+0x48
// FUNCTION: LEGO1 0x100021f0
virtual void operator-=(const float* p_other) { SubImpl(p_other); } // vtable+0x58
// FUNCTION: LEGO1 0x10002200
virtual void operator-=(const Vector2& p_other) { SubImpl(p_other.m_data); } // vtable+0x54
// FUNCTION: LEGO1 0x10002210
virtual void operator*=(const float* p_other) { MulImpl(p_other); } // vtable+0x64
// FUNCTION: LEGO1 0x10002220
virtual void operator*=(const Vector2& p_other) { MulImpl(p_other.m_data); } // vtable+0x60
// FUNCTION: LEGO1 0x10002230
virtual void operator*=(const float& p_value) { MulImpl(p_value); } // vtable+0x5c
// FUNCTION: LEGO1 0x10002240
virtual void operator/=(const float& p_value) { DivImpl(p_value); } // vtable+0x68
// FUNCTION: LEGO1 0x10002250
virtual void SetVector(const float* p_other) { EqualsImpl(p_other); } // vtable+0x70
// FUNCTION: LEGO1 0x10002260
// FUNCTION: BETA10 0x100110c0
virtual void SetVector(const Vector2& p_other) { EqualsImpl(p_other.m_data); } // vtable+0x6c
// Note: it's unclear whether Vector3::operator= has been defined explicitly
// with the same function body as Vector2& operator=. The BETA indicates that;
// however, it makes LEGO1 0x10010be0 disappear and worsens matches in
// at least these functions:
// LEGO1 0x100109b0
// LEGO1 0x10023130
// LEGO1 0x1002de10
// LEGO1 0x10050a80
// LEGO1 0x10053980
// LEGO1 0x100648f0
// LEGO1 0x10064b50
// LEGO1 0x10084030
// LEGO1 0x100a9410
// However, defining it as in the BETA improves at least these functions:
// LEGO1 0x10042300
inline virtual float* GetData(); // vtable+0x28
inline virtual const float* GetData() const; // vtable+0x24
inline virtual void Clear(); // vtable+0x2c
inline virtual float Dot(const float* p_a, const float* p_b) const; // vtable+0x3c
inline virtual float Dot(const Vector2& p_a, const Vector2& p_b) const; // vtable+0x38
inline virtual float Dot(const float* p_a, const Vector2& p_b) const; // vtable+0x34
inline virtual float Dot(const Vector2& p_a, const float* p_b) const; // vtable+0x30
inline virtual float LenSquared() const; // vtable+0x40
inline virtual int Unitize(); // vtable+0x44
inline virtual void operator+=(float p_value); // vtable+0x50
inline virtual void operator+=(const float* p_other); // vtable+0x4c
inline virtual void operator+=(const Vector2& p_other); // vtable+0x48
inline virtual void operator-=(const float* p_other); // vtable+0x58
inline virtual void operator-=(const Vector2& p_other); // vtable+0x54
inline virtual void operator*=(const float* p_other); // vtable+0x64
inline virtual void operator*=(const Vector2& p_other); // vtable+0x60
inline virtual void operator*=(const float& p_value); // vtable+0x5c
inline virtual void operator/=(const float& p_value); // vtable+0x68
inline virtual void operator=(const float* p_other); // vtable+0x70
inline virtual void operator=(const Vector2& p_other); // vtable+0x6c
// SYNTHETIC: LEGO1 0x10010be0
// SYNTHETIC: BETA10 0x100121e0
@ -178,26 +59,28 @@ public:
// SYNTHETIC: BETA10 0x1004af40
// Vector4::operator=
Vector2& operator=(const Vector2& p_other)
{
Vector2::SetVector(p_other);
return *this;
}
// FUNCTION: BETA10 0x1001d140
float& operator[](int idx) { return m_data[idx]; }
// FUNCTION: BETA10 0x1001d170
const float& operator[](int idx) const { return m_data[idx]; }
protected:
float* m_data; // 0x04
};
// VTABLE: LEGO1 0x100d4518
// VTABLE: BETA10 0x101b8398
// SIZE 0x08
class Vector3 : public Vector2 {
protected:
inline void AddImpl(const float* p_value) override; // vtable+0x04
inline void AddImpl(float p_value) override; // vtable+0x00
inline void SubImpl(const float* p_value) override; // vtable+0x08
inline void MulImpl(const float* p_value) override; // vtable+0x10
inline void MulImpl(const float& p_value) override; // vtable+0x0c
inline void DivImpl(const float& p_value) override; // vtable+0x14
inline float DotImpl(const float* p_a, const float* p_b) const override; // vtable+0x18
inline void EqualsImpl(const float* p_data) override; // vtable+0x20
inline virtual void EqualsCrossImpl(const float* p_a, const float* p_b); // vtable+0x74
public:
// FUNCTION: LEGO1 0x1001d150
// FUNCTION: BETA10 0x10011660
@ -209,111 +92,14 @@ public:
// initialization with a const source fundamentally incompatible.
// FUNCTION: BETA10 0x100109a0
Vector3(const float* p_data) : Vector2((float*) p_data) {}
Vector3(const float* p_data) : Vector2(p_data) {}
// Note: virtual function overloads appear in the virtual table
// in reverse order of appearance.
// FUNCTION: LEGO1 0x10002270
// FUNCTION: BETA10 0x10011350
virtual void EqualsCrossImpl(const float* p_a, const float* p_b)
{
m_data[0] = p_a[1] * p_b[2] - p_a[2] * p_b[1];
m_data[1] = p_a[2] * p_b[0] - p_a[0] * p_b[2];
m_data[2] = p_a[0] * p_b[1] - p_a[1] * p_b[0];
} // vtable+0x74
// FUNCTION: LEGO1 0x100022c0
// FUNCTION: BETA10 0x10011430
virtual void EqualsCross(const Vector3& p_a, const Vector3& p_b)
{
EqualsCrossImpl(p_a.m_data, p_b.m_data);
} // vtable+0x80
// FUNCTION: LEGO1 0x100022e0
virtual void EqualsCross(const Vector3& p_a, const float* p_b) { EqualsCrossImpl(p_a.m_data, p_b); } // vtable+0x7c
// FUNCTION: LEGO1 0x10002300
virtual void EqualsCross(const float* p_a, const Vector3& p_b) { EqualsCrossImpl(p_a, p_b.m_data); } // vtable+0x78
// FUNCTION: LEGO1 0x10003bf0
virtual void Fill(const float& p_value)
{
m_data[0] = p_value;
m_data[1] = p_value;
m_data[2] = p_value;
} // vtable+0x84
// Vector2 overrides
// FUNCTION: LEGO1 0x10003a60
void AddImpl(const float* p_value) override
{
m_data[0] += p_value[0];
m_data[1] += p_value[1];
m_data[2] += p_value[2];
} // vtable+0x04
// FUNCTION: LEGO1 0x10003a90
void AddImpl(float p_value) override
{
m_data[0] += p_value;
m_data[1] += p_value;
m_data[2] += p_value;
} // vtable+0x00
// FUNCTION: LEGO1 0x10003ac0
void SubImpl(const float* p_value) override
{
m_data[0] -= p_value[0];
m_data[1] -= p_value[1];
m_data[2] -= p_value[2];
} // vtable+0x08
// FUNCTION: LEGO1 0x10003af0
void MulImpl(const float* p_value) override
{
m_data[0] *= p_value[0];
m_data[1] *= p_value[1];
m_data[2] *= p_value[2];
} // vtable+0x10
// FUNCTION: LEGO1 0x10003b20
void MulImpl(const float& p_value) override
{
m_data[0] *= p_value;
m_data[1] *= p_value;
m_data[2] *= p_value;
} // vtable+0x0c
// FUNCTION: LEGO1 0x10003b50
void DivImpl(const float& p_value) override
{
m_data[0] /= p_value;
m_data[1] /= p_value;
m_data[2] /= p_value;
} // vtable+0x14
// FUNCTION: LEGO1 0x10003b80
float DotImpl(const float* p_a, const float* p_b) const override
{
return p_a[0] * p_b[0] + p_a[2] * p_b[2] + p_a[1] * p_b[1];
} // vtable+0x18
// FUNCTION: LEGO1 0x10003ba0
// FUNCTION: BETA10 0x100113f0
void EqualsImpl(const float* p_data) override { memcpy(m_data, p_data, sizeof(float) * 3); } // vtable+0x20
// FUNCTION: LEGO1 0x10003bc0
// FUNCTION: BETA10 0x100114f0
void Clear() override { memset(m_data, 0, sizeof(float) * 3); } // vtable+0x2c
// FUNCTION: LEGO1 0x10003bd0
// FUNCTION: BETA10 0x10011530
float LenSquared() const override
{
return m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2];
} // vtable+0x40
inline void Clear() override; // vtable+0x2c
inline float LenSquared() const override; // vtable+0x40
inline virtual void EqualsCross(const Vector3& p_a, const Vector3& p_b); // vtable+0x80
inline virtual void EqualsCross(const Vector3& p_a, const float* p_b); // vtable+0x7c
inline virtual void EqualsCross(const float* p_a, const Vector3& p_b); // vtable+0x78
inline virtual void Fill(const float& p_value); // vtable+0x84
friend class Mx3DPointFloat;
};
@ -322,6 +108,16 @@ public:
// VTABLE: BETA10 0x101bac38
// SIZE 0x08
class Vector4 : public Vector3 {
protected:
inline void AddImpl(const float* p_value) override; // vtable+0x04
inline void AddImpl(float p_value) override; // vtable+0x00
inline void SubImpl(const float* p_value) override; // vtable+0x08
inline void MulImpl(const float* p_value) override; // vtable+0x10
inline void MulImpl(const float& p_value) override; // vtable+0x0c
inline void DivImpl(const float& p_value) override; // vtable+0x14
inline float DotImpl(const float* p_a, const float* p_b) const override; // vtable+0x18
inline void EqualsImpl(const float* p_data) override; // vtable+0x20
public:
// FUNCTION: BETA10 0x10048780
Vector4(float* p_data) : Vector3(p_data) {}
@ -334,112 +130,16 @@ public:
// supporting the theory that this decompilation is correct.
// FUNCTION: BETA10 0x100701b0
Vector4(const float* p_data) : Vector3((float*) p_data) {}
// Note: virtual function overloads appear in the virtual table
// in reverse order of appearance.
// FUNCTION: LEGO1 0x10002a40
virtual void SetMatrixProduct(const float* p_vec, const float* p_mat)
{
m_data[0] = p_vec[0] * p_mat[0] + p_vec[1] * p_mat[4] + p_vec[2] * p_mat[8] + p_vec[3] * p_mat[12];
m_data[1] = p_vec[0] * p_mat[1] + p_vec[1] * p_mat[5] + p_vec[2] * p_mat[9] + p_vec[4] * p_mat[13];
m_data[2] = p_vec[0] * p_mat[2] + p_vec[1] * p_mat[6] + p_vec[2] * p_mat[10] + p_vec[4] * p_mat[14];
m_data[3] = p_vec[0] * p_mat[3] + p_vec[1] * p_mat[7] + p_vec[2] * p_mat[11] + p_vec[4] * p_mat[15];
} // vtable+0x8c
// FUNCTION: LEGO1 0x10002ae0
virtual void SetMatrixProduct(const Vector4& p_a, const float* p_b)
{
SetMatrixProduct(p_a.m_data, p_b);
} // vtable+0x88
Vector4(const float* p_data) : Vector3(p_data) {}
inline void Clear() override; // vtable+0x2c
inline float LenSquared() const override; // vtable+0x40
inline void Fill(const float& p_value) override; // vtable+0x84
inline virtual void SetMatrixProduct(const float* p_vec, const float* p_mat); // vtable+0x8c
inline virtual void SetMatrixProduct(const Vector4& p_a, const float* p_b); // vtable+0x88
inline virtual int NormalizeQuaternion(); // vtable+0x90
inline virtual int EqualsHamiltonProduct(const Vector4& p_a, const Vector4& p_b); // vtable+0x94
// Vector3 overrides
// FUNCTION: LEGO1 0x10002870
void AddImpl(const float* p_value) override
{
m_data[0] += p_value[0];
m_data[1] += p_value[1];
m_data[2] += p_value[2];
m_data[3] += p_value[3];
} // vtable+0x04
// FUNCTION: LEGO1 0x100028b0
void AddImpl(float p_value) override
{
m_data[0] += p_value;
m_data[1] += p_value;
m_data[2] += p_value;
m_data[3] += p_value;
} // vtable+0x00
// FUNCTION: LEGO1 0x100028f0
void SubImpl(const float* p_value) override
{
m_data[0] -= p_value[0];
m_data[1] -= p_value[1];
m_data[2] -= p_value[2];
m_data[3] -= p_value[3];
} // vtable+0x08
// FUNCTION: LEGO1 0x10002930
void MulImpl(const float* p_value) override
{
m_data[0] *= p_value[0];
m_data[1] *= p_value[1];
m_data[2] *= p_value[2];
m_data[3] *= p_value[3];
} // vtable+0x10
// FUNCTION: LEGO1 0x10002970
void MulImpl(const float& p_value) override
{
m_data[0] *= p_value;
m_data[1] *= p_value;
m_data[2] *= p_value;
m_data[3] *= p_value;
} // vtable+0x0c
// FUNCTION: LEGO1 0x100029b0
void DivImpl(const float& p_value) override
{
m_data[0] /= p_value;
m_data[1] /= p_value;
m_data[2] /= p_value;
m_data[3] /= p_value;
} // vtable+0x14
// FUNCTION: LEGO1 0x100029f0
float DotImpl(const float* p_a, const float* p_b) const override
{
return p_a[0] * p_b[0] + p_a[2] * p_b[2] + (p_a[1] * p_b[1] + p_a[3] * p_b[3]);
} // vtable+0x18
// FUNCTION: LEGO1 0x10002a20
void EqualsImpl(const float* p_data) override { memcpy(m_data, p_data, sizeof(float) * 4); } // vtable+0x20
// FUNCTION: LEGO1 0x10002b00
void Clear() override { memset(m_data, 0, sizeof(float) * 4); } // vtable+0x2c
// FUNCTION: LEGO1 0x10002b20
float LenSquared() const override
{
return m_data[1] * m_data[1] + m_data[0] * m_data[0] + m_data[2] * m_data[2] + m_data[3] * m_data[3];
} // vtable+0x40
// FUNCTION: LEGO1 0x10002b40
void Fill(const float& p_value) override
{
m_data[0] = p_value;
m_data[1] = p_value;
m_data[2] = p_value;
m_data[3] = p_value;
} // vtable+0x84
float& operator[](int idx) { return m_data[idx]; }
// FUNCTION: BETA10 0x10010890
@ -448,41 +148,4 @@ public:
friend class Mx4DPointFloat;
};
// FUNCTION: LEGO1 0x10002b70
// FUNCTION: BETA10 0x10048ad0
inline int Vector4::NormalizeQuaternion()
{
float length = m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2];
if (length > 0.0f) {
float theta = m_data[3] * 0.5f;
float magnitude = sin((double) theta);
m_data[3] = cos((double) theta);
magnitude = magnitude / (float) sqrt((double) length);
m_data[0] *= magnitude;
m_data[1] *= magnitude;
m_data[2] *= magnitude;
return 0;
}
else {
return -1;
}
}
// FUNCTION: LEGO1 0x10002bf0
// FUNCTION: BETA10 0x10048c20
inline int Vector4::EqualsHamiltonProduct(const Vector4& p_a, const Vector4& p_b)
{
m_data[3] = p_a.m_data[3] * p_b.m_data[3] -
(p_a.m_data[0] * p_b.m_data[0] + p_a.m_data[2] * p_b.m_data[2] + p_a.m_data[1] * p_b.m_data[1]);
Vector3::EqualsCrossImpl(p_a.m_data, p_b.m_data);
m_data[0] = p_b.m_data[3] * p_a.m_data[0] + p_a.m_data[3] * p_b.m_data[0] + m_data[0];
m_data[1] = p_b.m_data[1] * p_a.m_data[3] + p_a.m_data[1] * p_b.m_data[3] + m_data[1];
m_data[2] = p_b.m_data[2] * p_a.m_data[3] + p_a.m_data[2] * p_b.m_data[3] + m_data[2];
return 0;
}
#endif // VECTOR_H

View file

@ -0,0 +1,203 @@
#ifndef VECTOR2D_H
#define VECTOR2D_H
#include "vector.h"
#include <math.h>
#include <memory.h>
// FUNCTION: LEGO1 0x10001f80
void Vector2::AddImpl(const float* p_value)
{
m_data[0] += p_value[0];
m_data[1] += p_value[1];
}
// FUNCTION: LEGO1 0x10001fa0
void Vector2::AddImpl(float p_value)
{
m_data[0] += p_value;
m_data[1] += p_value;
}
// FUNCTION: LEGO1 0x10001fc0
void Vector2::SubImpl(const float* p_value)
{
m_data[0] -= p_value[0];
m_data[1] -= p_value[1];
}
// FUNCTION: LEGO1 0x10001fe0
void Vector2::MulImpl(const float* p_value)
{
m_data[0] *= p_value[0];
m_data[1] *= p_value[1];
}
// FUNCTION: LEGO1 0x10002000
void Vector2::MulImpl(const float& p_value)
{
m_data[0] *= p_value;
m_data[1] *= p_value;
}
// FUNCTION: LEGO1 0x10002020
void Vector2::DivImpl(const float& p_value)
{
m_data[0] /= p_value;
m_data[1] /= p_value;
}
// FUNCTION: LEGO1 0x10002040
float Vector2::DotImpl(const float* p_a, const float* p_b) const
{
return p_b[0] * p_a[0] + p_b[1] * p_a[1];
}
// FUNCTION: LEGO1 0x10002060
// FUNCTION: BETA10 0x10010c90
void Vector2::SetData(float* p_data)
{
m_data = p_data;
}
// FUNCTION: LEGO1 0x10002070
void Vector2::EqualsImpl(const float* p_data)
{
memcpy(m_data, p_data, sizeof(float) * 2);
}
// FUNCTION: LEGO1 0x10002090
float* Vector2::GetData()
{
return m_data;
}
// FUNCTION: LEGO1 0x100020a0
const float* Vector2::GetData() const
{
return m_data;
}
// FUNCTION: LEGO1 0x100020b0
void Vector2::Clear()
{
memset(m_data, 0, sizeof(float) * 2);
}
// FUNCTION: LEGO1 0x100020d0
float Vector2::Dot(const float* p_a, const float* p_b) const
{
return DotImpl(p_a, p_b);
}
// FUNCTION: LEGO1 0x100020f0
// FUNCTION: BETA10 0x100108c0
float Vector2::Dot(const Vector2& p_a, const Vector2& p_b) const
{
return DotImpl(p_a.m_data, p_b.m_data);
}
// FUNCTION: LEGO1 0x10002110
float Vector2::Dot(const float* p_a, const Vector2& p_b) const
{
return DotImpl(p_a, p_b.m_data);
}
// FUNCTION: LEGO1 0x10002130
float Vector2::Dot(const Vector2& p_a, const float* p_b) const
{
return DotImpl(p_a.m_data, p_b);
}
// FUNCTION: LEGO1 0x10002150
float Vector2::LenSquared() const
{
return m_data[0] * m_data[0] + m_data[1] * m_data[1];
}
// FUNCTION: LEGO1 0x10002160
// FUNCTION: BETA10 0x10010900
int Vector2::Unitize()
{
float sq = LenSquared();
if (sq > 0.0f) {
float root = sqrt(sq);
if (root > 0.0f) {
DivImpl(root);
return 0;
}
}
return -1;
}
// FUNCTION: LEGO1 0x100021c0
void Vector2::operator+=(float p_value)
{
AddImpl(p_value);
}
// FUNCTION: LEGO1 0x100021d0
void Vector2::operator+=(const float* p_other)
{
AddImpl(p_other);
}
// FUNCTION: LEGO1 0x100021e0
void Vector2::operator+=(const Vector2& p_other)
{
AddImpl(p_other.m_data);
}
// FUNCTION: LEGO1 0x100021f0
void Vector2::operator-=(const float* p_other)
{
SubImpl(p_other);
}
// FUNCTION: LEGO1 0x10002200
void Vector2::operator-=(const Vector2& p_other)
{
SubImpl(p_other.m_data);
}
// FUNCTION: LEGO1 0x10002210
void Vector2::operator*=(const float* p_other)
{
MulImpl(p_other);
}
// FUNCTION: LEGO1 0x10002220
void Vector2::operator*=(const Vector2& p_other)
{
MulImpl(p_other.m_data);
}
// FUNCTION: LEGO1 0x10002230
void Vector2::operator*=(const float& p_value)
{
MulImpl(p_value);
}
// FUNCTION: LEGO1 0x10002240
void Vector2::operator/=(const float& p_value)
{
DivImpl(p_value);
}
// FUNCTION: LEGO1 0x10002250
void Vector2::operator=(const float* p_other)
{
EqualsImpl(p_other);
}
// FUNCTION: LEGO1 0x10002260
// FUNCTION: BETA10 0x100110c0
void Vector2::operator=(const Vector2& p_other)
{
EqualsImpl(p_other.m_data);
}
#endif // VECTOR2D_H

View file

@ -0,0 +1,117 @@
#ifndef VECTOR3D_H
#define VECTOR3D_H
#include "vector2d.inl.h"
// FUNCTION: LEGO1 0x10002270
// FUNCTION: BETA10 0x10011350
void Vector3::EqualsCrossImpl(const float* p_a, const float* p_b)
{
m_data[0] = p_a[1] * p_b[2] - p_a[2] * p_b[1];
m_data[1] = p_a[2] * p_b[0] - p_a[0] * p_b[2];
m_data[2] = p_a[0] * p_b[1] - p_a[1] * p_b[0];
}
// FUNCTION: LEGO1 0x100022c0
// FUNCTION: BETA10 0x10011430
void Vector3::EqualsCross(const Vector3& p_a, const Vector3& p_b)
{
EqualsCrossImpl(p_a.m_data, p_b.m_data);
}
// FUNCTION: LEGO1 0x100022e0
void Vector3::EqualsCross(const Vector3& p_a, const float* p_b)
{
EqualsCrossImpl(p_a.m_data, p_b);
}
// FUNCTION: LEGO1 0x10002300
void Vector3::EqualsCross(const float* p_a, const Vector3& p_b)
{
EqualsCrossImpl(p_a, p_b.m_data);
}
// FUNCTION: LEGO1 0x10003a60
void Vector3::AddImpl(const float* p_value)
{
m_data[0] += p_value[0];
m_data[1] += p_value[1];
m_data[2] += p_value[2];
}
// FUNCTION: LEGO1 0x10003a90
void Vector3::AddImpl(float p_value)
{
m_data[0] += p_value;
m_data[1] += p_value;
m_data[2] += p_value;
}
// FUNCTION: LEGO1 0x10003ac0
void Vector3::SubImpl(const float* p_value)
{
m_data[0] -= p_value[0];
m_data[1] -= p_value[1];
m_data[2] -= p_value[2];
}
// FUNCTION: LEGO1 0x10003af0
void Vector3::MulImpl(const float* p_value)
{
m_data[0] *= p_value[0];
m_data[1] *= p_value[1];
m_data[2] *= p_value[2];
}
// FUNCTION: LEGO1 0x10003b20
void Vector3::MulImpl(const float& p_value)
{
m_data[0] *= p_value;
m_data[1] *= p_value;
m_data[2] *= p_value;
}
// FUNCTION: LEGO1 0x10003b50
void Vector3::DivImpl(const float& p_value)
{
m_data[0] /= p_value;
m_data[1] /= p_value;
m_data[2] /= p_value;
}
// FUNCTION: LEGO1 0x10003b80
float Vector3::DotImpl(const float* p_a, const float* p_b) const
{
return p_a[0] * p_b[0] + p_a[2] * p_b[2] + p_a[1] * p_b[1];
}
// FUNCTION: LEGO1 0x10003ba0
// FUNCTION: BETA10 0x100113f0
void Vector3::EqualsImpl(const float* p_data)
{
memcpy(m_data, p_data, sizeof(float) * 3);
}
// FUNCTION: LEGO1 0x10003bc0
// FUNCTION: BETA10 0x100114f0
void Vector3::Clear()
{
memset(m_data, 0, sizeof(float) * 3);
}
// FUNCTION: LEGO1 0x10003bd0
// FUNCTION: BETA10 0x10011530
float Vector3::LenSquared() const
{
return m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2];
}
// FUNCTION: LEGO1 0x10003bf0
void Vector3::Fill(const float& p_value)
{
m_data[0] = p_value;
m_data[1] = p_value;
m_data[2] = p_value;
}
#endif // VECTOR3D_H

View file

@ -0,0 +1,145 @@
#ifndef VECTOR4D_H
#define VECTOR4D_H
#include "vector.h"
// FUNCTION: LEGO1 0x10002870
void Vector4::AddImpl(const float* p_value)
{
m_data[0] += p_value[0];
m_data[1] += p_value[1];
m_data[2] += p_value[2];
m_data[3] += p_value[3];
}
// FUNCTION: LEGO1 0x100028b0
void Vector4::AddImpl(float p_value)
{
m_data[0] += p_value;
m_data[1] += p_value;
m_data[2] += p_value;
m_data[3] += p_value;
}
// FUNCTION: LEGO1 0x100028f0
void Vector4::SubImpl(const float* p_value)
{
m_data[0] -= p_value[0];
m_data[1] -= p_value[1];
m_data[2] -= p_value[2];
m_data[3] -= p_value[3];
}
// FUNCTION: LEGO1 0x10002930
void Vector4::MulImpl(const float* p_value)
{
m_data[0] *= p_value[0];
m_data[1] *= p_value[1];
m_data[2] *= p_value[2];
m_data[3] *= p_value[3];
}
// FUNCTION: LEGO1 0x10002970
void Vector4::MulImpl(const float& p_value)
{
m_data[0] *= p_value;
m_data[1] *= p_value;
m_data[2] *= p_value;
m_data[3] *= p_value;
}
// FUNCTION: LEGO1 0x100029b0
void Vector4::DivImpl(const float& p_value)
{
m_data[0] /= p_value;
m_data[1] /= p_value;
m_data[2] /= p_value;
m_data[3] /= p_value;
}
// FUNCTION: LEGO1 0x100029f0
float Vector4::DotImpl(const float* p_a, const float* p_b) const
{
return p_a[0] * p_b[0] + p_a[2] * p_b[2] + (p_a[1] * p_b[1] + p_a[3] * p_b[3]);
}
// FUNCTION: LEGO1 0x10002a20
void Vector4::EqualsImpl(const float* p_data)
{
memcpy(m_data, p_data, sizeof(float) * 4);
}
// FUNCTION: LEGO1 0x10002a40
void Vector4::SetMatrixProduct(const float* p_vec, const float* p_mat)
{
m_data[0] = p_vec[0] * p_mat[0] + p_vec[1] * p_mat[4] + p_vec[2] * p_mat[8] + p_vec[3] * p_mat[12];
m_data[1] = p_vec[0] * p_mat[1] + p_vec[1] * p_mat[5] + p_vec[2] * p_mat[9] + p_vec[4] * p_mat[13];
m_data[2] = p_vec[0] * p_mat[2] + p_vec[1] * p_mat[6] + p_vec[2] * p_mat[10] + p_vec[4] * p_mat[14];
m_data[3] = p_vec[0] * p_mat[3] + p_vec[1] * p_mat[7] + p_vec[2] * p_mat[11] + p_vec[4] * p_mat[15];
}
// FUNCTION: LEGO1 0x10002ae0
void Vector4::SetMatrixProduct(const Vector4& p_a, const float* p_b)
{
SetMatrixProduct(p_a.m_data, p_b);
}
// FUNCTION: LEGO1 0x10002b00
void Vector4::Clear()
{
memset(m_data, 0, sizeof(float) * 4);
}
// FUNCTION: LEGO1 0x10002b20
float Vector4::LenSquared() const
{
return m_data[1] * m_data[1] + m_data[0] * m_data[0] + m_data[2] * m_data[2] + m_data[3] * m_data[3];
}
// FUNCTION: LEGO1 0x10002b40
void Vector4::Fill(const float& p_value)
{
m_data[0] = p_value;
m_data[1] = p_value;
m_data[2] = p_value;
m_data[3] = p_value;
}
// FUNCTION: LEGO1 0x10002b70
// FUNCTION: BETA10 0x10048ad0
int Vector4::NormalizeQuaternion()
{
float length = m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2];
if (length > 0.0f) {
float theta = m_data[3] * 0.5f;
float magnitude = sin((double) theta);
m_data[3] = cos((double) theta);
magnitude = magnitude / (float) sqrt((double) length);
m_data[0] *= magnitude;
m_data[1] *= magnitude;
m_data[2] *= magnitude;
return 0;
}
else {
return -1;
}
}
// FUNCTION: LEGO1 0x10002bf0
// FUNCTION: BETA10 0x10048c20
int Vector4::EqualsHamiltonProduct(const Vector4& p_a, const Vector4& p_b)
{
m_data[3] = p_a.m_data[3] * p_b.m_data[3] -
(p_a.m_data[0] * p_b.m_data[0] + p_a.m_data[2] * p_b.m_data[2] + p_a.m_data[1] * p_b.m_data[1]);
Vector3::EqualsCrossImpl(p_a.m_data, p_b.m_data);
m_data[0] = p_b.m_data[3] * p_a.m_data[0] + p_a.m_data[3] * p_b.m_data[0] + m_data[0];
m_data[1] = p_b.m_data[1] * p_a.m_data[3] + p_a.m_data[1] * p_b.m_data[3] + m_data[1];
m_data[2] = p_b.m_data[2] * p_a.m_data[3] + p_a.m_data[2] * p_b.m_data[3] + m_data[2];
return 0;
}
#endif // VECTOR4D_H