mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-10-23 17:21:07 +00:00
DETOUR return status codes changed, check blog! Changed Detour status codes to be bitfields which describes the highlevel status plus some details about the failure or quality of the result.
This commit is contained in:
@@ -442,7 +442,8 @@ void NavMeshTesterTool::handleToggle()
|
||||
m_pathIterPolyCount -= npos;
|
||||
|
||||
// Handle the connection.
|
||||
if (m_navMesh->getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startPos, endPos) == DT_SUCCESS)
|
||||
dtStatus status = m_navMesh->getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startPos, endPos);
|
||||
if (dtStatusSucceed(status))
|
||||
{
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
@@ -476,12 +477,11 @@ void NavMeshTesterTool::handleUpdate(const float /*dt*/)
|
||||
{
|
||||
if (m_toolMode == TOOLMODE_PATHFIND_SLICED)
|
||||
{
|
||||
if (m_pathFindStatus == DT_IN_PROGRESS)
|
||||
if (dtStatusInProgress(m_pathFindStatus))
|
||||
{
|
||||
m_pathFindStatus = m_navQuery->updateSlicedFindPath(1);
|
||||
}
|
||||
|
||||
if (m_pathFindStatus == DT_SUCCESS)
|
||||
if (dtStatusSucceed(m_pathFindStatus))
|
||||
{
|
||||
m_navQuery->finalizeSlicedFindPath(m_polys, &m_npolys, MAX_POLYS);
|
||||
m_nstraightPath = 0;
|
||||
@@ -498,7 +498,7 @@ void NavMeshTesterTool::handleUpdate(const float /*dt*/)
|
||||
m_straightPathPolys, &m_nstraightPath, MAX_POLYS);
|
||||
}
|
||||
|
||||
m_pathFindStatus = DT_FAILURE;
|
||||
m_pathFindStatus = DT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -639,7 +639,8 @@ void NavMeshTesterTool::recalc()
|
||||
npolys -= npos;
|
||||
|
||||
// Handle the connection.
|
||||
if (m_navMesh->getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startPos, endPos) == DT_SUCCESS)
|
||||
dtStatus status = m_navMesh->getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startPos, endPos);
|
||||
if (dtStatusSucceed(status))
|
||||
{
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
@@ -856,7 +857,8 @@ static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center)
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
if (navMesh->getTileAndPolyByRef(ref, &tile, &poly) != DT_SUCCESS)
|
||||
dtStatus status = navMesh->getTileAndPolyByRef(ref, &tile, &poly);
|
||||
if (dtStatusFailed(status))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < (int)poly->vertCount; ++i)
|
||||
|
||||
@@ -640,14 +640,18 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA) != DT_SUCCESS)
|
||||
dtStatus status;
|
||||
|
||||
status = m_navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
dtFree(navData);
|
||||
m_ctx->log(RC_LOG_ERROR, "Could not init Detour navmesh");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_navQuery->init(m_navMesh, 2048) != DT_SUCCESS)
|
||||
status = m_navQuery->init(m_navMesh, 2048);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "Could not init Detour navmesh query");
|
||||
return false;
|
||||
|
||||
@@ -1082,14 +1082,18 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA) != DT_SUCCESS)
|
||||
dtStatus status;
|
||||
|
||||
status = m_navMesh->init(navData, navDataSize, DT_TILE_FREE_DATA);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
dtFree(navData);
|
||||
m_ctx->log(RC_LOG_ERROR, "Could not init Detour navmesh");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_navQuery->init(m_navMesh, 2048) != DT_SUCCESS)
|
||||
status = m_navQuery->init(m_navMesh, 2048);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "Could not init Detour navmesh query");
|
||||
return false;
|
||||
|
||||
@@ -296,8 +296,13 @@ dtNavMesh* Sample_TileMesh::loadAll(const char* path)
|
||||
}
|
||||
|
||||
dtNavMesh* mesh = dtAllocNavMesh();
|
||||
|
||||
if (!mesh || mesh->init(&header.params) != DT_SUCCESS)
|
||||
if (!mesh)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
dtStatus status = mesh->init(&header.params);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
@@ -712,13 +717,18 @@ bool Sample_TileMesh::handleBuild()
|
||||
params.tileHeight = m_tileSize*m_cellSize;
|
||||
params.maxTiles = m_maxTiles;
|
||||
params.maxPolys = m_maxPolysPerTile;
|
||||
if (m_navMesh->init(¶ms) != DT_SUCCESS)
|
||||
|
||||
dtStatus status;
|
||||
|
||||
status = m_navMesh->init(¶ms);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init navmesh.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_navQuery->init(m_navMesh, 2048) != DT_SUCCESS)
|
||||
status = m_navQuery->init(m_navMesh, 2048);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not init Detour navmesh query");
|
||||
return false;
|
||||
@@ -766,7 +776,8 @@ void Sample_TileMesh::buildTile(const float* pos)
|
||||
m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty),0,0);
|
||||
|
||||
// Let the navmesh own the data.
|
||||
if (m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0) != DT_SUCCESS)
|
||||
dtStatus status = m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0);
|
||||
if (dtStatusFailed(status))
|
||||
dtFree(data);
|
||||
}
|
||||
|
||||
@@ -846,7 +857,8 @@ void Sample_TileMesh::buildAllTiles()
|
||||
// Remove any previous data (navmesh owns and deletes the data).
|
||||
m_navMesh->removeTile(m_navMesh->getTileRefAt(x,y),0,0);
|
||||
// Let the navmesh own the data.
|
||||
if (m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0) != DT_SUCCESS)
|
||||
dtStatus status = m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0);
|
||||
if (dtStatusFailed(status))
|
||||
dtFree(data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user