From 80c45ad46aa47c8d5d5c0760c22f40675643ece2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Nov 2013 12:45:04 +0000 Subject: [PATCH] Added BoundingBox::contains(const vec_type& v, value_type epsilon) method with new epsilon parameter to make it easier to test for containment in the presence of numerical errors --- include/osg/BoundingBox | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/osg/BoundingBox b/include/osg/BoundingBox index 4201d4047..c3c4c0ba5 100644 --- a/include/osg/BoundingBox +++ b/include/osg/BoundingBox @@ -227,6 +227,15 @@ class BoundingBoxImpl (v.y()>=_min.y() && v.y()<=_max.y()) && (v.z()>=_min.z() && v.z()<=_max.z()); } + + /** Returns true if this bounding box contains the specified coordinate allowing for specific epsilon. */ + inline bool contains(const vec_type& v, value_type epsilon) const + { + return valid() && + ((v.x()+epsilon)>=_min.x() && (v.x()-epsilon)<=_max.x()) && + ((v.y()+epsilon)>=_min.y() && (v.y()-epsilon)<=_max.y()) && + ((v.z()+epsilon)>=_min.z() && (v.z()-epsilon)<=_max.z()); + } }; typedef BoundingBoxImpl BoundingBoxf;