Add CompositorInstance::Listener::notifyMaterialRemoved
Posted: Thu Jan 31, 2013 1:42 pm
Hi guys,
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
OgreCompositorInstance.cpp:
Inside the RSQuadOperation class, add a destructor:
Edit: due to how the compositor is designed, we need to ensure that the rende operations will be destroyed before it's parent technique, so we've to add clearCompiledState() to the the following compositor chain functions: (OgreCompositorChain.cpp)
Not a very smart solution, but it works
. Any better solution would require deeper changes so, since in Ogre 2.0 the compositor system will be updated (see dark_sylinc notes), I think it's ok for now.
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;
}