Allow dynamic changes to effect priority
parent
70237de361
commit
1fd98d08d2
|
|
@ -69,7 +69,6 @@ LLVector4 LLTweenableValueLerp<LLVector4>::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<bool(const LLVisualEffect*)> 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);
|
||||
|
|
|
|||
|
|
@ -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<typename T> 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<bool(const LLVisualEffect*)> fnFilter, LLVisualEffectParams* pParams);
|
||||
static bool cmpEffect(const LLVisualEffect* pLHS, const LLVisualEffect* pRHS);
|
||||
|
|
@ -180,7 +184,7 @@ protected:
|
|||
* Member variables
|
||||
*/
|
||||
protected:
|
||||
std::set<LLVisualEffect*, decltype(&cmpEffect)> m_Effects;
|
||||
std::vector<LLVisualEffect*> m_Effects;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Reference in New Issue