Hi Tim,

To clean up the way the childrenRemoved list is populated I have added
a method to CountPagedLODVisitor::removeExpiredChildrenAndCountPagedLODs(..)
which simplifies the code in DatabasePager::removeExpiredSubgraphs(..)
to just:

        osg::ref_ptr<osg::PagedLOD> plod = itr->lock();
        if (plod.valid() &&
countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
        {
            
countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs(plod.get(),
expiryTime, expiryFrame, childrenRemoved);

            // advance the iterator to the next element
            ++itr;
        }
        else ...

The CountPagedLODVisitor::removeExpiredChildrenAndCountPagedLODs(..)
method is implemented thus:

    bool removeExpiredChildrenAndCountPagedLODs(osg::PagedLOD* plod,
double expiryTime, int expiryFrame, osg::NodeList& removedChildren)
    {
        size_t sizeBefore = removedChildren.size();
        plod->removeExpiredChildren(expiryTime, expiryFrame, removedChildren);
        for(size_t i = sizeBefore; i<removedChildren.size(); ++i)
        {
            removedChildren[i]->accept(*this);
        }
        return sizeBefore!=removedChildren.size();
    }


This cleans up the code up whilst making enabling the optimization
that you were introducing - avoiding the need to copy data to and
frame an extra vector of ref_ptr<>.  I've also added a
removedChildren.reserve(nomToPune) to the avoid any resizing of the
vector<>.

I'd appreciate a view of these changes to catch any mistakes that
might have crept in.

http://www.openscenegraph.org/projects/osg/changeset/11469/OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp

Cheers,
Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to