From 0a02abd0e37905676dccaa57963f52e9d228313f Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 7 May 2018 14:17:25 +0200 Subject: [PATCH] Move most of the behaviour modifier code over to the new files --HG-- branch : RLVa --- indra/newview/llglsandbox.cpp | 2 +- indra/newview/llselectmgr.cpp | 2 +- indra/newview/lltoolplacer.cpp | 2 +- indra/newview/lltoolselect.cpp | 2 +- indra/newview/rlvactions.cpp | 2 + indra/newview/rlvhelper.cpp | 48 ++++++------- indra/newview/rlvhelper.h | 110 +----------------------------- indra/newview/rlvmodifiers.h | 119 +++++++++++++++++++++++++++++++++ 8 files changed, 152 insertions(+), 135 deletions(-) diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 22f3143f45..db3819f58a 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -66,7 +66,7 @@ // [RLVa:KB] - Checked: 2010-04-11 (RLVa-1.2.0e) #include "rlvactions.h" #include "rlvhandler.h" -#include "rlvhelper.h" +#include "rlvmodifiers.h" // [/RLVa:KB] #include diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 6dd5f516e6..6b350f6205 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -97,7 +97,7 @@ // [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a) #include "rlvactions.h" #include "rlvhandler.h" -#include "rlvhelper.h" +#include "rlvmodifiers.h" // [/RLVa:KB] #include "llglheaders.h" diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index ea819811ef..864d0d77b0 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -45,7 +45,7 @@ #include "llui.h" // [RLVa:KB] - Checked: 2010-03-23 (RLVa-1.2.0a) #include "rlvhandler.h" -#include "rlvhelper.h" +#include "rlvmodifiers.h" // [/RLVa:KB] //Headers added for functions moved from viewer.cpp diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 92f8db9ddb..a572b06dff 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -49,7 +49,7 @@ #include "llworld.h" // [RLVa:KB] - Checked: RLVa-2.0.0 #include "rlvactions.h" -#include "rlvhelper.h" +#include "rlvmodifiers.h" #include "llfloaterreg.h" // [/RLVa:KB] diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index f724737e0d..74207b96a7 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -20,10 +20,12 @@ #include "llviewercamera.h" #include "llvoavatarself.h" #include "llworld.h" + #include "rlvactions.h" #include "rlvhelper.h" #include "rlvhandler.h" #include "rlvinventory.h" +#include "rlvmodifiers.h" // ============================================================================ // Camera diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 22256d1da4..8dbfc69215 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -101,7 +101,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourGenericProcessor("editobj", RLV_BHVR_EDITOBJ)); addEntry(new RlvBehaviourGenericProcessor("emote", RLV_BHVR_EMOTE)); addEntry(new RlvBehaviourGenericProcessor("fartouch", RLV_BHVR_FARTOUCH)); - addModifier(RLV_BHVR_FARTOUCH, RLV_MODIFIER_FARTOUCHDIST, new RlvBehaviourModifier("Fartouch Distance", RLV_MODIFIER_FARTOUCH_DEFAULT, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_FARTOUCH, RLV_MODIFIER_FARTOUCHDIST, new RlvBehaviourModifier("Fartouch Distance", RLV_MODIFIER_FARTOUCH_DEFAULT, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("fly", RLV_BHVR_FLY)); addEntry(new RlvBehaviourGenericProcessor("interact", RLV_BHVR_INTERACT, RlvBehaviourInfo::BHVR_EXTENDED)); addEntry(new RlvBehaviourInfo("notify", RLV_BHVR_NOTIFY, RLV_TYPE_ADDREM)); @@ -111,8 +111,8 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourGenericProcessor("recvemote", RLV_BHVR_RECVEMOTE, RlvBehaviourInfo::BHVR_STRICT)); addEntry(new RlvBehaviourGenericProcessor("recvemotefrom", RLV_BHVR_RECVEMOTEFROM, RlvBehaviourInfo::BHVR_STRICT)); addEntry(new RlvBehaviourProcessor("recvim", RlvBehaviourInfo::BHVR_STRICT)); - addModifier(RLV_BHVR_RECVIM, RLV_MODIFIER_RECVIMDISTMIN, new RlvBehaviourModifier("RecvIM Distance (Min)", F32_MAX, true, new RlvBehaviourModifier_CompMax)); - addModifier(RLV_BHVR_RECVIM, RLV_MODIFIER_RECVIMDISTMAX, new RlvBehaviourModifier("RecvIM Distance (Max)", F32_MAX, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_RECVIM, RLV_MODIFIER_RECVIMDISTMIN, new RlvBehaviourModifier("RecvIM Distance (Min)", F32_MAX, true, new RlvBehaviourModifierCompMax)); + addModifier(RLV_BHVR_RECVIM, RLV_MODIFIER_RECVIMDISTMAX, new RlvBehaviourModifier("RecvIM Distance (Max)", F32_MAX, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("recvimfrom", RLV_BHVR_RECVIMFROM, RlvBehaviourInfo::BHVR_STRICT)); addEntry(new RlvBehaviourInfo("redirchat", RLV_BHVR_REDIRCHAT, RLV_TYPE_ADDREM)); addEntry(new RlvBehaviourInfo("rediremote", RLV_BHVR_REDIREMOTE, RLV_TYPE_ADDREM)); @@ -123,8 +123,8 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourProcessor("sendchannel_except", RlvBehaviourInfo::BHVR_STRICT | RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addEntry(new RlvBehaviourGenericProcessor("sendchat", RLV_BHVR_SENDCHAT)); addEntry(new RlvBehaviourToggleProcessor("sendim", RlvBehaviourInfo::BHVR_STRICT)); - addModifier(RLV_BHVR_SENDIM, RLV_MODIFIER_SENDIMDISTMIN, new RlvBehaviourModifier("SendIM Distance (Min)", F32_MAX, true, new RlvBehaviourModifier_CompMax)); - addModifier(RLV_BHVR_SENDIM, RLV_MODIFIER_SENDIMDISTMAX, new RlvBehaviourModifier("SendIM Distance (Max)", F32_MAX, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_SENDIM, RLV_MODIFIER_SENDIMDISTMIN, new RlvBehaviourModifier("SendIM Distance (Min)", F32_MAX, true, new RlvBehaviourModifierCompMax)); + addModifier(RLV_BHVR_SENDIM, RLV_MODIFIER_SENDIMDISTMAX, new RlvBehaviourModifier("SendIM Distance (Max)", F32_MAX, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("sendimto", RLV_BHVR_SENDIMTO, RlvBehaviourInfo::BHVR_STRICT)); addEntry(new RlvBehaviourGenericProcessor("sendgesture", RLV_BHVR_SENDGESTURE, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addEntry(new RlvBehaviourGenericToggleProcessor("setdebug")); @@ -147,11 +147,11 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourGenericProcessor("showworldmap", RLV_BHVR_SHOWWORLDMAP)); addEntry(new RlvBehaviourGenericProcessor("sit", RLV_BHVR_SIT)); addEntry(new RlvBehaviourGenericProcessor("sittp", RLV_BHVR_SITTP)); - addModifier(RLV_BHVR_SITTP, RLV_MODIFIER_SITTPDIST, new RlvBehaviourModifier("SitTp Distance", RLV_MODIFIER_SITTP_DEFAULT, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_SITTP, RLV_MODIFIER_SITTPDIST, new RlvBehaviourModifier("SitTp Distance", RLV_MODIFIER_SITTP_DEFAULT, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("standtp", RLV_BHVR_STANDTP)); addEntry(new RlvBehaviourProcessor("startim", RlvBehaviourInfo::BHVR_STRICT)); - addModifier(RLV_BHVR_STARTIM, RLV_MODIFIER_STARTIMDISTMIN, new RlvBehaviourModifier("StartIM Distance (Min)", F32_MAX, true, new RlvBehaviourModifier_CompMax)); - addModifier(RLV_BHVR_STARTIM, RLV_MODIFIER_STARTIMDISTMAX, new RlvBehaviourModifier("StartIM Distance (Max)", F32_MAX, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_STARTIM, RLV_MODIFIER_STARTIMDISTMIN, new RlvBehaviourModifier("StartIM Distance (Min)", F32_MAX, true, new RlvBehaviourModifierCompMax)); + addModifier(RLV_BHVR_STARTIM, RLV_MODIFIER_STARTIMDISTMAX, new RlvBehaviourModifier("StartIM Distance (Max)", F32_MAX, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("startimto", RLV_BHVR_STARTIMTO, RlvBehaviourInfo::BHVR_STRICT)); addEntry(new RlvBehaviourGenericProcessor("temprun", RLV_BHVR_TEMPRUN)); addEntry(new RlvBehaviourGenericProcessor("touchall", RLV_BHVR_TOUCHALL)); @@ -166,7 +166,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourGenericProcessor("tplm", RLV_BHVR_TPLM)); addEntry(new RlvBehaviourGenericProcessor("tploc", RLV_BHVR_TPLOC)); addEntry(new RlvBehaviourGenericProcessor("tplocal", RLV_BHVR_TPLOCAL, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); - addModifier(RLV_BHVR_TPLOCAL, RLV_MODIFIER_TPLOCALDIST, new RlvBehaviourModifier("Local Teleport Distance", RLV_MODIFIER_TPLOCAL_DEFAULT, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_TPLOCAL, RLV_MODIFIER_TPLOCALDIST, new RlvBehaviourModifier("Local Teleport Distance", RLV_MODIFIER_TPLOCAL_DEFAULT, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("tplure", RLV_BHVR_TPLURE, RlvBehaviourInfo::BHVR_STRICT)); addEntry(new RlvBehaviourGenericProcessor("tprequest", RLV_BHVR_TPREQUEST, RlvBehaviourInfo::BHVR_STRICT | RlvBehaviourInfo::BHVR_EXTENDED)); addEntry(new RlvBehaviourInfo("unsharedunwear", RLV_BHVR_UNSHAREDUNWEAR, RLV_TYPE_ADDREM)); @@ -179,21 +179,21 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() // Camera addEntry(new RlvBehaviourGenericToggleProcessor("setcam")); addEntry(new RlvBehaviourGenericProcessor("setcam_avdistmin", RLV_BHVR_SETCAM_AVDISTMIN, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); - addModifier(RLV_BHVR_SETCAM_AVDISTMIN, RLV_MODIFIER_SETCAM_AVDISTMIN, new RlvBehaviourModifierHandler("Camera - Avatar Distance (Min)", 0.0f, false, new RlvBehaviourModifier_CompMax())); + addModifier(RLV_BHVR_SETCAM_AVDISTMIN, RLV_MODIFIER_SETCAM_AVDISTMIN, new RlvBehaviourModifierHandler("Camera - Avatar Distance (Min)", 0.0f, false, new RlvBehaviourModifierCompMax())); addEntry(new RlvBehaviourGenericProcessor("setcam_avdistmax", RLV_BHVR_SETCAM_AVDISTMAX, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); - addModifier(RLV_BHVR_SETCAM_AVDISTMAX, RLV_MODIFIER_SETCAM_AVDISTMAX, new RlvBehaviourModifier("Camera - Avatar Distance (Max)", F32_MAX, false, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_SETCAM_AVDISTMAX, RLV_MODIFIER_SETCAM_AVDISTMAX, new RlvBehaviourModifier("Camera - Avatar Distance (Max)", F32_MAX, false, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericProcessor("setcam_origindistmin", RLV_BHVR_SETCAM_ORIGINDISTMIN, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); - addModifier(RLV_BHVR_SETCAM_ORIGINDISTMIN, RLV_MODIFIER_SETCAM_ORIGINDISTMIN, new RlvBehaviourModifier("Camera - Focus Distance (Min)", 0.0f, true, new RlvBehaviourModifier_CompMax)); + addModifier(RLV_BHVR_SETCAM_ORIGINDISTMIN, RLV_MODIFIER_SETCAM_ORIGINDISTMIN, new RlvBehaviourModifier("Camera - Focus Distance (Min)", 0.0f, true, new RlvBehaviourModifierCompMax)); addEntry(new RlvBehaviourGenericProcessor("setcam_origindistmax", RLV_BHVR_SETCAM_ORIGINDISTMAX, RlvBehaviourInfo::BHVR_EXPERIMENTAL)); - addModifier(RLV_BHVR_SETCAM_ORIGINDISTMAX, RLV_MODIFIER_SETCAM_ORIGINDISTMAX, new RlvBehaviourModifier("Camera - Focus Distance (Max)", F32_MAX, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_SETCAM_ORIGINDISTMAX, RLV_MODIFIER_SETCAM_ORIGINDISTMAX, new RlvBehaviourModifier("Camera - Focus Distance (Max)", F32_MAX, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericToggleProcessor("setcam_eyeoffset", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addModifier(RLV_BHVR_SETCAM_EYEOFFSET, RLV_MODIFIER_SETCAM_EYEOFFSET, new RlvBehaviourModifierHandler("Camera - Eye Offset", LLVector3::zero, true, nullptr)); addEntry(new RlvBehaviourGenericToggleProcessor("setcam_focusoffset", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addModifier(RLV_BHVR_SETCAM_FOCUSOFFSET, RLV_MODIFIER_SETCAM_FOCUSOFFSET, new RlvBehaviourModifierHandler("Camera - Focus Offset", LLVector3::zero, true, nullptr)); addEntry(new RlvBehaviourProcessor("setcam_fovmin")); - addModifier(RLV_BHVR_SETCAM_FOVMIN, RLV_MODIFIER_SETCAM_FOVMIN, new RlvBehaviourModifierHandler("Camera - FOV (Min)", DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifier_CompMax)); + addModifier(RLV_BHVR_SETCAM_FOVMIN, RLV_MODIFIER_SETCAM_FOVMIN, new RlvBehaviourModifierHandler("Camera - FOV (Min)", DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifierCompMax)); addEntry(new RlvBehaviourProcessor("setcam_fovmax")); - addModifier(RLV_BHVR_SETCAM_FOVMAX, RLV_MODIFIER_SETCAM_FOVMAX, new RlvBehaviourModifierHandler("Camera - FOV (Max)", DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifier_CompMin)); + addModifier(RLV_BHVR_SETCAM_FOVMAX, RLV_MODIFIER_SETCAM_FOVMAX, new RlvBehaviourModifierHandler("Camera - FOV (Max)", DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifierCompMin)); addEntry(new RlvBehaviourGenericToggleProcessor("setcam_mouselook")); addEntry(new RlvBehaviourGenericProcessor("setcam_textures", RLV_BHVR_SETCAM_TEXTURES)); addModifier(RLV_BHVR_SETCAM_TEXTURES, RLV_MODIFIER_SETCAM_TEXTURE, new RlvBehaviourModifierHandler("Camera - Forced Texture", IMG_DEFAULT, true, nullptr)); @@ -209,13 +209,13 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() // Overlay addEntry(new RlvBehaviourGenericToggleProcessor("setoverlay", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addModifier(new RlvForceGenericProcessor("setoverlay_alpha", RLV_BHVR_SETOVERLAY_ALPHA, RlvBehaviourInfo::BHVR_EXPERIMENTAL), - RLV_MODIFIER_OVERLAY_ALPHA, new RlvBehaviourModifier("Overlay - Alpha", 1.0f, false, new RlvBehaviourModifier_Comp())); + RLV_MODIFIER_OVERLAY_ALPHA, new RlvBehaviourModifier("Overlay - Alpha", 1.0f, false, new RlvBehaviourModifierComp())); addModifier(new RlvForceGenericProcessor("setoverlay_texture", RLV_BHVR_SETOVERLAY_TEXTURE, RlvBehaviourInfo::BHVR_EXPERIMENTAL), - RLV_MODIFIER_OVERLAY_TEXTURE, new RlvBehaviourModifierHandler("Overlay - Texture", LLUUID::null, false, new RlvBehaviourModifier_Comp())); + RLV_MODIFIER_OVERLAY_TEXTURE, new RlvBehaviourModifierHandler("Overlay - Texture", LLUUID::null, false, new RlvBehaviourModifierComp())); addModifier(new RlvForceGenericProcessor("setoverlay_tint", RLV_BHVR_SETOVERLAY_TINT, RlvBehaviourInfo::BHVR_EXPERIMENTAL), - RLV_MODIFIER_OVERLAY_TINT, new RlvBehaviourModifier("Overlay - Tint", LLVector3(1.0f, 1.0f, 1.0f), false, new RlvBehaviourModifier_Comp())); + RLV_MODIFIER_OVERLAY_TINT, new RlvBehaviourModifier("Overlay - Tint", LLVector3(1.0f, 1.0f, 1.0f), false, new RlvBehaviourModifierComp())); addModifier(new RlvBehaviourGenericProcessor("setoverlay_touch", RLV_BHVR_SETOVERLAY_TOUCH, RlvBehaviourInfo::BHVR_EXPERIMENTAL), - RLV_MODIFIER_OVERLAY_TOUCH, new RlvBehaviourModifier("Overlay - Touch", true, true, new RlvBehaviourModifier_Comp())); + RLV_MODIFIER_OVERLAY_TOUCH, new RlvBehaviourModifier("Overlay - Touch", true, true, new RlvBehaviourModifierComp())); addEntry(new RlvForceProcessor("setoverlay_tween", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); // @@ -449,10 +449,10 @@ void RlvBehaviourDictionary::toggleBehaviourFlag(const std::string& strBhvr, ERl // RlvBehaviourModifier // -RlvBehaviourModifier::RlvBehaviourModifier(std::string strName, const RlvBehaviourModifierValue& defaultValue, bool fAddDefaultOnEmpty, RlvBehaviourModifier_Comp* pValueComparator) +RlvBehaviourModifier::RlvBehaviourModifier(std::string strName, const RlvBehaviourModifierValue& defaultValue, bool fAddDefaultOnEmpty, RlvBehaviourModifierComp* pValueComparator) : m_strName(strName), m_DefaultValue(defaultValue), m_fAddDefaultOnEmpty(fAddDefaultOnEmpty), m_pValueComparator(pValueComparator) { - m_pValueComparator = (pValueComparator) ? pValueComparator : new RlvBehaviourModifier_Comp(); + m_pValueComparator = (pValueComparator) ? pValueComparator : new RlvBehaviourModifierComp(); } RlvBehaviourModifier::~RlvBehaviourModifier() @@ -468,7 +468,7 @@ bool RlvBehaviourModifier::addValue(const RlvBehaviourModifierValue& modValue, c { if (modValue.which() == m_DefaultValue.which()) { - m_Values.insert((m_pValueComparator) ? std::lower_bound(m_Values.begin(), m_Values.end(), std::make_tuple(modValue, idRlvObj, eBhvr), boost::bind(&RlvBehaviourModifier_Comp::operator(), m_pValueComparator, _1, _2)) : m_Values.end(), std::make_tuple(modValue, idRlvObj, eBhvr)); + m_Values.insert((m_pValueComparator) ? std::lower_bound(m_Values.begin(), m_Values.end(), std::make_tuple(modValue, idRlvObj, eBhvr), boost::bind(&RlvBehaviourModifierComp::operator(), m_pValueComparator, _1, _2)) : m_Values.end(), std::make_tuple(modValue, idRlvObj, eBhvr)); // NOTE: change signal needs to trigger before modifier handlers so cached values have a chance to update properly m_ChangeSignal(getValue()); onValueChange(); @@ -528,7 +528,7 @@ void RlvBehaviourModifier::setPrimaryObject(const LLUUID& idPrimaryObject) if (m_pValueComparator) { m_pValueComparator->m_idPrimaryObject = idPrimaryObject; - m_Values.sort(boost::bind(&RlvBehaviourModifier_Comp::operator(), m_pValueComparator, _1, _2)); + m_Values.sort(boost::bind(&RlvBehaviourModifierComp::operator(), m_pValueComparator, _1, _2)); onValueChange(); m_ChangeSignal(getValue()); } @@ -547,7 +547,7 @@ void RlvBehaviourModifier::setValue(const RlvBehaviourModifierValue& modValue, c // The object already has a modifier value set => change it std::get<0>(*itValue) = modValue; if (m_pValueComparator) - m_Values.sort(boost::bind(&RlvBehaviourModifier_Comp::operator(), m_pValueComparator, _1, _2)); + m_Values.sort(boost::bind(&RlvBehaviourModifierComp::operator(), m_pValueComparator, _1, _2)); onValueChange(); m_ChangeSignal(getValue()); } diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index 97116894d9..6cf2c5c62e 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -30,6 +30,7 @@ // class RlvBehaviourModifier; +struct RlvBehaviourModifierComp; // ============================================================================ // RlvBehaviourInfo class - Generic behaviour descriptor (used by restrictions, reply and force commands) @@ -230,42 +231,10 @@ template RlvBehaviourModifierValueTuple; -struct RlvBehaviourModifier_Comp -{ - virtual ~RlvBehaviourModifier_Comp() {} - virtual bool operator()(const RlvBehaviourModifierValueTuple& lhs, const RlvBehaviourModifierValueTuple& rhs) - { - // Values that match the primary object take precedence (otherwise maintain relative ordering) - if ( (std::get<1>(rhs) == m_idPrimaryObject) && (std::get<1>(lhs) != m_idPrimaryObject) ) - return false; - return true; - } - - LLUUID m_idPrimaryObject; -}; -struct RlvBehaviourModifier_CompMin : public RlvBehaviourModifier_Comp -{ - bool operator()(const RlvBehaviourModifierValueTuple& lhs, const RlvBehaviourModifierValueTuple& rhs) override - { - if ( (m_idPrimaryObject.isNull()) || ((std::get<1>(lhs) == m_idPrimaryObject) && (std::get<1>(rhs) == m_idPrimaryObject)) ) - return std::get<0>(lhs) < std::get<0>(rhs); - return RlvBehaviourModifier_Comp::operator()(lhs, rhs); - } -}; -struct RlvBehaviourModifier_CompMax : public RlvBehaviourModifier_Comp -{ - bool operator()(const RlvBehaviourModifierValueTuple& lhs, const RlvBehaviourModifierValueTuple& rhs) override - { - if ( (m_idPrimaryObject.isNull()) || ((std::get<1>(lhs) == m_idPrimaryObject) && (std::get<1>(rhs) == m_idPrimaryObject)) ) - return std::get<0>(rhs) < std::get<0>(lhs); - return RlvBehaviourModifier_Comp::operator()(lhs, rhs); - } -}; - class RlvBehaviourModifier { public: - RlvBehaviourModifier(const std::string strName, const RlvBehaviourModifierValue& defaultValue, bool fAddDefaultOnEmpty, RlvBehaviourModifier_Comp* pValueComparator = nullptr); + RlvBehaviourModifier(const std::string strName, const RlvBehaviourModifierValue& defaultValue, bool fAddDefaultOnEmpty, RlvBehaviourModifierComp* pValueComparator = nullptr); virtual ~RlvBehaviourModifier(); /* @@ -301,80 +270,7 @@ protected: bool m_fAddDefaultOnEmpty; std::list m_Values; change_signal_t m_ChangeSignal; - RlvBehaviourModifier_Comp* m_pValueComparator; -}; - -template -class RlvBehaviourModifierHandler : public RlvBehaviourModifier -{ -public: - //using RlvBehaviourModifier::RlvBehaviourModifier; // Needs VS2015 and up - RlvBehaviourModifierHandler(const std::string& strName, const RlvBehaviourModifierValue& defaultValue, bool fAddDefaultOnEmpty, RlvBehaviourModifier_Comp* pValueComparator) - : RlvBehaviourModifier(strName, defaultValue, fAddDefaultOnEmpty, pValueComparator) {} -protected: - void onValueChange() const override; -}; - -// Inspired by LLControlCache -template -class RlvBehaviourModifierCache : public LLRefCount, public LLInstanceTracker, ERlvBehaviourModifier> -{ -public: - RlvBehaviourModifierCache(ERlvBehaviourModifier eModifier) - : LLInstanceTracker, ERlvBehaviourModifier>(eModifier) - { - RlvBehaviourModifier* pBhvrModifier = (eModifier < RLV_MODIFIER_COUNT) ? RlvBehaviourDictionary::instance().getModifier(eModifier) : nullptr; - if (pBhvrModifier) - { - mConnection = pBhvrModifier->getSignal().connect(boost::bind(&RlvBehaviourModifierCache::handleValueChange, this, _1)); - mCachedValue = pBhvrModifier->getValue(); - } - else - { - mCachedValue = {}; - } - } - ~RlvBehaviourModifierCache() {} - - /* - * Member functions - */ -public: - const T& getValue() const { return mCachedValue; } -protected: - void handleValueChange(const RlvBehaviourModifierValue& newValue) { mCachedValue = boost::get(newValue); } - - /* - * Member variables - */ -protected: - T mCachedValue; - boost::signals2::scoped_connection mConnection; -}; - -// Inspired by LLCachedControl -template -class RlvCachedBehaviourModifier -{ -public: - RlvCachedBehaviourModifier(ERlvBehaviourModifier eModifier) - { - if ((mCachedModifierPtr = RlvBehaviourModifierCache::getInstance(eModifier)) == nullptr) - mCachedModifierPtr = new RlvBehaviourModifierCache(eModifier); - } - - /* - * Operators - */ -public: - operator const T&() const { return mCachedModifierPtr->getValue(); } - const T& operator()() { return mCachedModifierPtr->getValue(); } - - /* - * Member variables - */ -protected: - LLPointer> mCachedModifierPtr; + RlvBehaviourModifierComp* m_pValueComparator; }; // ============================================================================ diff --git a/indra/newview/rlvmodifiers.h b/indra/newview/rlvmodifiers.h index 7328530a97..3ccec3e71c 100644 --- a/indra/newview/rlvmodifiers.h +++ b/indra/newview/rlvmodifiers.h @@ -20,6 +20,59 @@ #include "llsingleton.h" #include "rlvhelper.h" +// ==================================================================================== +// RlvBehaviourModifierHandler - Behaviour modifiers change handler class (use this if changes require code to be processed) +// + +template +class RlvBehaviourModifierHandler : public RlvBehaviourModifier +{ +public: + //using RlvBehaviourModifier::RlvBehaviourModifier; // Needs VS2015 and up + RlvBehaviourModifierHandler(const std::string& strName, const RlvBehaviourModifierValue& defaultValue, bool fAddDefaultOnEmpty, RlvBehaviourModifierComp* pValueComparator) + : RlvBehaviourModifier(strName, defaultValue, fAddDefaultOnEmpty, pValueComparator) {} +protected: + void onValueChange() const override; +}; + +// ==================================================================================== +// RlvBehaviourModifierComp - Behaviour modifiers comparers (used for sorting) +// + +struct RlvBehaviourModifierComp +{ + virtual ~RlvBehaviourModifierComp() {} + virtual bool operator()(const RlvBehaviourModifierValueTuple& lhs, const RlvBehaviourModifierValueTuple& rhs) + { + // Values that match the primary object take precedence (otherwise maintain relative ordering) + if ( (std::get<1>(rhs) == m_idPrimaryObject) && (std::get<1>(lhs) != m_idPrimaryObject) ) + return false; + return true; + } + + LLUUID m_idPrimaryObject; +}; + +struct RlvBehaviourModifierCompMin : public RlvBehaviourModifierComp +{ + bool operator()(const RlvBehaviourModifierValueTuple& lhs, const RlvBehaviourModifierValueTuple& rhs) override + { + if ( (m_idPrimaryObject.isNull()) || ((std::get<1>(lhs) == m_idPrimaryObject) && (std::get<1>(rhs) == m_idPrimaryObject)) ) + return std::get<0>(lhs) < std::get<0>(rhs); + return RlvBehaviourModifierComp::operator()(lhs, rhs); + } +}; + +struct RlvBehaviourModifierCompMax : public RlvBehaviourModifierComp +{ + bool operator()(const RlvBehaviourModifierValueTuple& lhs, const RlvBehaviourModifierValueTuple& rhs) override + { + if ( (m_idPrimaryObject.isNull()) || ((std::get<1>(lhs) == m_idPrimaryObject) && (std::get<1>(rhs) == m_idPrimaryObject)) ) + return std::get<0>(rhs) < std::get<0>(lhs); + return RlvBehaviourModifierComp::operator()(lhs, rhs); + } +}; + // ==================================================================================== // RlvBehaviourModifierAnimator - A class to animate behaviour modifiers // @@ -71,3 +124,69 @@ protected: }; // ==================================================================================== +// RlvCachedBehaviourModifier - Provides an optimized way to access a modifier that's frequently accessed and rarely updated +// + +// Inspired by LLControlCache +template +class RlvBehaviourModifierCache : public LLRefCount, public LLInstanceTracker, ERlvBehaviourModifier> +{ +public: + RlvBehaviourModifierCache(ERlvBehaviourModifier eModifier) + : LLInstanceTracker, ERlvBehaviourModifier>(eModifier) + { + if (RlvBehaviourModifier* pBhvrModifier = RlvBehaviourDictionary::instance().getModifier(eModifier)) + { + mConnection = pBhvrModifier->getSignal().connect(boost::bind(&RlvBehaviourModifierCache::handleValueChange, this, _1)); + mCachedValue = pBhvrModifier->getValue(); + } + else + { + mCachedValue = {}; + RLV_ASSERT(false); + } + } + ~RlvBehaviourModifierCache() {} + + /* + * Member functions + */ +public: + const T& getValue() const { return mCachedValue; } +protected: + void handleValueChange(const RlvBehaviourModifierValue& newValue) { mCachedValue = boost::get(newValue); } + + /* + * Member variables + */ +protected: + T mCachedValue; + boost::signals2::scoped_connection mConnection; +}; + +// Inspired by LLCachedControl +template +class RlvCachedBehaviourModifier +{ +public: + RlvCachedBehaviourModifier(ERlvBehaviourModifier eModifier) + { + if ((mCachedModifierPtr = RlvBehaviourModifierCache::getInstance(eModifier)) == nullptr) + mCachedModifierPtr = new RlvBehaviourModifierCache(eModifier); + } + + /* + * Operators + */ +public: + operator const T&() const { return mCachedModifierPtr->getValue(); } + const T& operator()() { return mCachedModifierPtr->getValue(); } + + /* + * Member variables + */ +protected: + LLPointer> mCachedModifierPtr; +}; + +// ====================================================================================