Experiments at fixing seam handling.
This commit is contained in:
@@ -45,18 +45,56 @@ void TXPSeamLOD::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR && _children.size()==2)
|
||||
{
|
||||
float distance = nv.getDistanceToEyePoint(_center,true);
|
||||
if (distance<_mid)
|
||||
|
||||
#if 1
|
||||
osg::PagedLOD* pagedLOD = TileMapper::instance()->getPagedLOD(_neighbourTileX,_neighbourTileY, _neighbourTileLOD);
|
||||
if (pagedLOD)
|
||||
{
|
||||
// cap the lod's that can be used to what is available in the adjacent PagedLOD.
|
||||
osg::PagedLOD* pagedLOD = TileMapper::instance()->getPagedLOD(_neighbourTileX,_neighbourTileY, _neighbourTileLOD);
|
||||
if (pagedLOD && pagedLOD->getNumChildren()>1) getChild(1)->accept(nv);
|
||||
else getChild(0)->accept(nv);
|
||||
|
||||
float distance = nv.getDistanceToEyePoint(_center,true);
|
||||
distance = nv.getDistanceToEyePoint(pagedLOD->getCenter(),true);
|
||||
|
||||
//std::cout<<"distance to eye from center = "<<distance<<" min = "<< _min<<" mid = "<< _mid << " max = "<<_max<<std::endl;
|
||||
//std::cout<<" TXPSeam::_center "<<_center<<" PageLOD::_center "<<pagedLOD->getCenter()<<std::endl;
|
||||
int numChildren = osg::minimum(getNumChildren(),pagedLOD->getNumChildren());
|
||||
for(int i=numChildren-1;i>=0;--i)
|
||||
{
|
||||
//std::cout<<" child "<<i<<" range = min "<<pagedLOD->getMinRange(i)<<" max = "<<pagedLOD->getMaxRange(i)<<std::endl;
|
||||
if (distance<=pagedLOD->getMaxRange(i))
|
||||
{
|
||||
getChild(i)->accept(nv);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getChild(0)->accept(nv);
|
||||
getChild(0)->accept(nv); // pick low res
|
||||
}
|
||||
#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
|
||||
{
|
||||
|
||||
@@ -125,10 +125,31 @@ osg::Node* TXPTileNode::seamReplacement(osg::Node* child,int x, int y, int level
|
||||
}
|
||||
}
|
||||
|
||||
TXPSeamLOD* seam = new TXPSeamLOD(x,y,level,lod1->getCenter(),lod2->getMinRange(0),lod2->getMaxRange(0),lod1->getMaxRange(0));
|
||||
// std::cout<<"seamReplacement lod1 min="<<lod1->getMinRange(0)<<" max="<<lod1->getMaxRange(0)<<std::endl;
|
||||
// std::cout<<" lod2 min="<<lod2->getMinRange(0)<<" max="<<lod2->getMaxRange(0)<<std::endl;
|
||||
|
||||
if (lod1->getMaxRange(0)<lod2->getMaxRange(0))
|
||||
{
|
||||
// std::cout<<" lod1 is high res, lod2 is low res."<<std::endl;
|
||||
}
|
||||
else if (lod1->getMaxRange(0)==lod2->getMaxRange(0))
|
||||
{
|
||||
// std::cout<<" lod1 and lod2 range equal. ****************"<<std::endl;
|
||||
// don't replace with seam LOD node, leave as a standard LOD.
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout<<" lod1 is low res, lod2 is high res. --------------"<<std::endl;
|
||||
// don't replace with seam LOD node, leave as a standard LOD
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TXPSeamLOD* seam = new TXPSeamLOD(x,y,level,lod1->getCenter(),lod1->getMinRange(0),lod1->getMaxRange(0),lod2->getMaxRange(0));
|
||||
seam->setArchive(_archive);
|
||||
seam->addChild(lod1->getChild(0));
|
||||
seam->addChild(lod2->getChild(0));
|
||||
seam->addChild(lod1->getChild(0)); // high res
|
||||
seam->addChild(lod2->getChild(0)); // low res
|
||||
return seam;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user