diff --git a/indra/newview/llvisualeffect.cpp b/indra/newview/llvisualeffect.cpp index 0d95d565e2..3a4594ff09 100644 --- a/indra/newview/llvisualeffect.cpp +++ b/indra/newview/llvisualeffect.cpp @@ -69,7 +69,6 @@ LLVector4 LLTweenableValueLerp::get() // LLVfxManager::LLVfxManager() - : m_Effects(&cmpEffect) { } @@ -81,7 +80,7 @@ bool LLVfxManager::addEffect(LLVisualEffect* pEffectInst) if (m_Effects.end() != itEffect) return false; - m_Effects.insert(pEffectInst); + m_Effects.insert(std::upper_bound(m_Effects.begin(), m_Effects.end(), pEffectInst, cmpEffect), pEffectInst); return true; } @@ -143,6 +142,18 @@ void LLVfxManager::runEffect(std::function predicat } } +void LLVfxManager::updateEffect(LLVisualEffect* pEffect, bool fEnabled, U32 nPriority) +{ + llassert(m_Effects.end() != std::find(m_Effects.begin(), m_Effects.end(), pEffect)); + + if ( (pEffect->getEnabled() != fEnabled) || (pEffect->getPriority() != nPriority) ) + { + pEffect->setEnabled(fEnabled); + pEffect->setPriority(nPriority); + std::sort(m_Effects.begin(), m_Effects.end(), cmpEffect); + } +} + // static bool LLVfxManager::cmpEffect(const LLVisualEffect* pLHS, const LLVisualEffect* pRHS) { @@ -150,7 +161,7 @@ bool LLVfxManager::cmpEffect(const LLVisualEffect* pLHS, const LLVisualEffect* p { // Sort by code, then priority, then memory address return (pLHS->getCode() == pRHS->getCode()) ? (pLHS->getPriority() == pRHS->getPriority() ? pLHS < pRHS - : pLHS->getPriority() < pRHS->getPriority()) + : pLHS->getPriority() > pRHS->getPriority()) : pLHS->getCode() < pRHS->getCode(); } return (pLHS); diff --git a/indra/newview/llvisualeffect.h b/indra/newview/llvisualeffect.h index dc90327fa9..959e0dbc83 100644 --- a/indra/newview/llvisualeffect.h +++ b/indra/newview/llvisualeffect.h @@ -71,6 +71,7 @@ struct LLShaderEffectParams : LLVisualEffectParams class LLVisualEffect { + friend class LLVfxManager; public: LLVisualEffect(LLUUID id, EVisualEffect eCode, EVisualEffectType eType) : m_id(id), m_eCode(eCode), m_eType(eType) @@ -83,10 +84,12 @@ public: U32 getPriority() const { return m_nPriority; } EVisualEffectType getType() const { return m_eType;} void setEnabled(bool enable) { m_fEnabled = enable; } - void setPriority(U32 priority) { m_nPriority = priority; } virtual void run(const LLVisualEffectParams* pParams) = 0; +protected: + void setPriority(U32 priority) { m_nPriority = priority; } + /* * Member variables */ @@ -172,6 +175,7 @@ public: template bool removeEffect(const LLUUID& idEffect) { return removeEffect(T::EffectCode, idEffect); } void runEffect(EVisualEffect eCode, LLVisualEffectParams* pParams = nullptr); void runEffect(EVisualEffectType eType, LLVisualEffectParams* pParams = nullptr); + void updateEffect(LLVisualEffect* pEffect, bool fEnabled, U32 nPriority); protected: void runEffect(std::function fnFilter, LLVisualEffectParams* pParams); static bool cmpEffect(const LLVisualEffect* pLHS, const LLVisualEffect* pRHS); @@ -180,7 +184,7 @@ protected: * Member variables */ protected: - std::set m_Effects; + std::vector m_Effects; }; // ============================================================================