Skip to content

Commit

Permalink
Match Helicopter::HandleEndAnim
Browse files Browse the repository at this point in the history
  • Loading branch information
foxtacles committed Dec 25, 2024
1 parent 0f338a8 commit daf87f5
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 58 deletions.
5 changes: 0 additions & 5 deletions LEGO1/lego/legoomni/include/helicopter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,9 @@ class HelicopterState : public LegoState {
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
};

Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/include/legoworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class LegoWorld : public LegoEntity {
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; }
Expand Down
57 changes: 28 additions & 29 deletions LEGO1/lego/legoomni/src/actors/helicopter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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);
Expand Down Expand Up @@ -238,19 +238,19 @@ 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;
location += lookat;

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);

Expand Down Expand Up @@ -295,14 +295,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,
Expand All @@ -317,25 +320,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: {
Expand All @@ -344,10 +339,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,
Expand All @@ -362,13 +361,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
Expand Down Expand Up @@ -414,7 +413,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) {
Expand Down Expand Up @@ -445,7 +444,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;

Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/src/common/legoutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,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
Expand Down
22 changes: 11 additions & 11 deletions LEGO1/lego/legoomni/src/entity/legoentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,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)
Expand All @@ -72,10 +72,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);
}
}

Expand Down Expand Up @@ -193,8 +193,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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/src/paths/legopathactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions LEGO1/lego/legoomni/src/race/legoracers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,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);
Expand Down
8 changes: 4 additions & 4 deletions LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,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());
Expand All @@ -650,7 +650,7 @@ void LegoAnimPresenter::PutFrame()

up = und;

up -= m_currentWorld->GetCamera()->GetWorldLocation();
up -= m_currentWorld->GetCameraController()->GetWorldLocation();
dir /= dirsqr;
pos.EqualsCross(dir, up);
pos.Unitize();
Expand Down Expand Up @@ -930,8 +930,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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions LEGO1/lego/legoomni/src/video/legoloopinganimpresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down

0 comments on commit daf87f5

Please sign in to comment.