Problem with resources when recreating Hydrax


10-04-2009 01:55:07

In my project I've got the option to select several graphics configurations. To get that done I want to destroy Hydrax completely and replace it with a much more simple water animation or a new Hydrax instance. Each time the graphics configuration changes I dispose and delete Hydrax, instantiate it, create it and load a different configuration file. All of this seems to work - no exception and no weird log message.

The problem is, when Ogre renders its next frame I get the following exception:OGRE EXCEPTION(4:ItemIdentityException): Resource with the name _Hydrax_Depth_VP already exists. in ResourceManager::add at ..\src\OgreResourceManager.cpp (line 113)
I've searched the Hydrax resourceGroup and all other resourceGroups and I can't find this resource. Neither does any ResourceManager tell me that he holds this resource. The log file tells me that several resources are being loaded manually but that specific resource isn't among them.

Since VP seems to refer to Viewport I tried destroying/removing my camera and viewport and recreated them. Didn't help - same exception.
I also tried destroying the whole Hydrax resourceGroup and recreated it, added resource locations and initialized it again. Same.

Does anyone have an idea how to solve this? How do I destroy this resource? Or maybe is there another way to recreate Hydrax?


12-04-2009 00:50:25

I just found out that simply calling Hydrax->remove() and unloading my terrain ResourceGroup (NOT the Hydrax ResourceGroup!), then calling Hydrax->create() again leads to the same issue.

I guess I also found the cause: If I don't add a depth technique to my terrain everything works as expected.
So there seems to be at least one resource being created which Hydrax doesn't remove/destroy properly. Bug? :)
I'm adding the DepthTechnique only one time after instatiating Hydrax.

Since DepthTechniques are added like this to the MaterialManager, maybe it would be good to provide a similar way to remove the DepthTechnique?

I haven't looked into Hydrax code deep enough to submit a patch since I'm not very familiar with techniques, passes etc. But I'll try...
If anyone's able to supply a quick patch to this it would be very appreciated.

PS: Calling mHydrax->getMaterialManager()->removeMaterials() did not do the trick.