//---------------------------------------------------------------------
void CompositorManager::_reconstructAllCompositorResources()
{
    // In order to deal with shared resources, we have to disable *all* compositors
    // first, that way shared resources will get freed
    typedef vector<CompositorInstance*>::type InstVec;
    InstVec instancesToReenable;
    for (Chains::iterator i = mChains.begin(); i != mChains.end(); ++i)
    {
        CompositorChain* chain = i->second;
        CompositorChain::InstanceIterator instIt = chain->getCompositors();
        while (instIt.hasMoreElements())
        {
            CompositorInstance* inst = instIt.getNext();
            if (inst->getEnabled())
            {
                inst->setEnabled(false);
                instancesToReenable.push_back(inst);
            }
        }
    }

    //UVs are lost, and will never be reconstructed unless we do them again, now
    if( mRectangle )
        mRectangle->setDefaultUVs();

    for (InstVec::iterator i = instancesToReenable.begin(); i != instancesToReenable.end(); ++i)
    {
        CompositorInstance* inst = *i;
        inst->setEnabled(true);
    }
}
DeferredShadingSystem::~DeferredShadingSystem()
{
	// Delete mini lights
	for(std::set<MLight*>::iterator i=mLights.begin(); i!=mLights.end(); ++i)
	{
		delete (*i);
	}
	// Delete the ambient light
	delete mAmbientLight;

	if (mCurrentMode==DSM_SHOWLIT && mInstance[mCurrentMode]->getEnabled())
	{
		RenderTarget* renderTarget = mInstance[mCurrentMode]->getRenderTarget("mrt_output");
		assert(renderTarget);

		LogManager::getSingleton().logMessage("Removing Listener from:");
		LogManager::getSingleton().logMessage(renderTarget->getName());

		renderTarget->removeListener(this);
	}

	CompositorChain *chain = CompositorManager::getSingleton().getCompositorChain(mViewport);
	for(int i=0; i<DSM_COUNT; ++i)
		chain->_removeInstance(mInstance[i]);

	delete mLightMaterialGenerator;
}
Beispiel #3
0
	DeferredShadingSystem::~DeferredShadingSystem()
	{
		CompositorChain *chain = CompositorManager::getSingleton().getCompositorChain(mViewport);
		for(int i=0; i<DSM_COUNT; ++i)
			chain->_removeInstance(mInstance[i]);
		CompositorManager::getSingleton().removeCompositorChain(mViewport);
	}
//-----------------------------------------------------------------------
CompositorInstance *CompositorManager::addCompositor(Viewport *vp, const String &compositor, int addPosition)
{
    CompositorPtr comp = getByName(compositor);
    if(comp.isNull())
        return 0;
    CompositorChain *chain = getCompositorChain(vp);
    return chain->addCompositor(comp, addPosition==-1 ? CompositorChain::LAST : (size_t)addPosition);
}
//-----------------------------------------------------------------------
void CompositorManager::setCompositorEnabled(Viewport *vp, const String &compositor, bool value)
{
    CompositorChain *chain = getCompositorChain(vp);
    for(size_t pos=0; pos < chain->getNumCompositors(); ++pos)
    {
        CompositorInstance *instance = chain->getCompositor(pos);
        if(instance->getCompositor()->getName() == compositor)
        {
            chain->setCompositorEnabled(pos, value);
            break;
        }
    }
}
//-----------------------------------------------------------------------
void CompositorManager::removeCompositor(Viewport *vp, const String &compositor)
{
    CompositorChain *chain = getCompositorChain(vp);
    for(size_t pos=0; pos < chain->getNumCompositors(); ++pos)
    {
        CompositorInstance *instance = chain->getCompositor(pos);
        if(instance->getCompositor()->getName() == compositor)
        {
            chain->removeCompositor(pos);
            break;
        }
    }
}
//-----------------------------------------------------------------------
void CompositorManager::_relocateChain( Viewport* sourceVP, Viewport* destVP )
{
    if (sourceVP != destVP)
    {
        CompositorChain *chain = getCompositorChain(sourceVP);
        Ogre::RenderTarget *srcTarget = sourceVP->getTarget();
        Ogre::RenderTarget *dstTarget = destVP->getTarget();
        if (srcTarget != dstTarget)
        {
            srcTarget->removeListener(chain);
            dstTarget->addListener(chain);
        }
        chain->_notifyViewport(destVP);
        mChains.erase(sourceVP);
        mChains[destVP] = chain;
    }
}
Beispiel #8
0
//---------------------------------------------------------------------
void CompositorManager::_reconstructAllCompositorResources()
{
	for (Chains::iterator i = mChains.begin(); i != mChains.end(); ++i)
	{
		CompositorChain* chain = i->second;
		CompositorChain::InstanceIterator instIt = chain->getCompositors();
		while (instIt.hasMoreElements())
		{
			CompositorInstance* inst = instIt.getNext();
			if (inst->getEnabled())
			{
				inst->setEnabled(false);
				inst->setEnabled(true);
			}
		}
	}
}
DeferredShadingSystem::~DeferredShadingSystem()
{
	CompositorChain *chain = CompositorManager::getSingleton().getCompositorChain(mViewport);
	for(int i=0; i<DSM_COUNT; ++i)
		chain->_removeInstance(mInstance[i]);
	CompositorManager::getSingleton().removeCompositorChain(mViewport);

	Ogre::CompositorManager& compMgr = Ogre::CompositorManager::getSingleton();
	CompositorLogicMap::const_iterator itor = mCompositorLogics.begin();
	CompositorLogicMap::const_iterator end  = mCompositorLogics.end();
	while( itor != end )
	{
		compMgr.unregisterCompositorLogic( itor->first );
		delete itor->second;
		++itor;
	}
	mCompositorLogics.clear();
}