diff --git a/src/osg/CollectOccludersVisitor.cpp b/src/osg/CollectOccludersVisitor.cpp index 3fe2bf2f1..951fa5143 100644 --- a/src/osg/CollectOccludersVisitor.cpp +++ b/src/osg/CollectOccludersVisitor.cpp @@ -225,21 +225,26 @@ void CollectOccludersVisitor::removeOccludedOccluders() break; } - // now check all the holes in the occludee against the occluder, - // do so in reverse order so that the iterators remain valid. - for(ShadowVolumeOccluder::HoleList::reverse_iterator holeItr=holeList.rbegin(); - holeItr!=holeList.rend(); - ) + // now check all the holes in the occludee against the occluder, and remove the ones that won't be valid + unsigned int previous_valid_hole_i = 0; + for(unsigned int i=0; icontains((*holeItr).getReferenceVertexList())) + if (!occluder->contains(holeList[i].getReferenceVertexList())) { - holeList.erase((++holeItr).base()); - } - else - { - ++holeItr; - } + if (previous_valid_hole_i