Clear unknowns in LegoNavController

This commit is contained in:
Fabian Neundorf 2026-01-13 22:08:47 +01:00
parent 600079215f
commit ac82c3bf1c
2 changed files with 54 additions and 54 deletions

View File

@ -44,7 +44,7 @@ class LegoNavController : public MxCore {
const Vector3& p_curDir, const Vector3& p_curDir,
Vector3& p_newPos, Vector3& p_newPos,
Vector3& p_newDir, Vector3& p_newDir,
const Vector3* p_und const Vector3* p_up
); );
static void GetDefaults( static void GetDefaults(
@ -126,7 +126,7 @@ class LegoNavController : public MxCore {
float CalculateNewTargetVel(int p_pos, int p_center, float p_max); float CalculateNewTargetVel(int p_pos, int p_center, float p_max);
float CalculateNewAccel(int p_pos, int p_center, float p_max, int p_min); float CalculateNewAccel(int p_pos, int p_center, float p_max, int p_min);
MxResult ProcessJoystickInput(MxBool& p_und); MxResult ProcessJoystickInput(MxBool& p_rotatedY);
MxResult ProcessKeyboardInput(); MxResult ProcessKeyboardInput();
int m_hMax; // 0x08 int m_hMax; // 0x08
@ -151,10 +151,10 @@ class LegoNavController : public MxCore {
MxBool m_useRotationalVel; // 0x54 MxBool m_useRotationalVel; // 0x54
MxTime m_lastTime; // 0x58 MxTime m_lastTime; // 0x58
MxBool m_trackDefault; // 0x5c MxBool m_trackDefault; // 0x5c
MxBool m_unk0x5d; // 0x5d MxBool m_keyPressed; // 0x5d
float m_unk0x60; // 0x60 float m_additionalHeightOffset; // 0x60
float m_unk0x64; // 0x64 float m_additionalScale; // 0x64
float m_unk0x68; // 0x68 float m_additionalRotationY; // 0x68
MxBool m_isAccelerating; // 0x6c MxBool m_isAccelerating; // 0x6c
// one copy of defaults (these can be set by App.) // one copy of defaults (these can be set by App.)

View File

@ -134,11 +134,11 @@ LegoNavController::LegoNavController()
m_linearAccel = 0.0f; m_linearAccel = 0.0f;
m_rotationalAccel = 0.0f; m_rotationalAccel = 0.0f;
m_trackDefault = FALSE; m_trackDefault = FALSE;
m_unk0x5d = FALSE; m_keyPressed = FALSE;
m_isAccelerating = FALSE; m_isAccelerating = FALSE;
m_unk0x64 = 0.0f; m_additionalScale = 0.0f;
m_unk0x68 = 0.0f; m_additionalRotationY = 0.0f;
m_unk0x60 = 0.0f; m_additionalHeightOffset = 0.0f;
m_lastTime = Timer()->GetTime(); m_lastTime = Timer()->GetTime();
@ -322,7 +322,7 @@ MxBool LegoNavController::CalculateNewPosDir(
const Vector3& p_curDir, const Vector3& p_curDir,
Vector3& p_newPos, Vector3& p_newPos,
Vector3& p_newDir, Vector3& p_newDir,
const Vector3* p_und const Vector3* p_up
) )
{ {
if (!g_isWorldActive) { if (!g_isWorldActive) {
@ -330,14 +330,14 @@ MxBool LegoNavController::CalculateNewPosDir(
} }
MxBool changed = FALSE; MxBool changed = FALSE;
MxBool und = FALSE; MxBool rotatedY = FALSE;
MxTime currentTime = Timer()->GetTime(); MxTime currentTime = Timer()->GetTime();
float deltaTime = (currentTime - m_lastTime) / 1000.0; float deltaTime = (currentTime - m_lastTime) / 1000.0;
m_lastTime = currentTime; m_lastTime = currentTime;
if (ProcessKeyboardInput() == FAILURE) { if (ProcessKeyboardInput() == FAILURE) {
ProcessJoystickInput(und); ProcessJoystickInput(rotatedY);
} }
if (m_useRotationalVel) { if (m_useRotationalVel) {
@ -349,7 +349,7 @@ MxBool LegoNavController::CalculateNewPosDir(
m_linearVel = CalculateNewVel(m_targetLinearVel, m_linearVel, m_linearAccel, deltaTime); m_linearVel = CalculateNewVel(m_targetLinearVel, m_linearVel, m_linearAccel, deltaTime);
if (und || (Abs(m_rotationalVel) > m_zeroThreshold) || (Abs(m_linearVel) > m_zeroThreshold)) { if (rotatedY || (Abs(m_rotationalVel) > m_zeroThreshold) || (Abs(m_linearVel) > m_zeroThreshold)) {
float rot_mat[3][3]; float rot_mat[3][3];
Mx3DPointFloat delta_pos, new_dir, new_pos; Mx3DPointFloat delta_pos, new_dir, new_pos;
@ -368,7 +368,7 @@ MxBool LegoNavController::CalculateNewPosDir(
delta_rad = DTOR(m_rotationalVel * m_rotSensitivity); delta_rad = DTOR(m_rotationalVel * m_rotSensitivity);
} }
if (p_und != NULL && (*p_und)[1] < 0.0f) { if (p_up != NULL && (*p_up)[1] < 0.0f) {
delta_rad = -delta_rad; delta_rad = -delta_rad;
} }
@ -381,7 +381,7 @@ MxBool LegoNavController::CalculateNewPosDir(
changed = TRUE; changed = TRUE;
} }
if (m_unk0x5d) { if (m_keyPressed) {
float rot_mat[3][3]; float rot_mat[3][3];
Mx3DPointFloat delta_pos, new_pos, new_dir; Mx3DPointFloat delta_pos, new_pos, new_dir;
@ -394,20 +394,20 @@ MxBool LegoNavController::CalculateNewPosDir(
SET3(new_dir, p_curDir); SET3(new_dir, p_curDir);
} }
if (m_unk0x64 != 0.0f) { if (m_additionalScale != 0.0f) {
delta_pos[0] = new_dir[0] * m_unk0x64; delta_pos[0] = new_dir[0] * m_additionalScale;
delta_pos[1] = new_dir[1] * m_unk0x64; delta_pos[1] = new_dir[1] * m_additionalScale;
delta_pos[2] = new_dir[2] * m_unk0x64; delta_pos[2] = new_dir[2] * m_additionalScale;
} }
else { else {
FILLVEC3(delta_pos, 0.0f); FILLVEC3(delta_pos, 0.0f);
} }
delta_pos[1] += m_unk0x60; delta_pos[1] += m_additionalHeightOffset;
VPV3(p_newPos, new_pos, delta_pos); VPV3(p_newPos, new_pos, delta_pos);
if (m_unk0x68 != 0.0f) { if (m_additionalRotationY != 0.0f) {
float delta_rad = DTOR(m_unk0x68); float delta_rad = DTOR(m_additionalRotationY);
IDENTMAT3(rot_mat); IDENTMAT3(rot_mat);
rot_mat[0][0] = rot_mat[2][2] = cos(delta_rad); rot_mat[0][0] = rot_mat[2][2] = cos(delta_rad);
rot_mat[0][2] = rot_mat[2][0] = sin(delta_rad); rot_mat[0][2] = rot_mat[2][0] = sin(delta_rad);
@ -418,8 +418,8 @@ MxBool LegoNavController::CalculateNewPosDir(
SET3(p_newDir, new_dir); SET3(p_newDir, new_dir);
} }
m_unk0x60 = m_unk0x64 = m_unk0x68 = 0.0f; m_additionalHeightOffset = m_additionalScale = m_additionalRotationY = 0.0f;
m_unk0x5d = FALSE; m_keyPressed = FALSE;
changed = TRUE; changed = TRUE;
} }
@ -515,7 +515,7 @@ MxS32 LegoNavController::GetNumLocations()
} }
// FUNCTION: LEGO1 0x10055750 // FUNCTION: LEGO1 0x10055750
MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und) MxResult LegoNavController::ProcessJoystickInput(MxBool& p_rotatedY)
{ {
LegoOmni* instance = LegoOmni::GetInstance(); LegoOmni* instance = LegoOmni::GetInstance();
@ -550,7 +550,7 @@ MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und)
if (world && world->GetCameraController()) { if (world && world->GetCameraController()) {
world->GetCameraController()->RotateY(DTOR(povPosition)); world->GetCameraController()->RotateY(DTOR(povPosition));
p_und = TRUE; p_rotatedY = TRUE;
} }
} }
@ -648,7 +648,7 @@ MxResult LegoNavController::ProcessKeyboardInput()
MxLong LegoNavController::Notify(MxParam& p_param) MxLong LegoNavController::Notify(MxParam& p_param)
{ {
if (((MxNotificationParam&) p_param).GetNotification() == c_notificationKeyPress) { if (((MxNotificationParam&) p_param).GetNotification() == c_notificationKeyPress) {
m_unk0x5d = TRUE; m_keyPressed = TRUE;
MxU8 key = ((LegoEventNotificationParam&) p_param).GetKey(); MxU8 key = ((LegoEventNotificationParam&) p_param).GetKey();
switch (key) { switch (key) {
@ -767,7 +767,7 @@ MxLong LegoNavController::Notify(MxParam& p_param)
g_fpsEnabled = TRUE; g_fpsEnabled = TRUE;
} }
default: default:
m_unk0x5d = FALSE; m_keyPressed = FALSE;
break; break;
case '0': case '0':
case '1': case '1':
@ -914,7 +914,7 @@ MxLong LegoNavController::Notify(MxParam& p_param)
g_locationCalcStep = 1; g_locationCalcStep = 1;
break; break;
case 'D': case 'D':
m_unk0x60 = -1.0; m_additionalHeightOffset = -1.0;
break; break;
case 'F': case 'F':
RealtimeView::SetUserMaxLOD(0.0); RealtimeView::SetUserMaxLOD(0.0);
@ -980,7 +980,7 @@ MxLong LegoNavController::Notify(MxParam& p_param)
BackgroundAudioManager()->Enable(g_enableMusic); BackgroundAudioManager()->Enable(g_enableMusic);
break; break;
case 'U': case 'U':
m_unk0x60 = 1.0; m_additionalHeightOffset = 1.0;
break; break;
case 'V': case 'V':
if (g_nextAnimation > 0 && g_animationCalcStep == 0) { if (g_nextAnimation > 0 && g_animationCalcStep == 0) {