From fb9591d6bc1f8b6656395c8a3adf3807705982d8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Jun 2016 10:02:39 +0100 Subject: [PATCH] Added handling of zero points --- src/osgUtil/PolytopeIntersector.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/osgUtil/PolytopeIntersector.cpp b/src/osgUtil/PolytopeIntersector.cpp index 8cdc1eb4b..10492d34e 100644 --- a/src/osgUtil/PolytopeIntersector.cpp +++ b/src/osgUtil/PolytopeIntersector.cpp @@ -49,8 +49,15 @@ namespace PolytopeIntersectorUtils if (distance > _maxDistance) _maxDistance = distance; if (_numPoints==MaxNumIntesections) break; } - center /= value_type(_numPoints); - _distance = referencePlane.distance( center ); + if (_numPoints>0) + { + center /= value_type(_numPoints); + _distance = referencePlane.distance( center ); + } + else + { + _distance = _maxDistance; + } } bool operator<(const PolytopeIntersection& rhs) const { return _distance < rhs._distance; }