From ac2d7255e437b148736974f826431f6988cdc97b Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Mon, 29 Jun 2020 22:18:51 -0400 Subject: [PATCH] Fix a bunch of camera constraint issues and settings --- indra/newview/alcontrolcache.cpp | 6 ++++ indra/newview/alcontrolcache.h | 3 ++ .../newview/app_settings/settings_alchemy.xml | 11 +++++++ indra/newview/llagentcamera.cpp | 29 ++++++++++--------- indra/newview/llagentcamera.h | 7 +---- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/indra/newview/alcontrolcache.cpp b/indra/newview/alcontrolcache.cpp index eb552aeb462..39f38c5957e 100644 --- a/indra/newview/alcontrolcache.cpp +++ b/indra/newview/alcontrolcache.cpp @@ -6,6 +6,7 @@ bool ALControlCache::AutoSnapshot = false; bool ALControlCache::AutomaticFly = true; bool ALControlCache::DebugAvatarRezTime = false; +bool ALControlCache::DisableCameraConstraints = false; bool ALControlCache::EditLinkedParts = false; F32 ALControlCache::GridDrawSize; F32 ALControlCache::GridOpacity; @@ -24,6 +25,8 @@ bool ALControlCache::ShowAdultEvents; bool ALControlCache::ShowMatureEvents; bool ALControlCache::SnapEnabled; S32 ALControlCache::ToastGap; +F32 ALControlCache::YawFromMousePosition = 90.f; +F32 ALControlCache::PitchFromMousePosition = 90.f; #define DECLARE_CTRL(ctrl, type, ctrl_type) \ @@ -56,6 +59,7 @@ void ALControlCache::initControls() DECLARE_CTRL_BOOL(AutoSnapshot); DECLARE_CTRL_BOOL(AutomaticFly); DECLARE_CTRL_BOOL(DebugAvatarRezTime); + DECLARE_CTRL_BOOL(DisableCameraConstraints); DECLARE_CTRL_BOOL(EditLinkedParts); DECLARE_CTRL_F32(GridDrawSize); DECLARE_CTRL_F32(GridOpacity); @@ -74,4 +78,6 @@ void ALControlCache::initControls() DECLARE_CTRL_BOOL(ShowMatureEvents); DECLARE_CTRL_BOOL(SnapEnabled); DECLARE_CTRL_S32(ToastGap); + DECLARE_CTRL_F32(YawFromMousePosition); + DECLARE_CTRL_F32(PitchFromMousePosition); } diff --git a/indra/newview/alcontrolcache.h b/indra/newview/alcontrolcache.h index 30b6ac93778..44b6fa2aae4 100644 --- a/indra/newview/alcontrolcache.h +++ b/indra/newview/alcontrolcache.h @@ -8,6 +8,7 @@ struct ALControlCache static bool AutoSnapshot; static bool AutomaticFly; static bool DebugAvatarRezTime; + static bool DisableCameraConstraints; static bool EditLinkedParts; static F32 GridDrawSize; static F32 GridOpacity; @@ -26,6 +27,8 @@ struct ALControlCache static bool ShowMatureEvents; static bool SnapEnabled; static S32 ToastGap; + static F32 YawFromMousePosition; + static F32 PitchFromMousePosition; }; #endif \ No newline at end of file diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml index ba05ff17b72..d464162e281 100644 --- a/indra/newview/app_settings/settings_alchemy.xml +++ b/indra/newview/app_settings/settings_alchemy.xml @@ -211,6 +211,17 @@ <key>Value</key> <string>/tp2cam</string> </map> + <key>AlchemyDisableCameraCollision</key> + <map> + <key>Comment</key> + <string>Disable collision of camera with objects and ground plane</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>AlchemyDisableEffectSpiral</key> <map> <key>Comment</key> diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 646029e5de2..3b291a891a9 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -581,7 +581,7 @@ 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() || mFocusObject->isMesh() || - mDisableCameraConstraints) + ALControlCache::DisableCameraConstraints) { obj_min_distance = 0.f; return TRUE; @@ -963,7 +963,7 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction) new_distance = llmax(new_distance, min_zoom); - F32 max_distance = getCameraMaxZoomDistance(); + F32 max_distance = getCameraMaxZoomDistance(true); max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance. MAINT-3154 @@ -1037,12 +1037,12 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters) new_distance = llmax(new_distance, min_zoom); - F32 max_distance = getCameraMaxZoomDistance(); + F32 max_distance = getCameraMaxZoomDistance(true); if (new_distance > max_distance) { // Unless camera is unlocked - if (!mDisableCameraConstraints) + if (!ALControlCache::DisableCameraConstraints) { return; } @@ -1203,8 +1203,8 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) F32 y_from_center = ((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f; - frameCamera.yaw( - x_from_center * mYawFromMousePosition * DEG_TO_RAD); - frameCamera.pitch( - y_from_center * mPitchFromMousePosition * DEG_TO_RAD); + frameCamera.yaw( - x_from_center * ALControlCache::YawFromMousePosition * DEG_TO_RAD); + frameCamera.pitch( - y_from_center * ALControlCache::PitchFromMousePosition * DEG_TO_RAD); lookAtType = LOOKAT_TARGET_FREELOOK; } @@ -1991,7 +1991,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) camera_position_global = focusPosGlobal + mCameraFocusOffset; } - if (!mDisableCameraConstraints && !gAgent.isGodlike()) + if (!ALControlCache::DisableCameraConstraints && !gAgent.isGodlike()) { LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); bool constrain = true; @@ -2119,7 +2119,7 @@ bool LLAgentCamera::clampCameraPosition(LLVector3d& posCamGlobal, const LLVector m_fRlvMinDist = true; } - if (!isnan(nDistMult)) + if (!llisnan(nDistMult)) { posCamGlobal = posCamRefGlobal + nDistMult * offsetCamera; m_posRlvRefGlobal = posCamRefGlobal; @@ -2176,12 +2176,13 @@ F32 LLAgentCamera::getCameraOffsetScale() const } // [/RLVa:KB] -F32 LLAgentCamera::getCameraMaxZoomDistance() +F32 LLAgentCamera::getCameraMaxZoomDistance(bool allow_disabled_constraints/* = false */) { - // Ignore "DisableCameraConstraints", we don't want to be out of draw range when we focus onto objects or avatars - return llmin(MAX_CAMERA_DISTANCE_FROM_OBJECT, - mDrawDistance - 1, // convenience, don't hit draw limit when focusing on something - LLWorld::getInstance()->getRegionWidthInMeters() - CAMERA_FUDGE_FROM_OBJECT); + return (allow_disabled_constraints && ALControlCache::DisableCameraConstraints) + ? INT_MAX + : llmin(MAX_CAMERA_DISTANCE_FROM_OBJECT, + mDrawDistance - 1, // convenience, don't hit draw limit when focusing on something + LLWorld::getInstance()->getRegionWidthInMeters() - CAMERA_FUDGE_FROM_OBJECT); } LLVector3 LLAgentCamera::getAvatarRootPosition() @@ -2255,7 +2256,7 @@ F32 LLAgentCamera::getCameraMinOffGround() { return 0.f; } - return mDisableCameraConstraints ? -1000.f : 0.5f; + return ALControlCache::DisableCameraConstraints ? -1000.f : 0.5f; } diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 61b74c9932d..f2c451a0389 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -139,7 +139,7 @@ class LLAgentCamera private: /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */ - F32 getCameraMaxZoomDistance(); + F32 getCameraMaxZoomDistance(bool allow_disabled_constraints = false); /** Camera preset in Third Person Mode */ ECameraPreset mCameraPreset; @@ -458,11 +458,6 @@ class LLAgentCamera /** Keys ** ** *******************************************************************************/ - // Settings - bool mDisableCameraConstraints = false; - F32 mCameraOffsetScale = 1.f; - F32 mYawFromMousePosition = 90.f; - F32 mPitchFromMousePosition = 90.f; }; extern LLAgentCamera gAgentCamera; -- GitLab