From f95037e929db34dc62c3cbfd5569e9afb582679f Mon Sep 17 00:00:00 2001 From: Zi Ree Date: Wed, 8 Jun 2022 14:08:26 +0200 Subject: [PATCH] FIRE-31719 - Fix storing camera position and focus while in flycam mode --- indra/newview/llagentcamera.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index b8a7bb482b..d376cb8beb 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -3266,7 +3266,13 @@ S32 LLAgentCamera::directionToKey(S32 direction) void LLAgentCamera::storeCameraPosition() { gSavedPerAccountSettings.setVector3d("FSStoredCameraPos", getCameraPositionGlobal()); - gSavedPerAccountSettings.setVector3d("FSStoredCameraFocus", getFocusTargetGlobal()); + + // get a vector pointing forward from the camera view manually, getFocusTargetGlobal() will + // not return useful values if the camera is in flycam mode or was just switched out of + // flycam mode and not repositioned after + LLVector3d forward = LLVector3d(1.0, 0.0, 0.0) * LLViewerCamera::getInstance()->getQuaternion() + getCameraPositionGlobal(); + gSavedPerAccountSettings.setVector3d("FSStoredCameraFocus", forward); + LLUUID stored_camera_focus_object_id = LLUUID::null; if (mFocusObject) { @@ -3296,6 +3302,15 @@ void LLAgentCamera::loadCameraPosition() return; } + // switch off flycam mode if needed + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + handle_toggle_flycam(); + + // exiting from flycam usually keeps the camera where it is but here we want it to actually move + LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); + } + unlockView(); setCameraPosAndFocusGlobal(stored_camera_pos, stored_camera_focus, stored_camera_focus_object_id); }