Added support for priority offset and scale into PagedLOD.
This commit is contained in:
@@ -95,6 +95,9 @@ bool Group::insertChild( unsigned int index, Node *child )
|
||||
|
||||
// register as parent of child.
|
||||
child->addParent(this);
|
||||
|
||||
// tell any subclasses that a child has been inserted so that they can update themselves.
|
||||
childInserted(index);
|
||||
|
||||
dirtyBound();
|
||||
|
||||
@@ -168,6 +171,8 @@ bool Group::removeChild(unsigned int pos,unsigned int numChildrenToRemove)
|
||||
|
||||
_children.erase(_children.begin()+pos,_children.begin()+endOfRemoveRange);
|
||||
|
||||
childRemoved(pos,endOfRemoveRange-pos);
|
||||
|
||||
if (appCallbackRemoved)
|
||||
{
|
||||
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()-appCallbackRemoved);
|
||||
|
||||
@@ -61,16 +61,31 @@ bool LOD::addChild( Node *child )
|
||||
{
|
||||
if (Group::addChild(child))
|
||||
{
|
||||
float maxRange = 0.0f;
|
||||
if (!_rangeList.empty()) maxRange=_rangeList.back().second;
|
||||
|
||||
if (_children.size()>_rangeList.size()) _rangeList.resize(_children.size(),MinMaxPair(maxRange,maxRange));
|
||||
if (_children.size()>_rangeList.size())
|
||||
{
|
||||
float maxRange = !_rangeList.empty()?
|
||||
maxRange=_rangeList.back().second : 0.0f;
|
||||
|
||||
_rangeList.resize(_children.size(),MinMaxPair(maxRange,maxRange));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LOD::childRemoved(unsigned int /*pos*/, unsigned int /*numChildrenToRemove*/)
|
||||
{
|
||||
//std::cout<<"LOD::childRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void LOD::childInserted(unsigned int /*pos*/)
|
||||
{
|
||||
//std::cout<<"LOD::childInserted("<<pos<<")"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
bool LOD::addChild(Node *child, float min, float max)
|
||||
{
|
||||
if (Group::addChild(child))
|
||||
|
||||
@@ -13,8 +13,7 @@ PagedLOD::PagedLOD(const PagedLOD& plod,const CopyOp& copyop):
|
||||
LOD(plod,copyop),
|
||||
_radius(plod._radius),
|
||||
_numChildrenThatCannotBeExpired(plod._numChildrenThatCannotBeExpired),
|
||||
_fileNameList(plod._fileNameList),
|
||||
_timeStampList(plod._timeStampList)
|
||||
_perRangeDataList(plod._perRangeDataList)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,7 +41,7 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
||||
{
|
||||
if (i<_children.size())
|
||||
{
|
||||
if (updateTimeStamp) _timeStampList[i]=timeStamp;
|
||||
if (updateTimeStamp) _perRangeDataList[i]._timeStamp=timeStamp;
|
||||
|
||||
//std::cout<<"PagedLOD::traverse() - Selecting child "<<i<<std::endl;
|
||||
_children[i]->accept(nv);
|
||||
@@ -64,16 +63,16 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
||||
if (numChildren>0 && ((int)numChildren-1)!=lastChildTraversed)
|
||||
{
|
||||
//std::cout<<" to child "<<numChildren-1<<std::endl;
|
||||
if (updateTimeStamp) _timeStampList[numChildren-1]=timeStamp;
|
||||
if (updateTimeStamp) _perRangeDataList[numChildren-1]._timeStamp=timeStamp;
|
||||
_children[numChildren-1]->accept(nv);
|
||||
}
|
||||
|
||||
// now request the loading of the next unload child.
|
||||
if (nv.getDatabaseRequestHandler() && numChildren<_fileNameList.size())
|
||||
if (nv.getDatabaseRequestHandler() && numChildren<_perRangeDataList.size())
|
||||
{
|
||||
float priority = (_rangeList[numChildren].second-distance)/(_rangeList[numChildren].second-_rangeList[numChildren].first);
|
||||
//std::cout<<" requesting child "<<_fileNameList[numChildren]<<" priotity = "<<priority<<std::endl;
|
||||
nv.getDatabaseRequestHandler()->requestNodeFile(_fileNameList[numChildren],this,priority,nv.getFrameStamp());
|
||||
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp());
|
||||
}
|
||||
|
||||
|
||||
@@ -103,12 +102,41 @@ bool PagedLOD::computeBound() const
|
||||
}
|
||||
}
|
||||
|
||||
void PagedLOD::childRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||
{
|
||||
LOD::childRemoved(pos, numChildrenToRemove);
|
||||
//std::cout<<"PagedLOD::childRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void PagedLOD::childInserted(unsigned int pos)
|
||||
{
|
||||
LOD::childInserted(pos);
|
||||
//std::cout<<"PagedLOD::childInserted("<<pos<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void PagedLOD::rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||
{
|
||||
LOD::rangeRemoved(pos, numChildrenToRemove);
|
||||
std::cout<<"PagedLOD::rangeRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void PagedLOD::rangeInserted(unsigned int pos)
|
||||
{
|
||||
LOD::rangeInserted(pos);
|
||||
std::cout<<"PagedLOD::rangeInserted("<<pos<<")"<<std::endl;
|
||||
expandPerRangeDataTo(pos);
|
||||
}
|
||||
|
||||
void PagedLOD::expandPerRangeDataTo(unsigned int pos)
|
||||
{
|
||||
if (pos>=_perRangeDataList.size()) _perRangeDataList.resize(pos+1);
|
||||
}
|
||||
|
||||
bool PagedLOD::addChild( Node *child )
|
||||
{
|
||||
if (LOD::addChild(child))
|
||||
{
|
||||
if (_children.size()>_fileNameList.size()) _fileNameList.resize(_children.size());
|
||||
if (_children.size()>_timeStampList.size()) _timeStampList.resize(_children.size(),0);
|
||||
expandPerRangeDataTo(_children.size());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -118,24 +146,20 @@ bool PagedLOD::addChild(Node *child, float min, float max)
|
||||
{
|
||||
if (LOD::addChild(child,min,max))
|
||||
{
|
||||
if (_children.size()>_fileNameList.size()) _fileNameList.resize(_children.size());
|
||||
if (_children.size()>_timeStampList.size()) _timeStampList.resize(_children.size(),0.0);
|
||||
|
||||
expandPerRangeDataTo(_children.size());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PagedLOD::addChild(Node *child, float min, float max,const std::string& filename)
|
||||
bool PagedLOD::addChild(Node *child, float min, float max,const std::string& filename, float priorityOffset, float priorityScale)
|
||||
{
|
||||
if (LOD::addChild(child,min,max))
|
||||
{
|
||||
if (_children.size()>_fileNameList.size()) _fileNameList.resize(_children.size());
|
||||
if (_children.size()>_timeStampList.size()) _timeStampList.resize(_children.size(),0.0);
|
||||
|
||||
_fileNameList[_children.size()-1] = filename;
|
||||
|
||||
setFileName(_children.size()-1,filename);
|
||||
setPriorityOffset(_children.size()-1,priorityOffset);
|
||||
setPriorityScale(_children.size()-1,priorityScale);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -147,31 +171,18 @@ bool PagedLOD::removeChild( Node *child )
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
_rangeList.erase(_rangeList.begin()+pos);
|
||||
_fileNameList.erase(_fileNameList.begin()+pos);
|
||||
_timeStampList.erase(_timeStampList.begin()+pos);
|
||||
if (pos<_rangeList.size()) _rangeList.erase(_rangeList.begin()+pos);
|
||||
if (pos<_perRangeDataList.size()) _perRangeDataList.erase(_perRangeDataList.begin()+pos);
|
||||
|
||||
return Group::removeChild(child);
|
||||
}
|
||||
|
||||
void PagedLOD::setFileName(unsigned int childNo, const std::string& filename)
|
||||
{
|
||||
if (childNo>=_fileNameList.size()) _fileNameList.resize(childNo+1);
|
||||
_fileNameList[childNo] = filename;
|
||||
}
|
||||
|
||||
void PagedLOD::setTimeStamp(unsigned int childNo, double timeStamp)
|
||||
{
|
||||
if (childNo>=_timeStampList.size()) _timeStampList.resize(childNo+1,0.0);
|
||||
_timeStampList[childNo] = timeStamp;
|
||||
}
|
||||
|
||||
void PagedLOD::removeExpiredChildren(double expiryTime,NodeList& removedChildren)
|
||||
{
|
||||
for(unsigned int i=_children.size();i>_numChildrenThatCannotBeExpired;)
|
||||
{
|
||||
--i;
|
||||
if (!_fileNameList[i].empty() && _timeStampList[i]<expiryTime)
|
||||
if (!_perRangeDataList[i]._filename.empty() && _perRangeDataList[i]._timeStamp<expiryTime)
|
||||
{
|
||||
//std::cout<<"Removing child "<<_children[i].get()<<std::endl;
|
||||
removedChildren.push_back(_children[i]);
|
||||
|
||||
@@ -46,15 +46,12 @@ bool LOD_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
// set up coordinates.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
int capacity;
|
||||
|
||||
if (matchFirst)
|
||||
{
|
||||
fr += 2;
|
||||
}
|
||||
else if (fr[1].getInt(capacity))
|
||||
else
|
||||
{
|
||||
lod.getRangeList().reserve(capacity);
|
||||
fr += 3;
|
||||
}
|
||||
|
||||
@@ -86,15 +83,12 @@ bool LOD_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
// set up coordinates.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
int capacity;
|
||||
|
||||
if (matchFirst)
|
||||
{
|
||||
fr += 2;
|
||||
}
|
||||
else if (fr[1].getInt(capacity))
|
||||
else
|
||||
{
|
||||
lod.getRangeList().reserve(capacity);
|
||||
fr += 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,15 +49,12 @@ bool PagedLOD_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
// set up coordinates.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
int capacity;
|
||||
|
||||
if (matchFirst)
|
||||
{
|
||||
fr += 2;
|
||||
}
|
||||
else if (fr[1].getInt(capacity))
|
||||
else
|
||||
{
|
||||
lod.getFileNameList().reserve(capacity);
|
||||
fr += 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,8 @@ osg::Node* TXPNode::addPagedLODTile(int x, int y, int lod)
|
||||
|
||||
osg::PagedLOD* pagedLOD = new osg::PagedLOD;
|
||||
pagedLOD->setFileName(0,pagedLODfile);
|
||||
pagedLOD->setPriorityOffset(0,1.0f);
|
||||
pagedLOD->setPriorityScale(0,1.0f);
|
||||
pagedLOD->setRange(0,0.0,info.maxRange);
|
||||
pagedLOD->setCenter(info.center);
|
||||
pagedLOD->setRadius(info.radius);
|
||||
|
||||
@@ -402,12 +402,12 @@ public:
|
||||
|
||||
double availableTime = 0.0025; // 5 ms
|
||||
|
||||
// compile any GL objects that are required.
|
||||
_databasePager->compileRenderingObjects(*(_sceneView->getState()),availableTime);
|
||||
|
||||
// flush deleted GL objects.
|
||||
_sceneView->flushDeletedGLObjects(availableTime);
|
||||
|
||||
// compile any GL objects that are required.
|
||||
_databasePager->compileRenderingObjects(*(_sceneView->getState()),availableTime);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user