From e63c0a78a3b924b2de3baae41d54d25abb14a928 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 27 Nov 2015 17:43:08 -0600 Subject: [PATCH 1/5] 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; From 45055f8f3e638b2fed977f54157f8798eea28e91 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 27 Nov 2015 18:18:21 -0600 Subject: [PATCH 2/5] formatting --- Engine/source/navigation/navMesh.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 5575327e8..738348d2f 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -113,8 +113,8 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals for(U32 i = 0; i < set->size(); i++) { NavMesh *m = static_cast(set->at(i)); - if (m) - { + if (m) + { m->cancelBuild(); m->buildTiles(obj->getWorldBox()); } From f06db00255c85f4ea7f2d230570bc58c3f1c1a35 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Thu, 3 Dec 2015 18:34:53 -0600 Subject: [PATCH 3/5] dynamic_cast check for regeneration for paranoias sake + an alias method. --- Engine/source/navigation/navMesh.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 738348d2f..74d71dc77 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -112,7 +112,7 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals SimSet *set = NavMesh::getServerSet(); for(U32 i = 0; i < set->size(); i++) { - NavMesh *m = static_cast(set->at(i)); + NavMesh *m = dynamic_cast(set->at(i)); if (m) { m->cancelBuild(); @@ -123,6 +123,28 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals obj->enableCollision(); } +DefineConsoleFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), (0, false), + "@brief Update all NavMesh tiles that intersect the given object's world box.") +{ + SceneObject *obj; + if (!Sim::findObject(objid, obj)) + return; + if (remove) + obj->disableCollision(); + SimSet *set = NavMesh::getServerSet(); + for (U32 i = 0; i < set->size(); i++) + { + NavMesh *m = dynamic_cast(set->at(i)); + if (m) + { + m->cancelBuild(); + m->buildTiles(obj->getWorldBox()); + } + } + if (remove) + obj->enableCollision(); +} + DefineConsoleFunction(NavMeshUpdateOne, void, (S32 meshid, S32 objid, bool remove), (0, 0, false), "@brief Update all tiles in a given NavMesh that intersect the given object's world box.") { From f3ff1995549cda16929d761a0131214452e5187f Mon Sep 17 00:00:00 2001 From: Anis Date: Sat, 13 Feb 2016 18:50:11 +0100 Subject: [PATCH 4/5] Update navMesh.cpp --- Engine/source/navigation/navMesh.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 74d71dc77..22a47a9f3 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -123,28 +123,6 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals obj->enableCollision(); } -DefineConsoleFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), (0, false), - "@brief Update all NavMesh tiles that intersect the given object's world box.") -{ - SceneObject *obj; - if (!Sim::findObject(objid, obj)) - return; - if (remove) - obj->disableCollision(); - SimSet *set = NavMesh::getServerSet(); - for (U32 i = 0; i < set->size(); i++) - { - NavMesh *m = dynamic_cast(set->at(i)); - if (m) - { - m->cancelBuild(); - m->buildTiles(obj->getWorldBox()); - } - } - if (remove) - obj->enableCollision(); -} - DefineConsoleFunction(NavMeshUpdateOne, void, (S32 meshid, S32 objid, bool remove), (0, 0, false), "@brief Update all tiles in a given NavMesh that intersect the given object's world box.") { From 612d932372efa0b54d730317e15bba49812a3a57 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 19 Feb 2016 17:34:27 -0600 Subject: [PATCH 5/5] Revert "Update navMesh.cpp" This reverts commit f3ff1995549cda16929d761a0131214452e5187f. --- Engine/source/navigation/navMesh.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 22a47a9f3..74d71dc77 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -123,6 +123,28 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals obj->enableCollision(); } +DefineConsoleFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), (0, false), + "@brief Update all NavMesh tiles that intersect the given object's world box.") +{ + SceneObject *obj; + if (!Sim::findObject(objid, obj)) + return; + if (remove) + obj->disableCollision(); + SimSet *set = NavMesh::getServerSet(); + for (U32 i = 0; i < set->size(); i++) + { + NavMesh *m = dynamic_cast(set->at(i)); + if (m) + { + m->cancelBuild(); + m->buildTiles(obj->getWorldBox()); + } + } + if (remove) + obj->enableCollision(); +} + DefineConsoleFunction(NavMeshUpdateOne, void, (S32 meshid, S32 objid, bool remove), (0, 0, false), "@brief Update all tiles in a given NavMesh that intersect the given object's world box.") {