mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +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
1 changed files with 16 additions and 6 deletions
|
|
@ -113,7 +113,11 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals
|
||||||
for(U32 i = 0; i < set->size(); i++)
|
for(U32 i = 0; i < set->size(); i++)
|
||||||
{
|
{
|
||||||
NavMesh *m = static_cast<NavMesh*>(set->at(i));
|
NavMesh *m = static_cast<NavMesh*>(set->at(i));
|
||||||
m->buildTiles(obj->getWorldBox());
|
if (m)
|
||||||
|
{
|
||||||
|
m->cancelBuild();
|
||||||
|
m->buildTiles(obj->getWorldBox());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(remove)
|
if(remove)
|
||||||
obj->enableCollision();
|
obj->enableCollision();
|
||||||
|
|
@ -147,7 +151,7 @@ NavMesh::NavMesh()
|
||||||
mFileName = StringTable->insert("");
|
mFileName = StringTable->insert("");
|
||||||
mNetFlags.clear(Ghostable);
|
mNetFlags.clear(Ghostable);
|
||||||
|
|
||||||
mSaveIntermediates = true;
|
mSaveIntermediates = false;
|
||||||
nm = NULL;
|
nm = NULL;
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
|
|
@ -765,13 +769,15 @@ void NavMesh::buildNextTile()
|
||||||
// Intermediate data for tile build.
|
// Intermediate data for tile build.
|
||||||
TileData tempdata;
|
TileData tempdata;
|
||||||
TileData &tdata = mSaveIntermediates ? mTileData[i] : 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.
|
// Generate navmesh for this tile.
|
||||||
U32 dataSize = 0;
|
U32 dataSize = 0;
|
||||||
unsigned char* data = buildTileData(tile, tdata, dataSize);
|
unsigned char* data = buildTileData(tile, tdata, dataSize);
|
||||||
if(data)
|
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).
|
// Add new data (navmesh owns and deletes the data).
|
||||||
dtStatus status = nm->addTile(data, dataSize, DT_TILE_FREE_DATA, 0, 0);
|
dtStatus status = nm->addTile(data, dataSize, DT_TILE_FREE_DATA, 0, 0);
|
||||||
int success = 1;
|
int success = 1;
|
||||||
|
|
@ -830,6 +836,7 @@ unsigned char *NavMesh::buildTileData(const Tile &tile, TileData &data, U32 &dat
|
||||||
SceneContainer::CallbackInfo info;
|
SceneContainer::CallbackInfo info;
|
||||||
info.context = PLC_Navigation;
|
info.context = PLC_Navigation;
|
||||||
info.boundingBox = box;
|
info.boundingBox = box;
|
||||||
|
data.geom.clear();
|
||||||
info.polyList = &data.geom;
|
info.polyList = &data.geom;
|
||||||
info.key = this;
|
info.key = this;
|
||||||
getContainer()->findObjects(box, StaticShapeObjectType | TerrainObjectType, buildCallback, &info);
|
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.
|
// Check for no geometry.
|
||||||
if(!data.geom.getVertCount())
|
if (!data.geom.getVertCount())
|
||||||
return false;
|
{
|
||||||
|
data.geom.clear();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out voxel dimensions of this tile.
|
// Figure out voxel dimensions of this tile.
|
||||||
U32 width = 0, height = 0;
|
U32 width = 0, height = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue