From e63c0a78a3b924b2de3baae41d54d25abb14a928 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 27 Nov 2015 17:43:08 -0600 Subject: [PATCH] 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) --- Engine/source/navigation/navMesh.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 7df05ee2e..5575327e8 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -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(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;