From cea6ca478cfb90cac0b16d825647d1234d595117 Mon Sep 17 00:00:00 2001 From: Kitty Barnett <develop@catznip.com> Date: Mon, 12 Jul 2021 23:18:19 +0200 Subject: [PATCH] [FIXED] @setoverlay_touch stopped working with the introduction of @setsphere --- indra/newview/llviewerwindow.cpp | 6 +++--- indra/newview/llvisualeffect.h | 21 ++++++++++++++++++++- indra/newview/rlvdefines.h | 2 +- indra/newview/rlveffects.cpp | 9 --------- indra/newview/rlveffects.h | 2 +- indra/newview/rlvhandler.cpp | 17 +++++++++++++++-- indra/newview/rlvhelper.cpp | 2 +- 7 files changed, 41 insertions(+), 18 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index e7f8997b940..9ab3eb90afe 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5711,11 +5711,11 @@ void LLPickInfo::fetchResults() // [RLVa:KB] - Checked: RLVa-2.2 (@setoverlay) if ( (RlvActions::hasBehaviour(RLV_BHVR_SETOVERLAY)) && (hit_object) && (!hit_object->isHUDAttachment()) ) { - std::list<LLVisualEffect*> effects; + std::list<RlvOverlayEffect*> effects; LLVfxManager::instance().getEffects<RlvOverlayEffect>(effects); - for (const LLVisualEffect* pEffect : effects) + for (const RlvOverlayEffect* pEffect : effects) { - if (pEffect->getEnabled() && static_cast<const RlvOverlayEffect*>(pEffect)->hitTest(mMousePt)) + if (pEffect->getEnabled() && pEffect->hitTest(mMousePt)) { hit_object = nullptr; break; diff --git a/indra/newview/llvisualeffect.h b/indra/newview/llvisualeffect.h index 959e0dbc836..843584b1d98 100644 --- a/indra/newview/llvisualeffect.h +++ b/indra/newview/llvisualeffect.h @@ -169,7 +169,7 @@ class LLVfxManager : public LLSingleton<LLVfxManager> LLVisualEffect* getEffect(EVisualEffect eCode, const LLUUID& idEffect) const; template<typename T> T* getEffect(const LLUUID& idEffect) const { return dynamic_cast<T*>(getEffect(T::EffectCode, idEffect)); } bool getEffects(std::list<LLVisualEffect*>& effectList, std::function<bool(const LLVisualEffect*)> fnFilter); - template<typename T> bool getEffects(std::list<LLVisualEffect*>& effectList) { return getEffects(effectList, [](const LLVisualEffect* pEffect) { return pEffect->getCode() == T::EffectCode; }); } + template<typename T> bool getEffects(std::list<T*>& effectList); bool hasEffect(EVisualEffect eCode) const; bool removeEffect(EVisualEffect eCode, const LLUUID& idEffect); template<typename T> bool removeEffect(const LLUUID& idEffect) { return removeEffect(T::EffectCode, idEffect); } @@ -196,4 +196,23 @@ inline bool LLVfxManager::hasEffect(EVisualEffect eCode) const return m_Effects.end() != std::find_if(m_Effects.begin(), m_Effects.end(), [eCode](const LLVisualEffect* pEffect) { return pEffect->getCode() == eCode; }); } +template<typename T> +inline bool LLVfxManager::getEffects(std::list<T*>& effectList) +{ + effectList.clear(); + + std::function<bool(const LLVisualEffect*)> fnFilter = [](const LLVisualEffect* pEffect) { return pEffect->getCode() == T::EffectCode; }; + auto itEffect = boost::make_filter_iterator(fnFilter, m_Effects.begin(), m_Effects.end()), + endEffect = boost::make_filter_iterator(fnFilter, m_Effects.end(), m_Effects.end()); + while (itEffect != endEffect) + { + if (T* pEffect = dynamic_cast<T*>(*itEffect++)) + { + effectList.push_back(pEffect); + } + } + + return effectList.size(); +} + // ============================================================================ diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index 4b6a2f543d4..dff03ef5361 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -252,6 +252,7 @@ enum ERlvBehaviour { // Effects RLV_BHVR_SETSPHERE, // Gives an object exclusive control of the 'vision spheres' effect RLV_BHVR_SETOVERLAY, // Gives an object exclusive control of the overlay + RLV_BHVR_SETOVERLAY_TOUCH, // Determines whether the overlay texture's alpha channel will be used to allow/block world interaction RLV_BHVR_SETOVERLAY_TWEEN, // Animate between the current overlay settings and the supplied values RLV_BHVR_COUNT, @@ -292,7 +293,6 @@ enum class ERlvLocalBhvrModifier OverlayAlpha, // Transparency level of the overlay texture (in addition to the texture's own alpha channel) OverlayTexture, // Specifies the UUID of the overlay texture OverlayTint, // The tint that's applied to the overlay texture - OverlayTouch, // Determines whether the overlay texture's alpha channel will be used to allow/block world interaction // @setsphere SphereMode, // The type of effect that will apply to any pixel that intersects with the sphere (e.g. blend, blur, ...) SphereOrigin, // The origin of the sphere can either be the avatar or the camera position diff --git a/indra/newview/rlveffects.cpp b/indra/newview/rlveffects.cpp index 70e90301444..b3ad4646468 100644 --- a/indra/newview/rlveffects.cpp +++ b/indra/newview/rlveffects.cpp @@ -58,15 +58,6 @@ ERlvCmdRet RlvOverlayEffect::onAlphaValueChanged(const LLUUID& idRlvObj, const b return RLV_RET_SUCCESS; } -// static -ERlvCmdRet RlvOverlayEffect::onBlockTouchValueChanged(const LLUUID& idRlvObj, const boost::optional<RlvBehaviourModifierValue> newValue) -{ - if (RlvOverlayEffect* pEffect = LLVfxManager::instance().getEffect<RlvOverlayEffect>(idRlvObj)) - { - pEffect->m_fBlockTouch = (newValue) ? boost::get<bool>(newValue.value()) : false; - } - return RLV_RET_SUCCESS; -} // static ERlvCmdRet RlvOverlayEffect::onColorValueChanged(const LLUUID& idRlvObj, const boost::optional<RlvBehaviourModifierValue> newValue) { diff --git a/indra/newview/rlveffects.h b/indra/newview/rlveffects.h index d4378da88f1..e0649ad90b6 100644 --- a/indra/newview/rlveffects.h +++ b/indra/newview/rlveffects.h @@ -39,10 +39,10 @@ class RlvOverlayEffect : public LLVisualEffect public: bool hitTest(const LLCoordGL& ptMouse) const; void run(const LLVisualEffectParams*) override; + void setBlockTouch(bool block_touch) { m_fBlockTouch = block_touch; } void tweenAlpha(float endAlpha, double duration) { m_nAlpha.start(endAlpha, duration); } void tweenColor(LLColor3 endColor, double duration) { m_Color.start(endColor, duration); } static ERlvCmdRet onAlphaValueChanged(const LLUUID& idRlvObj, const boost::optional<RlvBehaviourModifierValue> newValue); - static ERlvCmdRet onBlockTouchValueChanged(const LLUUID& idRlvObj, const boost::optional<RlvBehaviourModifierValue> newValue); static ERlvCmdRet onColorValueChanged(const LLUUID& idRlvObj, const boost::optional<RlvBehaviourModifierValue> newValue); static ERlvCmdRet onTextureChanged(const LLUUID& idRlvObj, const boost::optional<RlvBehaviourModifierValue> newValue); protected: diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 26022657b9e..ffc3870386b 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -2089,7 +2089,7 @@ ERlvCmdRet RlvBehaviourHandler<RLV_BHVR_SETOVERLAY>::onCommand(const RlvCommand& } // Refresh overlay effects according to object hierarchy - std::list<LLVisualEffect*> effects; + std::list<RlvOverlayEffect*> effects; if (LLVfxManager::instance().getEffects<RlvOverlayEffect>(effects)) { auto itActiveEffect = std::find_if(effects.begin(), effects.end(), [](const LLVisualEffect* pEffect) { return pEffect->getEnabled(); }); @@ -2100,17 +2100,30 @@ ERlvCmdRet RlvBehaviourHandler<RLV_BHVR_SETOVERLAY>::onCommand(const RlvCommand& } const LLUUID idActiveRootObj = (effects.end() != itActiveEffect) ? Rlv::getObjectRootId((*itActiveEffect)->getId()) : LLUUID::null; - for (LLVisualEffect* pEffect : effects) + for (RlvOverlayEffect* pEffect : effects) { bool isActive = (idActiveRootObj.isNull() && pEffect == effects.front()) || (Rlv::getObjectRootId(pEffect->getId()) == idActiveRootObj); int nPriority = (isActive) ? 256 - Rlv::getObjectLinkNumber(pEffect->getId()) : pEffect->getPriority(); LLVfxManager::instance().updateEffect(pEffect, isActive, nPriority); + pEffect->setBlockTouch(gRlvHandler.hasBehaviour(pEffect->getId(), RLV_BHVR_SETOVERLAY_TOUCH)); } } return eRet; } +// Handles: @setoverlay_touch=n +template<> template<> +ERlvCmdRet RlvBehaviourHandler<RLV_BHVR_SETOVERLAY_TOUCH>::onCommand(const RlvCommand& rlvCmd, bool& fRefCount) +{ + if (RlvOverlayEffect* pOverlayEffect = LLVfxManager::instance().getEffect<RlvOverlayEffect>(rlvCmd.getObjectID())) + { + pOverlayEffect->setBlockTouch( RLV_TYPE_ADD == rlvCmd.getParamType() ); + } + + return RLV_RET_SUCCESS; +} + // Handles: @setsphere=n|y template<> template<> ERlvCmdRet RlvBehaviourHandler<RLV_BHVR_SETSPHERE>::onCommand(const RlvCommand& rlvCmd, bool& fRefCount) diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 4923d09dc74..212871bbe83 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -228,8 +228,8 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() pSetOverlayBhvr->addModifier(ERlvLocalBhvrModifier::OverlayAlpha, typeid(float), "alpha", &RlvOverlayEffect::onAlphaValueChanged); pSetOverlayBhvr->addModifier(ERlvLocalBhvrModifier::OverlayTexture, typeid(LLUUID), "texture", &RlvOverlayEffect::onTextureChanged); pSetOverlayBhvr->addModifier(ERlvLocalBhvrModifier::OverlayTint, typeid(LLVector3), "tint", &RlvOverlayEffect::onColorValueChanged); - pSetOverlayBhvr->addModifier(ERlvLocalBhvrModifier::OverlayTouch, typeid(LLVector3), "touch", &RlvOverlayEffect::onBlockTouchValueChanged); addEntry(pSetOverlayBhvr); + addEntry(new RlvBehaviourProcessor<RLV_BHVR_SETOVERLAY_TOUCH>("setoverlay_touch")); addEntry(new RlvForceProcessor<RLV_BHVR_SETOVERLAY_TWEEN>("setoverlay_tween")); // Sphere -- GitLab