Hi,
My code architecture is :
void Scene::Load() {
mResourceGroup = "MyResGroup";
ResourceGroupManager::getSingleton().addResourceLocation(...);
ResourceGroupManager::getSingleton().addResourceLocation(...);
ResourceGroupManager::getSingleton().addResourceLocation(...);
...;
ResourceGroupManager::getSingleton().initialiseResourceGroup( mResourceGroup );
}
void Scene::destroySceneObjects( void ) {
if( mResourceGroup ) {
ResourceGroupManager::getSingleton().unloadResourceGroup( mResourceGroup );
ResourceGroupManager::getSingleton().destroyResourceGroup( mResourceGroup );
}
// destroy all overlay while changing scene
OverlayManager::getSingleton().destroyAllOverlayElements(false);
OverlayManager::getSingleton().destroyAllOverlayElements(true);
OverlayManager::getSingleton().destroyAll();
}
My problem is, when I change scene, I have to destroy all overlay by
OverlayManager, I can not only destroy the scene's overlay, because
OverlayManager::mLoadedScripts, this member record the overlay scripts
that have been loaded into ogre, and when I reload the scene, I can
not parse overlay scripts again just because :
void OverlayManager::parseScript(DataStreamPtr& stream, const String& groupName)
{
if ( !stream->getName().empty() &&
mLoadedScripts.find(stream->getName()) != mLoadedScripts.end())
{
LogManager::getSingleton().logMessage(
"Skipping loading overlay include: '"
+ stream->getName() + " as it is already loaded.");
return;
}
...;
}
I think i have to find someway to erase mLoadedScripts, but the
OverlayManager does not seems to provide the method.
Is there another solution to do this?
Thanks a lot
how to use OverlayManager to Destroy/Reload an overlay
-
- Gnoblar
- Posts: 13
- Joined: Thu Aug 31, 2006 3:35 pm
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
-
- Gnoblar
- Posts: 5
- Joined: Sun Jan 14, 2007 4:22 am
But, if i destroy them through:sinbad wrote:Separate out your overlays into scripts based on the units you wish to destroy, then use getOrigin() to identify which ones you want to destroy.
Code: Select all
OverlayManager::getSingleton().destroyOverlayElement();
OverlayManager::getSingleton().destroy();
Code: Select all
Find all "mLoadedScripts", Match case, Whole word, Subfolders, Find Results 1, "Current Project", "*.c;*.cpp;*.cxx;*.cc;*.tli;*.tlh;*.h;*.hpp;*.hxx;*.hh;*.inl;*.rc;*.resx;*.idl;*.asm;*.inc"
OgreMain\include\OgreOverlayManager.h(74): LoadedScripts mLoadedScripts;
OgreMain\src\OgreOverlayManager.cpp(168): mLoadedScripts.clear();
OgreMain\src\OgreOverlayManager.cpp(181): mLoadedScripts.find(stream->getName()) != mLoadedScripts.end())
OgreMain\src\OgreOverlayManager.cpp(264): mLoadedScripts.insert(stream->getName());
Matching lines: 4 Matching files: 2 Total files searched: 385
Code: Select all
Overlay *o = i->second;
mLoadedScripts.erase( o->getOrigin() );
delete o;
Code: Select all
delete i->second;
What do you think of that?
-
- Gnoblar
- Posts: 13
- Joined: Thu Aug 31, 2006 3:35 pm
I finally change my method
I thought Overlay is a kind of "Global Resource", and do not allow individiual load/reload, so, when I need to clear all overlay resource, I will ask all loaded scenes (only one in active, others are not active) if somebody use/load the "Global Resource", if it is true, then I do not destroy all overlay, else, I could destroy all overlay
I thought Overlay is a kind of "Global Resource", and do not allow individiual load/reload, so, when I need to clear all overlay resource, I will ask all loaded scenes (only one in active, others are not active) if somebody use/load the "Global Resource", if it is true, then I do not destroy all overlay, else, I could destroy all overlay