summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llagentcamera.cpp179
1 files changed, 91 insertions, 88 deletions
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index d2fe570069..098ff8fea9 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -100,6 +100,12 @@ const F32 GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME = 0.5f;
const F32 OBJECT_EXTENTS_PADDING = 0.5f;
+static bool isDisableCameraConstraints()
+{
+ static LLCachedControl<bool> sDisableCameraConstraints(gSavedSettings, "DisableCameraConstraints", false);
+ return sDisableCameraConstraints;
+}
+
// The agent instance.
LLAgentCamera gAgentCamera;
@@ -570,9 +576,9 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
{
BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
- if (!mFocusObject || mFocusObject->isDead() ||
+ if (!mFocusObject || mFocusObject->isDead() ||
mFocusObject->isMesh() ||
- gSavedSettings.getBOOL("DisableCameraConstraints"))
+ isDisableCameraConstraints())
{
obj_min_distance = 0.f;
return TRUE;
@@ -742,39 +748,44 @@ F32 LLAgentCamera::getCameraZoomFraction(bool get_third_person)
// already [0,1]
return mHUDTargetZoom;
}
- else if (get_third_person || (mFocusOnAvatar && cameraThirdPerson()))
+
+ if (isDisableCameraConstraints())
+ {
+ return mCameraZoomFraction;
+ }
+
+ if (get_third_person || (mFocusOnAvatar && cameraThirdPerson()))
{
return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f);
}
- else if (cameraCustomizeAvatar())
+
+ if (cameraCustomizeAvatar())
{
F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
}
- else
- {
- F32 min_zoom;
- F32 max_zoom = getCameraMaxZoomDistance();
- F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
- if (mFocusObject.notNull())
+ F32 min_zoom;
+ F32 max_zoom = getCameraMaxZoomDistance();
+
+ F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
+ if (mFocusObject.notNull())
+ {
+ if (mFocusObject->isAvatar())
{
- if (mFocusObject->isAvatar())
- {
- min_zoom = AVATAR_MIN_ZOOM;
- }
- else
- {
- min_zoom = OBJECT_MIN_ZOOM;
- }
+ min_zoom = AVATAR_MIN_ZOOM;
}
else
{
- min_zoom = LAND_MIN_ZOOM;
+ min_zoom = OBJECT_MIN_ZOOM;
}
-
- return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
}
+ else
+ {
+ min_zoom = LAND_MIN_ZOOM;
+ }
+
+ return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
}
void LLAgentCamera::setCameraZoomFraction(F32 fraction)
@@ -787,6 +798,10 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction)
{
mHUDTargetZoom = fraction;
}
+ else if (isDisableCameraConstraints())
+ {
+ mCameraZoomFraction = fraction;
+ }
else if (mFocusOnAvatar && cameraThirdPerson())
{
mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
@@ -821,6 +836,7 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction)
camera_offset_dir.normalize();
mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
}
+
startCameraAnimation();
}
@@ -925,49 +941,40 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction)
return;
}
-
- LLVector3d camera_offset_unit(mCameraFocusOffsetTarget);
- F32 min_zoom = LAND_MIN_ZOOM;
+ LLVector3d camera_offset_unit(mCameraFocusOffsetTarget);
F32 current_distance = (F32)camera_offset_unit.normalize();
F32 new_distance = current_distance * fraction;
- // Don't move through focus point
- if (mFocusObject)
+ // Unless camera is unlocked
+ if (!isDisableCameraConstraints())
{
- LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]);
+ F32 min_zoom = LAND_MIN_ZOOM;
- if (mFocusObject->isAvatar())
- {
- calcCameraMinDistance(min_zoom);
- }
- else
+ // Don't move through focus point
+ if (mFocusObject)
{
- min_zoom = OBJECT_MIN_ZOOM;
- }
- }
+ LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]);
- new_distance = llmax(new_distance, min_zoom);
-
- F32 max_distance = getCameraMaxZoomDistance();
+ if (mFocusObject->isAvatar())
+ {
+ calcCameraMinDistance(min_zoom);
+ }
+ else
+ {
+ min_zoom = OBJECT_MIN_ZOOM;
+ }
+ }
- max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance. MAINT-3154
+ new_distance = llmax(new_distance, min_zoom);
- if (new_distance > max_distance)
- {
- new_distance = max_distance;
+ F32 max_distance = getCameraMaxZoomDistance();
+ max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance. MAINT-3154
+ new_distance = llmin(new_distance, max_distance);
- /*
- // Unless camera is unlocked
- if (!LLViewerCamera::sDisableCameraConstraints)
+ if (cameraCustomizeAvatar())
{
- return;
+ new_distance = llclamp(new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM);
}
- */
- }
-
- if(cameraCustomizeAvatar())
- {
- new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
}
mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
@@ -990,53 +997,52 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters)
changeCameraToMouselook(FALSE);
}
- mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION);
+ if (!isDisableCameraConstraints())
+ {
+ mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION);
+ }
}
else
{
LLVector3d camera_offset_unit(mCameraFocusOffsetTarget);
F32 current_distance = (F32)camera_offset_unit.normalize();
F32 new_distance = current_distance - meters;
- F32 min_zoom = LAND_MIN_ZOOM;
-
- // Don't move through focus point
- if (mFocusObject.notNull())
+
+ // Unless camera is unlocked
+ if (!isDisableCameraConstraints())
{
- if (mFocusObject->isAvatar())
- {
- min_zoom = AVATAR_MIN_ZOOM;
- }
- else
+ F32 min_zoom = LAND_MIN_ZOOM;
+
+ // Don't move through focus point
+ if (mFocusObject.notNull())
{
- min_zoom = OBJECT_MIN_ZOOM;
+ if (mFocusObject->isAvatar())
+ {
+ min_zoom = AVATAR_MIN_ZOOM;
+ }
+ else
+ {
+ min_zoom = OBJECT_MIN_ZOOM;
+ }
}
- }
- new_distance = llmax(new_distance, min_zoom);
+ new_distance = llmax(new_distance, min_zoom);
- F32 max_distance = getCameraMaxZoomDistance();
+ F32 max_distance = getCameraMaxZoomDistance();
+ new_distance = llmin(new_distance, max_distance);
- if (new_distance > max_distance)
- {
- // Unless camera is unlocked
- if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
+ if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
{
- return;
+ new_distance = llclamp(new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM);
}
}
- if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() )
- {
- new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
- }
-
// Compute new camera offset
mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
cameraZoomIn(1.f);
}
}
-
//-----------------------------------------------------------------------------
// cameraPanIn()
//-----------------------------------------------------------------------------
@@ -1835,7 +1841,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
}
- if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
+ if (!isDisableCameraConstraints() && !mCameraCollidePlane.isExactlyZero() &&
+ (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
{
LLVector3 plane_normal;
plane_normal.setVec(mCameraCollidePlane.mV);
@@ -1954,7 +1961,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
camera_position_global = focusPosGlobal + mCameraFocusOffset;
}
- if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike())
+ if (!isDisableCameraConstraints() && !gAgent.isGodlike())
{
LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
bool constrain = true;
@@ -2118,17 +2125,13 @@ F32 LLAgentCamera::getCameraMinOffGround()
{
return 0.f;
}
- else
+
+ if (isDisableCameraConstraints())
{
- if (gSavedSettings.getBOOL("DisableCameraConstraints"))
- {
- return -1000.f;
- }
- else
- {
- return 0.5f;
- }
+ return -1000.f;
}
+
+ return 0.5f;
}