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:
|
||||
|
||||
struct Proxy {
|
||||
Proxy(const Effect* effect)
|
||||
Proxy(const Effect* effect): _effect(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;
|
||||
@ -43,6 +50,8 @@ namespace osgFX
|
||||
|
||||
inline void registerEffect(const Effect* effect);
|
||||
|
||||
inline void removeEffect(const Effect* effect);
|
||||
|
||||
inline const EffectMap& getEffectMap() const;
|
||||
|
||||
protected:
|
||||
@ -69,6 +78,15 @@ namespace osgFX
|
||||
_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
|
||||
|
Loading…
Reference in New Issue
Block a user