Improved the effectiveness of the new max target number PageLOD's

This commit is contained in:
Robert Osfield
2008-12-17 22:52:36 +00:00
parent f8151127e3
commit 1cd6541bfd
3 changed files with 39 additions and 12 deletions

View File

@@ -117,7 +117,11 @@ void PagedLOD::traverse(NodeVisitor& nv)
{
// set the frame number of the traversal so that external nodes can find out how active this
// node is.
if (nv.getFrameStamp()) setFrameNumberOfLastTraversal(nv.getFrameStamp()->getFrameNumber());
if (nv.getFrameStamp() &&
nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
{
setFrameNumberOfLastTraversal(nv.getFrameStamp()->getFrameNumber());
}
double timeStamp = nv.getFrameStamp()?nv.getFrameStamp()->getReferenceTime():0.0;
int frameNumber = nv.getFrameStamp()?nv.getFrameStamp()->getFrameNumber():0;

View File

@@ -1584,7 +1584,6 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
int inactivePLOD = _inactivePagedLODList.size();
PagedLODList& pagedLODList = _inactivePagedLODList;
osg::Timer_t end_a_Tick = osg::Timer::instance()->tick();
double time_a = osg::Timer::instance()->delta_m(startTick,end_a_Tick);
@@ -1606,6 +1605,7 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
numToPrune = inactivePLOD;
}
osg::NodeList childrenRemoved;
double expiryTime = frameStamp.getReferenceTime() - 0.1;
@@ -1613,9 +1613,29 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
MarkPagedLODsVisitor markerVistor("NeedToRemove");
for(PagedLODList::iterator itr = _inactivePagedLODList.begin();
itr!=_inactivePagedLODList.end() && markerVistor._numPagedLODsMarked<numToPrune;
++itr)
{
osg::PagedLOD* plod = itr->get();
for(PagedLODList::iterator itr = pagedLODList.begin();
itr!=pagedLODList.end() && markerVistor._numPagedLODsMarked<numToPrune;
osg::NodeList localChildrenRemoved;
plod->removeExpiredChildren(expiryTime, expiryFrame, localChildrenRemoved);
if (!localChildrenRemoved.empty())
{
for(osg::NodeList::iterator critr = localChildrenRemoved.begin();
critr!=localChildrenRemoved.end();
++critr)
{
(*critr)->accept(markerVistor);
}
std::copy(localChildrenRemoved.begin(),localChildrenRemoved.end(),std::back_inserter(childrenRemoved));
}
}
for(PagedLODList::iterator itr = _activePagedLODList.begin();
itr!=_activePagedLODList.end() && markerVistor._numPagedLODsMarked<numToPrune;
++itr)
{
osg::PagedLOD* plod = itr->get();
@@ -1644,6 +1664,8 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
//osg::notify(osg::NOTICE)<<"numToPrune "<<numToPrune<< " markerVistor._numPagedLODsMarked="<<markerVistor._numPagedLODsMarked<< " childrenRemoved.size()="<<childrenRemoved.size()<<std::endl;
if (!childrenRemoved.empty())
{
bool updateBlock = false;
@@ -1667,12 +1689,12 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
int numToRemove = markerVistor._numPagedLODsMarked;
// osg::notify(osg::NOTICE)<<"Children to remove "<<childrenRemoved.size()<<" numToRemove="<<numToRemove<<std::endl;
//osg::notify(osg::NOTICE)<<"Children to remove "<<childrenRemoved.size()<<" numToRemove="<<numToRemove<<std::endl;
// osg::notify(osg::NOTICE)<<" time 2 "<<osg::Timer::instance()->delta_m(before,osg::Timer::instance()->tick())<<" ms "<<std::endl;
int numSkipped = 0;
for(PagedLODList::iterator itr = pagedLODList.begin();
itr!=pagedLODList.end() && numRemoved<numToRemove;
for(PagedLODList::iterator itr = _inactivePagedLODList.begin();
itr!=_inactivePagedLODList.end() && numRemoved<numToRemove;
)
{
osg::PagedLOD* plod = itr->get();
@@ -1682,19 +1704,19 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
++numSkipped;
//osg::notify(osg::NOTICE)<<"skipping"<<std::endl;
// osg::notify(osg::NOTICE)<<"skipping"<<std::endl;
}
else
{
//osg::notify(osg::NOTICE)<<"removing"<<std::endl;
// osg::notify(osg::NOTICE)<<"removing"<<std::endl;
++numRemoved;
itr = pagedLODList.erase(itr);
itr = _inactivePagedLODList.erase(itr);
}
}
// osg::notify(osg::NOTICE)<<"Number of PagedLODs skipped="<<numSkipped<<" removed "<<numRemoved<<std::endl;
osg::notify(osg::INFO)<<"Number of PagedLODs skipped="<<numSkipped<<" removed "<<numRemoved<<std::endl;
childrenRemoved.clear();
@@ -1714,6 +1736,7 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
if (s_total_max_stage_c<time_c) s_total_max_stage_c = time_c;
osg::notify(osg::INFO)<<"active="<<_activePagedLODList.size()<<" inactive="<<_inactivePagedLODList.size()<<" overall = "<<osg::Timer::instance()->delta_m(startTick,end_c_Tick)<<
" A="<<time_a<<" avg="<<s_total_time_stage_a/s_total_iter_stage_a<<" max = "<<s_total_max_stage_a<<
" B="<<time_b<<" avg="<<s_total_time_stage_b/s_total_iter_stage_b<<" max = "<<s_total_max_stage_b<<

View File

@@ -195,7 +195,7 @@ void osgParticle::ParticleSystem::single_pass_render(osg::State& /*state*/, con
else
{
xAxis /= (scaleX*scaleX);
yAxis /= (scaleX*scaleY);
yAxis /= (scaleY*scaleY);
}
}