Hi Robert, Thanks for being so precise. Well I knew most of it, but that's always good to remember all of this. :) And to also be precise: I just wanted to benchmark my system, and I had values than outcame my expectations. So I told others about this. Cheers,
Sukender PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ Le Wed, 03 Dec 2008 10:35:54 +0100, Robert Osfield <[EMAIL PROTECTED]> a écrit: > 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 > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

