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)
{
...
}
Best regards
Lax