diff --git a/src/osgPlugins/txp/TileMapper.cpp b/src/osgPlugins/txp/TileMapper.cpp index 94ead961f..16d16dd85 100644 --- a/src/osgPlugins/txp/TileMapper.cpp +++ b/src/osgPlugins/txp/TileMapper.cpp @@ -104,9 +104,9 @@ void TileMapper::apply(osg::Group& node) #if 0 std::cout<<"found Group="<lod - <<" X="<x - <<" Y="<y - <<" ptr="<<&node<=2) ? &ts[ts.size()-2] : 0; - // note parent here, is tid's parents parent. - const TileStack::value_type* parent = (ts.size()>=3) ? &ts[ts.size()-3] : 0; - if (!tile) { // no self!!! so we can descend safely?!! shouldn't ever get here. @@ -253,6 +250,12 @@ bool TileMapper::canParentBeTraversed(const TileIdentifier& tid) const return true; } + + // note parent here, is tid's parents parent. + const TileStack::value_type* parent = (ts.size()>=3) ? &ts[ts.size()-3] : 0; + + + if (!parent) { // no parent so we can descend safely. @@ -271,14 +274,22 @@ bool TileMapper::canParentBeTraversed(const TileIdentifier& tid) const return true; } + // FIXME: this guy gives us wrong parent + // Nick 2010/12/12 +#if 0 const TileIdentifier& parent_tid = parent->first; +#else + TileIdentifier parent_tid(tid.x/2,tid.y/2,tid.lod-1); +#endif bool parentHasNorthNeighour = _tileMap.count(TileIdentifier(parent_tid.x,parent_tid.y+1,parent_tid.lod))!=0; bool parentHasEastNeighour = _tileMap.count(TileIdentifier(parent_tid.x+1,parent_tid.y,parent_tid.lod))!=0; bool parentHasSouthNeighour = _tileMap.count(TileIdentifier(parent_tid.x,parent_tid.y-1,parent_tid.lod))!=0; bool parentHasWestNeighour = _tileMap.count(TileIdentifier(parent_tid.x-1,parent_tid.y,parent_tid.lod))!=0; - + // FIXME: this guy gives us wrong parent + // Nick 2010/12/12 +#if 0 // identify whether the tile is a NE/SE/SW/NW tile relative to its parent. osg::Vec3 delta = tile->second->getBound().center() - parent->second->getBound().center(); @@ -308,6 +319,37 @@ bool TileMapper::canParentBeTraversed(const TileIdentifier& tid) const return (!parentHasSouthNeighour && !parentHasWestNeighour); } } +#else + // identify whether the tile is a NE/SE/SW/NW tile relative to its parent. + osg::Vec3 delta(tid.x%2,tid.y%2,0); + + if (delta.y()>0.0f) // noth side + { + if (delta.x()>0.0f) + { + // NE, only traverse if our parent doesn't have any neighbours to the north or east. + return (!parentHasNorthNeighour && !parentHasEastNeighour); + } + else + { + // NW, only traverse if our parent doesn't have any neighbours to the north or west. + return (!parentHasNorthNeighour && !parentHasWestNeighour); + } + } + else // south side + { + if (delta.x()>0.0f) + { + // SE, only traverse if our parent doesn't have any neighbours to the south or east. + return (!parentHasSouthNeighour && !parentHasEastNeighour); + } + else + { + // SW, only traverse if our parent doesn't have any neighbours to the south or west. + return (!parentHasSouthNeighour && !parentHasWestNeighour); + } + } +#endif } void TileMapper::checkValidityOfAllVisibleTiles() @@ -321,7 +363,7 @@ void TileMapper::checkValidityOfAllVisibleTiles() do { // std::cout<<"doing checkAllVisibleTiles() loop with "<<_tileMap.size()<