MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / removeTile

Method removeTile

Source/ThirdParty/recastnavigation/DetourNavMesh.cpp:1250–1343  ·  view source on GitHub ↗

@par This function returns the data for the tile so that, if desired, it can be added back to the navigation mesh at a later point. @see #addTile

Source from the content-addressed store, hash-verified

1248///
1249/// @see #addTile
1250dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSize)
1251{
1252 if (!ref)
1253 return DT_FAILURE | DT_INVALID_PARAM;
1254 unsigned int tileIndex = decodePolyIdTile((dtPolyRef)ref);
1255 unsigned int tileSalt = decodePolyIdSalt((dtPolyRef)ref);
1256 if ((int)tileIndex >= m_maxTiles)
1257 return DT_FAILURE | DT_INVALID_PARAM;
1258 dtMeshTile* tile = &m_tiles[tileIndex];
1259 if (tile->salt != tileSalt)
1260 return DT_FAILURE | DT_INVALID_PARAM;
1261
1262 // Remove tile from hash lookup.
1263 int h = computeTileHash(tile->header->x,tile->header->y,m_tileLutMask);
1264 dtMeshTile* prev = 0;
1265 dtMeshTile* cur = m_posLookup[h];
1266 while (cur)
1267 {
1268 if (cur == tile)
1269 {
1270 if (prev)
1271 prev->next = cur->next;
1272 else
1273 m_posLookup[h] = cur->next;
1274 break;
1275 }
1276 prev = cur;
1277 cur = cur->next;
1278 }
1279
1280 // Remove connections to neighbour tiles.
1281 static const int MAX_NEIS = 32;
1282 dtMeshTile* neis[MAX_NEIS];
1283 int nneis;
1284
1285 // Disconnect from other layers in current tile.
1286 nneis = getTilesAt(tile->header->x, tile->header->y, neis, MAX_NEIS);
1287 for (int j = 0; j < nneis; ++j)
1288 {
1289 if (neis[j] == tile) continue;
1290 unconnectLinks(neis[j], tile);
1291 }
1292
1293 // Disconnect from neighbour tiles.
1294 for (int i = 0; i < 8; ++i)
1295 {
1296 nneis = getNeighbourTilesAt(tile->header->x, tile->header->y, i, neis, MAX_NEIS);
1297 for (int j = 0; j < nneis; ++j)
1298 unconnectLinks(neis[j], tile);
1299 }
1300
1301 // Reset tile.
1302 if (tile->flags & DT_TILE_FREE_DATA)
1303 {
1304 // Owns data
1305 dtFree(tile->data);
1306 tile->data = 0;
1307 tile->dataSize = 0;

Callers 3

RemoveTileMethod · 0.45
RemoveTilesMethod · 0.45
AddTileInternalMethod · 0.45

Calls 2

dtFreeFunction · 0.85
computeTileHashFunction · 0.70

Tested by

no test coverage detected