From c71e2100ecc8b374bb3849cb0dbbc053083df547 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 4 Jan 2004 22:28:37 +0000 Subject: [PATCH] Experiments at fixing seam handling. --- src/osgPlugins/txp/TXPSeamLOD.cpp | 52 ++++++++++++++++++++++++++---- src/osgPlugins/txp/TXPTileNode.cpp | 27 ++++++++++++++-- 2 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/osgPlugins/txp/TXPSeamLOD.cpp b/src/osgPlugins/txp/TXPSeamLOD.cpp index 4e159959b..7b8d8b092 100644 --- a/src/osgPlugins/txp/TXPSeamLOD.cpp +++ b/src/osgPlugins/txp/TXPSeamLOD.cpp @@ -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 = "<getCenter()<getNumChildren()); + for(int i=numChildren-1;i>=0;--i) + { + //std::cout<<" child "<getMinRange(i)<<" max = "<getMaxRange(i)<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 = "<getNumChildren()<getNumChildren();++i) + { + //std::cout<<" child "<getMinRange(i)<<" max = "<getMaxRange(i)<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 { diff --git a/src/osgPlugins/txp/TXPTileNode.cpp b/src/osgPlugins/txp/TXPTileNode.cpp index 04daaa402..30f6cda23 100644 --- a/src/osgPlugins/txp/TXPTileNode.cpp +++ b/src/osgPlugins/txp/TXPTileNode.cpp @@ -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="<getMinRange(0)<<" max="<getMaxRange(0)<getMaxRange(0)==lod2->getMaxRange(0)) + { +// std::cout<<" lod1 and lod2 range equal. ****************"<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; } }