From 5c4ae5b11a44ab4711f0148cb721f35be9f18100 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Thu, 23 Feb 2017 17:50:36 -0500 Subject: STORM-2145 Camera Presets -- some initial work --- indra/newview/llagentcamera.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index e335eabd1a..1b006a2311 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -208,10 +208,12 @@ void LLAgentCamera::init() mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView"); mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView"); mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView"); + mCameraOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("CameraOffsetCustom0"); mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView"); mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView"); mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView"); + mFocusOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("FocusOffsetCustom0"); mCameraCollidePlane.clearVec(); mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); -- cgit v1.3 From 527388694a8bb3f3c3bf1510e1e79562dd426385 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Sat, 13 Jan 2018 12:18:40 -0500 Subject: STORM-2145 Added a small floater --- indra/llui/llfloater.cpp | 2 + indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 31 ----- indra/newview/llagentcamera.cpp | 2 - indra/newview/llfloaterpreference.cpp | 2 +- indra/newview/llfloaterpreferencemoveadvanced.cpp | 151 +++++++++++++++++++++ indra/newview/llfloaterpreferencemoveadvanced.h | 58 ++++++++ indra/newview/llpanelpresetscamerapulldown.cpp | 2 +- indra/newview/llpresetsmanager.cpp | 10 -- indra/newview/llviewerfloaterreg.cpp | 2 + .../xui/en/floater_preferences_move_advanced.xml | 140 +++++++++++++++++++ .../default/xui/en/panel_preferences_move.xml | 14 ++ 12 files changed, 371 insertions(+), 45 deletions(-) create mode 100644 indra/newview/llfloaterpreferencemoveadvanced.cpp create mode 100644 indra/newview/llfloaterpreferencemoveadvanced.h create mode 100644 indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e5fe6967d1..663d96bdd4 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -64,6 +64,8 @@ // use this to control "jumping" behavior when Ctrl-Tabbing const S32 TABBED_FLOATER_OFFSET = 0; +extern LLControlGroup gSavedSettings; + namespace LLInitParam { void TypeValues::declareValues() diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 658c3c56fc..7de4e85316 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -277,6 +277,7 @@ set(viewer_SOURCE_FILES llfloaterperms.cpp llfloaterpostprocess.cpp llfloaterpreference.cpp + llfloaterpreferencemoveadvanced.cpp llfloaterpreviewtrash.cpp llfloaterproperties.cpp llfloaterregiondebugconsole.cpp @@ -901,6 +902,7 @@ set(viewer_HEADER_FILES llfloaterperms.h llfloaterpostprocess.h llfloaterpreference.h + llfloaterpreferencemoveadvanced.h llfloaterpreviewtrash.h llfloaterproperties.h llfloaterregiondebugconsole.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9b5b614111..bcce87dc13 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -16176,36 +16176,5 @@ Value - CameraOffsetCustom0 - - Comment - Customized camera offset from avatar - Persist - 1 - Type - Vector3 - Value - - -3.0 - 0.0 - 0.75 - - - FocusOffsetCustom0 - - Comment - Custom focus point offset relative to avatar (x-axis is forward) - Persist - 1 - Type - Vector3D - Value - - 1.0 - 0.0 - 1.0 - - - diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index e0ade4d395..5b9f1b9d4f 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -208,12 +208,10 @@ void LLAgentCamera::init() mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView"); mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView"); mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView"); - mCameraOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("CameraOffsetCustom0"); mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView"); mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView"); mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView"); - mFocusOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("FocusOffsetCustom0"); mCameraCollidePlane.clearVec(); mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 212cb922f2..872e961a70 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -661,7 +661,7 @@ void LLFloaterPreference::cancel() // hide spellchecker settings folder LLFloaterReg::hideInstance("prefs_spellchecker"); - // hide advancede floater + // hide advanced graphics floater LLFloaterReg::hideInstance("prefs_graphics_advanced"); // reverts any changes to current skin diff --git a/indra/newview/llfloaterpreferencemoveadvanced.cpp b/indra/newview/llfloaterpreferencemoveadvanced.cpp new file mode 100644 index 0000000000..3ff19147b1 --- /dev/null +++ b/indra/newview/llfloaterpreferencemoveadvanced.cpp @@ -0,0 +1,151 @@ +/** + * @file llfloaterpreferencemoveadvanced.cpp + * @brief floater for adjusting camera position + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2018, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llfloaterpreferencemoveadvanced.h" +#include "llfloater.h" +#include "llfloaterreg.h" +#include "lluictrlfactory.h" +#include "llspinctrl.h" +#include "llviewercontrol.h" + + +LLFloaterPreferenceMoveAdvanced::LLFloaterPreferenceMoveAdvanced(const LLSD& key) +: LLFloater(key) +{ + mCommitCallbackRegistrar.add("Cancel", boost::bind(&LLFloaterPreferenceMoveAdvanced::onClickCancel, this)); + mCommitCallbackRegistrar.add("CommitSettings", boost::bind(&LLFloaterPreferenceMoveAdvanced::onCommitSettings, this)); + mCommitCallbackRegistrar.add("Ok", boost::bind(&LLFloaterPreferenceMoveAdvanced::onClickOk, this)); + +} + +LLFloaterPreferenceMoveAdvanced::~LLFloaterPreferenceMoveAdvanced() +{} + +void LLFloaterPreferenceMoveAdvanced::onClickOk() +{ + closeFloater(); +} + +void LLFloaterPreferenceMoveAdvanced::onClickCancel() +{ + gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved); + gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved); + + updateCameraControl(mCameraSaved); + updateFocusControl(mFocusSaved); +} + +BOOL LLFloaterPreferenceMoveAdvanced::postBuild() +{ + mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView"); + mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView"); + + updateCameraControl(mCameraSaved); + updateFocusControl(mFocusSaved); + + return TRUE; +} + +void LLFloaterPreferenceMoveAdvanced::updateCameraControl(LLVector3 vector) +{ + LLSpinCtrl* spinnerx = getChild("camera_x"); + LLSpinCtrl* spinnery = getChild("camera_y"); + LLSpinCtrl* spinnerz = getChild("camera_z"); + + if (!spinnerx || !spinnery || !spinnerz) + { + LL_WARNS() << "Could not find all desired UI camera elements" + << LL_ENDL; + return; + } + + if (!spinnerx->hasFocus()) + { + spinnerx->setValue(vector[VX]); + } + + if (!spinnery->hasFocus()) + { + spinnery->setValue(vector[VY]); + } + + if (!spinnerz->hasFocus()) + { + spinnerz->setValue(vector[VZ]); + } +} + +void LLFloaterPreferenceMoveAdvanced::updateFocusControl(LLVector3d vector3d) +{ + LLSpinCtrl* spinnerx = getChild("focus_x"); + LLSpinCtrl* spinnery = getChild("focus_y"); + LLSpinCtrl* spinnerz = getChild("focus_z"); + + if (!spinnerx || !spinnery || !spinnerz) + { + LL_WARNS() << "Could not find all desired UI focus elements" + << LL_ENDL; + return; + } + + if (!spinnerx->hasFocus()) + { + spinnerx->setValue(vector3d[VX]); + } + + if (!spinnery->hasFocus()) + { + spinnery->setValue(vector3d[VY]); + } + + if (!spinnerz->hasFocus()) + { + spinnerz->setValue(vector3d[VZ]); + } +} + + void LLFloaterPreferenceMoveAdvanced::draw() +{ +// updateControl(); + LLFloater::draw(); +} + +void LLFloaterPreferenceMoveAdvanced::onCommitSettings() +{ + LLVector3 vector; + LLVector3d vector3d; + + vector.mV[VX] = (F32)getChild("camera_x")->getValue().asReal(); + vector.mV[VY] = (F32)getChild("camera_y")->getValue().asReal(); + vector.mV[VZ] = (F32)getChild("camera_z")->getValue().asReal(); + gSavedSettings.setVector3("CameraOffsetRearView", vector); + + vector3d.mdV[VX] = (F32)getChild("focus_x")->getValue().asReal(); + vector3d.mdV[VY] = (F32)getChild("focus_y")->getValue().asReal(); + vector3d.mdV[VZ] = (F32)getChild("focus_z")->getValue().asReal(); + gSavedSettings.setVector3d("FocusOffsetRearView", vector3d); +} diff --git a/indra/newview/llfloaterpreferencemoveadvanced.h b/indra/newview/llfloaterpreferencemoveadvanced.h new file mode 100644 index 0000000000..98648af19e --- /dev/null +++ b/indra/newview/llfloaterpreferencemoveadvanced.h @@ -0,0 +1,58 @@ +/** + * @file llfloaterpreferencemoveadvanced.h + * @brief floater for adjusting camera position + * + * $LicenseInfo:firstyear=2018&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2018, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLFLOATERPREFERENCEMOVEADVANCED_H +#define LLFLOATERPREFERENCEMOVEADVANCED_H + +#include "llcontrol.h" +#include "llfloater.h" + +class LLFloaterPreferenceMoveAdvanced +: public LLFloater +{ + friend class LLFloaterReg; + +public: + LLFloaterPreferenceMoveAdvanced(const LLSD& key); + virtual BOOL postBuild(); + virtual void draw(); + + void onCommitSettings(); + void onClickCancel(); + void onClickOk(); + void updateCameraControl(LLVector3 vector); + void updateFocusControl(LLVector3d vector3d); + +private: + virtual ~LLFloaterPreferenceMoveAdvanced(); + + LLVector3 mCameraSaved; + LLVector3d mFocusSaved; + +}; + +#endif //LLFLOATERPREFERENCEMOVEADVANCED_H + diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp index 2c95c06c31..ffdfc445ce 100644 --- a/indra/newview/llpanelpresetscamerapulldown.cpp +++ b/indra/newview/llpanelpresetscamerapulldown.cpp @@ -64,9 +64,9 @@ BOOL LLPanelPresetsCameraPulldown::postBuild() if (presetsMgr) { presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this)); -LL_WARNS() << "DBG pulldown" << LL_ENDL; // Make sure there is a default preference file presetsMgr->createMissingDefault(PRESETS_CAMERA); + presetsMgr->startWatching(PRESETS_CAMERA); } diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 80386b61f7..3daa6894f0 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -92,7 +92,6 @@ void LLPresetsManager::startWatching(const std::string& subdirectory) for (std::vector::iterator it = name_list.begin(); it != name_list.end(); ++it) { std::string ctrl_name = *it; -LL_WARNS() << "DBG starting watch on " << ctrl_name << LL_ENDL; if (gSavedSettings.controlExists(ctrl_name)) { LLPointer cntrl_ptr = gSavedSettings.getControl(ctrl_name); @@ -189,23 +188,18 @@ bool LLPresetsManager::isCameraDirty() void LLPresetsManager::settingChanged() { -LL_WARNS() << "DBG setting changed" << LL_ENDL; setCameraDirty(true); } void LLPresetsManager::getControlNames(std::vector& names) { names = boost::assign::list_of - ("CameraOffsetCustom0") - ("FocusOffsetCustom0") // From panel_preferences_move.xml ("CameraAngle") ("CameraOffsetScale") - ("CameraOpacity") ("EditCameraMovement") ("AppearanceCameraMovement") // From llagentcamera.cpp - ("RenderFarClip") ("CameraOffsetBuild") ("CameraPreset") ("CameraOffsetRearView") @@ -246,10 +240,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n else if(PRESETS_CAMERA == subdirectory) { gSavedSettings.setString("PresetGraphicActive", name); -// gSavedSettings.setU32("CameraPreset", CAMERA_PRESET_CUSTOM0); - -// gSavedSettings.setVector3d("CameraOffsetCustom0", gAgentCamera.calcCameraPositionTargetGlobal()); -// gSavedSettings.setVector3d("FocusOffsetCustom0", gAgentCamera.calcFocusPositionTargetGlobal()); getControlNames(name_list); name_list.push_back("PresetCameraActive"); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 0ebacddd9b..440bf46b1e 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -104,6 +104,7 @@ #include "llfloaterperms.h" #include "llfloaterpostprocess.h" #include "llfloaterpreference.h" +#include "llfloaterpreferencemoveadvanced.h" #include "llfloaterpreviewtrash.h" #include "llfloaterproperties.h" #include "llfloaterregiondebugconsole.h" @@ -295,6 +296,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("prefs_move_advanced", "floater_preferences_move_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml new file mode 100644 index 0000000000..28e5d2c607 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml @@ -0,0 +1,140 @@ + + + + + Camera offset: + + + + + + + + + + + + + + + + Focus offset: + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml index e4a5f5e283..d832dac4ff 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml @@ -127,6 +127,20 @@ tool_tip="Use automatic camera positioning while in edit mode" width="242" /> + + - - - + left_pad="2" + name="buttons_panel" + top="22" + width="212"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml index 5b2cbee914..3826ead5c2 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml @@ -1,10 +1,10 @@ @@ -113,28 +113,4 @@ - - - diff --git a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml index a9cda26f0b..178ecad0f3 100644 --- a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml +++ b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml @@ -1,51 +1,71 @@ + width="280"> Save Graphic Preset Save Camera Preset - - Save + Replace + - Type a name for the preset or choose an existing preset. - + top="15" + width="150" + name="radio_save_preset"> + + + + -- cgit v1.3 From 7637f343865960ee509ae31205c097f0bb04aac1 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 13 Nov 2019 17:39:40 +0200 Subject: SL-12186 WIP Get rid of excessive offset settings as we moved to store data in xml --- indra/newview/app_settings/camera/Front.xml | 4 +-- indra/newview/app_settings/camera/Side.xml | 4 +-- indra/newview/llagentcamera.cpp | 37 +++------------------ indra/newview/llagentcamera.h | 12 +++---- indra/newview/llfloaterpreferenceviewadvanced.cpp | 4 +-- indra/newview/llpresetsmanager.cpp | 40 ++++------------------- indra/newview/llpresetsmanager.h | 1 - indra/newview/llviewermenu.cpp | 8 ----- 8 files changed, 21 insertions(+), 89 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml index a4b5ace33c..cb3380589e 100644 --- a/indra/newview/app_settings/camera/Front.xml +++ b/indra/newview/app_settings/camera/Front.xml @@ -37,7 +37,7 @@ 6 - CameraOffsetFrontView + CameraOffsetRearView Comment Initial camera offset from avatar in Front View @@ -74,7 +74,7 @@ Value 0 - FocusOffsetFrontView + FocusOffsetRearView Comment Initial focus point offset relative to avatar for the camera preset Front View (x-axis is forward) diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml index 677fd47e20..49582a8a3c 100644 --- a/indra/newview/app_settings/camera/Side.xml +++ b/indra/newview/app_settings/camera/Side.xml @@ -37,7 +37,7 @@ 6 - CameraOffsetGroupView + CameraOffsetRearView Comment Initial camera offset from avatar in Side View @@ -74,7 +74,7 @@ Value 0 - FocusOffsetGroupView + FocusOffsetRearView Comment Initial focus point offset relative to avatar for the camera preset Side View (x-axis is forward) diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 882e3cee55..285a1509cd 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -207,15 +207,8 @@ void LLAgentCamera::init() mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); - mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView"); - mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView"); - mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView"); - mCameraOffsetInitial[CAMERA_PRESET_CUSTOM] = gSavedSettings.getControl("CameraOffsetCustomPreset"); - - mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView"); - mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView"); - mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView"); - mFocusOffsetInitial[CAMERA_PRESET_CUSTOM] = gSavedSettings.getControl("FocusOffsetCustomPreset"); + mCameraOffsetInitial = gSavedSettings.getControl("CameraOffsetRearView"); + mFocusOffsetInitial = gSavedSettings.getControl("FocusOffsetRearView"); mCameraCollidePlane.clearVec(); mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); @@ -1603,7 +1596,7 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation(); } - focus_offset = convert_from_llsd(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, ""); + focus_offset = convert_from_llsd(mFocusOffsetInitial->get(), TYPE_VEC3D, ""); return focus_offset * agent_rot; } @@ -1935,32 +1928,12 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCameraOffsetInitial() { - return convert_from_llsd(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, ""); + return convert_from_llsd(mCameraOffsetInitial->get(), TYPE_VEC3, ""); } LLVector3d LLAgentCamera::getFocusOffsetInitial() { - return convert_from_llsd(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, ""); -} - -std::string LLAgentCamera::getCameraOffsetCtrlName() -{ - return mCameraOffsetInitial[mCameraPreset]->getName(); -} - -std::string LLAgentCamera::getCameraOffsetCtrlName(ECameraPreset preset) -{ - return mCameraOffsetInitial[preset]->getName(); -} - -std::string LLAgentCamera::getFocusOffsetCtrlName() -{ - return mFocusOffsetInitial[mCameraPreset]->getName(); -} - -std::string LLAgentCamera::getFocusOffsetCtrlName(ECameraPreset preset) -{ - return mFocusOffsetInitial[preset]->getName(); + return convert_from_llsd(mFocusOffsetInitial->get(), TYPE_VEC3D, ""); } F32 LLAgentCamera::getCameraMaxZoomDistance() diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 5c8172bbfc..8a922bf678 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -117,10 +117,6 @@ public: /** Determines default focus offset depending on the current camera preset */ LLVector3d getFocusOffsetInitial(); - std::string getCameraOffsetCtrlName(); - std::string getCameraOffsetCtrlName(ECameraPreset preset); - std::string getFocusOffsetCtrlName(); - std::string getFocusOffsetCtrlName(ECameraPreset preset); private: /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ F32 getCameraMaxZoomDistance(); @@ -128,11 +124,11 @@ private: /** Camera preset in Third Person Mode */ ECameraPreset mCameraPreset; - /** Initial camera offsets */ - std::map > mCameraOffsetInitial; + /** Initial camera offset */ + LLPointer mCameraOffsetInitial; - /** Initial focus offsets */ - std::map > mFocusOffsetInitial; + /** Initial focus offset */ + LLPointer mFocusOffsetInitial; //-------------------------------------------------------------------- // Position diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp index 57484d0d0a..f8db738923 100644 --- a/indra/newview/llfloaterpreferenceviewadvanced.cpp +++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp @@ -73,10 +73,10 @@ void LLFloaterPreferenceViewAdvanced::onCommitSettings() vector.mV[VX] = (F32)getChild("camera_x")->getValue().asReal(); vector.mV[VY] = (F32)getChild("camera_y")->getValue().asReal(); vector.mV[VZ] = (F32)getChild("camera_z")->getValue().asReal(); - gSavedSettings.setVector3(gAgentCamera.getCameraOffsetCtrlName(), vector); + gSavedSettings.setVector3("CameraOffsetRearView", vector); vector3d.mdV[VX] = (F32)getChild("focus_x")->getValue().asReal(); vector3d.mdV[VY] = (F32)getChild("focus_y")->getValue().asReal(); vector3d.mdV[VZ] = (F32)getChild("focus_z")->getValue().asReal(); - gSavedSettings.setVector3d(gAgentCamera.getFocusOffsetCtrlName(), vector3d); + gSavedSettings.setVector3d("FocusOffsetRearView", vector3d); } diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 71f0cd72d4..4f25e93ebd 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -102,7 +102,6 @@ void LLPresetsManager::startWatching(const std::string& subdirectory) { std::vector name_list; getControlNames(name_list); - getOffsetControlNames(name_list); for (std::vector::iterator it = name_list.begin(); it != name_list.end(); ++it) { @@ -254,23 +253,10 @@ void LLPresetsManager::getControlNames(std::vector& names) ("CameraOffsetBuild") ("CameraOffsetScale") ("TrackFocusObject") - ; - names = camera_controls; -} - -void LLPresetsManager::getOffsetControlNames(std::vector& names) -{ - const std::vector offset_controls = boost::assign::list_of ("CameraOffsetRearView") - ("CameraOffsetFrontView") - ("CameraOffsetGroupView") - ("CameraOffsetCustomPreset") ("FocusOffsetRearView") - ("FocusOffsetFrontView") - ("FocusOffsetGroupView") - ("FocusOffsetCustomPreset") - ; - names.insert(std::end(names), std::begin(offset_controls), std::end(offset_controls)); + ; + names = camera_controls; } bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault) @@ -317,8 +303,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n name_list.clear(); getControlNames(name_list); name_list.push_back("PresetCameraActive"); - name_list.push_back(gAgentCamera.getCameraOffsetCtrlName()); - name_list.push_back(gAgentCamera.getFocusOffsetCtrlName()); } else { @@ -368,18 +352,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n for (std::vector::iterator it = name_list.begin(); it != name_list.end(); ++it) { std::string ctrl_name = *it; - std::string dest_ctrl_name = ctrl_name; - if (IS_CAMERA && new_camera_offsets) - { - if (ctrl_name == gAgentCamera.getCameraOffsetCtrlName()) - { - dest_ctrl_name = gAgentCamera.getCameraOffsetCtrlName(new_camera_preset); - } - if (ctrl_name == gAgentCamera.getFocusOffsetCtrlName()) - { - dest_ctrl_name = gAgentCamera.getFocusOffsetCtrlName(new_camera_preset); - } - } LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get(); if (ctrl) @@ -388,10 +360,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n std::string type = LLControlGroup::typeEnumToString(ctrl->type()); LLSD value = ctrl->getValue(); - paramsData[dest_ctrl_name]["Comment"] = comment; - paramsData[dest_ctrl_name]["Persist"] = 1; - paramsData[dest_ctrl_name]["Type"] = type; - paramsData[dest_ctrl_name]["Value"] = value; + paramsData[ctrl_name]["Comment"] = comment; + paramsData[ctrl_name]["Persist"] = 1; + paramsData[ctrl_name]["Type"] = type; + paramsData[ctrl_name]["Value"] = value; } } if (IS_CAMERA) diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h index d489a0ad5a..09010413a9 100644 --- a/indra/newview/llpresetsmanager.h +++ b/indra/newview/llpresetsmanager.h @@ -97,7 +97,6 @@ public: LOG_CLASS(LLPresetsManager); void getControlNames(std::vector& names); - void getOffsetControlNames(std::vector& names); static void settingChanged(); boost::signals2::connection mCameraChangedSignal; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index c18d63d72b..7dfb6a6ac2 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -4109,14 +4109,6 @@ void handle_reset_view() // switching to outfit selector should automagically save any currently edited wearable LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "my_outfits")); } - if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM) - { - gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM); - } - else - { - gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW); - } reset_view_final( TRUE ); LLFloaterCamera::resetCameraMode(); -- cgit v1.3 From f4d4fb2ad0927ebb8545bac1abd1b74918a006f5 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 22 Nov 2019 14:34:20 +0200 Subject: SL-12288 Enhancement for Rotate and Track camera controls --- indra/newview/llagentcamera.cpp | 58 ++++++++++++- indra/newview/llagentcamera.h | 13 ++- indra/newview/lljoystickbutton.cpp | 95 +++++++++++++++++---- indra/newview/lljoystickbutton.h | 9 +- .../textures/bottomtray/Cam_Rotate_Center.png | Bin 0 -> 10689 bytes .../textures/bottomtray/Cam_Tracking_Center.png | Bin 0 -> 1714 bytes indra/newview/skins/default/textures/textures.xml | 2 + 7 files changed, 155 insertions(+), 22 deletions(-) create mode 100644 indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png create mode 100644 indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index e5fba7f28f..67b117657f 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -184,6 +184,9 @@ LLAgentCamera::LLAgentCamera() : clearGeneralKeys(); clearOrbitKeys(); clearPanKeys(); + + resetPanDiff(); + resetOrbitDiff(); } // Requires gSavedSettings to be initialized. @@ -343,7 +346,8 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) mCameraFOVZoomFactor = 0.f; } - + resetPanDiff(); + resetOrbitDiff(); mHUDTargetZoom = 1.f; } @@ -822,6 +826,7 @@ void LLAgentCamera::cameraOrbitAround(const F32 radians) } else { + mOrbitAroundRadians += radians; mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f); cameraZoomIn(1.f); @@ -853,12 +858,34 @@ void LLAgentCamera::cameraOrbitOver(const F32 angle) LLVector3d left_axis; left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD); + mOrbitOverAngle += angle_from_up - new_angle; mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis); cameraZoomIn(1.f); } } +void LLAgentCamera::resetCameraOrbit() +{ + LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); + camera_offset_unit.normalize(); + + LLVector3d left_axis; + left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); + mCameraFocusOffsetTarget.rotVec(-mOrbitOverAngle, left_axis); + + mCameraFocusOffsetTarget.rotVec(-mOrbitAroundRadians, 0.f, 0.f, 1.f); + + cameraZoomIn(1.f); + resetOrbitDiff(); +} + +void LLAgentCamera::resetOrbitDiff() +{ + mOrbitAroundRadians = 0; + mOrbitOverAngle = 0; +} + //----------------------------------------------------------------------------- // cameraZoomIn() //----------------------------------------------------------------------------- @@ -997,6 +1024,8 @@ void LLAgentCamera::cameraPanIn(F32 meters) LLVector3d at_axis; at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis()); + mPanFocusDiff += meters * at_axis; + mFocusTargetGlobal += meters * at_axis; mFocusGlobal = mFocusTargetGlobal; // don't enforce zoom constraints as this is the only way for users to get past them easily @@ -1013,6 +1042,8 @@ void LLAgentCamera::cameraPanLeft(F32 meters) LLVector3d left_axis; left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); + mPanFocusDiff += meters * left_axis; + mFocusTargetGlobal += meters * left_axis; mFocusGlobal = mFocusTargetGlobal; @@ -1033,6 +1064,8 @@ void LLAgentCamera::cameraPanUp(F32 meters) LLVector3d up_axis; up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis()); + mPanFocusDiff += meters * up_axis; + mFocusTargetGlobal += meters * up_axis; mFocusGlobal = mFocusTargetGlobal; @@ -1045,6 +1078,26 @@ void LLAgentCamera::cameraPanUp(F32 meters) mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); } +void LLAgentCamera::resetCameraPan() +{ + mFocusTargetGlobal -= mPanFocusDiff; + + mFocusGlobal = mFocusTargetGlobal; + mCameraSmoothingStop = true; + + cameraZoomIn(1.f); + updateFocusOffset(); + + mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); + + resetPanDiff(); +} + +void LLAgentCamera::resetPanDiff() +{ + mPanFocusDiff.clear(); +} + //----------------------------------------------------------------------------- // updateLookAt() //----------------------------------------------------------------------------- @@ -2330,6 +2383,9 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset) mCameraPreset = preset; + resetPanDiff(); + resetOrbitDiff(); + gSavedSettings.setU32("CameraPreset", mCameraPreset); } diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 8a922bf678..0608507d1a 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -262,7 +262,8 @@ public: void cameraOrbitAround(const F32 radians); // Rotate camera CCW radians about build focus point void cameraOrbitOver(const F32 radians); // Rotate camera forward radians over build focus point void cameraOrbitIn(const F32 meters); // Move camera in toward build focus point - + void resetCameraOrbit(); + void resetOrbitDiff(); //-------------------------------------------------------------------- // Zoom //-------------------------------------------------------------------- @@ -279,8 +280,9 @@ public: public: void cameraPanIn(const F32 meters); void cameraPanLeft(const F32 meters); - void cameraPanUp(const F32 meters); - + void cameraPanUp(const F32 meters); + void resetCameraPan(); + void resetPanDiff(); //-------------------------------------------------------------------- // View //-------------------------------------------------------------------- @@ -367,6 +369,9 @@ private: F32 mOrbitInKey; F32 mOrbitOutKey; + F32 mOrbitAroundRadians; + F32 mOrbitOverAngle; + //-------------------------------------------------------------------- // Pan //-------------------------------------------------------------------- @@ -394,6 +399,8 @@ private: F32 mPanInKey; F32 mPanOutKey; + LLVector3d mPanFocusDiff; + /** Keys ** ** *******************************************************************************/ diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 59e14e6cc0..eb4e4f4100 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -37,6 +37,7 @@ #include "llui.h" #include "llagent.h" #include "llagentcamera.h" +#include "llviewercamera.h" #include "llviewertexture.h" #include "llviewertexturelist.h" #include "llviewerwindow.h" @@ -54,6 +55,8 @@ static LLDefaultChildRegistry::Register r5("joystick_trac const F32 NUDGE_TIME = 0.25f; // in seconds const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed +const S32 CENTER_DOT_RADIUS = 7; + // // Public Methods // @@ -138,9 +141,25 @@ bool LLJoystick::pointInCircle(S32 x, S32 y) const //center is x and y coordinates of center of joystick circle, and also its radius int center = this->getLocalRect().getHeight()/2; bool in_circle = (x - center) * (x - center) + (y - center) * (y - center) <= center * center; + return in_circle; } +bool LLJoystick::pointInCenterDot(S32 x, S32 y, S32 radius) const +{ + if (this->getLocalRect().getHeight() != this->getLocalRect().getWidth()) + { + LL_WARNS() << "Joystick shape is not square" << LL_ENDL; + return true; + } + + S32 center = this->getLocalRect().getHeight() / 2; + + bool in_center_circle = (x - center) * (x - center) + (y - center) * (y - center) <= radius * radius; + + return in_center_circle; +} + BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask) { //LL_INFOS() << "joystick mouse down " << x << ", " << y << LL_ENDL; @@ -403,8 +422,11 @@ LLJoystickCameraRotate::LLJoystickCameraRotate(const LLJoystickCameraRotate::Par mInLeft( FALSE ), mInTop( FALSE ), mInRight( FALSE ), - mInBottom( FALSE ) -{ } + mInBottom( FALSE ), + mInCenter( FALSE ) +{ + mCenterImageName = "Cam_Rotate_Center"; +} void LLJoystickCameraRotate::updateSlop() @@ -434,7 +456,16 @@ BOOL LLJoystickCameraRotate::handleMouseDown(S32 x, S32 y, MASK mask) S32 dx = x - horiz_center; S32 dy = y - vert_center; - if (dy > dx && dy > -dx) + if (pointInCenterDot(x, y, CENTER_DOT_RADIUS)) + { + mInitialOffset.mX = 0; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_ORIGIN; + mInCenter = TRUE; + + resetJoystickCamera(); + } + else if (dy > dx && dy > -dx) { // top mInitialOffset.mX = 0; @@ -469,9 +500,20 @@ BOOL LLJoystickCameraRotate::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLJoystickCameraRotate::handleMouseUp(S32 x, S32 y, MASK mask) { gAgent.setMovementLocked(FALSE); + mInCenter = FALSE; return LLJoystick::handleMouseUp(x, y, mask); } +BOOL LLJoystickCameraRotate::handleHover(S32 x, S32 y, MASK mask) +{ + if (!pointInCenterDot(x, y, CENTER_DOT_RADIUS)) + { + mInCenter = FALSE; + } + + return LLJoystick::handleHover(x, y, mask); +} + void LLJoystickCameraRotate::onHeldDown() { updateSlop(); @@ -504,6 +546,11 @@ void LLJoystickCameraRotate::onHeldDown() } } +void LLJoystickCameraRotate::resetJoystickCamera() +{ + gAgentCamera.resetCameraOrbit(); +} + F32 LLJoystickCameraRotate::getOrbitRate() { F32 time = getElapsedHeldDownTime(); @@ -536,24 +583,31 @@ void LLJoystickCameraRotate::draw() getImageUnselected()->draw( 0, 0 ); LLPointer image = getImageSelected(); - if( mInTop ) + if (mInCenter) { - drawRotatedImage( getImageSelected(), 0 ); + drawRotatedImage(LLUI::getUIImage(mCenterImageName), 0); } - - if( mInRight ) + else { - drawRotatedImage( getImageSelected(), 1 ); - } + if (mInTop) + { + drawRotatedImage(getImageSelected(), 0); + } - if( mInBottom ) - { - drawRotatedImage( getImageSelected(), 2 ); - } + if (mInRight) + { + drawRotatedImage(getImageSelected(), 1); + } - if( mInLeft ) - { - drawRotatedImage( getImageSelected(), 3 ); + if (mInBottom) + { + drawRotatedImage(getImageSelected(), 2); + } + + if (mInLeft) + { + drawRotatedImage(getImageSelected(), 3); + } } } @@ -613,7 +667,9 @@ LLJoystickCameraTrack::Params::Params() LLJoystickCameraTrack::LLJoystickCameraTrack(const LLJoystickCameraTrack::Params& p) : LLJoystickCameraRotate(p) -{} +{ + mCenterImageName = "Cam_Tracking_Center"; +} void LLJoystickCameraTrack::onHeldDown() @@ -646,3 +702,8 @@ void LLJoystickCameraTrack::onHeldDown() gAgentCamera.setPanDownKey(getOrbitRate()); } } + +void LLJoystickCameraTrack::resetJoystickCamera() +{ + gAgentCamera.resetCameraPan(); +} diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h index 4e6c774cad..3e29215f61 100644 --- a/indra/newview/lljoystickbutton.h +++ b/indra/newview/lljoystickbutton.h @@ -79,7 +79,8 @@ public: * Image containing circle is square and this square has adherent points with joystick * circle. Make sure to change method according to shape other than square. */ - bool pointInCircle(S32 x, S32 y) const; + bool pointInCircle(S32 x, S32 y) const; + bool pointInCenterDot(S32 x, S32 y, S32 radius) const; static std::string nameFromQuadrant(const EJoystickQuadrant quadrant); static EJoystickQuadrant quadrantFromName(const std::string& name); @@ -147,7 +148,9 @@ public: virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual void onHeldDown(); + virtual void resetJoystickCamera(); virtual void draw(); protected: @@ -160,6 +163,9 @@ protected: BOOL mInTop; BOOL mInRight; BOOL mInBottom; + BOOL mInCenter; + + std::string mCenterImageName; }; @@ -176,6 +182,7 @@ public: LLJoystickCameraTrack(const LLJoystickCameraTrack::Params&); virtual void onHeldDown(); + virtual void resetJoystickCamera(); }; #endif // LL_LLJOYSTICKBUTTON_H diff --git a/indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png b/indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png new file mode 100644 index 0000000000..ffc3c85ea2 Binary files /dev/null and b/indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png differ diff --git a/indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png b/indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png new file mode 100644 index 0000000000..2812d614e6 Binary files /dev/null and b/indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index b086f7dfa8..2a4171f11b 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -113,8 +113,10 @@ with the same filename but different name + + -- cgit v1.3 From 5f86203f261b376ad74814e1e635dba077c7718b Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 10 Dec 2019 15:44:01 +0200 Subject: SL-12429 Use different setting name to prevent crash on old viewer --- indra/newview/app_settings/settings.xml | 15 +++++++++++++-- indra/newview/llagentcamera.cpp | 4 ++-- indra/newview/llfloatercamera.cpp | 6 +++--- indra/newview/llpresetsmanager.cpp | 6 +++--- 4 files changed, 21 insertions(+), 10 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2fe5817772..86c3e6cf3f 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1562,10 +1562,10 @@ Value 1.0 - CameraPreset + CameraPreset Comment - Preset camera position - view (0 - rear, 1 - front, 2 - group, 3 - custom) + Preset camera position - view (0 - rear, 1 - front, 2 - group) Persist 1 Type @@ -16351,6 +16351,17 @@ Value Rear View + CameraPresetType + + Comment + Preset camera position - view (0 - rear, 1 - front, 2 - group, 3 - custom) + Persist + 1 + Type + U32 + Value + 0 + CefVerboseLog Comment diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 67b117657f..eb730d105d 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -208,7 +208,7 @@ void LLAgentCamera::init() mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); - mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); + mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPresetType"); mCameraOffsetInitial = gSavedSettings.getControl("CameraOffsetRearView"); mFocusOffsetInitial = gSavedSettings.getControl("FocusOffsetRearView"); @@ -2386,7 +2386,7 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset) resetPanDiff(); resetOrbitDiff(); - gSavedSettings.setU32("CameraPreset", mCameraPreset); + gSavedSettings.setU32("CameraPresetType", mCameraPreset); } diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index d3c1ba764b..7e538d1bfc 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -498,7 +498,7 @@ void LLFloaterCamera::updateState() void LLFloaterCamera::updateItemsSelection() { - ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); + ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPresetType"); LLSD argument; argument["selected"] = (preset == CAMERA_PRESET_REAR_VIEW) && !sFreeCamera; getChild("rear_view")->setValue(argument); @@ -588,11 +588,11 @@ void LLFloaterCamera::populatePresetCombo() std::string active_preset_name = gSavedSettings.getString("PresetCameraActive"); if (active_preset_name.empty()) { - gSavedSettings.setU32("CameraPreset", CAMERA_PRESET_CUSTOM); + gSavedSettings.setU32("CameraPresetType", CAMERA_PRESET_CUSTOM); updateItemsSelection(); mPresetCombo->setLabel(getString("inactive_combo_text")); } - else if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM) + else if ((ECameraPreset)gSavedSettings.getU32("CameraPresetType") == CAMERA_PRESET_CUSTOM) { mPresetCombo->selectByValue(active_preset_name); } diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index dda705eeca..c4161ed1bc 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -309,7 +309,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n } else { - ECameraPreset new_camera_preset = (ECameraPreset)gSavedSettings.getU32("CameraPreset"); + ECameraPreset new_camera_preset = (ECameraPreset)gSavedSettings.getU32("CameraPresetType"); bool new_camera_offsets = false; if (IS_CAMERA) { @@ -332,7 +332,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n { new_camera_preset = CAMERA_PRESET_CUSTOM; } - new_camera_offsets = (!isDefaultCameraPreset(name) || (ECameraPreset)gSavedSettings.getU32("CameraPreset") != new_camera_preset); + new_camera_offsets = (!isDefaultCameraPreset(name) || (ECameraPreset)gSavedSettings.getU32("CameraPresetType") != new_camera_preset); } for (std::vector::iterator it = name_list.begin(); it != name_list.end(); ++it) { @@ -353,7 +353,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n } if (IS_CAMERA) { - gSavedSettings.setU32("CameraPreset", new_camera_preset); + gSavedSettings.setU32("CameraPresetType", new_camera_preset); } } -- cgit v1.3 From fcbccd59d98ea0a4a11b26da6b19a9f90f65dae5 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 17 Jan 2020 17:54:40 +0200 Subject: SL-12424 Allow saving offsets based on current camera position --- indra/newview/llagentcamera.cpp | 16 ++++++++++++++++ indra/newview/llagentcamera.h | 4 ++++ indra/newview/llfloatersavecamerapreset.cpp | 6 ++++++ 3 files changed, 26 insertions(+) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 04d726a131..18825d5b27 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1985,6 +1985,22 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) } +LLVector3 LLAgentCamera::getCurrentCameraOffset() +{ + LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->getRenderPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion(); + return camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale"); +} + +LLVector3d LLAgentCamera::getCurrentFocusOffset() +{ + return (mFocusTargetGlobal - gAgent.getPositionGlobal()) * ~gAgent.getFrameAgent().getQuaternion(); +} + +bool LLAgentCamera::isJoystickCameraUsed() +{ + return ((mOrbitAroundRadians != 0) || (mOrbitOverAngle != 0) || !mPanFocusDiff.isNull()); +} + LLVector3 LLAgentCamera::getCameraOffsetInitial() { return convert_from_llsd(mCameraOffsetInitial->get(), TYPE_VEC3, ""); diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 6e73b7b0f0..af65ab431a 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -117,6 +117,10 @@ public: /** Determines default focus offset depending on the current camera preset */ LLVector3d getFocusOffsetInitial(); + LLVector3 getCurrentCameraOffset(); + LLVector3d getCurrentFocusOffset(); + bool isJoystickCameraUsed(); + private: /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ F32 getCameraMaxZoomDistance(); diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index 5d62aff0e2..bbc4b5e354 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -28,6 +28,7 @@ #include "llfloatersavecamerapreset.h" +#include "llagentcamera.h" #include "llbutton.h" #include "llcombobox.h" #include "llfloaterpreference.h" @@ -101,6 +102,11 @@ void LLFloaterSaveCameraPreset::onBtnSave() } else { + if (gAgentCamera.isJoystickCameraUsed()) + { + gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); + gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset()); + } if (is_saving_new) { std::list preset_names; -- cgit v1.3 From e865c94513ea22f06ceab4c3698cb180fb30707a Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 17 Jan 2020 18:58:07 +0200 Subject: SL-12424 Use correct avatar position --- indra/newview/llagentcamera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 18825d5b27..d4d4f8e124 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1987,7 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCurrentCameraOffset() { - LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->getRenderPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion(); + LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->mRoot->getWorldPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion(); return camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale"); } -- cgit v1.3 From 2c7a8a2485b98ff56e6fdc431bba5ccd226ae740 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 30 Jan 2020 17:51:41 +0200 Subject: SL-12618 FIXED The camera zoom position is incorrect after selecting the preset in some cases --- indra/newview/app_settings/camera/Front.xml | 2 +- indra/newview/app_settings/camera/Rear.xml | 2 +- indra/newview/app_settings/camera/Side.xml | 2 +- indra/newview/llagentcamera.cpp | 4 ++-- indra/newview/llagentcamera.h | 8 ++++---- indra/newview/llpresetsmanager.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml index e4839d48ec..7b5d597fdf 100644 --- a/indra/newview/app_settings/camera/Front.xml +++ b/indra/newview/app_settings/camera/Front.xml @@ -72,7 +72,7 @@ Type F32 Value - 0.9 + 0.90322577953338623 EditCameraMovement diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml index 72e6c5d93a..7aa36c3e59 100644 --- a/indra/newview/app_settings/camera/Rear.xml +++ b/indra/newview/app_settings/camera/Rear.xml @@ -72,7 +72,7 @@ Type F32 Value - 0.9 + 0.90322577953338623 EditCameraMovement diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml index eb3b3253c1..8890d9cbce 100644 --- a/indra/newview/app_settings/camera/Side.xml +++ b/indra/newview/app_settings/camera/Side.xml @@ -72,7 +72,7 @@ Type F32 Value - 0.9 + 0.90322577953338623 EditCameraMovement diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index d4d4f8e124..6b1dd4c3c3 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -717,7 +717,7 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) return TRUE; } -F32 LLAgentCamera::getCameraZoomFraction() +F32 LLAgentCamera::getCameraZoomFraction(bool get_third_person) { // 0.f -> camera zoomed all the way out // 1.f -> camera zoomed all the way in @@ -727,7 +727,7 @@ F32 LLAgentCamera::getCameraZoomFraction() // already [0,1] return mHUDTargetZoom; } - else if (mFocusOnAvatar && cameraThirdPerson()) + else if (get_third_person || (mFocusOnAvatar && cameraThirdPerson())) { return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f); } diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index af65ab431a..128974666e 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -272,10 +272,10 @@ public: // Zoom //-------------------------------------------------------------------- public: - void handleScrollWheel(S32 clicks); // Mousewheel driven zoom - void cameraZoomIn(const F32 factor); // Zoom in by fraction of current distance - F32 getCameraZoomFraction(); // Get camera zoom as fraction of minimum and maximum zoom - void setCameraZoomFraction(F32 fraction); // Set camera zoom as fraction of minimum and maximum zoom + void handleScrollWheel(S32 clicks); // Mousewheel driven zoom + void cameraZoomIn(const F32 factor); // Zoom in by fraction of current distance + F32 getCameraZoomFraction(bool get_third_person = false); // Get camera zoom as fraction of minimum and maximum zoom + void setCameraZoomFraction(F32 fraction); // Set camera zoom as fraction of minimum and maximum zoom F32 calcCameraFOVZoomFactor(); F32 getAgentHUDTargetZoom(); diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 6b83be2b70..eaf139b106 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -288,7 +288,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n getControlNames(name_list); name_list.push_back("PresetCameraActive"); - gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction()); + gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction(true)); name_list.push_back("CameraZoomFraction"); } else -- cgit v1.3 From 3e403ffb4f6d295b11c9842bed53df5d15848f0b Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Mon, 16 Mar 2020 17:48:23 +0200 Subject: SL-4495 Add setting to ignore Hover height when setting Camera position --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llagentcamera.cpp | 10 ++++++++-- indra/newview/llagentcamera.h | 2 ++ .../default/xui/en/floater_edit_hover_height.xml | 19 +++++++++++++------ 4 files changed, 34 insertions(+), 8 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f35408f48e..cc86ba85c1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -16406,6 +16406,17 @@ Value 0 + HoverHeightAffectsCamera + + Comment + Camera view is affected by Hover Height setting + Persist + 1 + Type + Boolean + Value + 1 + CefVerboseLog Comment diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 6b1dd4c3c3..a1920f0332 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1730,7 +1730,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) F32 camera_land_height; LLVector3d frame_center_global = !isAgentAvatarValid() ? gAgent.getPositionGlobal() : - gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition()); + gAgent.getPosGlobalFromAgent(getAvatarRootPosition()); BOOL isConstrained = FALSE; LLVector3d head_offset; @@ -1987,7 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCurrentCameraOffset() { - LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->mRoot->getWorldPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion(); + LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion(); return camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale"); } @@ -2019,6 +2019,12 @@ F32 LLAgentCamera::getCameraMaxZoomDistance() LLWorld::getInstance()->getRegionWidthInMeters() - CAMERA_FUDGE_FROM_OBJECT); } +LLVector3 LLAgentCamera::getAvatarRootPosition() +{ + static LLCachedControl use_hover_height(gSavedSettings, "HoverHeightAffectsCamera"); + return use_hover_height ? gAgentAvatarp->mRoot->getWorldPosition() : gAgentAvatarp->mRoot->getWorldPosition() - gAgentAvatarp->getHoverOffset(); + +} //----------------------------------------------------------------------------- // handleScrollWheel() //----------------------------------------------------------------------------- diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 128974666e..a9f57cf956 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -147,6 +147,8 @@ public: F32 getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.length(); } void clearCameraLag() { mCameraLag.clearVec(); } private: + LLVector3 getAvatarRootPosition(); + F32 mCurrentCameraDistance; // Current camera offset from avatar F32 mTargetCameraDistance; // Target camera offset from avatar F32 mCameraFOVZoomFactor; // Amount of fov zoom applied to camera when zeroing in on an object diff --git a/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml b/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml index 52084e5f8e..3570456b44 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml @@ -4,18 +4,16 @@ legacy_header_height="225" can_minimize="true" can_close="true" - can_resize="true" - min_height="65" - min_width="515" - height="65" + can_resize="false" + height="80" + width="515" layout="topleft" name="HoverHeight" single_instance="true" help_topic="hover_height" save_rect="true" save_visibility="true" - title="SET HOVER HEIGHT" - width="515"> + title="SET HOVER HEIGHT"> + -- cgit v1.3 From aefd01bd9cd3f8bf88231b15462abc1ccd79a7b9 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 27 Mar 2020 20:00:27 +0200 Subject: SL-12904 FIXED Camera Preset does not restore correctly when sitting --- indra/newview/llagentcamera.cpp | 12 ++++++++++-- indra/newview/llagentcamera.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index a1920f0332..bac31d48a1 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1987,13 +1987,21 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCurrentCameraOffset() { - LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion(); + LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation(); return camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale"); } LLVector3d LLAgentCamera::getCurrentFocusOffset() { - return (mFocusTargetGlobal - gAgent.getPositionGlobal()) * ~gAgent.getFrameAgent().getQuaternion(); + return (mFocusTargetGlobal - gAgent.getPositionGlobal()) * ~getCurrentAvatarRotation(); +} + +LLQuaternion LLAgentCamera::getCurrentAvatarRotation() +{ + LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent(); + LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion(); + LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT; + return av_rot * obj_rot; } bool LLAgentCamera::isJoystickCameraUsed() diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index a9f57cf956..357dd5e12a 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -119,6 +119,7 @@ public: LLVector3 getCurrentCameraOffset(); LLVector3d getCurrentFocusOffset(); + LLQuaternion getCurrentAvatarRotation(); bool isJoystickCameraUsed(); private: -- cgit v1.3 From 2dde3869171105748c1005502481c51eeff59511 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 2 Apr 2020 15:32:04 +0300 Subject: SL-12927 FIXED [Camera Presets] when sitting pressing ESC key causes rotation --- indra/newview/llagentcamera.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index bac31d48a1..5a5a3efc0f 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2312,15 +2312,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) } // Remove any pitch from the avatar - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis * ~obj_rot); - } - else + if (!isAgentAvatarValid() || !gAgentAvatarp->getParent()) { at_axis = gAgent.getFrameAgent().getAtAxis(); at_axis.mV[VZ] = 0.f; @@ -2691,15 +2683,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) if (mCameraMode == CAMERA_MODE_THIRD_PERSON) { LLVector3 at_axis; - if (isAgentAvatarValid() && gAgentAvatarp->getParent()) - { - LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation(); - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - gAgent.resetAxes(at_axis * ~obj_rot); - } - else + if (!isAgentAvatarValid() || !gAgentAvatarp->getParent()) { at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; -- cgit v1.3 From 1f5bb7be28768fe5341b1ca4b5a5d366f176045e Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 6 Apr 2020 16:03:19 +0300 Subject: SL-12904 FIXED Camera Preset does not restore correctly when sitting --- indra/newview/llagentcamera.cpp | 6 ++---- indra/newview/llviewerkeyboard.cpp | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 5a5a3efc0f..d1da132587 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1805,7 +1805,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) at_axis.normalize(); gAgent.resetAxes(at_axis * ~parent_rot); - local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot; + local_camera_offset = local_camera_offset * parent_rot; } else { @@ -1999,9 +1999,7 @@ LLVector3d LLAgentCamera::getCurrentFocusOffset() LLQuaternion LLAgentCamera::getCurrentAvatarRotation() { LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent(); - LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion(); - LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT; - return av_rot * obj_rot; + return sit_object ? sit_object->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); } bool LLAgentCamera::isJoystickCameraUsed() diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index e930eb20d3..bccbe61f44 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -345,6 +345,7 @@ void camera_spin_around_ccw_sitting( EKeystate s ) else { //change camera but do not send keystrokes + gAgentCamera.unlockView(); gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); } } @@ -361,6 +362,7 @@ void camera_spin_around_cw_sitting( EKeystate s ) else { //change camera but do not send keystrokes + gAgentCamera.unlockView(); gAgentCamera.setOrbitRightKey( get_orbit_rate() ); } } -- cgit v1.3 From 944b908be10367ae5770db03bddddd40cd4d18d8 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 10 Apr 2020 18:38:56 +0300 Subject: SL-12994 FIXED [Camera Presets] Zoom fraction should be saved as a part of Camera preset, not as separate setting --- indra/newview/llagentcamera.cpp | 8 ++++++-- indra/newview/llagentcamera.h | 3 +++ indra/newview/llfloatercamera.cpp | 3 ++- indra/newview/llfloatersavecamerapreset.cpp | 6 ++++++ indra/newview/llpresetsmanager.cpp | 3 --- 5 files changed, 17 insertions(+), 6 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index d1da132587..f1d8bf3cf1 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1987,8 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCurrentCameraOffset() { - LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation(); - return camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale"); + return (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation(); } LLVector3d LLAgentCamera::getCurrentFocusOffset() @@ -2829,6 +2828,11 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, return mPointAt->setPointAt(target_type, object, position); } +void LLAgentCamera::resetCameraZoomFraction() +{ + mCameraZoomFraction = INITIAL_ZOOM_FRACTION; +} + ELookAtType LLAgentCamera::getLookAtType() { if (mLookAt) diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 357dd5e12a..420cc0b601 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -282,6 +282,9 @@ public: F32 calcCameraFOVZoomFactor(); F32 getAgentHUDTargetZoom(); + void resetCameraZoomFraction(); + F32 getCurrentCameraZoomFraction() { return mCameraZoomFraction; } + //-------------------------------------------------------------------- // Pan //-------------------------------------------------------------------- diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index cc02862868..e1e7ee8445 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -565,7 +565,8 @@ void LLFloaterCamera::switchToPreset(const std::string& name) { LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); } - gAgentCamera.setCameraZoomFraction(gSavedSettings.getF32("CameraZoomFraction")); + + gAgentCamera.resetCameraZoomFraction(); LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); if (camera_floater) diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index 34aefdf1c1..e2bd2e6d6a 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -107,6 +107,12 @@ void LLFloaterSaveCameraPreset::onBtnSave() gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset()); } + else + { + LLVector3 camera_offset = gSavedSettings.getVector3("CameraOffsetRearView") * gAgentCamera.getCurrentCameraZoomFraction(); + gSavedSettings.setVector3("CameraOffsetRearView", camera_offset); + gAgentCamera.resetCameraZoomFraction(); + } if (is_saving_new) { std::list preset_names; diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index fd89a1fcb6..129187ccbd 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -309,9 +309,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n name_list.clear(); getControlNames(name_list); name_list.push_back("PresetCameraActive"); - - gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction(true)); - name_list.push_back("CameraZoomFraction"); } else { -- cgit v1.3 From 70d340a1bff2707138ac41fdd1408a5b2e46fc71 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 13 Apr 2020 20:02:58 +0300 Subject: SL-12993 Focus on avatar after saving new preset --- indra/newview/llagentcamera.cpp | 4 ++-- indra/newview/llagentcamera.h | 2 +- indra/newview/llfloatersavecamerapreset.cpp | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index f1d8bf3cf1..5efd614b22 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2656,7 +2656,7 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer //----------------------------------------------------------------------------- // setFocusOnAvatar() //----------------------------------------------------------------------------- -void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) +void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate, BOOL reset_axes) { if (focus_on_avatar != mFocusOnAvatar) { @@ -2673,7 +2673,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) //RN: when focused on the avatar, we're not "looking" at it // looking implies intent while focusing on avatar means // you're just walking around with a camera on you...eesh. - if (!mFocusOnAvatar && focus_on_avatar) + if (!mFocusOnAvatar && focus_on_avatar && reset_axes) { setFocusGlobal(LLVector3d::zero); mCameraFOVZoomFactor = 0.f; diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 420cc0b601..841b0e353d 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -217,7 +217,7 @@ public: void validateFocusObject(); void setFocusGlobal(const LLPickInfo& pick); void setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null); - void setFocusOnAvatar(BOOL focus, BOOL animate); + void setFocusOnAvatar(BOOL focus, BOOL animate, BOOL reset_axes = TRUE); void setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id); void clearFocusObject(); void setFocusObject(LLViewerObject* object); diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index e2bd2e6d6a..c02f8f0ea1 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -106,6 +106,8 @@ void LLFloaterSaveCameraPreset::onBtnSave() { gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset()); + gAgentCamera.resetCameraZoomFraction(); + gAgentCamera.setFocusOnAvatar(TRUE, TRUE, FALSE); } else { -- cgit v1.3 From 74d6e6b65c9c3e85e8ec84939b35a1e584379e1f Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 20 Apr 2020 14:27:22 +0300 Subject: SL-12904 FIXED Camera Preset does not restore correctly when sitting --- indra/llmath/llquaternion.h | 24 ++++++++++++++ indra/llxml/llcontrol.cpp | 51 +++++++++++++++++++++++++++++ indra/llxml/llcontrol.h | 15 ++++++--- indra/llxml/llcontrolgroupreader.h | 1 + indra/newview/app_settings/camera/Front.xml | 16 +++++++++ indra/newview/app_settings/camera/Rear.xml | 16 +++++++++ indra/newview/app_settings/camera/Side.xml | 16 +++++++++ indra/newview/app_settings/settings.xml | 16 +++++++++ indra/newview/llagentcamera.cpp | 15 +++++++-- indra/newview/llagentcamera.h | 4 +++ indra/newview/llfloatercamera.cpp | 14 ++++++++ indra/newview/llfloatersavecamerapreset.cpp | 6 ++++ indra/newview/llfloatersettingsdebug.cpp | 42 ++++++++++++++++++++++++ indra/newview/llpresetsmanager.cpp | 1 + indra/newview/llvoavatar.cpp | 3 +- 15 files changed, 232 insertions(+), 8 deletions(-) (limited to 'indra/newview/llagentcamera.cpp') diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index aa0b1752f4..95e4c09695 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -28,6 +28,7 @@ #define LLQUATERNION_H #include +#include #ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies #error "Please include llmath.h first." @@ -64,6 +65,29 @@ public: const LLVector3 &y_axis, const LLVector3 &z_axis); // Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis] + explicit LLQuaternion(const LLSD& sd) + { + setValue(sd); + } + + void setValue(const LLSD& sd) + { + mQ[VX] = (F32) sd[0].asReal(); + mQ[VY] = (F32) sd[1].asReal(); + mQ[VZ] = (F32) sd[2].asReal(); + mQ[VS] = (F32) sd[3].asReal(); + } + + LLSD getValue() const + { + LLSD ret; + ret[0] = mQ[VX]; + ret[1] = mQ[VY]; + ret[2] = mQ[VZ]; + ret[3] = mQ[VS]; + return ret; + } + BOOL isIdentity() const; BOOL isNotIdentity() const; BOOL isFinite() const; // checks to see if all values of LLQuaternion are finite diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index ccf4f3ddf5..80a414d00f 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -40,6 +40,7 @@ #include "v4coloru.h" #include "v4color.h" #include "v3color.h" +#include "llquaternion.h" #include "llrect.h" #include "llxmltree.h" #include "llsdserialize.h" @@ -125,6 +126,9 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) case TYPE_VEC3D: result = LLVector3d(a) == LLVector3d(b); break; + case TYPE_QUAT: + result = LLQuaternion(a) == LLQuaternion(b); + break; case TYPE_RECT: result = LLRect(a) == LLRect(b); break; @@ -361,6 +365,7 @@ const std::string LLControlGroup::mTypeString[TYPE_COUNT] = { "U32" ,"String" ,"Vector3" ,"Vector3D" + ,"Quaternion" ,"Rect" ,"Color4" ,"Color3" @@ -523,6 +528,11 @@ LLControlVariable* LLControlGroup::declareVec3d(const std::string& name, const L return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist); } +LLControlVariable* LLControlGroup::declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist) +{ + return declareControl(name, TYPE_QUAT, initial_val.getValue(), comment, persist); +} + LLControlVariable* LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist) { return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist); @@ -600,6 +610,11 @@ LLVector3d LLControlGroup::getVector3d(const std::string& name) return get(name); } +LLQuaternion LLControlGroup::getQuaternion(const std::string& name) +{ + return get(name); +} + LLRect LLControlGroup::getRect(const std::string& name) { return get(name); @@ -677,6 +692,11 @@ void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val) set(name, val); } +void LLControlGroup::setQuaternion(const std::string& name, const LLQuaternion &val) +{ + set(name, val); +} + void LLControlGroup::setRect(const std::string& name, const LLRect &val) { set(name, val); @@ -859,6 +879,16 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require validitems++; } break; + case TYPE_QUAT: + { + LLQuaternion quat; + + child_nodep->getAttributeQuat("value", quat); + + control->set(quat.getValue()); + validitems++; + } + break; case TYPE_RECT: { //RN: hack to support reading rectangles from a string @@ -1201,6 +1231,11 @@ template <> eControlType get_control_type() return TYPE_VEC3D; } +template <> eControlType get_control_type() +{ + return TYPE_QUAT; +} + template <> eControlType get_control_type() { return TYPE_RECT; @@ -1236,6 +1271,10 @@ template <> LLSD convert_to_llsd(const LLVector3d& in) { return in.getValue(); } +template <> LLSD convert_to_llsd(const LLQuaternion& in) +{ + return in.getValue(); +} template <> LLSD convert_to_llsd(const LLRect& in) { @@ -1348,6 +1387,18 @@ LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, cons } } +template<> +LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +{ + if (type == TYPE_QUAT) + return (LLQuaternion)sd; + else + { + CONTROL_ERRS << "Invalid LLQuaternion value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL; + return LLQuaternion(); + } +} + template<> LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) { diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index de0d366492..f136918896 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -67,6 +67,7 @@ class LLVector3; class LLVector3d; +class LLQuaternion; class LLColor4; class LLColor3; @@ -80,6 +81,7 @@ typedef enum e_control_type TYPE_STRING, TYPE_VEC3, TYPE_VEC3D, + TYPE_QUAT, TYPE_RECT, TYPE_COL4, TYPE_COL3, @@ -220,6 +222,7 @@ public: LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); + LLControlVariable* declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT); @@ -234,10 +237,10 @@ public: LLWString getWString(const std::string& name); LLVector3 getVector3(const std::string& name); - LLVector3d getVector3d(const std::string& name); + LLVector3d getVector3d(const std::string& name); LLRect getRect(const std::string& name); LLSD getLLSD(const std::string& name); - + LLQuaternion getQuaternion(const std::string& name); LLColor4 getColor(const std::string& name); LLColor4 getColor4(const std::string& name); @@ -270,6 +273,7 @@ public: void setString(const std::string& name, const std::string& val); void setVector3(const std::string& name, const LLVector3 &val); void setVector3d(const std::string& name, const LLVector3d &val); + void setQuaternion(const std::string& name, const LLQuaternion &val); void setRect(const std::string& name, const LLRect &val); void setColor4(const std::string& name, const LLColor4 &val); void setLLSD(const std::string& name, const LLSD& val); @@ -436,7 +440,8 @@ template <> eControlType get_control_type(); //template <> eControlType get_control_type () template <> eControlType get_control_type(); template <> eControlType get_control_type(); -template <> eControlType get_control_type(); +template <> eControlType get_control_type(); +template <> eControlType get_control_type(); template <> eControlType get_control_type(); template <> eControlType get_control_type(); template <> eControlType get_control_type(); @@ -444,7 +449,8 @@ template <> eControlType get_control_type(); template <> LLSD convert_to_llsd(const U32& in); template <> LLSD convert_to_llsd(const LLVector3& in); -template <> LLSD convert_to_llsd(const LLVector3d& in); +template <> LLSD convert_to_llsd(const LLVector3d& in); +template <> LLSD convert_to_llsd(const LLQuaternion& in); template <> LLSD convert_to_llsd(const LLRect& in); template <> LLSD convert_to_llsd(const LLColor4& in); template <> LLSD convert_to_llsd(const LLColor3& in); @@ -453,6 +459,7 @@ template<> std::string convert_from_llsd(const LLSD& sd, eControlTy template<> LLWString convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); +template<> LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> bool convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); template<> S32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); diff --git a/indra/llxml/llcontrolgroupreader.h b/indra/llxml/llcontrolgroupreader.h index 6a27a65499..fe77d33fc4 100644 --- a/indra/llxml/llcontrolgroupreader.h +++ b/indra/llxml/llcontrolgroupreader.h @@ -65,6 +65,7 @@ public: virtual void setString(const std::string& name, const std::string& val) {} virtual void setVector3(const std::string& name, const LLVector3 &val) {} virtual void setVector3d(const std::string& name, const LLVector3d &val) {} + virtual void setQuaternion(const std::string& name, const LLQuaternion &val) {} virtual void setRect(const std::string& name, const LLRect &val) {} virtual void setColor4(const std::string& name, const LLColor4 &val) {} virtual void setLLSD(const std::string& name, const LLSD& val) {} diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml index 7b5d597fdf..f9f615c4a7 100644 --- a/indra/newview/app_settings/camera/Front.xml +++ b/indra/newview/app_settings/camera/Front.xml @@ -11,6 +11,22 @@ Value 1 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + CameraAngle Comment diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml index 7aa36c3e59..a084f83bfe 100644 --- a/indra/newview/app_settings/camera/Rear.xml +++ b/indra/newview/app_settings/camera/Rear.xml @@ -11,6 +11,22 @@ Value 1 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + CameraAngle Comment diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml index 8890d9cbce..5db5b164bd 100644 --- a/indra/newview/app_settings/camera/Side.xml +++ b/indra/newview/app_settings/camera/Side.xml @@ -11,6 +11,22 @@ Value 1 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + CameraAngle Comment diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index cc86ba85c1..84448919e1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4397,6 +4397,22 @@ 1.0 + AvatarSitRotation + + Comment + Avatar real sitting rotation used in preset + Persist + 1 + Type + Quaternion + Value + + 0 + 0 + 0 + 1 + + FocusPosOnLogout Comment diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 5efd614b22..7a82cf2f66 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1804,8 +1804,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) at_axis.mV[VZ] = 0.f; at_axis.normalize(); gAgent.resetAxes(at_axis * ~parent_rot); - - local_camera_offset = local_camera_offset * parent_rot; + + local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot; } else { @@ -1998,7 +1998,10 @@ LLVector3d LLAgentCamera::getCurrentFocusOffset() LLQuaternion LLAgentCamera::getCurrentAvatarRotation() { LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent(); - return sit_object ? sit_object->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); + + LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion(); + LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT; + return av_rot * obj_rot; } bool LLAgentCamera::isJoystickCameraUsed() @@ -2828,6 +2831,12 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, return mPointAt->setPointAt(target_type, object, position); } +void LLAgentCamera::rotateToInitSitRot() +{ + gAgent.rotate(~gAgent.getFrameAgent().getQuaternion()); + gAgent.rotate(mInitSitRot); +} + void LLAgentCamera::resetCameraZoomFraction() { mCameraZoomFraction = INITIAL_ZOOM_FRACTION; diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 841b0e353d..ec1ed433d7 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -121,6 +121,8 @@ public: LLVector3d getCurrentFocusOffset(); LLQuaternion getCurrentAvatarRotation(); bool isJoystickCameraUsed(); + void setInitSitRot(LLQuaternion sit_rot) { mInitSitRot = sit_rot; }; + void rotateToInitSitRot(); private: /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ @@ -135,6 +137,8 @@ private: /** Initial focus offset */ LLPointer mFocusOffsetInitial; + LLQuaternion mInitSitRot; + //-------------------------------------------------------------------- // Position //-------------------------------------------------------------------- diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index e1e7ee8445..2399e4f495 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -44,6 +44,7 @@ #include "llfirstuse.h" #include "llhints.h" #include "lltabcontainer.h" +#include "llvoavatarself.h" static LLDefaultChildRegistry::Register r("panel_camera_item"); @@ -566,6 +567,19 @@ void LLFloaterCamera::switchToPreset(const std::string& name) LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name); } + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + LLQuaternion sit_rot = gSavedSettings.getQuaternion("AvatarSitRotation"); + if (sit_rot != LLQuaternion()) + { + gAgent.rotate(~gAgent.getFrameAgent().getQuaternion()); + gAgent.rotate(sit_rot); + } + else + { + gAgentCamera.rotateToInitSitRot(); + } + } gAgentCamera.resetCameraZoomFraction(); LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp index c02f8f0ea1..5704a7a525 100644 --- a/indra/newview/llfloatersavecamerapreset.cpp +++ b/indra/newview/llfloatersavecamerapreset.cpp @@ -28,6 +28,7 @@ #include "llfloatersavecamerapreset.h" +#include "llagent.h" #include "llagentcamera.h" #include "llbutton.h" #include "llcombobox.h" @@ -38,6 +39,7 @@ #include "llpresetsmanager.h" #include "llradiogroup.h" #include "lltrans.h" +#include "llvoavatarself.h" LLFloaterSaveCameraPreset::LLFloaterSaveCameraPreset(const LLSD &key) : LLModalDialog(key) @@ -102,6 +104,10 @@ void LLFloaterSaveCameraPreset::onBtnSave() } else { + if (isAgentAvatarValid() && gAgentAvatarp->getParent()) + { + gSavedSettings.setQuaternion("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion()); + } if (gAgentCamera.isJoystickCameraUsed()) { gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset()); diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp index fb202b4c40..186994c857 100644 --- a/indra/newview/llfloatersettingsdebug.cpp +++ b/indra/newview/llfloatersettingsdebug.cpp @@ -111,6 +111,7 @@ void LLFloaterSettingsDebug::onCommitSettings() LLVector3 vector; LLVector3d vectord; + LLQuaternion quat; LLRect rect; LLColor4 col4; LLColor3 col3; @@ -146,6 +147,13 @@ void LLFloaterSettingsDebug::onCommitSettings() vectord.mdV[VZ] = getChild("val_spinner_3")->getValue().asReal(); controlp->set(vectord.getValue()); break; + case TYPE_QUAT: + quat.mQ[VX] = getChild("val_spinner_1")->getValue().asReal(); + quat.mQ[VY] = getChild("val_spinner_2")->getValue().asReal(); + quat.mQ[VZ] = getChild("val_spinner_3")->getValue().asReal(); + quat.mQ[VS] = getChild("val_spinner_4")->getValue().asReal();; + controlp->set(quat.getValue()); + break; case TYPE_RECT: rect.mLeft = getChild("val_spinner_1")->getValue().asInteger(); rect.mRight = getChild("val_spinner_2")->getValue().asInteger(); @@ -351,6 +359,40 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp) } break; } + case TYPE_QUAT: + { + LLQuaternion q; + q.setValue(sd); + spinner1->setVisible(TRUE); + spinner1->setLabel(std::string("X")); + spinner2->setVisible(TRUE); + spinner2->setLabel(std::string("Y")); + spinner3->setVisible(TRUE); + spinner3->setLabel(std::string("Z")); + spinner4->setVisible(TRUE); + spinner4->setLabel(std::string("S")); + if (!spinner1->hasFocus()) + { + spinner1->setPrecision(4); + spinner1->setValue(q.mQ[VX]); + } + if (!spinner2->hasFocus()) + { + spinner2->setPrecision(4); + spinner2->setValue(q.mQ[VY]); + } + if (!spinner3->hasFocus()) + { + spinner3->setPrecision(4); + spinner3->setValue(q.mQ[VZ]); + } + if (!spinner4->hasFocus()) + { + spinner4->setPrecision(4); + spinner4->setValue(q.mQ[VS]); + } + break; + } case TYPE_RECT: { LLRect r; diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 129187ccbd..4dbd6a523d 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -261,6 +261,7 @@ void LLPresetsManager::getControlNames(std::vector& names) ("TrackFocusObject") ("CameraOffsetRearView") ("FocusOffsetRearView") + ("AvatarSitRotation") ; names = camera_controls; } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index b524db478e..7fb4cc6822 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -7336,7 +7336,8 @@ void LLVOAvatar::sitOnObject(LLViewerObject *sit_object) mRoot->updateWorldMatrixChildren(); stopMotion(ANIM_AGENT_BODY_NOISE); - + + gAgentCamera.setInitSitRot(gAgent.getFrameAgent().getQuaternion()); } //----------------------------------------------------------------------------- -- cgit v1.3