From 32c79ca554daf0579df2df4a2efcc2f22e34b31b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 4 Jan 2002 20:43:20 +0000 Subject: [PATCH] Added a guard to osg::LOD::evaluate so that it returns -1 if the range matched does not have a corresponding child to relate to. This can happen if a user creates more than n+1 ranges, where n is the number of LOD children. --- src/osg/LOD.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/osg/LOD.cpp b/src/osg/LOD.cpp index 762041f8f..ebfe6d230 100644 --- a/src/osg/LOD.cpp +++ b/src/osg/LOD.cpp @@ -33,15 +33,17 @@ void LOD::setRange(const unsigned int index, const float range) const int LOD::evaluate(const Vec3& eye_local, const float bias) const { // For cache coherency, use _rangeList2 exclusively - if (_rangeList2.size()==0) return -1; + if (_rangeList2.empty()) return -1; // Test distance-squared against the stored array of squared ranges float LODRange = (eye_local-_center).length2()*bias; if (LODRange<_rangeList2[0]) return -1; - for(unsigned int i=0;i<_rangeList2.size()-1;++i) + unsigned int end_marker = _rangeList2.size()-1; + if (end_marker>_children.size()) end_marker=_children.size(); + for(unsigned int i=0;i