diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 1392f155b84238f19275bec15e77b667a2332fc9..744c49085b6710ab2c2cad1d6ecafaa28eea38d9 100755 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2150,6 +2150,10 @@ void LLAgentCamera::resetCamera() void LLAgentCamera::changeCameraToMouselook(BOOL animate) { if (!gSavedSettings.getBOOL("EnableMouselook") +// [RLVa:KB] - Checked: RLVa-2.0.0 + || ( (RlvActions::isRlvEnabled()) && (!RlvActions::canChangeToMouselook()) ) +// [/RLVa:KB] + || LLViewerJoystick::getInstance()->getOverrideCamera()) { return; diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index f1c9ec27ab0a073b23d40880c0941cf2e1891cb0..528694617f488859405ab4d2fb49c04e69bda674 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -41,6 +41,17 @@ bool RlvActions::canChangeCameraPreset(const LLUUID& idRlvObject) (!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_EYEOFFSET)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_FOCUSOFFSET)); } +bool RlvActions::canChangeToMouselook() +{ + // User can switch to mouselook if: + // - not specifically prevented from going into mouselook (NOTE: if an object has exclusive camera control only that object can prevent mouselook) + // - there is no minimum camera distance defined (or it's higher than > 0m) + const RlvBehaviourModifier* pCamDistMinModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_SETCAM_AVDISTMIN); + return + ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM)) ? !gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_MOUSELOOK) : !gRlvHandler.hasBehaviour(pCamDistMinModifier->getPrimaryObject(), RLV_BHVR_SETCAM_MOUSELOOK) ) && + ( (!pCamDistMinModifier->hasValue()) || (pCamDistMinModifier->getValue<float>() == 0.f) ); +} + bool RlvActions::isCameraDistanceClamped() { return diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index 2fbe9e0acadf100815d9abbf5b23d813762f3da4..fab61644123c50d0e622ec04b588d008682273c5 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -39,6 +39,11 @@ public: */ static bool canChangeCameraPreset(const LLUUID& idRlvObject); + /* + * Returns true if the user can switch to mouselook + */ + static bool canChangeToMouselook(); + /* * Returns true if the camera's distance (from either the avatar of the focus) is currently restricted/clamped */ diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index db6c9845864b801a7b8ebc4f270ba255bb80ae7e..086b54e8bf3ddc236af0d07834bbd22200e9c308 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -200,6 +200,7 @@ enum ERlvBehaviour { RLV_BHVR_SETCAM_FOV, // Changes the current (vertical) field of view RLV_BHVR_SETCAM_FOVMIN, // Enforces a minimum (vertical) FOV RLV_BHVR_SETCAM_FOVMAX, // Enforces a maximum (vertical) FOV + RLV_BHVR_SETCAM_MOUSELOOK, // Prevent the user from going into mouselook RLV_BHVR_SETCAM_TEXTURES, // Replaces all textures with the specified texture (or the default unrezzed one) RLV_BHVR_SETCAM_UNLOCK, // Forces the camera focus to the user's avatar diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 072950200e2bd3cc67668d604369558c5e993d97..29d0e13d64e1db162c55aeb14a1250bc11a240f1 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -1639,12 +1639,13 @@ void RlvBehaviourToggleHandler<RLV_BHVR_SENDIM>::onCommandToggle(ERlvBehaviour e gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->setHiddenFromSettingsEditor(fHasBhvr); } -// Handles: @setcam_unlock=n|y toggles -template<> template<> -void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM_UNLOCK>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) +// Handles: @setcam_avdistmin:<distance>=n|y changes +template<> +void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_AVDISTMIN>::onValueChange() const { - if (fHasBhvr) - handle_reset_view(); + const RlvBehaviourModifier* pBhvrModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_SETCAM_AVDISTMIN); + if ( (gAgentCamera.cameraMouselook()) && (!RlvActions::canChangeToMouselook()) ) + gAgentCamera.changeCameraToThirdPerson(); } // Handles: @setcam_eyeoffset:<vector3>=n|y and @setcam_focusoffset:<vector3>=n|y toggles @@ -1706,6 +1707,14 @@ void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_FOVMAX>::onValueChange() co LLViewerCamera::instance().setDefaultFOV(LLViewerCamera::instance().getDefaultFOV()); } +// Handles: @setcam_mouselook=n|y toggles +template<> template<> +void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM_MOUSELOOK>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) +{ + if ((fHasBhvr) && (gAgentCamera.cameraMouselook())) + gAgentCamera.changeCameraToThirdPerson(); +} + // Handles: @setcam_textures[:<uuid>=n|y changes template<> void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_TEXTURE>::onValueChange() const @@ -1727,6 +1736,14 @@ void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_TEXTURE>::onValueChange() c } } +// Handles: @setcam_unlock=n|y toggles +template<> template<> +void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM_UNLOCK>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) +{ + if (fHasBhvr) + handle_reset_view(); +} + // Handles: @setcam=n|y toggles template<> template<> void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr) diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 83a8949e0dead07c51213e092bf9db92cb525a7a..a7b3b8c9600c666874b1d13ed22ea90d275a27a1 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -162,9 +162,9 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() // Camera addEntry(new RlvBehaviourToggleProcessor<RLV_BHVR_SETCAM, RLV_OPTION_NONE>("setcam")); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_avdistmin", RLV_BHVR_SETCAM_AVDISTMIN)); - addModifier(RLV_BHVR_SETCAM_AVDISTMIN, RLV_MODIFIER_SETCAM_AVDISTMIN, new RlvBehaviourModifier(0.0f, true, new RlvBehaviourModifier_CompMax())); + addModifier(RLV_BHVR_SETCAM_AVDISTMIN, RLV_MODIFIER_SETCAM_AVDISTMIN, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_AVDISTMIN>(0.0f, false, new RlvBehaviourModifier_CompMax())); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_avdistmax", RLV_BHVR_SETCAM_AVDISTMAX)); - addModifier(RLV_BHVR_SETCAM_AVDISTMAX, RLV_MODIFIER_SETCAM_AVDISTMAX, new RlvBehaviourModifier(F32_MAX, true, new RlvBehaviourModifier_CompMin())); + addModifier(RLV_BHVR_SETCAM_AVDISTMAX, RLV_MODIFIER_SETCAM_AVDISTMAX, new RlvBehaviourModifier(F32_MAX, false, new RlvBehaviourModifier_CompMin())); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_focusdistmin", RLV_BHVR_SETCAM_FOCUSDISTMIN)); addModifier(RLV_BHVR_SETCAM_FOCUSDISTMIN, RLV_MODIFIER_SETCAM_FOCUSDISTMIN, new RlvBehaviourModifier(0.0f, true, new RlvBehaviourModifier_CompMax())); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_focusdistmax", RLV_BHVR_SETCAM_FOCUSDISTMAX)); @@ -176,6 +176,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_fovmin", RLV_BHVR_SETCAM_FOVMIN)); addModifier(RLV_BHVR_SETCAM_FOVMIN, RLV_MODIFIER_SETCAM_FOVMIN, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_FOVMIN>(DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifier_CompMax())); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_fovmax", RLV_BHVR_SETCAM_FOVMAX)); + addEntry(new RlvBehaviourToggleProcessor<RLV_BHVR_SETCAM_MOUSELOOK, RLV_OPTION_NONE>("setcam_mouselook")); addModifier(RLV_BHVR_SETCAM_FOVMAX, RLV_MODIFIER_SETCAM_FOVMAX, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_FOVMAX>(DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifier_CompMin())); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE_OR_MODIFIER>("setcam_textures", RLV_BHVR_SETCAM_TEXTURES)); addModifier(RLV_BHVR_SETCAM_TEXTURES, RLV_MODIFIER_SETCAM_TEXTURE, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_TEXTURE>(IMG_DEFAULT, true, nullptr)); @@ -415,6 +416,11 @@ bool RlvBehaviourModifier::addValue(const RlvBehaviourModifierValue& modValue, c return false; } +const LLUUID& RlvBehaviourModifier::getPrimaryObject() const +{ + return (m_pValueComparator) ? m_pValueComparator->m_idPrimaryObject : LLUUID::null; +} + bool RlvBehaviourModifier::hasValue() const { // If no primary object is set this returns "any value set"; otherwise it returns "any value set by the primary object" if ( (!m_pValueComparator) || (m_pValueComparator->m_idPrimaryObject.isNull()) ) diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index f8e94468dd80f3880cdde7bcb2f7fa3520805004..35576d40516e01f4481ea64aadef3082668463cc 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -212,6 +212,7 @@ public: bool convertOptionValue(const std::string& optionValue, RlvBehaviourModifierValue& modValue) const; bool getAddDefault() const { return m_fAddDefaultOnEmpty; } const RlvBehaviourModifierValue& getDefaultValue() const { return m_DefaultValue; } + const LLUUID& getPrimaryObject() const; const RlvBehaviourModifierValue& getValue() const { return (hasValue()) ? m_Values.front().first : m_DefaultValue; } template<typename T> const T& getValue() const { return boost::get<T>(getValue()); } bool hasValue() const;