Code:
//from common.h
// 2 fields additional mask:
// XXX
//XXXXX
//XXOXX
//XXXXX
// XXX
int RobotMask[][2]={ {-1, 2},{0, 2},{1, 2},
{-2, 1},{-1, 1},{0, 1},{1, 1},{2, 1},
{-2, 0},{-1, 0},{0, 0},{1, 0},{2, 0},
{-2, -1},{-1, -1},{0, -1},{1, -1},{2, -1},
{-1, -2},{0, -2},{1, -2}
};
void Grid::Set(int x, int y, int8_t val)
{
Tile* tile = GetTile(x,y, true);
if (tile == nullptr)
return;
int8_t e = tile->Set((x-xMin)%SLAM_TILESIZE,(y-yMin)%SLAM_TILESIZE, val);
if (e !=0)
{
int ex, ey;
for (int i=0;i <sizeof(RobotMask)/8;i++)
{
ex= x+RobotMask[i][0];
ey= y+RobotMask[i][1];
tile = GetTile(ex,ey, true);
if (tile != nullptr)
tile->AddToEroded((ex-xMin)%SLAM_TILESIZE,(ey-yMin)%SLAM_TILESIZE, e);
}
}
}
Das Resultat: Dickere Wände, freie Felder sind 0, besetzte Felder haben einen positiven Wert.
Lesezeichen