From 9c311b40772dd7d3a1b57fb5d58867040a79c53d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 25 Nov 2003 10:56:42 +0000 Subject: [PATCH] Added intersect method. --- include/osg/BoundingBox | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/osg/BoundingBox b/include/osg/BoundingBox index 8c75bae87..d364e4aae 100644 --- a/include/osg/BoundingBox +++ b/include/osg/BoundingBox @@ -61,7 +61,7 @@ class SG_EXPORT BoundingBox inline bool valid() const { - return _max.x()>=_min.x(); + return _max.x()>=_min.x() && _max.y()>=_min.y() && _max.z()>=_min.z(); } inline void set (float xmin,float ymin,float zmin, @@ -161,6 +161,14 @@ class SG_EXPORT BoundingBox /** If incoming sphere is out-with the box expand to encompass incoming sphere. If this box is empty then move set this box to encompass the sphere. */ void expandBy(const BoundingSphere& sh); + + + /** Compute the intesection of this bounding box with the specified bounding box.*/ + BoundingBox intersect(const BoundingBox& bb) const + { return osg::BoundingBox(osg::maximum(xMin(),bb.xMin()),osg::maximum(yMin(),bb.yMin()),osg::maximum(zMin(),bb.zMin()), + osg::minimum(xMax(),bb.xMax()),osg::minimum(yMax(),bb.yMax()),osg::minimum(zMax(),bb.zMax())); + + } /** return true is vertex v is within the box.*/ inline bool contains(const Vec3& v) const