Re: [osg-users] Safe downcast

2012-08-22 Thread Jean-Sébastien Guay
Hello, For the answer, I suggest you revise the C++ docs about dynamic_cast and also check the class hierarchy of OSG's node types. dynamic_castA* succeeds for any pointer to an object of class A or any pointer to an object of a derived class of A. So even if you don't have a proper Group

Re: [osg-users] Safe downcast

2012-08-21 Thread Robert Osfield
Hi Peterakos, You should always check that the node set by the dynamic_cast is not NULL before doing any operation on it, this is a very basic programming practice, you shouldn't assume that the root node will always be a Group or a subclass from Group. Robert. On 20 August 2012 18:15,

Re: [osg-users] Safe downcast

2012-08-21 Thread Peterakos
Hello. I forgot to mention that i check it. That's why i posted it. Cause it is very strange to run even though there is no group as root.. osg::ref_ptrosg::Group node = dynamic_castosg::Group*(osgDB::readNodeFile( astroboy_walk.dae )); if(!node) { std::cout Model could not be loaded

[osg-users] Safe downcast

2012-08-20 Thread Peterakos
Hello. In the example osganimationviewer in main there is the following line: osg::Group* node = dynamic_castosg::Group*(osgDB::readNodeFiles(arguments)); How safe is this if i use only 1 model in arguments and it is not Group ? Thank you for your time.

Re: [osg-users] Safe downcast

2012-08-20 Thread Jason Daly
On 08/20/2012 09:00 AM, Peterakos wrote: Hello. In the example osganimationviewer in main there is the following line: osg::Group* node = dynamic_castosg::Group*(osgDB::readNodeFiles(arguments)); How safe is this if i use only 1 model in arguments and it is not Group ? osgDB::readNodeFiles