Merge pull request from foxtacles/merge-isle-2

Merge from isledecomp/isle
This commit is contained in:
Christian Semmler 2024-12-27 10:57:13 -07:00 committed by GitHub
commit 4457f94153
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 1998 additions and 1974 deletions

View file

@ -38,14 +38,9 @@ public:
return TRUE;
} // vtable+0x18
void SetUnknown8(MxU32 p_unk0x08) { m_unk0x08 = p_unk0x08; }
MxU32 GetUnkown8() { return m_unk0x08; }
// SYNTHETIC: LEGO1 0x1000e190
// HelicopterState::`scalar deleting destructor'
// TODO: Most likely getters/setters are not used according to BETA.
MxU32 m_unk0x08; // 0x08
};

View file

@ -12,7 +12,18 @@ public:
m_name = p_name;
m_list = p_list;
}
~LegoNamedPart() { delete m_list; }
~LegoNamedPart()
{
LegoLODListCursor cursor(m_list);
LegoLOD* lod;
while (cursor.First(lod)) {
cursor.Detach();
delete lod;
}
delete m_list;
}
const MxString* GetName() const { return &m_name; }
LegoLODList* GetList() { return m_list; }

View file

@ -102,7 +102,7 @@ public:
MxCore* Find(const MxAtomId& p_atom, MxS32 p_entityId);
// FUNCTION: BETA10 0x1002b4f0
LegoCameraController* GetCamera() { return m_cameraController; }
LegoCameraController* GetCameraController() { return m_cameraController; }
LegoEntityList* GetEntityList() { return m_entityList; }
LegoOmni::World GetWorldId() { return m_worldId; }

View file

