summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2020-04-20 14:27:22 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2020-04-20 14:27:22 +0300
commit74d6e6b65c9c3e85e8ec84939b35a1e584379e1f (patch)
tree594978c1282ff02e37525b6f94f310d4299a1583 /indra/newview
parent70d340a1bff2707138ac41fdd1408a5b2e46fc71 (diff)
SL-12904 FIXED Camera Preset does not restore correctly when sitting
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/camera/Front.xml16
-rw-r--r--indra/newview/app_settings/camera/Rear.xml16
-rw-r--r--indra/newview/app_settings/camera/Side.xml16
-rw-r--r--indra/newview/app_settings/settings.xml16
-rw-r--r--indra/newview/llagentcamera.cpp15
-rw-r--r--indra/newview/llagentcamera.h4
-rw-r--r--indra/newview/llfloatercamera.cpp14
-rw-r--r--indra/newview/llfloatersavecamerapreset.cpp6
-rw-r--r--indra/newview/llfloatersettingsdebug.cpp42
-rw-r--r--indra/newview/llpresetsmanager.cpp1
-rw-r--r--indra/newview/llvoavatar.cpp3
11 files changed, 145 insertions, 4 deletions
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 @@
<key>Value</key>
<integer>1</integer>
</map>
+ <key>AvatarSitRotation</key>
+ <map>
+ <key>Comment</key>
+ <string>Avatar real sitting rotation used in preset</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Quaternion</string>
+ <key>Value</key>
+ <array>
+ <real>0</real>
+ <real>0</real>
+ <real>0</real>
+ <real>1</real>
+ </array>
+ </map>
<key>CameraAngle</key>
<map>
<key>Comment</key>
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 @@
<key>Value</key>
<integer>1</integer>
</map>
+ <key>AvatarSitRotation</key>
+ <map>
+ <key>Comment</key>
+ <string>Avatar real sitting rotation used in preset</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Quaternion</string>
+ <key>Value</key>
+ <array>
+ <real>0</real>
+ <real>0</real>
+ <real>0</real>
+ <real>1</real>
+ </array>
+ </map>
<key>CameraAngle</key>
<map>
<key>Comment</key>
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 @@
<key>Value</key>
<integer>1</integer>
</map>
+ <key>AvatarSitRotation</key>
+ <map>
+ <key>Comment</key>
+ <string>Avatar real sitting rotation used in preset</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Quaternion</string>
+ <key>Value</key>
+ <array>
+ <real>0</real>
+ <real>0</real>
+ <real>0</real>
+ <real>1</real>
+ </array>
+ </map>
<key>CameraAngle</key>
<map>
<key>Comment</key>
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 @@
<real>1.0</real>
</array>
</map>
+ <key>AvatarSitRotation</key>
+ <map>
+ <key>Comment</key>
+ <string>Avatar real sitting rotation used in preset</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Quaternion</string>
+ <key>Value</key>
+ <array>
+ <real>0</real>
+ <real>0</real>
+ <real>0</real>
+ <real>1</real>
+ </array>
+ </map>
<key>FocusPosOnLogout</key>
<map>
<key>Comment</key>
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<LLControlVariable> 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<LLPanelCameraItem> 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<LLUICtrl>("val_spinner_3")->getValue().asReal();
controlp->set(vectord.getValue());
break;
+ case TYPE_QUAT:
+ quat.mQ[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
+ quat.mQ[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
+ quat.mQ[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
+ quat.mQ[VS] = getChild<LLUICtrl>("val_spinner_4")->getValue().asReal();;
+ controlp->set(quat.getValue());
+ break;
case TYPE_RECT:
rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger();
rect.mRight = getChild<LLUICtrl>("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<std::string>& 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());
}
//-----------------------------------------------------------------------------