[osg-users] questions about boundingBox and contains()

Robert Osfield robert.osfield at gmail.com
Tue Mar 10 07:35:44 PDT 2009

Hi Christain,

On Tue, Mar 10, 2009 at 2:25 PM, Christian Sam <osgforum at tevs.eu> wrote:
> as far as i understand every Drawable object in the scenegraph does have a "_boundingBox" data member.
> * does the user have to manually initalize this boundingBox (with a call like "myDrawableOject.computeBound()"), or has it already been set by osg to nodes' geometry extent (xmin, xmax, ymin, ymax, zmin, zmax)?

The BoundingBox is computed automatically when the dirtyBound flag is
set, if you modify the geometry then you should call
drawable->dirtyBound() to force an update.

> * if the user wants to query, if a ceratin vec3 position lies inside a Drawable object, can this be done with something like: "myDrawableObject.getBound().contains(osg::Vec3f(...))"?

Yes, this is what the contains(Vec3) method is for ;-)

> * if the user has a non-rectangluar polygon (e.g. an area in form of pentagram), will the above also work? if not, can you give me a hint how to implement an adequate contains()-query?

Well there isn't a BoundingBox::contains(anyShape) method so the
answer has to be no.  You'll need to build your own test.


More information about the osg-users mailing list