HI Philip, Could you try another compiler under OSX as this looks like a compiler bug to me.
Robert. On 7 February 2013 04:34, Philip Lamb <p...@eden.net.nz> wrote: > Hi all, > > I'm running into an interesting bug in my code which manifests as behaviour > that works on one platform (Windows) and not on another (OS X) with the same > OSG code. (Using OSG trunk, around 3.1.4) > > I am using the following node visitor to reset animations attached to > transform nodes: > > class ResetAnimationNodesVisitor : public osg::NodeVisitor > { > public: > > > > ResetAnimationNodesVisitor(): > osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} > > > > virtual void apply(osg::Transform& transform) > { > osg::NodeCallback *nc = transform.getUpdateCallback(); > osg::AnimationPathCallback* apc = > dynamic_cast<osg::AnimationPathCallback*>(nc); > if (apc) { > apc->reset(); > apc->update(transform); > } > traverse(transform); > } > }; > > This visitor is instantiated on a node thus: > > void resetAnimationTime(osg::ref_ptr<osg::Node> modelNode) > { > ResetAnimationNodesVisitor ranv; > modelNode->accept(ranv); > } > > When compiled and run on an animated model under Windows (compiled with > Visual Studio 2010 SP1) all works as expected. When the exact same code is > compiled and run under OS X (using Xcode 4.5.2, with LLVM 4.2.1) the dynamic > cast to osg::AnimationPathCallback* is always NULL. > > I have checked that RTTI is not disabled (it's on by default, and no errors > are produced by the dynamic_cast<>, and that indeed things are as expected > with this snippet inside apply(): > > if (nc) osg::notify(osg::NOTICE) << "UpdateCallback: className is " > << std::string(transform.getUpdateCallback()->className()) << " and > type_id.name() is " typeid(transform.getUpdateCallback()).name() << > std::endl; > > which produces the output: > > UpdateCallback: className is AnimationPathCallback and type_id.name() is > PN3osg12NodeCallbackE > > So it looks like a failure somewhere in RTTI. Both typeid and the > dynamic_cast<> fail to convert the osg::NodeCallback* to an > osg::AnimationPathCallback*. Yet clearly, the callback IS the right type, as > evidenced by OSG's className() function's output. > > Any ideas about where this kind of issue might be coming from? > > Regards, > Phil. > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org