mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
NavMeshUpdateAll leak suppression (not 100% preventative)
1) Reset the build when adding potential dirties to the list to ensure it isn't trying to kill off a dirty entry that it's passed by. 2) mSaveIntermediates = true; causes leakage even with all this. still tracking that end. 3) Need to remove a dead tile whether there's new data to replace it with or not. Empty tiles are an entirely possible case. Even a probable one if you have high verticality in a level. 4) Likewise you don't want to re-feed the same geometry list for a given tile in case the conditions have changed. 5) If no vertcount then clear all geometry entries. (that one might be paranoia)
This commit is contained in:
parent
272e3138a0
commit
e63c0a78a3
|
|
@ -113,7 +113,11 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals
|
|||
for(U32 i = 0; i < set->size(); i++)
|
||||
{
|
||||
NavMesh *m = static_cast<NavMesh*>(set->at(i));
|
||||
m->buildTiles(obj->getWorldBox());
|
||||
if (m)
|
||||
{
|
||||
m->cancelBuild();
|
||||
m->buildTiles(obj->getWorldBox());
|
||||
}
|
||||
}
|
||||
if(remove)
|
||||
obj->enableCollision();
|
||||
|
|
@ -147,7 +151,7 @@ NavMesh::NavMesh()
|
|||
mFileName = StringTable->insert("");
|
||||
mNetFlags.clear(Ghostable);
|
||||
|
||||
mSaveIntermediates = true;
|
||||
mSaveIntermediates = false;
|
||||
nm = NULL;
|
||||
ctx = NULL;
|
||||
|
||||
|
|
@ -765,13 +769,15 @@ void NavMesh::buildNextTile()
|
|||
// Intermediate data for tile build.
|
||||
TileData tempdata;
|
||||
TileData &tdata = mSaveIntermediates ? mTileData[i] : tempdata;
|
||||
|
||||
// Remove any previous data.
|
||||
nm->removeTile(nm->getTileRefAt(tile.x, tile.y, 0), 0, 0);
|
||||
|
||||
// Generate navmesh for this tile.
|
||||
U32 dataSize = 0;
|
||||
unsigned char* data = buildTileData(tile, tdata, dataSize);
|
||||
if(data)
|
||||
{
|
||||
// Remove any previous data.
|
||||
nm->removeTile(nm->getTileRefAt(tile.x, tile.y, 0), 0, 0);
|
||||
// Add new data (navmesh owns and deletes the data).
|
||||
dtStatus status = nm->addTile(data, dataSize, DT_TILE_FREE_DATA, 0, 0);
|
||||
int success = 1;
|
||||
|
|
@ -830,6 +836,7 @@ unsigned char *NavMesh::buildTileData(const Tile &tile, TileData &data, U32 &dat
|
|||
SceneContainer::CallbackInfo info;
|
||||
info.context = PLC_Navigation;
|
||||
info.boundingBox = box;
|
||||
data.geom.clear();
|
||||
info.polyList = &data.geom;
|
||||
info.key = this;
|
||||
getContainer()->findObjects(box, StaticShapeObjectType | TerrainObjectType, buildCallback, &info);
|
||||
|
|
@ -843,8 +850,11 @@ unsigned char *NavMesh::buildTileData(const Tile &tile, TileData &data, U32 &dat
|
|||
}
|
||||
|
||||
// Check for no geometry.
|
||||
if(!data.geom.getVertCount())
|
||||
return false;
|
||||
if (!data.geom.getVertCount())
|
||||
{
|
||||
data.geom.clear();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Figure out voxel dimensions of this tile.
|
||||
U32 width = 0, height = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue