From 07e43822e6ba7796449b4ee2969e533f0f3f7b65 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 18 May 2010 15:33:59 +0000 Subject: [PATCH] Added better invalidation of the inactive and active PageLOD lists when children are invalidated when parents are removed. --- src/osgDB/DatabasePager.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index cfb49ea5c..91f130c2c 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -1569,10 +1569,14 @@ public: virtual void apply(osg::PagedLOD& plod) { ++_numPagedLODs; + _pagedLODs.insert(&plod); traverse(plod); } - - int _numPagedLODs; + + + typedef std::set PagedLODset; + PagedLODset _pagedLODs; + int _numPagedLODs; }; void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) @@ -1684,15 +1688,16 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) for(PagedLODList::iterator itr = _inactivePagedLODList.begin(); itr!=_inactivePagedLODList.end() && countPagedLODsVisitor._numPagedLODs plod = itr->lock(); - if (plod.valid()) + if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0) { osg::NodeList localChildrenRemoved; plod->removeExpiredChildren(expiryTime, expiryFrame, localChildrenRemoved); if (!localChildrenRemoved.empty()) { + for(osg::NodeList::iterator critr = localChildrenRemoved.begin(); critr!=localChildrenRemoved.end(); ++critr) @@ -1702,19 +1707,23 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) std::copy(localChildrenRemoved.begin(),localChildrenRemoved.end(),std::back_inserter(childrenRemoved)); } + + // advance the iterator to the next element + ++itr; } else { + itr = _inactivePagedLODList.erase(itr); OSG_NOTICE<<"DatabasePager::removeExpiredSubgraphs() _inactivePagedLOD has been invalidated, but ignored"< plod = itr->lock(); - if (plod.valid()) + if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0) { osg::NodeList localChildrenRemoved; plod->removeExpiredChildren(expiryTime, expiryFrame, localChildrenRemoved); @@ -1729,9 +1738,13 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) std::copy(localChildrenRemoved.begin(),localChildrenRemoved.end(),std::back_inserter(childrenRemoved)); } + + // advance the iterator to the next element + ++itr; } else { + itr = _inactivePagedLODList.erase(itr); OSG_NOTICE<<"DatabasePager::removeExpiredSubgraphs() _activePagedLOD has been invalidated, but ignored"<