From Johannes Scholz, "as we need to dynamically add and remove Effects to and from our Application, I created a small patch for osgFX/Registry to add the osgFX::Registry::removeEffect(effect*) method and extended osgFX::Registry::Proxy to call removeEffect upon its destruction."
This commit is contained in:
parent
a270a7635e
commit
2f1d3626de
@ -31,10 +31,17 @@ namespace osgFX
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
struct Proxy {
|
struct Proxy {
|
||||||
Proxy(const Effect* effect)
|
Proxy(const Effect* effect): _effect(effect)
|
||||||
{
|
{
|
||||||
Registry::instance()->registerEffect(effect);
|
Registry::instance()->registerEffect(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Proxy()
|
||||||
|
{
|
||||||
|
Registry::instance()->removeEffect(_effect.get());
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
osg::ref_ptr<const Effect> _effect;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<std::string, osg::ref_ptr<const Effect> > EffectMap;
|
typedef std::map<std::string, osg::ref_ptr<const Effect> > EffectMap;
|
||||||
@ -43,6 +50,8 @@ namespace osgFX
|
|||||||
|
|
||||||
inline void registerEffect(const Effect* effect);
|
inline void registerEffect(const Effect* effect);
|
||||||
|
|
||||||
|
inline void removeEffect(const Effect* effect);
|
||||||
|
|
||||||
inline const EffectMap& getEffectMap() const;
|
inline const EffectMap& getEffectMap() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -69,6 +78,15 @@ namespace osgFX
|
|||||||
_effects[effect->effectName()] = effect;
|
_effects[effect->effectName()] = effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Registry::removeEffect(const Effect* effect)
|
||||||
|
{
|
||||||
|
EffectMap::iterator itr = _effects.find(effect->effectName());
|
||||||
|
if (itr != _effects.end())
|
||||||
|
{
|
||||||
|
_effects.erase(itr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user