Skip to content
Snippets Groups Projects
Commit fcbccd59 authored by maxim_productengine's avatar maxim_productengine
Browse files

SL-12424 Allow saving offsets based on current camera position

parent 65ea5990
No related branches found
No related tags found
No related merge requests found
......@@ -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, "");
......
......@@ -117,6 +117,10 @@ class LLAgentCamera
/** 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();
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment