diff --git a/indra/newview/app_settings/settings_per_account_alchemy.xml b/indra/newview/app_settings/settings_per_account_alchemy.xml index 1601d9744729a6f1699b7d19afbdf588931a4a14..5da79d1731460e483e1bdd94effbe75d0bb9ac55 100644 --- a/indra/newview/app_settings/settings_per_account_alchemy.xml +++ b/indra/newview/app_settings/settings_per_account_alchemy.xml @@ -66,5 +66,46 @@ <key>Value</key> <real>0.5</real> </map> + <key>ALStoredCameraPos</key> + <map> + <key>Comment</key> + <string>Stored camera position in camera tools</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Vector3D</string> + <key>Value</key> + <array> + <real>0.0</real> + <real>0.0</real> + <real>0.0</real> + </array> + </map> + <key>ALStoredCameraFocus</key> + <map> + <key>Comment</key> + <string>Stored camera focus position in camera tools</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Vector3D</string> + <key>Value</key> + <array> + <real>0.0</real> + <real>0.0</real> + <real>0.0</real> + </array> + </map> + <key>ALStoredCameraFocusObjectId</key> + <map> + <key>Comment</key> + <string>Stored object ID of camera focus in camera tools</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>String</string> + <key>Value</key> + <string /> + </map> </map> -</llsd> +</llsd> \ No newline at end of file diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index c2cb41961d3cee91cc493f368f5d00f0cd02c0cb..25731591b54aa1c690257679457b01b39692c0ca 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -55,6 +55,7 @@ #include "rlvactions.h" #include "rlvhandler.h" // [/RLVa:KB] +#include "llnotificationsutil.h" using namespace LLAvatarAppearanceDefines; @@ -3199,6 +3200,57 @@ S32 LLAgentCamera::directionToKey(S32 direction) return 0; } +void LLAgentCamera::storeCameraPosition() +{ + gSavedPerAccountSettings.setVector3d("ALStoredCameraPos", getCameraPositionGlobal()); + + // 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("ALStoredCameraFocus", forward); + + LLUUID stored_camera_focus_object_id = LLUUID::null; + if (mFocusObject) + { + stored_camera_focus_object_id = mFocusObject->getID(); + } + gSavedPerAccountSettings.setString("ALStoredCameraFocusObjectId", stored_camera_focus_object_id.asString()); +} + +void LLAgentCamera::loadCameraPosition() +{ + LLVector3d stored_camera_pos = gSavedPerAccountSettings.getVector3d("ALStoredCameraPos"); + LLVector3d stored_camera_focus = gSavedPerAccountSettings.getVector3d("ALStoredCameraFocus"); + LLUUID stored_camera_focus_object_id = LLUUID(gSavedPerAccountSettings.getString("ALStoredCameraFocusObjectId")); + + F32 renderFarClip = gSavedSettings.getF32("RenderFarClip"); + F32 far_clip_squared = renderFarClip * renderFarClip; + + if (stored_camera_pos.isNull()) + { + LLNotificationsUtil::add("LoadCameraPositionNoneSaved", LLSD()); + return; + } + + if (dist_vec_squared(gAgent.getPositionGlobal(), stored_camera_pos) > far_clip_squared) + { + LLNotificationsUtil::add("LoadCameraPositionOutsideDrawDistance", LLSD()); + 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); +} // EOF diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index c9d471a309695a761bdc7fe2866cf38bdc3fe7a0..0ee26a66ad84c5b6b8f73b48bc6226b39ee305c4 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -448,6 +448,9 @@ class LLAgentCamera /** Keys ** ** *******************************************************************************/ +public: + void storeCameraPosition(); + void loadCameraPosition(); }; extern LLAgentCamera gAgentCamera; diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 988a7d48bdad8e5435784ed153dc50bf8b0b42c6..450b942b291ee1bbbb4a81878130341acd9f6235 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -356,6 +356,9 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2)); mCommitCallbackRegistrar.add("CameraPresets.Save", boost::bind(&LLFloaterCamera::onSavePreset, this)); mCommitCallbackRegistrar.add("CameraPresets.ShowPresetsList", boost::bind(&LLFloaterReg::showInstance, "camera_presets", LLSD(), FALSE)); + + mCommitCallbackRegistrar.add("Camera.SavePosition", [](LLUICtrl* ctrl, const LLSD& param) { gAgentCamera.storeCameraPosition(); }); + mCommitCallbackRegistrar.add("Camera.RestorePosition", [](LLUICtrl* ctrl, const LLSD& param) { gAgentCamera.loadCameraPosition(); }); } // virtual @@ -647,5 +650,5 @@ void LLFloaterCamera::collapse() BOOL collapse = gSavedSettings.getBOOL("AlchemyCameraExpanded"); mBtnCollapse->setImageOverlay(collapse ? "Conv_toolbar_collapse" : "Conv_toolbar_expand"); getChild<LLPanel>("buttons_panel")->setVisible(collapse); - reshape(collapse ? 362 : 210, getRect().getHeight(), FALSE); + reshape(collapse ? 370 : 210, getRect().getHeight(), FALSE); } diff --git a/indra/newview/skins/default/textures/icons/Cam_Recall.png b/indra/newview/skins/default/textures/icons/Cam_Recall.png new file mode 100644 index 0000000000000000000000000000000000000000..dd183e19012c81235350be65730d3a95ef6f363f Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Cam_Recall.png differ diff --git a/indra/newview/skins/default/textures/icons/Cam_Save.png b/indra/newview/skins/default/textures/icons/Cam_Save.png new file mode 100644 index 0000000000000000000000000000000000000000..ba56b6f275d1074b6499ac0df544bd728d9046eb Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Cam_Save.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 7a3289d4906118a65929a1b6b0dedf643bfbf443..27dff8b3ee4e9cbf0485848a3974e2c6ceecc749 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -952,4 +952,7 @@ with the same filename but different name <texture name="social_discord" file_name="alchemy/discord_32.png" preload="false" /> <texture name="social_mastodon" file_name="alchemy/mastodon_32.png" preload="false" /> + + <texture name="Cam_Recall" file_name="icons/Cam_Recall.png"/> + <texture name="Cam_Save" file_name="icons/Cam_Save.png"/> </textures> diff --git a/indra/newview/skins/default/textures/toolbar_icons/view.png b/indra/newview/skins/default/textures/toolbar_icons/view.png index ddf0df7c26fd9a54a44eb77cc27878aacc3df5b8..d1af6880ef5ab2a47c55f2d53cefa34dad75a4b1 100644 Binary files a/indra/newview/skins/default/textures/toolbar_icons/view.png and b/indra/newview/skins/default/textures/toolbar_icons/view.png differ diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml index 65e959a4963a87ed6ec8c6bf341aa920956bfe7b..25de9dd84e6d2da4ea42dec4950bdb318e7bc227 100644 --- a/indra/newview/skins/default/xui/en/floater_camera.xml +++ b/indra/newview/skins/default/xui/en/floater_camera.xml @@ -68,14 +68,14 @@ label="" layout="topleft" left_delta="0" - image_overlay="Icon_Gear" - name="gear_btn" + image_overlay="Cam_Save" + name="save_cam_pos_btn" tab_stop="false" - tool_tip="My Camera Presets" + tool_tip="Save current camera position and focus" top_pad="0" width="23"> <button.commit_callback - function="CameraPresets.ShowPresetsList"/> + function="Camera.SavePosition"/> </button> <button height="28" @@ -83,15 +83,14 @@ layout="topleft" top_pad="0" left_delta="0" - image_overlay="PanOrbit_Off" - name="pan_btn" + image_overlay="Cam_Recall" + name="restore_cam_pos_btn" tab_stop="false" tool_tip="Use precise controls" width="23"> <button.commit_callback - function="Floater.Toggle" - parameter="prefs_view_advanced"/> - </button> + function="Camera.RestorePosition"/> + </button> </panel> <panel border="false" @@ -275,6 +274,19 @@ name="Use preset" value="default" /> </combo_box> + <button + height="18" + width="18" + layout="topleft" + mouse_opaque="true" + name="gear_btn" + tool_tip="Save current camera position and focus" + top_delta="2" + left_pad="5" + image_overlay="Icon_Gear"> + <button.commit_callback + function="CameraPresets.ShowPresetsList"/> + </button> <button follows="top|left" height="23" @@ -287,5 +299,19 @@ <button.commit_callback function="CameraPresets.Save"/> </button> + <button + height="18" + width="18" + layout="topleft" + mouse_opaque="true" + name="pan_btn" + tool_tip="Use precise controls" + top_delta="2" + left_pad="5" + image_overlay="PanOrbit_Off"> + <button.commit_callback + function="Floater.Toggle" + parameter="prefs_view_advanced"/> + </button> </panel> </floater>