@ -444,6 +444,8 @@ MxS32 Act2Actor::VTable0xa0()
{
undefined4 newLocation;
assert(!m_grec);
CurrentWorld();
MxU16 randomVal = rand() / (RAND_MAX / 2) + 1;

View file

@ -30,6 +30,7 @@ DECOMP_SIZE_ASSERT(Matrix4, 0x08)
DECOMP_SIZE_ASSERT(MxMatrix, 0x48)
// FUNCTION: LEGO1 0x10001e60
// FUNCTION: BETA10 0x1002a0d0
Helicopter::Helicopter()
{
m_maxLinearVel = 60;
@ -43,6 +44,7 @@ Helicopter::~Helicopter()
}
// FUNCTION: LEGO1 0x100032c0
// FUNCTION: BETA10 0x1002a16d
MxResult Helicopter::Create(MxDSAction& p_dsAction)
{
MxResult result = IslePathActor::Create(p_dsAction);
@ -52,6 +54,8 @@ MxResult Helicopter::Create(MxDSAction& p_dsAction)
((Act3*) m_world)->SetHelicopter(this);
}
assert(m_world);
if (m_world != NULL) {
m_world->Add(this);
}
@ -61,6 +65,7 @@ MxResult Helicopter::Create(MxDSAction& p_dsAction)
}
// FUNCTION: LEGO1 0x10003320
// FUNCTION: BETA10 0x1002a240
void Helicopter::CreateState()
{
m_state = (HelicopterState*) GameState()->GetState("HelicopterState");
@ -70,8 +75,11 @@ void Helicopter::CreateState()
}
// FUNCTION: LEGO1 0x10003360
// FUNCTION: BETA10 0x1002a29a
void Helicopter::Exit()
{
assert(UserActor() == this);
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
SpawnPlayer(
LegoGameState::e_unk40,
@ -94,7 +102,7 @@ void Helicopter::Exit()
}
}
m_state->SetUnknown8(0);
m_state->m_unk0x08 = 0;
RemoveFromCurrentWorld(m_script, IsleScript::c_HelicopterDashboard_Bitmap);
RemoveFromCurrentWorld(m_script, IsleScript::c_HelicopterArms_Ctl);
RemoveFromCurrentWorld(m_script, IsleScript::c_Helicopter_TakeOff_Ctl);
@ -110,6 +118,7 @@ void Helicopter::Exit()
}
// FUNCTION: LEGO1 0x10003480
// FUNCTION: BETA10 0x1002a3db
MxLong Helicopter::HandleClick()
{
if (!FUN_1003ef60()) {
@ -118,6 +127,7 @@ MxLong Helicopter::HandleClick()
if (!m_world) {
m_world = CurrentWorld();
assert(m_world);
}
AnimationManager()->FUN_1005f6d0(FALSE);
@ -163,6 +173,8 @@ MxLong Helicopter::HandleClick()
MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
{
MxLong result = 0;
assert(m_world);
MxAtomId script;
switch (GameState()->GetCurrentAct()) {
@ -199,9 +211,10 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
break;
}
Act1State* state = (Act1State*) GameState()->GetState("Act1State");
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
assert(act1State);
if (m_state->m_unk0x08 == 0) {
state->m_unk0x018 = 4;
act1State->m_unk0x018 = 4;
m_state->m_unk0x08 = 1;
m_world->RemoveActor(this);
InvokeAction(Extra::ActionType::e_start, script, IsleScript::c_HelicopterTakeOff_Anim, NULL);
@ -238,11 +251,11 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
assert(m_pathController);
if (m_world && m_world->GetCamera()) {
if (m_world && m_world->GetCameraController()) {
Mx3DPointFloat location, direction, lookat;
location = m_world->GetCamera()->GetWorldLocation();
direction = m_world->GetCamera()->GetWorldDirection();
location = m_world->GetCameraController()->GetWorldLocation();
direction = m_world->GetCameraController()->GetWorldDirection();
lookat = direction;
lookat *= 3.0f;
@ -250,7 +263,7 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
Mx3DPointFloat v68, va4, up;
Mx3DPointFloat v90(0, 1, 0);
v68 = m_world->GetCamera()->GetWorldUp();
v68 = m_world->GetCameraController()->GetWorldUp();
va4.EqualsCross(v68, direction);
up.EqualsCross(va4, v90);
@ -295,14 +308,17 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
}
// FUNCTION: LEGO1 0x10003c20
// FUNCTION: BETA10 0x1002ab4c
MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
{
MxU32 ret = 0;
MxLong result = 0;
switch (m_state->GetUnkown8()) {
switch (m_state->m_unk0x08) {
case 1: {
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(4);
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
assert(act1State);
act1State->m_unk0x018 = 4;
SpawnPlayer(
LegoGameState::e_unk42,
TRUE,
@ -317,25 +333,17 @@ MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
);
}
m_state->SetUnknown8(2);
m_state->m_unk0x08 = 2;
MxMatrix matrix;
matrix.SetIdentity();
float s = sin(0.5235987901687622); // PI / 6, 30 deg
float c = cos(0.5235987901687622); // PI / 6, 30 deg
float matrixCopy[4][4];
memcpy(matrixCopy, matrix.GetData(), sizeof(matrixCopy));
for (MxS32 i = 0; i < 4; i++) {
matrix.GetData()[i][1] = matrixCopy[i][1] * c - matrixCopy[i][2] * s;
matrix.GetData()[i][2] = matrixCopy[i][2] * c + matrixCopy[i][1] * s;
}
matrix.RotateX(0.5235987901687622); // PI / 6, 30 deg
Vector3 at(matrix[3]), dir(matrix[2]), up(matrix[1]);
m_world->GetCamera()->SetWorldTransform(at, dir, up);
assert(m_world && m_world->GetCameraController());
m_world->GetCameraController()->SetWorldTransform(at, dir, up);
FUN_10010c30();
ret = 1;
result = 1;
break;
}
case 3: {
@ -344,10 +352,14 @@ MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
Vector3 at(matrix[3]), dir(matrix[2]), up(matrix[1]);
at[1] = 1.25;
m_world->GetCamera()->SetWorldTransform(at, dir, up);
assert(m_world && m_world->GetCameraController());
m_world->GetCameraController()->SetWorldTransform(at, dir, up);
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(0);
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
assert(act1State);
act1State->m_unk0x018 = 0;
SpawnPlayer(
LegoGameState::e_unk41,
TRUE,
@ -362,13 +374,13 @@ MxLong Helicopter::HandleEndAnim(LegoEndAnimNotificationParam& p_param)
);
}
m_state->SetUnknown8(0);
ret = 1;
m_state->m_unk0x08 = 0;
result = 1;
break;
}
}
return ret;
return result;
}
// FUNCTION: LEGO1 0x10003e90
@ -414,7 +426,7 @@ void Helicopter::Animate(float p_time)
v2 *= f2;
v2 += v1;
m_world->GetCamera()->FUN_100123e0(mat, 0);
m_world->GetCameraController()->FUN_100123e0(mat, 0);
}
else {
if (m_state->m_unk0x08 == 4) {
@ -424,7 +436,7 @@ void Helicopter::Animate(float p_time)
((Act3*) m_world)->FUN_10073430();
}
LegoPathActor::m_actorState = c_disabled;
SetActorState(c_disabled);
}
}
else {
@ -445,7 +457,7 @@ void Helicopter::FUN_100042a0(const Matrix4& p_matrix)
Vector3 vec5(m_unk0x1a8[2]); // EDI
Vector3 vec6(m_unk0x1a8[3]); // locala0 // esp+0x28
m_world->GetCamera()->FUN_100123b0(local48);
m_world->GetCameraController()->FUN_100123b0(local48);
m_unk0x1a8.SetIdentity();
local90 = p_matrix;

View file

@ -8,88 +8,88 @@ DECOMP_SIZE_ASSERT(LegoActorLOD, 0x58)
// GLOBAL: LEGO1 0x100da3b0
LegoActorLOD g_actorLODs[] = {
{"top", "top", 0, 0.000267, 0.780808, -0.01906, 0.951612, -0.461166, -0.002794, -0.299442, 0.4617,
1.56441, 0.261321, 0, 0, 0, 0, 0, 1, 0, 1, 0},
{"body", "body", LegoActorLOD::c_flag1,
0.00158332, 0.401828, -0.00048697,
0.408071, -0.287507, 0.150419,
-0.147452, 0.289219, 0.649774,
0.14258, -0.00089, 0.436353,
0.007277, 0, 0,
1, 0, 1,
0},
{"infohat", "infohat", LegoActorLOD::c_flag2,
0, -0.00938, -0.01955,
0.35, -0.231822, -0.140237,
-0.320954, 0.234149, 0.076968,
0.249083, 0.000191, 1.519793,
0.001767, 0, 0,
1, 0, 1,
0},
{"top", "top", 0, 0.000267f, 0.780808f, -0.01906f, 0.951612f, -0.461166f, -0.002794f, -0.299442f, 0.4617f,
1.56441f, 0.261321f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f},
{"body", "body", LegoActorLOD::c_flag1,
0.00158332f, 0.401828f, -0.00048697f,
0.408071f, -0.287507f, 0.150419f,
-0.147452f, 0.289219f, 0.649774f,
0.14258f, -0.00089f, 0.436353f,
0.007277f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f},
{"infohat", "infohat", LegoActorLOD::c_flag2,
0.0f, -0.00938f, -0.01955f,
0.35f, -0.231822f, -0.140237f,
-0.320954f, 0.234149f, 0.076968f,
0.249083f, 0.000191f, 1.519793f,
0.001767f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f},
{"infogron", "infogron", LegoActorLOD::c_flag2,
0, 0.11477, 0.00042,
0.26, -0.285558, -0.134391,
-0.142231, 0.285507, 0.152986,
0.143071, -0.00089, 0.436353,
0.007277, 0, 0,
1, 0, 1,
0},
{"head", "head", LegoActorLOD::c_flag1,
0, -0.03006, 0,
0.3, -0.189506, -0.209665,
-0.189824, 0.189532, 0.228822,
0.194945, -0.00105, 1.293115,
0.001781, 0, 0,
1, 0, 1,
0},
{"arm-lft", "arm-lft", LegoActorLOD::c_flag2,
-0.06815, -0.0973747, 0.0154655,
0.237, -0.137931, -0.282775,
-0.105316, 0.000989, 0.100221,
0.140759, -0.225678, 0.963312,
0.023286, -0.003031, -0.017187,
0.999848, 0.173622, 0.984658,
0.017453},
{"arm-rt", "arm-rt", LegoActorLOD::c_flag2,
0.0680946, -0.097152, 0.0152722,
0.237, 0.00141, -0.289604,
-0.100831, 0.138786, 0.09291,
0.145437, 0.223494, 0.963583,
0.018302, 0, 0,
1, -0.173648, 0.984808,
0},
{"claw-lft", "claw-lft", LegoActorLOD::c_flag2,
0.000773381, -0.101422, -0.0237761,
0.15, -0.089838, -0.246208,
-0.117735, 0.091275, 0.000263,
0.07215, -0.341869, 0.700355,
0.092779, 0.000001, 0.000003,
1, 0.190812, 0.981627,
-0.000003},
{"claw-rt", "claw-lft", LegoActorLOD::c_flag2,
0.000773381, -0.101422, -0.0237761,
0.15, -0.095016, -0.245349,
-0.117979, 0.086528, 0.00067,
0.069743, 0.343317, 0.69924,
0.096123, 0.00606, -0.034369,
0.999391, -0.190704, 0.981027,
0.034894},
{"leg-lft", "leg", LegoActorLOD::c_flag2,
0.00433584, -0.177404, -0.0313928,
0.33, -0.129782, -0.440428,
-0.184207, 0.13817, 0.118415,
0.122607, -0.156339, 0.436087,
0.006822, 0, 0,
1, 0, 1,
0},
{"leg-rt", "leg", LegoActorLOD::c_flag2,
0.00433584, -0.177404, -0.0313928,
0.33, -0.132864, -0.437138,
-0.183944, 0.134614, 0.12043,
0.121888, 0.151154, 0.436296,
0.007373, 0, 0,
1, 0, 1,
0}
0.0f, 0.11477f, 0.00042f,
0.26f, -0.285558f, -0.134391f,
-0.142231f, 0.285507f, 0.152986f,
0.143071f, -0.00089f, 0.436353f,
0.007277f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f},
{"head", "head", LegoActorLOD::c_flag1,
0.0f, -0.03006f, 0.0f,
0.3f, -0.189506f, -0.209665f,
-0.189824f, 0.189532f, 0.228822f,
0.194945f, -0.00105f, 1.293115f,
0.001781f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f},
{"arm-lft", "arm-lft", LegoActorLOD::c_flag2,
-0.06815f, -0.0973747f, 0.0154655f,
0.237f, -0.137931f, -0.282775f,
-0.105316f, 0.000989f, 0.100221f,
0.140759f, -0.225678f, 0.963312f,
0.023286f, -0.003031f, -0.017187f,
0.999848f, 0.173622f, 0.984658f,
0.017453f},
{"arm-rt", "arm-rt", LegoActorLOD::c_flag2,
0.0680946f, -0.097152f, 0.0152722f,
0.237f, 0.00141f, -0.289604f,
-0.100831f, 0.138786f, 0.09291f,
0.145437f, 0.223494f, 0.963583f,
0.018302f, 0.0f, 0.0f,
1.0f, -0.173648f, 0.984808f,
0.0f},
{"claw-lft", "claw-lft", LegoActorLOD::c_flag2,
0.000773381f, -0.101422f, -0.0237761f,
0.15f, -0.089838f, -0.246208f,
-0.117735f, 0.091275f, 0.000263f,
0.07215f, -0.341869f, 0.700355f,
0.092779f, 0.000001f, 0.000003f,
1.0f, 0.190812f, 0.981627f,
-0.000003f},
{"claw-rt", "claw-lft", LegoActorLOD::c_flag2,
0.000773381f, -0.101422f, -0.0237761f,
0.15f, -0.095016f, -0.245349f,
-0.117979f, 0.086528f, 0.00067f,
0.069743f, 0.343317f, 0.69924f,
0.096123f, 0.00606f, -0.034369f,
0.999391f, -0.190704f, 0.981027f,
0.034894f},
{"leg-lft", "leg", LegoActorLOD::c_flag2,
0.00433584f, -0.177404f, -0.0313928f,
0.33f, -0.129782f, -0.440428f,
-0.184207f, 0.13817f, 0.118415f,
0.122607f, -0.156339f, 0.436087f,
0.006822f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f},
{"leg-rt", "leg", LegoActorLOD::c_flag2,
0.00433584f, -0.177404f, -0.0313928f,
0.33f, -0.132864f, -0.437138f,
-0.183944f, 0.134614f, 0.12043f,
0.121888f, 0.151154f, 0.436296f,
0.007373f, 0.0f, 0.0f,
1.0f, 0.0f, 1.0f,
0.0f}
};
// GLOBAL: LEGO1 0x100da778

File diff suppressed because it is too large Load diff

View file

@ -386,7 +386,7 @@ void NotifyEntity(const char* p_filename, MxS32 p_entityId, LegoEntity* p_sender
// FUNCTION: LEGO1 0x1003eab0
void SetCameraControllerFromIsle()
{
InputManager()->SetCamera(FindWorld(*g_isleScript, IsleScript::c__Isle)->GetCamera());
InputManager()->SetCamera(FindWorld(*g_isleScript, IsleScript::c__Isle)->GetCameraController());
}
// FUNCTION: LEGO1 0x1003eae0

View file

@ -56,7 +56,8 @@ MxResult MxTransitionManager::GetDDrawSurfaceFromVideoManager() // vtable+0x14
// FUNCTION: LEGO1 0x1004bac0
MxResult MxTransitionManager::Tickle()
{
if (m_animationSpeed + m_systemTime > SDL_GetTicks()) {
Uint64 time = m_animationSpeed + m_systemTime;
if (time > SDL_GetTicks()) {
return SUCCESS;
}

View file

@ -44,21 +44,21 @@ void LegoEntity::ResetWorldTransform(MxBool p_cameraFlag)
{
LegoWorld* world = CurrentWorld();
if (world != NULL && world->GetCamera() != NULL) {
if (world != NULL && world->GetCameraController() != NULL) {
m_cameraFlag = p_cameraFlag;
if (m_cameraFlag) {
world->GetCamera()->SetEntity(this);
world->GetCamera()->SetWorldTransform(
world->GetCameraController()->SetEntity(this);
world->GetCameraController()->SetWorldTransform(
Mx3DPointFloat(0.0F, 1.25F, 0.0F),
Mx3DPointFloat(0.0F, 0.0F, 1.0F),
Mx3DPointFloat(0.0F, 1.0F, 0.0F)
);
}
else {
if (world->GetCamera()->GetEntity() == this) {
world->GetCamera()->SetEntity(NULL);
world->GetCamera()->SetWorldTransform(
if (world->GetCameraController()->GetEntity() == this) {
world->GetCameraController()->SetEntity(NULL);
world->GetCameraController()->SetWorldTransform(
Mx3DPointFloat(0.0F, 0.0F, 0.0F),
Mx3DPointFloat(0.0F, 0.0F, 1.0F),
Mx3DPointFloat(0.0F, 1.0F, 0.0F)
@ -74,10 +74,10 @@ void LegoEntity::SetWorldTransform(const Vector3& p_location, const Vector3& p_d
{
LegoWorld* world = CurrentWorld();
if (world != NULL && world->GetCamera() != NULL) {
if (world != NULL && world->GetCameraController() != NULL) {
m_cameraFlag = TRUE;
world->GetCamera()->SetEntity(this);
world->GetCamera()->SetWorldTransform(p_location, p_direction, p_up);
world->GetCameraController()->SetEntity(this);
world->GetCameraController()->SetWorldTransform(p_location, p_direction, p_up);
}
}
@ -195,8 +195,8 @@ void LegoEntity::FUN_10010c30()
{
LegoWorld* world = CurrentWorld();
if (m_cameraFlag && world && world->GetCamera() && m_roi) {
world->GetCamera()->FUN_100123e0(m_roi->GetLocal2World(), 1);
if (m_cameraFlag && world && world->GetCameraController() && m_roi) {
world->GetCameraController()->FUN_100123e0(m_roi->GetLocal2World(), 1);
}
}

File diff suppressed because it is too large Load diff

View file

@ -541,8 +541,8 @@ MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und)
if (povPosition >= 0) {
LegoWorld* world = CurrentWorld();
if (world && world->GetCamera()) {
world->GetCamera()->FUN_10012320(DTOR(povPosition));
if (world && world->GetCameraController()) {
world->GetCameraController()->FUN_10012320(DTOR(povPosition));
p_und = TRUE;
}
}

View file

@ -183,6 +183,7 @@ void LegoAnimActor::ClearMaps()
}
// FUNCTION: LEGO1 0x1001c870
// FUNCTION: BETA10 0x1003e7e4
void LegoAnimActor::SetWorldSpeed(MxFloat p_worldSpeed)
{
if (p_worldSpeed < 0) {

View file

@ -414,7 +414,7 @@ void LegoPathActor::Animate(float p_time)
LegoWorld* world = CurrentWorld();
if (world) {
world->GetCamera()->FUN_10012290(DTOR(m_unk0x14c));
world->GetCameraController()->FUN_10012290(DTOR(m_unk0x14c));
}
}
}

View file

@ -343,8 +343,8 @@ void LegoRaceCar::FUN_10012ff0(float p_param)
// Possible bug in the original code: The first argument is not initialized
a->GetAnimTreePtr()->GetCamAnim()->FUN_1009f490(deltaTime, transformationMatrix);
if (r->GetCamera()) {
r->GetCamera()->FUN_100123e0(transformationMatrix, 0);
if (r->GetCameraController()) {
r->GetCameraController()->FUN_100123e0(transformationMatrix, 0);
}
m_roi->FUN_100a58f0(transformationMatrix);

View file

@ -637,7 +637,7 @@ void LegoAnimPresenter::PutFrame()
FUN_1006b9a0(m_anim, time, m_unk0x78);
if (m_unk0x8c != NULL && m_currentWorld != NULL && m_currentWorld->GetCamera() != NULL) {
if (m_unk0x8c != NULL && m_currentWorld != NULL && m_currentWorld->GetCameraController() != NULL) {
for (MxS32 i = 0; i < m_unk0x94; i++) {
if (m_unk0x8c[i] != NULL) {
MxMatrix mat(m_unk0x8c[i]->GetLocal2World());
@ -653,7 +653,7 @@ void LegoAnimPresenter::PutFrame()
up = und;
up -= m_currentWorld->GetCamera()->GetWorldLocation();
up -= m_currentWorld->GetCameraController()->GetWorldLocation();
dir /= dirsqr;
pos.EqualsCross(dir, up);
pos.Unitize();
@ -719,7 +719,7 @@ MxResult LegoAnimPresenter::FUN_1006b140(LegoROI* p_roi)
for (i = 1; i <= m_roiMapSize; i++) {
if (m_roiMap[i] == p_roi) {
if (local5c[i].Unknown(local58) != SUCCESS) {
if (local5c[i].BETA_1005a590(local58) != SUCCESS) {
goto done;
}
@ -933,8 +933,8 @@ void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, Matrix4* p
MxMatrix transform(mat);
p_anim->GetCamAnim()->FUN_1009f490(p_time, transform);
if (m_currentWorld != NULL && m_currentWorld->GetCamera() != NULL) {
m_currentWorld->GetCamera()->FUN_100123e0(transform, 0);
if (m_currentWorld != NULL && m_currentWorld->GetCameraController() != NULL) {
m_currentWorld->GetCameraController()->FUN_100123e0(transform, 0);
}
}

View file

@ -50,7 +50,7 @@ void LegoLoopingAnimPresenter::PutFrame()
FUN_1006b9a0(m_anim, time, m_unk0x78);
if (m_unk0x8c != NULL && m_currentWorld != NULL && m_currentWorld->GetCamera() != NULL) {
if (m_unk0x8c != NULL && m_currentWorld != NULL && m_currentWorld->GetCameraController() != NULL) {
for (MxS32 i = 0; i < m_unk0x94; i++) {
if (m_unk0x8c[i] != NULL) {
MxMatrix mat(m_unk0x8c[i]->GetLocal2World());
@ -66,7 +66,7 @@ void LegoLoopingAnimPresenter::PutFrame()
up = und;
up -= m_currentWorld->GetCamera()->GetWorldLocation();
up -= m_currentWorld->GetCameraController()->GetWorldLocation();
dir /= dirsqr;
pos.EqualsCross(dir, up);
pos.Unitize();

View file

@ -138,7 +138,7 @@ public:
const char* data = p_str.GetData();
LegoU32 fullLength = strlen(data);
LegoU16 limitedLength = fullLength;
LegoU16 limitedLength = (LegoU16) fullLength;
Write(&limitedLength, sizeof(limitedLength));
Write((char*) data, (LegoS16) fullLength);

View file

@ -675,6 +675,9 @@
// LIBRARY: BETA10 0x100f9a50
// _sin
// LIBRARY: BETA10 0x100f9a5a
// _cos
// LIBRARY: BETA10 0x100f95d0
// _sqrt

View file

@ -164,9 +164,8 @@ inline int UnknownMx4DPointFloat::BETA_1004aaa0(Matrix4& p_matrix, float p_f)
if (FUN_100040a0(v, p_f) == 0) {
return p_matrix.FromQuaternion(v);
}
else {
return -1;
}
return -1;
}
// FUNCTION: LEGO1 0x10004520
@ -198,15 +197,17 @@ inline int UnknownMx4DPointFloat::FUN_100040a0(Vector4& p_v, float p_f)
{
if (m_unk0x30 == c_bit1) {
p_v = m_unk0x00;
p_v[3] = (1.0 - p_f) * acos((double) p_v[3]) * 2.0;
p_v[3] = (float) ((1.0 - p_f) * acos((double) p_v[3]) * 2.0);
return p_v.NormalizeQuaternion();
}
else if (m_unk0x30 == c_bit2) {
if (m_unk0x30 == c_bit2) {
p_v = m_unk0x18;
p_v[3] = p_f * acos((double) p_v[3]) * 2.0;
p_v[3] = (float) (p_f * acos((double) p_v[3]) * 2.0);
return p_v.NormalizeQuaternion();
}
else if (m_unk0x30 == (c_bit1 | c_bit2)) {
if (m_unk0x30 == (c_bit1 | c_bit2)) {
int i;
double d1 = p_v.Dot(m_unk0x00, m_unk0x18);
double a;
@ -225,7 +226,7 @@ inline int UnknownMx4DPointFloat::FUN_100040a0(Vector4& p_v, float p_f)
}
for (i = 0; i < 4; i++) {
p_v[i] = m_unk0x00[i] * a + m_unk0x18[i] * b;
p_v[i] = (float) (m_unk0x00[i] * a + m_unk0x18[i] * b);
}
}
else {
@ -237,15 +238,14 @@ inline int UnknownMx4DPointFloat::FUN_100040a0(Vector4& p_v, float p_f)
b = sin(p_f * 1.570796326794895);
for (i = 0; i < 3; i++) {
p_v[i] = m_unk0x00[i] * a + p_v[i] * b;
p_v[i] = (float) (m_unk0x00[i] * a + p_v[i] * b);
}
}
return 0;
}
else {
return -1;
}
return -1;
}
#endif // MXGEOMETRY3D_H

View file

@ -179,7 +179,7 @@ public:
}
}
inline int Unknown(Matrix4& p_mat);
inline int BETA_1005a590(Matrix4& p_mat);
// FUNCTION: LEGO1 0x1006b500
void Swap(int p_d1, int p_d2)
@ -202,9 +202,11 @@ protected:
// FUNCTION: BETA10 0x100101c0
inline void Matrix4::ToQuaternion(Vector4& p_outQuat)
{
float trace = m_data[0][0] + m_data[1][1] + m_data[2][2];
if (trace > 0) {
trace = sqrt(trace + 1.0);
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;
@ -212,7 +214,6 @@ inline void Matrix4::ToQuaternion(Vector4& p_outQuat)
p_outQuat[2] = (m_data[1][0] - m_data[0][1]) * trace;
}
else {
// GLOBAL: LEGO1 0x100d4090
static int rotateIndex[] = {1, 2, 0};
@ -228,7 +229,7 @@ inline void Matrix4::ToQuaternion(Vector4& p_outQuat)
int next = rotateIndex[largest];
int nextNext = rotateIndex[next];
float trace = sqrt(*Element(largest, largest) - (*Element(nextNext, nextNext) + *Element(next, next)) + 1.0);
trace = (float) sqrt(*Element(largest, largest) - (*Element(nextNext, nextNext) + *Element(next, next)) + 1.0);
p_outQuat[largest] = trace * 0.5f;
trace = 0.5f / trace;
@ -243,55 +244,56 @@ inline void Matrix4::ToQuaternion(Vector4& p_outQuat)
// FUNCTION: BETA10 0x10010550
inline int Matrix4::FromQuaternion(const Vector4& p_vec)
{
float len = p_vec.LenSquared();
float local14 = p_vec.LenSquared();
if (len > 0.0f) {
float v7 = 2.0f / len;
if (local14 > 0.0f) {
local14 = 2.0f / local14;
float v9 = p_vec[0] * v7;
float v11 = p_vec[1] * v7;
float v12 = p_vec[2] * v7;
float local24 = p_vec[0] * local14;
float local34 = p_vec[1] * local14;
float local10 = p_vec[2] * local14;
float v13 = p_vec[3] * v9;
float v14 = p_vec[3] * v11;
float v16 = p_vec[3] * v12;
float local28 = p_vec[3] * local24;
float local2c = p_vec[3] * local34;
float local30 = p_vec[3] * local10;
float v17 = p_vec[0] * v9;
float v22 = p_vec[0] * v11;
float v23 = p_vec[0] * v12;
float local38 = p_vec[0] * local24;
float local8 = p_vec[0] * local34;
float localc = p_vec[0] * local10;
float v18 = p_vec[1] * v11;
float v24 = p_vec[1] * v12;
float v19 = p_vec[2] * v12;
float local18 = p_vec[1] * local34;
float local1c = p_vec[1] * local10;
float local20 = p_vec[2] * local10;
m_data[0][0] = 1.0f - (v18 + v19);
m_data[1][0] = v22 + v16;
m_data[2][0] = v23 - v14;
m_data[0][0] = 1.0f - (local18 + local20);
m_data[1][0] = local8 + local30;
m_data[2][0] = localc - local2c;
m_data[0][1] = v22 - v16;
m_data[1][1] = 1.0f - (v17 + v19);
m_data[2][1] = v24 + v13;
m_data[0][1] = local8 - local30;
m_data[1][1] = 1.0f - (local38 + local20);
m_data[2][1] = local1c + local28;
m_data[0][2] = v14 + v23;
m_data[1][2] = v24 - v13;
m_data[2][2] = 1.0f - (v18 + v17);
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;
m_data[3][1] = 0;
m_data[3][2] = 0;
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;
m_data[1][3] = 0;
m_data[2][3] = 0;
m_data[0][3] = 0.0f;
m_data[1][3] = 0.0f;
m_data[2][3] = 0.0f;
return 0;
}
return -1;
else {
return -1;
}
}
// FUNCTION: BETA10 0x1005a590
inline int Matrix4::Unknown(Matrix4& p_mat)
inline int Matrix4::BETA_1005a590(Matrix4& p_mat)
{
float local5c[4][4];
Matrix4 localc(local5c);

View file

@ -121,35 +121,33 @@ public:
return -1;
} // vtable+0x44
private:
// FUNCTION: LEGO1 0x100021c0
virtual void Add(float p_value) { AddImpl(p_value); } // vtable+0x50
virtual void operator+=(float p_value) { AddImpl(p_value); } // vtable+0x50
// FUNCTION: LEGO1 0x100021d0
virtual void Add(const float* p_other) { AddImpl(p_other); } // vtable+0x4c
virtual void operator+=(const float* p_other) { AddImpl(p_other); } // vtable+0x4c
// FUNCTION: LEGO1 0x100021e0
virtual void Add(const Vector2& p_other) { AddImpl(p_other.m_data); } // vtable+0x48
virtual void operator+=(const Vector2& p_other) { AddImpl(p_other.m_data); } // vtable+0x48
// FUNCTION: LEGO1 0x100021f0
virtual void Sub(const float* p_other) { SubImpl(p_other); } // vtable+0x58
virtual void operator-=(const float* p_other) { SubImpl(p_other); } // vtable+0x58
// FUNCTION: LEGO1 0x10002200
virtual void Sub(const Vector2& p_other) { SubImpl(p_other.m_data); } // vtable+0x54
virtual void operator-=(const Vector2& p_other) { SubImpl(p_other.m_data); } // vtable+0x54
// FUNCTION: LEGO1 0x10002210
virtual void Mul(const float* p_other) { MulImpl(p_other); } // vtable+0x64
virtual void operator*=(const float* p_other) { MulImpl(p_other); } // vtable+0x64
// FUNCTION: LEGO1 0x10002220
virtual void Mul(const Vector2& p_other) { MulImpl(p_other.m_data); } // vtable+0x60
virtual void operator*=(const Vector2& p_other) { MulImpl(p_other.m_data); } // vtable+0x60
// FUNCTION: LEGO1 0x10002230
virtual void Mul(const float& p_value) { MulImpl(p_value); } // vtable+0x5c
virtual void operator*=(const float& p_value) { MulImpl(p_value); } // vtable+0x5c
// FUNCTION: LEGO1 0x10002240
virtual void Div(const float& p_value) { DivImpl(p_value); } // vtable+0x68
virtual void operator/=(const float& p_value) { DivImpl(p_value); } // vtable+0x68
public:
// FUNCTION: LEGO1 0x10002250
virtual void SetVector(const float* p_other) { EqualsImpl(p_other); } // vtable+0x70
@ -192,19 +190,6 @@ public:
// FUNCTION: BETA10 0x1001d170
const float& operator[](int idx) const { return m_data[idx]; }
void operator+=(float p_value) { Add(p_value); }
void operator+=(const float* p_other) { Add(p_other); }
void operator+=(const Vector2& p_other) { Add(p_other); }
void operator-=(const float* p_other) { Sub(p_other); }
void operator-=(const Vector2& p_other) { Sub(p_other); }
void operator*=(const float* p_other) { Mul(p_other); }
void operator*=(const Vector2& p_other) { Mul(p_other); }
void operator*=(const float& p_value) { Mul(p_value); }
void operator/=(const float& p_value) { Div(p_value); }
protected:
float* m_data; // 0x04
};
@ -467,38 +452,36 @@ public:
// FUNCTION: BETA10 0x10048ad0
inline int Vector4::NormalizeQuaternion()
{
float* v = m_data;
float magnitude = v[0] * v[0] + v[2] * v[2] + v[1] * v[1];
if (magnitude > 0.0f) {
float theta = v[3] * 0.5f;
v[3] = cos(theta);
magnitude = sin(theta) / sqrt(magnitude);
Vector3::MulImpl(magnitude);
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;
}
return -1;
}
inline static float QuaternionProductScalarPart(const float* bDat, const float* aDat)
{
// We have no indication from the beta that this function exists,
// but it helps with the stack layout of Vector4::EqualsHamiltonProduct()
return aDat[3] * bDat[3] - (aDat[0] * bDat[0] + aDat[2] * bDat[2] + aDat[1] * bDat[1]);
else {
return -1;
}
}
// FUNCTION: LEGO1 0x10002bf0
// FUNCTION: BETA10 0x10048c20
inline int Vector4::EqualsHamiltonProduct(const Vector4& p_a, const Vector4& p_b)
{
m_data[3] = QuaternionProductScalarPart(p_a.m_data, p_b.m_data);
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;
}

View file

@ -10,15 +10,15 @@ namespace Tgl
namespace Constant
{
const float Pi = 3.14159265358979323846;
const double Pi = 3.14159265358979323846;
};
inline float DegreesToRadians(float degrees)
inline double DegreesToRadians(double degrees)
{
return Constant::Pi * (degrees / 180.0);
}
inline float RadiansToDegrees(float radians)
inline double RadiansToDegrees(double radians)
{
return (radians / Constant::Pi) * 180.0;
}