From 017983429b49113aea1051531d2af571f7af653a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 22 Apr 2004 10:47:12 +0000 Subject: [PATCH] Added getBoundingBox() method to osg::Geode to provide a closer bound of the bounding volume of a Geode to be tracked. This sits alongside the existing getBound() method which returns a bounding sphere. --- include/osg/Geode | 9 +++++++++ src/osg/Geode.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/osg/Geode b/include/osg/Geode index 2c00d2ffe..a21047ec3 100644 --- a/include/osg/Geode +++ b/include/osg/Geode @@ -103,12 +103,21 @@ class SG_EXPORT Geode : public Node /** compile OpenGL Display List for each drawable.*/ void compileDrawables(State& state); + /** return the Geode's bounding box, which the union of all the + * bounding boxes of the geode's drawables.*/ + inline const BoundingBox& getBoundingBox() const + { + if(!_bsphere_computed) computeBound(); + return _bbox; + } + protected: virtual ~Geode(); virtual bool computeBound() const; + mutable osg::BoundingBox _bbox; DrawableList _drawables; }; diff --git a/src/osg/Geode.cpp b/src/osg/Geode.cpp index ddbd10998..5abf1a93e 100644 --- a/src/osg/Geode.cpp +++ b/src/osg/Geode.cpp @@ -161,19 +161,19 @@ bool Geode::computeBound() const { _bsphere.init(); - BoundingBox bb; + _bbox.init(); DrawableList::const_iterator itr; for(itr=_drawables.begin(); itr!=_drawables.end(); ++itr) { - bb.expandBy((*itr)->getBound()); + _bbox.expandBy((*itr)->getBound()); } - if (bb.valid()) + if (_bbox.valid()) { - _bsphere.expandBy(bb); + _bsphere.expandBy(_bbox); _bsphere_computed=true; return true; }