[RLVa] @camzoommax, @camzoommin

Reload current saved zoom for clamping when imposing this restriction, whether that be mouselook zoom or regular.
Also some code cleanup.
This commit is contained in:
Inusaito Sayori
2015-05-26 05:34:05 -04:00
parent 9616a43cb0
commit 1720f2ebe4
4 changed files with 54 additions and 10 deletions

View File

@@ -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

View File

@@ -9230,9 +9230,10 @@ void initialize_menus()
LLZoomer(F32 val, bool mult=true) : mVal(val), mMult(mult) {}
bool handleEvent(LLPointer<LLEvent> 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:

View File

@@ -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<F32>(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<F32>(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<LLColor3>(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<F32>(i->second.varOption));
@@ -1324,11 +1349,21 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd)
}
break;
case RLV_BHVR_CAMZOOMMAX: // @camzoommax:<max_multiplier>=n|y - Checked: 2015-05-25 (RLVa:LF)
eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement
break;
case RLV_BHVR_CAMZOOMMIN: // @camzoommin:<min_multiplier>=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:<max_distance>=n|y - Checked: 2015-05-25 (RLVa:LF)
eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement
break;

View File

@@ -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