I've a simple papercut related to the compositor instance listener: add another function to notify when a compositor local/temporal material has been "removed" (== the target operation has been removed), so the material is no longer valid.
Changes:
OgreCompositorInstance.h:
Inside the Listener class
Code: Select all
/** Notification of when a render target operation involving a material (like
rendering a quad) is destroyed, so the temporal material is no longer valid
@param pass_id Pass identifier within Compositor instance, this is specified
by the user by CompositionPass::setIdentifier().
@param mat Material, this may be changed at will and will only affect
the current instance of the Compositor, not the global material
it was cloned from.
*/
virtual void notifyMaterialRemoved(uint32 pass_id, MaterialPtr &mat);
Code: Select all
/** Notify listeners when a material is no longer valir
*/
void _fireNotifyMaterialRemoved(uint32 pass_id, MaterialPtr &mat);
Inside the RSQuadOperation class, add a destructor:
Code: Select all
~RSQuadOperation()
{
instance->_fireNotifyMaterialRemoved(pass_id, mat);
}
Code: Select all
void CompositorInstance::_fireNotifyMaterialRemoved(uint32 pass_id, MaterialPtr &mat)
{
Listeners::iterator i, iend=mListeners.end();
for(i=mListeners.begin(); i!=iend; ++i)
(*i)->notifyMaterialRemoved(pass_id, mat);
}
Code: Select all
void CompositorInstance::Listener::notifyMaterialRemoved(uint32 pass_id, MaterialPtr &mat)
{
}
Code: Select all
//-----------------------------------------------------------------------
void CompositorChain::removeCompositor(size_t index)
{
clearCompiledState();
assert (index < mInstances.size() && "Index out of bounds.");
Instances::iterator i = mInstances.begin() + index;
OGRE_DELETE *i;
mInstances.erase(i);
mDirty = true;
}
//-----------------------------------------------------------------------
size_t CompositorChain::getNumCompositors()
{
return mInstances.size();
}
//-----------------------------------------------------------------------
void CompositorChain::removeAllCompositors()
{
clearCompiledState();
Instances::iterator i, iend;
iend = mInstances.end();
for (i = mInstances.begin(); i != iend; ++i)
{
OGRE_DELETE *i;
}
mInstances.clear();
mDirty = true;
}