Fix for missing tiles in navmesh.
This commit is contained in:
parent
cb93a7062b
commit
6aa8b1d989
@ -49,6 +49,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// This value specifies how many layers (or "floors") each navmesh tile is expected to have.
|
||||||
|
static const int EXPECTED_LAYERS_PER_TILE = 4;
|
||||||
|
|
||||||
|
|
||||||
static bool isectSegAABB(const float* sp, const float* sq,
|
static bool isectSegAABB(const float* sp, const float* sq,
|
||||||
const float* amin, const float* amax,
|
const float* amin, const float* amax,
|
||||||
float& tmin, float& tmax)
|
float& tmin, float& tmax)
|
||||||
@ -855,6 +859,7 @@ void Sample_TempObstacles::handleSettings()
|
|||||||
imguiLabel("Tiling");
|
imguiLabel("Tiling");
|
||||||
imguiSlider("TileSize", &m_tileSize, 16.0f, 128.0f, 8.0f);
|
imguiSlider("TileSize", &m_tileSize, 16.0f, 128.0f, 8.0f);
|
||||||
|
|
||||||
|
int gridSize = 1;
|
||||||
if (m_geom)
|
if (m_geom)
|
||||||
{
|
{
|
||||||
const float* bmin = m_geom->getMeshBoundsMin();
|
const float* bmin = m_geom->getMeshBoundsMin();
|
||||||
@ -870,7 +875,7 @@ void Sample_TempObstacles::handleSettings()
|
|||||||
|
|
||||||
// Max tiles and max polys affect how the tile IDs are caculated.
|
// Max tiles and max polys affect how the tile IDs are caculated.
|
||||||
// There are 22 bits available for identifying a tile and a polygon.
|
// There are 22 bits available for identifying a tile and a polygon.
|
||||||
int tileBits = rcMin((int)dtIlog2(dtNextPow2(tw*th)), 14);
|
int tileBits = rcMin((int)dtIlog2(dtNextPow2(tw*th*EXPECTED_LAYERS_PER_TILE)), 14);
|
||||||
if (tileBits > 14) tileBits = 14;
|
if (tileBits > 14) tileBits = 14;
|
||||||
int polyBits = 22 - tileBits;
|
int polyBits = 22 - tileBits;
|
||||||
m_maxTiles = 1 << tileBits;
|
m_maxTiles = 1 << tileBits;
|
||||||
@ -879,6 +884,7 @@ void Sample_TempObstacles::handleSettings()
|
|||||||
imguiValue(text);
|
imguiValue(text);
|
||||||
snprintf(text, 64, "Max Polys %d", m_maxPolysPerTile);
|
snprintf(text, 64, "Max Polys %d", m_maxPolysPerTile);
|
||||||
imguiValue(text);
|
imguiValue(text);
|
||||||
|
gridSize = tw*th;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -895,6 +901,9 @@ void Sample_TempObstacles::handleSettings()
|
|||||||
|
|
||||||
snprintf(msg, 64, "Layers %d", m_cacheLayerCount);
|
snprintf(msg, 64, "Layers %d", m_cacheLayerCount);
|
||||||
imguiValue(msg);
|
imguiValue(msg);
|
||||||
|
snprintf(msg, 64, "Layers (per tile) %.1f", (float)m_cacheLayerCount/(float)gridSize);
|
||||||
|
imguiValue(msg);
|
||||||
|
|
||||||
snprintf(msg, 64, "Memory %.1f kB / %.1f kB (%.1f%%)", m_cacheCompressedSize/1024.0f, m_cacheRawSize/1024.0f, compressionRatio*100.0f);
|
snprintf(msg, 64, "Memory %.1f kB / %.1f kB (%.1f%%)", m_cacheCompressedSize/1024.0f, m_cacheRawSize/1024.0f, compressionRatio*100.0f);
|
||||||
imguiValue(msg);
|
imguiValue(msg);
|
||||||
snprintf(msg, 64, "Navmesh Build Time %.1f ms", m_cacheBuildTimeMs);
|
snprintf(msg, 64, "Navmesh Build Time %.1f ms", m_cacheBuildTimeMs);
|
||||||
@ -1217,7 +1226,7 @@ bool Sample_TempObstacles::handleBuild()
|
|||||||
tcparams.walkableRadius = m_agentRadius;
|
tcparams.walkableRadius = m_agentRadius;
|
||||||
tcparams.walkableClimb = m_agentMaxClimb;
|
tcparams.walkableClimb = m_agentMaxClimb;
|
||||||
tcparams.maxSimplificationError = m_edgeMaxError;
|
tcparams.maxSimplificationError = m_edgeMaxError;
|
||||||
tcparams.maxTiles = tw*th*2;
|
tcparams.maxTiles = tw*th*EXPECTED_LAYERS_PER_TILE;
|
||||||
tcparams.maxObstacles = 128;
|
tcparams.maxObstacles = 128;
|
||||||
|
|
||||||
dtFreeTileCache(m_tileCache);
|
dtFreeTileCache(m_tileCache);
|
||||||
@ -1300,7 +1309,6 @@ bool Sample_TempObstacles::handleBuild()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Build initial meshes
|
// Build initial meshes
|
||||||
m_ctx->startTimer(RC_TIMER_TOTAL);
|
m_ctx->startTimer(RC_TIMER_TOTAL);
|
||||||
|
@ -768,12 +768,13 @@ void Sample_TileMesh::buildTile(const float* pos)
|
|||||||
|
|
||||||
int dataSize = 0;
|
int dataSize = 0;
|
||||||
unsigned char* data = buildTileMesh(tx, ty, m_tileBmin, m_tileBmax, dataSize);
|
unsigned char* data = buildTileMesh(tx, ty, m_tileBmin, m_tileBmax, dataSize);
|
||||||
|
|
||||||
|
// Remove any previous data (navmesh owns and deletes the data).
|
||||||
|
m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),0,0);
|
||||||
|
|
||||||
|
// Add tile, or leave the location empty.
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
// Remove any previous data (navmesh owns and deletes the data).
|
|
||||||
m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),0,0);
|
|
||||||
|
|
||||||
// Let the navmesh own the data.
|
// Let the navmesh own the data.
|
||||||
dtStatus status = m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0);
|
dtStatus status = m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0);
|
||||||
if (dtStatusFailed(status))
|
if (dtStatusFailed(status))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user