Upates from Nick.
This commit is contained in:
@@ -6,7 +6,8 @@ TXPPagedLOD::TXPPagedLOD():
|
||||
PagedLOD(),
|
||||
_tileX(-1),
|
||||
_tileY(-1),
|
||||
_tileLOD(-1)
|
||||
_tileLOD(-1),
|
||||
_lastChildTraversed(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,12 +15,14 @@ TXPPagedLOD::TXPPagedLOD(const TXPPagedLOD& plod,const osg::CopyOp& copyop):
|
||||
PagedLOD(plod,copyop),
|
||||
_tileX(plod._tileX),
|
||||
_tileY(plod._tileY),
|
||||
_tileLOD(plod._tileLOD)
|
||||
_tileLOD(plod._tileLOD),
|
||||
_lastChildTraversed(plod._lastChildTraversed)
|
||||
{
|
||||
}
|
||||
|
||||
TXPPagedLOD::~TXPPagedLOD()
|
||||
{
|
||||
TileMapper::instance()->removePagedLOD(_tileX,_tileY,_tileLOD);
|
||||
}
|
||||
|
||||
void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
||||
@@ -37,7 +40,7 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
float distance = nv.getDistanceToEyePoint(getCenter(),true);
|
||||
|
||||
int lastChildTraversed = -1;
|
||||
_lastChildTraversed = -1;
|
||||
bool needToLoadChild = false;
|
||||
bool rollBack = false;
|
||||
for(unsigned int i=0;i<_rangeList.size();++i)
|
||||
@@ -66,7 +69,7 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (updateTimeStamp) _perRangeDataList[i]._timeStamp=timeStamp;
|
||||
_children[i]->accept(nv);
|
||||
lastChildTraversed = (int)i;
|
||||
_lastChildTraversed = (int)i;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -80,7 +83,7 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (updateTimeStamp) _perRangeDataList[0]._timeStamp=timeStamp;
|
||||
_children[0]->accept(nv);
|
||||
lastChildTraversed = 0;
|
||||
_lastChildTraversed = 0;
|
||||
//std::cout << "Rolling back" << std::endl;
|
||||
}
|
||||
|
||||
@@ -90,11 +93,12 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
||||
|
||||
//std::cout<<"PagedLOD::traverse() - falling back "<<std::endl;
|
||||
// select the last valid child.
|
||||
if (numChildren>0 && ((int)numChildren-1)!=lastChildTraversed)
|
||||
if (numChildren>0 && ((int)numChildren-1)!=_lastChildTraversed)
|
||||
{
|
||||
//std::cout<<" to child "<<numChildren-1<<std::endl;
|
||||
if (updateTimeStamp) _perRangeDataList[numChildren-1]._timeStamp=timeStamp;
|
||||
_children[numChildren-1]->accept(nv);
|
||||
_lastChildTraversed = numChildren-1;
|
||||
}
|
||||
|
||||
// now request the loading of the next unload child.
|
||||
@@ -120,5 +124,3 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,14 +63,16 @@ namespace txp
|
||||
_neighbours.push_back(n);
|
||||
}
|
||||
|
||||
int _tileX;
|
||||
int _tileX;
|
||||
int _tileY;
|
||||
int _tileLOD;
|
||||
|
||||
inline const int getLastTraversedChild() const { return _lastChildTraversed; }
|
||||
|
||||
protected:
|
||||
virtual ~TXPPagedLOD();
|
||||
|
||||
|
||||
int _lastChildTraversed;
|
||||
|
||||
struct Neighbour
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "TXPSeamLOD.h"
|
||||
#include "TXPArchive.h"
|
||||
#include "TXPTileNode.h"
|
||||
#include "TXPPagedLOD.h"
|
||||
#include "TileMapper.h"
|
||||
|
||||
using namespace txp;
|
||||
@@ -52,8 +53,14 @@ void TXPSeamLOD::traverse(osg::NodeVisitor& nv)
|
||||
if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR && _children.size()==2)
|
||||
{
|
||||
|
||||
osg::PagedLOD* pagedLOD = TileMapper::instance()->getPagedLOD(_neighbourTileX,_neighbourTileY, _neighbourTileLOD);
|
||||
//osg::PagedLOD* pagedLOD = TileMapper::instance()->getPagedLOD(_neighbourTileX,_neighbourTileY, _neighbourTileLOD);
|
||||
TXPPagedLOD* pagedLOD = dynamic_cast<TXPPagedLOD*>(TileMapper::instance()->getPagedLOD(_neighbourTileX,_neighbourTileY, _neighbourTileLOD));
|
||||
#if 1
|
||||
if (pagedLOD && pagedLOD->getLastTraversedChild()>0)
|
||||
getChild(1)->accept(nv);
|
||||
else
|
||||
getChild(0)->accept(nv);
|
||||
#else
|
||||
bool acceptLoRes = true;
|
||||
if (pagedLOD)
|
||||
{
|
||||
@@ -85,29 +92,6 @@ void TXPSeamLOD::traverse(osg::NodeVisitor& nv)
|
||||
for (int i = _nonSeamChildrenIndex; i < (int)getNumChildren(); i++ )
|
||||
getChild(i)->accept(nv);
|
||||
}
|
||||
#else
|
||||
float distance = nv.getDistanceToEyePoint(_center,true);
|
||||
if (distance<=_mid)
|
||||
{
|
||||
// cap the lod's that can be used to what is available in the adjacent PagedLOD.
|
||||
|
||||
//std::cout<<"distance to eye from center = "<<distance<<" min = "<< _min<<" mid = "<< _mid << " max = "<<_max<<std::endl;
|
||||
if (pagedLOD)
|
||||
{
|
||||
//std::cout<<" in cull pagedLOD="<<pagedLOD<<" numChildren=="<<pagedLOD->getNumChildren()<<std::endl;
|
||||
for(unsigned int i=0;i<pagedLOD->getNumChildren();++i)
|
||||
{
|
||||
//std::cout<<" child "<<i<<" range = min "<<pagedLOD->getMinRange(i)<<" max = "<<pagedLOD->getMaxRange(i)<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (pagedLOD && pagedLOD->getNumChildren()>1) getChild(1)->accept(nv); // pick high res
|
||||
else getChild(0)->accept(nv); // pick low res as fallback
|
||||
}
|
||||
else
|
||||
{
|
||||
getChild(0)->accept(nv); // pick low res
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -115,4 +99,3 @@ void TXPSeamLOD::traverse(osg::NodeVisitor& nv)
|
||||
Group::traverse(nv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::map< TileTriple, osg::ref_ptr<osg::PagedLOD> > TileMap;
|
||||
typedef std::map< TileTriple, osg::PagedLOD* > TileMap;
|
||||
|
||||
OpenThreads::Mutex _mutex;
|
||||
TileMap _tileMap;
|
||||
|
||||
Reference in New Issue
Block a user