summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaxim_productengine <mnikolenko@productengine.com>2020-01-17 17:54:40 +0200
committermaxim_productengine <mnikolenko@productengine.com>2020-01-17 17:54:40 +0200
commitfcbccd59d98ea0a4a11b26da6b19a9f90f65dae5 (patch)
tree28752362c2ba4f1dfd2bbf63af446b2fc58ab5a9
parent65ea59904c3372102f8c31d3876a231607d7525a (diff)
SL-12424 Allow saving offsets based on current camera position
-rw-r--r--indra/newview/llagentcamera.cpp16
-rw-r--r--indra/newview/llagentcamera.h4
-rw-r--r--indra/newview/llfloatersavecamerapreset.cpp6
3 files changed, 26 insertions, 0 deletions
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<LLVector3>(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<std::string> preset_names;