Optimize NavMesh to not allocate tile memory twice and add safelock to asset data

This commit is contained in:
Wojtek Figat
2025-04-03 17:21:48 +02:00
parent a29b556de6
commit 0c6f1ff9dc
5 changed files with 13 additions and 8 deletions

View File

@@ -13,8 +13,7 @@
#define MAX_NODES 2048
#define USE_DATA_LINK 0
#define USE_NAV_MESH_ALLOC 1
// TODO: try not using USE_NAV_MESH_ALLOC
#define USE_NAV_MESH_ALLOC 0
namespace
{
@@ -367,6 +366,9 @@ void NavMeshRuntime::EnsureCapacity(int32 tilesToAddCount)
if (dtStatusFailed(result))
{
LOG(Warning, "Could not add tile ({2}x{3}, layer {4}) to navmesh {0} (error: {1})", Properties.Name, result & ~DT_FAILURE, tile.X, tile.Y, tile.Layer);
#if USE_NAV_MESH_ALLOC
dtFree(data);
#endif
}
}
}
@@ -672,5 +674,8 @@ void NavMeshRuntime::AddTileInternal(NavMesh* navMesh, NavMeshTileData& tileData
if (dtStatusFailed(result))
{
LOG(Warning, "Could not add tile ({2}x{3}, layer {4}) to navmesh {0} (error: {1})", Properties.Name, result & ~DT_FAILURE, tileData.PosX, tileData.PosY, tileData.Layer);
#if USE_NAV_MESH_ALLOC
dtFree(data);
#endif
}
}