From 30b54e3af218e2fb9090db37b77a854d0cf4e9dd Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 20 May 2014 16:09:34 +0000 Subject: [PATCH] Moved the _boundingSphere set method into the update section of the Drawable::getBoundingBox() method Added an UpdateVisitor::apply(Drawable&) implementation. --- include/osg/Drawable | 12 +++++++----- include/osgUtil/UpdateVisitor | 13 ++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/osg/Drawable b/include/osg/Drawable index 9f14686af..530e516d2 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -145,18 +145,20 @@ class OSG_EXPORT Drawable : public Node if(!_boundingSphereComputed) { _boundingBox = _initialBound; + if (_computeBoundCallback.valid()) _boundingBox.expandBy(_computeBoundCallback->computeBound(*this)); else _boundingBox.expandBy(computeBoundingBox()); + if(_boundingBox.valid()){ + _boundingSphere.set(_boundingBox.center(), _boundingBox.radius()); + } else { + _boundingSphere.init(); + } + _boundingSphereComputed = true; } - if(_boundingBox.valid()){ - _boundingSphere.set(_boundingBox.center(), _boundingBox.radius()); - } else { - _boundingSphere.init(); - } return _boundingBox; } diff --git a/include/osgUtil/UpdateVisitor b/include/osgUtil/UpdateVisitor index de26cb1f4..799df2524 100644 --- a/include/osgUtil/UpdateVisitor +++ b/include/osgUtil/UpdateVisitor @@ -46,7 +46,18 @@ class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor virtual void reset(); /** During traversal each type of node calls its callbacks and its children traversed. */ - virtual void apply(osg::Node& node) { handle_callbacks_and_traverse(node); } + virtual void apply(osg::Node& node) { handle_callbacks_and_traverse(node); } + + virtual void apply(osg::Drawable& drawable) + { + osg::Drawable::UpdateCallback* callback = drawable.getUpdateCallback(); + if (callback) callback->update(this,&drawable); + + osg::NodeCallback* node_callback = drawable.osg::Node::getUpdateCallback(); + if (node_callback) (*node_callback)(&drawable, this); + + handle_callbacks(drawable.getStateSet()); + } virtual void apply(osg::Geode& node) { handle_geode_callbacks(node); } virtual void apply(osg::Billboard& node) { handle_geode_callbacks(node); }