From 4f546bc87e4de080fb6c549057f76f4d12e9f241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Mon, 28 Sep 2026 14:11:22 +0000 Subject: Fix Link being out of bounds while loading into scene on epona with spinning free cam (#7270) --- soh/soh/Enhancements/camera/FreeLook.cpp | 40 ++++++++++++++++++++++ .../Enhancements/camera/FreeLookDoorCamRelease.cpp | 28 --------------- 2 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 soh/soh/Enhancements/camera/FreeLook.cpp delete mode 100644 soh/soh/Enhancements/camera/FreeLookDoorCamRelease.cpp diff --git a/soh/soh/Enhancements/camera/FreeLook.cpp b/soh/soh/Enhancements/camera/FreeLook.cpp new file mode 100644 index 000000000..039073872 --- /dev/null +++ b/soh/soh/Enhancements/camera/FreeLook.cpp @@ -0,0 +1,40 @@ +#include + +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/controls/Mouse.h" +#include "soh/ShipInit.hpp" + +#include + +extern "C" { +#include "global.h" +#include "src/overlays/actors/ovl_En_Horse/z_en_horse.h" +} + +void RegisterFreeLookFixes() { + bool freeLook = CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0); + + COND_VB_SHOULD(VB_RELEASE_DOORC_CAMERA, freeLook, { + Camera* camera = va_arg(args, Camera*); + + // Also release the door peek camera when free look moves it, reusing SetCameraManual's threshold. + f32 freeLookX = -camera->play->state.input[0].cur.right_stick_x * 10.0f; + f32 freeLookY = camera->play->state.input[0].cur.right_stick_y * 10.0f; + Mouse_HandleThirdPerson(&freeLookX, &freeLookY); + + if (fabsf(freeLookX) >= 15.0f || fabsf(freeLookY) >= 15.0f) { + *should = true; + } + }); + + // EnHorse_Init sets riderPos as a world position instead of an offset, + // putting Link out of bounds until horse drawn. + COND_ID_HOOK(OnActorInit, ACTOR_EN_HORSE, freeLook, [](void* refActor) { + EnHorse* enHorse = reinterpret_cast(refActor); + enHorse->riderPos.x = 0.0f; + enHorse->riderPos.y = 70.0f; + enHorse->riderPos.z = 0.0f; + }); +} + +static RegisterShipInitFunc initFunc(RegisterFreeLookFixes, { CVAR_SETTING("FreeLook.Enabled") }); diff --git a/soh/soh/Enhancements/camera/FreeLookDoorCamRelease.cpp b/soh/soh/Enhancements/camera/FreeLookDoorCamRelease.cpp deleted file mode 100644 index 6eeb09757..000000000 --- a/soh/soh/Enhancements/camera/FreeLookDoorCamRelease.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -#include "soh/Enhancements/game-interactor/GameInteractor.h" -#include "soh/Enhancements/controls/Mouse.h" -#include "soh/ShipInit.hpp" - -#include - -extern "C" { -#include "global.h" -} - -void RegisterFreeLookDoorCamRelease() { - COND_VB_SHOULD(VB_RELEASE_DOORC_CAMERA, CVarGetInteger(CVAR_SETTING("FreeLook.Enabled"), 0), { - Camera* camera = va_arg(args, Camera*); - - // Also release the door peek camera when free look moves it, reusing SetCameraManual's threshold. - f32 freeLookX = -camera->play->state.input[0].cur.right_stick_x * 10.0f; - f32 freeLookY = camera->play->state.input[0].cur.right_stick_y * 10.0f; - Mouse_HandleThirdPerson(&freeLookX, &freeLookY); - - if (fabsf(freeLookX) >= 15.0f || fabsf(freeLookY) >= 15.0f) { - *should = true; - } - }); -} - -static RegisterShipInitFunc initFunc(RegisterFreeLookDoorCamRelease, { CVAR_SETTING("FreeLook.Enabled") }); -- cgit v1.2.3