On Wed, Dec 3, 2008 at 9:18 AM, Sukender <[EMAIL PROTECTED]> wrote: > Well of course a dynamic_cast is not always repleacable by a className() > call. This happens only sometimes. My bench' only says "if you can, then use > className()" and also says "use dynamic_cast wisely: it costs a lot".
dynamic_cast<> is documented in C++ texts as being relatively slow, it's best to go do some background reading on how its implemented to understand why it's so much slower than virtual function call. The OSG uses dynamic_cast<> sparingly, and not in any inner loops of on operations that are called often in a frame, I'd recommend doing the same. The OSG has several robust alternatives to dynamic_cast, first up is the NodeVisitor which uses double dispatch (two virtual function calls, see Visitor design pattern) to determine object type, and virtual Class* asClass() style methods that exhist for the most common types of base class to subclass operations. For instance Transform* node->asTransform() or Geometry* drawable->asGeometry(). Robert. _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org