Ogre::Any floods log when object cannot be casted

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
Lax
Gnome
Posts: 306
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 4

Ogre::Any floods log when object cannot be casted

Post by Lax » Mon Mar 19, 2018 9:39 pm

Hi,

I'm testing the new getUserObjectBindings().getUserAny() function. I have noticed that when an object cannot be casted, the log is flooded with exception messages:

21:32:19: OGRE EXCEPTION(2:InvalidParametersException): Bad cast from type 'void' to 'class NOWA::GameObject *' in Ogre::any_cast at d:\ogre\gameenginedevelopment\external\ogre2.1sdk\ogremain\include\ogreany.h (line 411)
21:32:19: OGRE EXCEPTION(2:InvalidParametersException): Bad cast from type 'void' to 'class NOWA::GameObject *' in Ogre::any_cast at d:\ogre\gameenginedevelopment\external\ogre2.1sdk\ogremain\include\ogreany.h (line 411)
...

I think, if an object cannot be casted, obviously its not the correct object, so skip that. I got rid of the exception by calling:

Code: Select all

NOWA::GameObject* gameObject = nullptr;
try
{
	gameObject = Ogre::any_cast<NOWA::GameObject*>(movableObject->getUserObjectBindings().getUserAny());
}
catch (Ogre::Exception& error)
{

}
if (nullptr != gameObject)
{
   ...
}
So my question is, would it be possible to leave the log message out, maybe by a default bool parameter?

Best regards
Lax
0 x

Post Reply