From 1720f2ebe46c83c2747241bd56f2bb67ac51dea8 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Tue, 26 May 2015 05:34:05 -0400 Subject: [PATCH] [RLVa] @camzoommax, @camzoommin Reload current saved zoom for clamping when imposing this restriction, whether that be mouselook zoom or regular. Also some code cleanup. --- indra/newview/llviewercamera.cpp | 8 +++++- indra/newview/llviewermenu.cpp | 7 ++--- indra/newview/rlvhandler.cpp | 45 ++++++++++++++++++++++++++++---- indra/newview/rlvhandler.h | 4 ++- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 3247d6884..b11d81411 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -715,11 +715,17 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts) // changes local camera and broadcasts change /* virtual */ void LLViewerCamera::setView(F32 vertical_fov_rads) { - F32 old_fov = LLViewerCamera::getInstance()->getView(); + F32 old_fov = getView(); // cap the FoV vertical_fov_rads = llclamp(vertical_fov_rads, getMinView(), getMaxView()); +// RLVa:LF - @camzoommax + if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMZOOMMAX)) + vertical_fov_rads = llmin(vertical_fov_rads, gRlvHandler.camMax(RLV_BHVR_CAMZOOMMAX)); + if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMZOOMMIN)) + vertical_fov_rads = llmax(vertical_fov_rads, gRlvHandler.camMin(RLV_BHVR_CAMZOOMMIN)); + if (vertical_fov_rads == old_fov) return; // send the new value to the simulator diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 25a44ec65..8ab7f27e4 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -9230,9 +9230,10 @@ void initialize_menus() LLZoomer(F32 val, bool mult=true) : mVal(val), mMult(mult) {} bool handleEvent(LLPointer event, const LLSD& userdata) { - F32 new_fov_rad = mMult ? LLViewerCamera::getInstance()->getDefaultFOV() * mVal : mVal; - LLViewerCamera::getInstance()->setDefaultFOV(new_fov_rad); - gSavedSettings.setF32("CameraAngle", LLViewerCamera::getInstance()->getView()); // setView may have clamped it. + LLViewerCamera& inst(LLViewerCamera::instance()); + F32 new_fov_rad = mMult ? inst.getDefaultFOV() * mVal : mVal; + inst.setDefaultFOV(new_fov_rad); + gSavedSettings.setF32("CameraAngle", inst.getView()); // setView may have clamped it. return true; } private: diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index a0ea47ebe..d0a1a64f4 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -21,6 +21,7 @@ #include "llgroupactions.h" #include "llhudtext.h" #include "llstartup.h" +#include "llviewercamera.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" @@ -840,11 +841,35 @@ bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const return true; } +F32 RlvHandler::camMax(const ERlvBehaviour& bhvr) const +{ + F32 ret(F32_MAX); + for (rlv_exception_map_t::const_iterator i = m_Exceptions.lower_bound(bhvr), + end = m_Exceptions.upper_bound(bhvr); i != end; ++i) + { + F32 val(boost::get(i->second.varOption)); + if (val < ret) ret = val; + } + return ret; +} + +F32 RlvHandler::camMin(const ERlvBehaviour& bhvr) const +{ + F32 ret(F32_MIN); + for (rlv_exception_map_t::const_iterator i = m_Exceptions.lower_bound(bhvr), + end = m_Exceptions.upper_bound(bhvr); i != end; ++i) + { + F32 val(boost::get(i->second.varOption)); + if (val > ret) ret = val; + } + return ret; +} + LLColor3 RlvHandler::camDrawColor() const { LLColor3 ret; U32 count(0); - for (rlv_exception_map_t::const_iterator i = m_Exceptions.lower_bound(RLV_BHVR_CAMDRAWCOLOR), + for (rlv_exception_map_t::const_iterator i = m_Exceptions.lower_bound(RLV_BHVR_CAMDRAWCOLOR), end = m_Exceptions.upper_bound(RLV_BHVR_CAMDRAWCOLOR); i != end; ++i, ++count) ret += boost::get(i->second.varOption); ret.mV[0]/=count; @@ -856,7 +881,7 @@ LLColor3 RlvHandler::camDrawColor() const F32 RlvHandler::camAvDist() const { F32 ret(F32_MAX); - for (rlv_exception_map_t::const_iterator i = m_Exceptions.lower_bound(RLV_BHVR_CAMAVDIST), + for (rlv_exception_map_t::const_iterator i = m_Exceptions.lower_bound(RLV_BHVR_CAMAVDIST), end = m_Exceptions.upper_bound(RLV_BHVR_CAMAVDIST); i != end; ++i) { F32 dist(boost::get(i->second.varOption)); @@ -1324,11 +1349,21 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd) } break; case RLV_BHVR_CAMZOOMMAX: // @camzoommax:=n|y - Checked: 2015-05-25 (RLVa:LF) - eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement - break; case RLV_BHVR_CAMZOOMMIN: // @camzoommin:=n|y - Checked: 2015-05-25 (RLVa:LF) - eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement + { + F32 zoom; + LLStringUtil::convertToF32(strOption, zoom); + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, zoom); + else + removeException(rlvCmd.getObjectID(), eBhvr, zoom); + if (hasBehaviour(eBhvr)) + { + LLViewerCamera& inst(LLViewerCamera::instance()); + inst.mSavedFOVLoaded ? inst.loadDefaultFOV() : inst.setDefaultFOV(gSavedSettings.getF32("CameraAngle")); + } break; + } case RLV_BHVR_CAMDISTMAX: // @camdistmax:=n|y - Checked: 2015-05-25 (RLVa:LF) eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement break; diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index d243e6d8d..a1b83e13d 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -100,7 +100,9 @@ public: bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; // @touch bool filterChat(std::string& strUTF8Text, bool fFilterEmote) const; // @sendchat, @recvchat and @redirchat bool redirectChatOrEmote(const std::string& strUTF8Test) const; // @redirchat and @rediremote - LLColor3 camDrawColor() const; // @camdrawcolor + F32 camMax(const ERlvBehaviour& bhvr) const; // @cam*max + F32 camMin(const ERlvBehaviour& bhvr) const; // @cam*min + LLColor3 camDrawColor() const; // @camdrawcolor F32 camAvDist() const; // @camavdist // Command processing helper functions