From Trajce Nikolov, "attached is a fix for the txp loader (in TileMapper). The code was giving wrong parent tile ids using the stack - I implemented differnt approach for that"
This commit is contained in:
parent
244e751146
commit
c12b04368a
@ -243,9 +243,6 @@ bool TileMapper::canParentBeTraversed(const TileIdentifier& tid) const
|
|||||||
// note tile here, is tid's parent.
|
// note tile here, is tid's parent.
|
||||||
const TileStack::value_type* tile = (ts.size()>=2) ? &ts[ts.size()-2] : 0;
|
const TileStack::value_type* tile = (ts.size()>=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)
|
if (!tile)
|
||||||
{
|
{
|
||||||
// no self!!! so we can descend safely?!! shouldn't ever get here.
|
// 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;
|
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)
|
if (!parent)
|
||||||
{
|
{
|
||||||
// no parent so we can descend safely.
|
// no parent so we can descend safely.
|
||||||
@ -271,14 +274,22 @@ bool TileMapper::canParentBeTraversed(const TileIdentifier& tid) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this guy gives us wrong parent
|
||||||
|
// Nick 2010/12/12
|
||||||
|
#if 0
|
||||||
const TileIdentifier& parent_tid = parent->first;
|
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 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 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 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;
|
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.
|
// 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();
|
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);
|
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()
|
void TileMapper::checkValidityOfAllVisibleTiles()
|
||||||
@ -385,7 +427,6 @@ void TileMapper::checkValidityOfAllVisibleTiles()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileMapper::isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx, int dy) const
|
bool TileMapper::isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx, int dy) const
|
||||||
{
|
{
|
||||||
if (_tileMap.count(TileIdentifier(tid.x+dx,tid.y+dy,tid.lod))!=0)
|
if (_tileMap.count(TileIdentifier(tid.x+dx,tid.y+dy,tid.lod))!=0)
|
||||||
@ -418,6 +459,10 @@ bool TileMapper::isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this guy gives us wrong parent
|
||||||
|
// Nick 2010/12/12
|
||||||
|
#if 0
|
||||||
|
|
||||||
// note parent here, is tid's parents parent.
|
// note parent here, is tid's parents parent.
|
||||||
const TileStack::value_type* parent = (ts.size()>=2) ? &ts[ts.size()-2] : 0;
|
const TileStack::value_type* parent = (ts.size()>=2) ? &ts[ts.size()-2] : 0;
|
||||||
|
|
||||||
@ -428,6 +473,11 @@ bool TileMapper::isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TileIdentifier& parent_tid = parent->first;
|
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 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 parentHasEastNeighour = _tileMap.count(TileIdentifier(parent_tid.x+1,parent_tid.y, parent_tid.lod))!=0;
|
||||||
@ -436,6 +486,10 @@ bool TileMapper::isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx
|
|||||||
|
|
||||||
|
|
||||||
// identify whether the tile is a NE/SE/SW/NW tile relative to its parent.
|
// identify whether the tile is a NE/SE/SW/NW tile relative to its parent.
|
||||||
|
|
||||||
|
// FIXME: wrong parent wrong values
|
||||||
|
// Nick 2010/12/12
|
||||||
|
#if 0
|
||||||
osg::Vec3 delta = tile->second->getBound().center() - parent->second->getBound().center();
|
osg::Vec3 delta = tile->second->getBound().center() - parent->second->getBound().center();
|
||||||
|
|
||||||
if (delta.y()>=0.0f) // noth side
|
if (delta.y()>=0.0f) // noth side
|
||||||
@ -476,6 +530,48 @@ bool TileMapper::isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx
|
|||||||
return parentHasWestNeighour;
|
return parentHasWestNeighour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
osg::Vec3 delta(tid.x%2,tid.y%2,0);
|
||||||
|
|
||||||
|
if (delta.y()>0.0f) // noth side
|
||||||
|
{
|
||||||
|
if (delta.x()>0.0f)
|
||||||
|
{
|
||||||
|
// NE
|
||||||
|
if (dy==1)
|
||||||
|
return parentHasNorthNeighour;
|
||||||
|
else if (dx==1)
|
||||||
|
return parentHasEastNeighour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// NW
|
||||||
|
if (dy==1)
|
||||||
|
return parentHasNorthNeighour;
|
||||||
|
else if (dx==-1)
|
||||||
|
return parentHasWestNeighour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // south side
|
||||||
|
{
|
||||||
|
if (delta.x()>0.0f)
|
||||||
|
{
|
||||||
|
// SE
|
||||||
|
if (dy==-1)
|
||||||
|
return parentHasSouthNeighour;
|
||||||
|
else if (dx==1)
|
||||||
|
return parentHasEastNeighour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// SW
|
||||||
|
if (dy==-1)
|
||||||
|
return parentHasSouthNeighour;
|
||||||
|
else if (dx==-1)
|
||||||
|
return parentHasWestNeighour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user