Solutions to 2 Hydrax crash issues

stealth977

26-08-2009 16:51:30

Problem one, Hydrax crashes on setWaterColour(): (Hydrax.cpp)


mRttManager->getTexture(RttManager::RTT_REFLECTION)->
getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);

mRttManager->getTexture(RttManager::RTT_REFRACTION)->
getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);


the Textures are null at some cases, so the fix is:

Ogre::TexturePtr tex = mRttManager->getTexture(RttManager::RTT_REFLECTION);
if(!tex.isNull())
tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);

tex = mRttManager->getTexture(RttManager::RTT_REFRACTION);
if(!tex.isNull())
tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);


Problem 2, hydrax crashes in setCompositorEnabled(...), the problem is not related to this function but related to removeCompositor(...)
(MaterialManager.cpp)

void MaterialManager::removeCompositor()
{
if (Ogre::MaterialManager::getSingleton().resourceExists(_def_Underwater_Compositor_Material_Name))
{
setCompositorEnable(COMP_UNDERWATER, false);

Ogre::CompositorManager::getSingleton().remove(_def_Underwater_Compositor_Name);

Ogre::MaterialManager::getSingleton().remove(_def_Underwater_Compositor_Material_Name);

Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_FP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_FP_Name);
}
}


Here the problem is CompositorManager::remove doesnt remove the compositor from the viewport's compositor chain, so when the compositor resource is removed, viewport still has a compositor instance in the chain whose pointer points to an invalid resource, which causes a crash with the next setCompositorEnabled(), fix:

void MaterialManager::removeCompositor()
{
if (Ogre::MaterialManager::getSingleton().resourceExists(_def_Underwater_Compositor_Material_Name))
{
setCompositorEnable(COMP_UNDERWATER, false);

Ogre::CompositorManager::getSingleton().removeCompositor(mHydrax->getViewport(), _def_Underwater_Compositor_Name);

Ogre::CompositorManager::getSingleton().remove(_def_Underwater_Compositor_Name);

Ogre::MaterialManager::getSingleton().remove(_def_Underwater_Compositor_Material_Name);

Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().unload(_def_Underwater_Compositor_Shader_FP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_VP_Name);
Ogre::HighLevelGpuProgramManager::getSingleton().remove(_def_Underwater_Compositor_Shader_FP_Name);
}
}

Just remove the compositor from chain before destroying it...

ismail,

Xavyiy

26-08-2009 18:44:20

Hi stealth!
Thanks for these bug-fixes!

P.D.: About the first one, I have fixed it a week ago when I was coding the Hydrax-SkyX demo (The crash appears when you haven't enabled the Underwater reflections and you are underwater while changing the water colour :) )

didito

27-08-2009 16:57:50

cool! thanks for the bug report.

i think it would be nice to release a fixed version (v5.1?) before v6.0.
or is there a public repository for hydrax?

keep up the good work!

stealth977

28-08-2009 21:29:43

Hi Xavyiy! :)

I have a problem, which is probably fixed, but hey my files in Ogitor are the first v0.5 files you released so that may be why, but, when loading from config file, underwater reflections/godrays etc.. seems not being loaded correctly and i get depthrefractionmap not found etc. errors in the log, if i disable and enabled underwater components, all seems to work fine, till next load of config file..

How can i solve it? Do you have a latest all bugs prior to release fixed version of Hydrax i can include?

Also, what kind of svn are you using? If you are not using any, or if you dont have your own, you know we switched to our own server for Ogitor and would be more than happy to supply you SVN or MERCURIAL as well as web/upload/download space... Feel free to send a PM :)

ismail,

jessome

24-07-2012 19:39:12

I'm going to bump this because the compositor issue still exists in 0.5.4.

heavydist

19-08-2012 15:04:30

There is probably going to be a git repository for the "community" version of hydrax soon, then we can add this bugfix there, thanks for reporting the problem.