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:
parent
7fbcfa9c4b
commit
08741e894c
@ -421,7 +421,7 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
if (mesh.getTileAndPolyByRef(ref, &tile, &poly) != DT_SUCCESS)
|
||||
if (dtStatusFailed(mesh.getTileAndPolyByRef(ref, &tile, &poly)))
|
||||
return;
|
||||
|
||||
dd->depthMask(false);
|
||||
|
@ -66,15 +66,48 @@ enum dtPolyTypes
|
||||
DT_POLYTYPE_OFFMESH_CONNECTION = 1, // Off-mesh connections.
|
||||
};
|
||||
|
||||
enum dtStatus
|
||||
|
||||
typedef unsigned int dtStatus;
|
||||
|
||||
// High level status.
|
||||
static const unsigned int DT_FAILURE = 1 << 31; // Operation failed.
|
||||
static const unsigned int DT_SUCCESS = 1 << 30; // Operation succeed.
|
||||
static const unsigned int DT_IN_PROGRESS = 1 << 29; // Operation still in progress.
|
||||
|
||||
// Detail information for status.
|
||||
static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff;
|
||||
static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized.
|
||||
static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version.
|
||||
static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory.
|
||||
static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid.
|
||||
static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results.
|
||||
static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search.
|
||||
static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess.
|
||||
|
||||
|
||||
// Returns true of status is success.
|
||||
inline bool dtStatusSucceed(dtStatus status)
|
||||
{
|
||||
DT_FAILURE = 0, // Operation failed.
|
||||
DT_FAILURE_DATA_MAGIC,
|
||||
DT_FAILURE_DATA_VERSION,
|
||||
DT_FAILURE_OUT_OF_MEMORY,
|
||||
DT_SUCCESS, // Operation succeed.
|
||||
DT_IN_PROGRESS, // Operation still in progress.
|
||||
};
|
||||
return (status & DT_SUCCESS) != 0;
|
||||
}
|
||||
|
||||
// Returns true of status is failure.
|
||||
inline bool dtStatusFailed(dtStatus status)
|
||||
{
|
||||
return (status & DT_FAILURE) != 0;
|
||||
}
|
||||
|
||||
// Returns true of status is in progress.
|
||||
inline bool dtStatusInProgress(dtStatus status)
|
||||
{
|
||||
return (status & DT_IN_PROGRESS) != 0;
|
||||
}
|
||||
|
||||
// Returns true if specific detail is set.
|
||||
inline bool dtStatusDetail(dtStatus status, unsigned int detail)
|
||||
{
|
||||
return (status & detail) != 0;
|
||||
}
|
||||
|
||||
|
||||
// Structure describing the navigation polygon data.
|
||||
@ -384,8 +417,8 @@ private:
|
||||
dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center,
|
||||
const float* extents, float* nearestPt) const;
|
||||
// Returns closest point on polygon.
|
||||
dtStatus closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip,
|
||||
const float* pos, float* closest) const;
|
||||
void closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip,
|
||||
const float* pos, float* closest) const;
|
||||
|
||||
dtNavMeshParams m_params; // Current initialization params. TODO: do not store this info twice.
|
||||
float m_orig[3]; // Origin of the tile (0,0)
|
||||
|
@ -365,7 +365,7 @@ private:
|
||||
dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center, const float* extents,
|
||||
const dtQueryFilter* filter, float* nearestPt) const;
|
||||
// Returns closest point on polygon.
|
||||
dtStatus closestPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly, const float* pos, float* closest) const;
|
||||
void closestPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly, const float* pos, float* closest) const;
|
||||
|
||||
// Returns portal points between two polygons.
|
||||
dtStatus getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
|
||||
|
@ -189,10 +189,10 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
|
||||
m_tiles = (dtMeshTile*)dtAlloc(sizeof(dtMeshTile)*m_maxTiles, DT_ALLOC_PERM);
|
||||
if (!m_tiles)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
m_posLookup = (dtMeshTile**)dtAlloc(sizeof(dtMeshTile*)*m_tileLutSize, DT_ALLOC_PERM);
|
||||
if (!m_posLookup)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
memset(m_tiles, 0, sizeof(dtMeshTile)*m_maxTiles);
|
||||
memset(m_posLookup, 0, sizeof(dtMeshTile*)*m_tileLutSize);
|
||||
m_nextFree = 0;
|
||||
@ -208,7 +208,7 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
m_polyBits = dtIlog2(dtNextPow2((unsigned int)params->maxPolys));
|
||||
m_saltBits = 32 - m_tileBits - m_polyBits;
|
||||
if (m_saltBits < 10)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
@ -218,9 +218,9 @@ dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int flag
|
||||
// Make sure the data is in right format.
|
||||
dtMeshHeader* header = (dtMeshHeader*)data;
|
||||
if (header->magic != DT_NAVMESH_MAGIC)
|
||||
return DT_FAILURE_DATA_MAGIC;
|
||||
return DT_FAILURE | DT_WRONG_MAGIC;
|
||||
if (header->version != DT_NAVMESH_VERSION)
|
||||
return DT_FAILURE_DATA_VERSION;
|
||||
return DT_FAILURE | DT_WRONG_VERSION;
|
||||
|
||||
dtNavMeshParams params;
|
||||
dtVcopy(params.orig, header->bmin);
|
||||
@ -229,9 +229,9 @@ dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int flag
|
||||
params.maxTiles = 1;
|
||||
params.maxPolys = header->polyCount;
|
||||
|
||||
dtStatus res = init(¶ms);
|
||||
if (res != DT_SUCCESS)
|
||||
return res;
|
||||
dtStatus status = init(¶ms);
|
||||
if (dtStatusFailed(status))
|
||||
return status;
|
||||
|
||||
return addTile(data, dataSize, flags, 0, 0);
|
||||
}
|
||||
@ -555,8 +555,8 @@ void dtNavMesh::connectIntOffMeshLinks(dtMeshTile* tile)
|
||||
}
|
||||
}
|
||||
|
||||
dtStatus dtNavMesh::closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip,
|
||||
const float* pos, float* closest) const
|
||||
void dtNavMesh::closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip,
|
||||
const float* pos, float* closest) const
|
||||
{
|
||||
const dtPoly* poly = &tile->polys[ip];
|
||||
|
||||
@ -583,8 +583,6 @@ dtStatus dtNavMesh::closestPointOnPolyInTile(const dtMeshTile* tile, unsigned in
|
||||
closestDistSqr = d;
|
||||
}
|
||||
}
|
||||
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
|
||||
dtPolyRef dtNavMesh::findNearestPolyInTile(const dtMeshTile* tile,
|
||||
@ -606,8 +604,7 @@ dtPolyRef dtNavMesh::findNearestPolyInTile(const dtMeshTile* tile,
|
||||
{
|
||||
dtPolyRef ref = polys[i];
|
||||
float closestPtPoly[3];
|
||||
if (closestPointOnPolyInTile(tile, decodePolyIdPoly(ref), center, closestPtPoly) != DT_SUCCESS)
|
||||
continue;
|
||||
closestPointOnPolyInTile(tile, decodePolyIdPoly(ref), center, closestPtPoly);
|
||||
float d = dtVdistSqr(center, closestPtPoly);
|
||||
if (d < nearestDistanceSqr)
|
||||
{
|
||||
@ -708,9 +705,9 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags,
|
||||
// Make sure the data is in right format.
|
||||
dtMeshHeader* header = (dtMeshHeader*)data;
|
||||
if (header->magic != DT_NAVMESH_MAGIC)
|
||||
return DT_FAILURE_DATA_MAGIC;
|
||||
return DT_FAILURE | DT_WRONG_MAGIC;
|
||||
if (header->version != DT_NAVMESH_VERSION)
|
||||
return DT_FAILURE_DATA_VERSION;
|
||||
return DT_FAILURE | DT_WRONG_VERSION;
|
||||
|
||||
// Make sure the location is free.
|
||||
if (getTileAt(header->x, header->y))
|
||||
@ -732,7 +729,7 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags,
|
||||
// Try to relocate the tile to specific index with same salt.
|
||||
int tileIndex = (int)decodePolyIdTile((dtPolyRef)lastRef);
|
||||
if (tileIndex >= m_maxTiles)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
// Try to find the specific tile id from the free list.
|
||||
dtMeshTile* target = &m_tiles[tileIndex];
|
||||
dtMeshTile* prev = 0;
|
||||
@ -744,7 +741,7 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags,
|
||||
}
|
||||
// Could not find the correct location.
|
||||
if (tile != target)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
// Remove from freelist
|
||||
if (!prev)
|
||||
m_nextFree = tile->next;
|
||||
@ -757,7 +754,7 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags,
|
||||
|
||||
// Make sure we could allocate a tile.
|
||||
if (!tile)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
|
||||
// Insert tile into the position lut.
|
||||
int h = computeTileHash(header->x, header->y, m_tileLutMask);
|
||||
@ -910,11 +907,12 @@ void dtNavMesh::calcTileLoc(const float* pos, int* tx, int* ty) const
|
||||
|
||||
dtStatus dtNavMesh::getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile** tile, const dtPoly** poly) const
|
||||
{
|
||||
if (!ref) return DT_FAILURE;
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE;
|
||||
if (ip >= (unsigned int)m_tiles[it].header->polyCount) return DT_FAILURE;
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (ip >= (unsigned int)m_tiles[it].header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
*tile = &m_tiles[it];
|
||||
*poly = &m_tiles[it].polys[ip];
|
||||
return DT_SUCCESS;
|
||||
@ -930,6 +928,7 @@ void dtNavMesh::getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile*
|
||||
|
||||
bool dtNavMesh::isValidPolyRef(dtPolyRef ref) const
|
||||
{
|
||||
if (!ref) return false;
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return false;
|
||||
@ -941,14 +940,14 @@ bool dtNavMesh::isValidPolyRef(dtPolyRef ref) const
|
||||
dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSize)
|
||||
{
|
||||
if (!ref)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
unsigned int tileIndex = decodePolyIdTile((dtPolyRef)ref);
|
||||
unsigned int tileSalt = decodePolyIdSalt((dtPolyRef)ref);
|
||||
if ((int)tileIndex >= m_maxTiles)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
dtMeshTile* tile = &m_tiles[tileIndex];
|
||||
if (tile->salt != tileSalt)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Remove tile from hash lookup.
|
||||
int h = computeTileHash(tile->header->x,tile->header->y,m_tileLutMask);
|
||||
@ -1057,7 +1056,7 @@ dtStatus dtNavMesh::storeTileState(const dtMeshTile* tile, unsigned char* data,
|
||||
// Make sure there is enough space to store the state.
|
||||
const int sizeReq = getTileStateSize(tile);
|
||||
if (maxDataSize < sizeReq)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_BUFFER_TOO_SMALL;
|
||||
|
||||
dtTileState* tileState = (dtTileState*)data; data += dtAlign4(sizeof(dtTileState));
|
||||
dtPolyState* polyStates = (dtPolyState*)data; data += dtAlign4(sizeof(dtPolyState) * tile->header->polyCount);
|
||||
@ -1084,18 +1083,18 @@ dtStatus dtNavMesh::restoreTileState(dtMeshTile* tile, const unsigned char* data
|
||||
// Make sure there is enough space to store the state.
|
||||
const int sizeReq = getTileStateSize(tile);
|
||||
if (maxDataSize < sizeReq)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
const dtTileState* tileState = (const dtTileState*)data; data += dtAlign4(sizeof(dtTileState));
|
||||
const dtPolyState* polyStates = (const dtPolyState*)data; data += dtAlign4(sizeof(dtPolyState) * tile->header->polyCount);
|
||||
|
||||
// Check that the restore is possible.
|
||||
if (tileState->magic != DT_NAVMESH_STATE_MAGIC)
|
||||
return DT_FAILURE_DATA_MAGIC;
|
||||
return DT_FAILURE | DT_WRONG_MAGIC;
|
||||
if (tileState->version != DT_NAVMESH_STATE_VERSION)
|
||||
return DT_FAILURE_DATA_VERSION;
|
||||
return DT_FAILURE | DT_WRONG_VERSION;
|
||||
if (tileState->ref != getTileRef(tile))
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Restore per poly state.
|
||||
for (int i = 0; i < tile->header->polyCount; ++i)
|
||||
@ -1114,12 +1113,15 @@ dtStatus dtNavMesh::getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyR
|
||||
{
|
||||
unsigned int salt, it, ip;
|
||||
|
||||
if (!polyRef)
|
||||
return DT_FAILURE;
|
||||
|
||||
// Get current polygon
|
||||
decodePolyId(polyRef, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE;
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
const dtMeshTile* tile = &m_tiles[it];
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE;
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
const dtPoly* poly = &tile->polys[ip];
|
||||
|
||||
// Make sure that the current poly is indeed off-mesh link.
|
||||
@ -1154,6 +1156,9 @@ const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef(dtPolyRef ref) c
|
||||
{
|
||||
unsigned int salt, it, ip;
|
||||
|
||||
if (!ref)
|
||||
return 0;
|
||||
|
||||
// Get current polygon
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return 0;
|
||||
@ -1174,12 +1179,13 @@ const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef(dtPolyRef ref) c
|
||||
|
||||
dtStatus dtNavMesh::setPolyFlags(dtPolyRef ref, unsigned short flags)
|
||||
{
|
||||
if (!ref) return DT_FAILURE;
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE;
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
dtMeshTile* tile = &m_tiles[it];
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE;
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
dtPoly* poly = &tile->polys[ip];
|
||||
|
||||
// Change flags.
|
||||
@ -1190,12 +1196,13 @@ dtStatus dtNavMesh::setPolyFlags(dtPolyRef ref, unsigned short flags)
|
||||
|
||||
dtStatus dtNavMesh::getPolyFlags(dtPolyRef ref, unsigned short* resultFlags) const
|
||||
{
|
||||
if (!ref) return DT_FAILURE;
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE;
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
const dtMeshTile* tile = &m_tiles[it];
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE;
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
const dtPoly* poly = &tile->polys[ip];
|
||||
|
||||
*resultFlags = poly->flags;
|
||||
@ -1205,12 +1212,13 @@ dtStatus dtNavMesh::getPolyFlags(dtPolyRef ref, unsigned short* resultFlags) con
|
||||
|
||||
dtStatus dtNavMesh::setPolyArea(dtPolyRef ref, unsigned char area)
|
||||
{
|
||||
if (!ref) return DT_FAILURE;
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE;
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
dtMeshTile* tile = &m_tiles[it];
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE;
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
dtPoly* poly = &tile->polys[ip];
|
||||
|
||||
poly->setArea(area);
|
||||
@ -1220,12 +1228,13 @@ dtStatus dtNavMesh::setPolyArea(dtPolyRef ref, unsigned char area)
|
||||
|
||||
dtStatus dtNavMesh::getPolyArea(dtPolyRef ref, unsigned char* resultArea) const
|
||||
{
|
||||
if (!ref) return DT_FAILURE;
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE;
|
||||
if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
const dtMeshTile* tile = &m_tiles[it];
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE;
|
||||
if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
|
||||
const dtPoly* poly = &tile->polys[ip];
|
||||
|
||||
*resultArea = poly->getArea();
|
||||
|
@ -121,7 +121,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
}
|
||||
m_nodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(maxNodes, dtNextPow2(maxNodes/4));
|
||||
if (!m_nodePool)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -132,7 +132,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
{
|
||||
m_tinyNodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(64, 32);
|
||||
if (!m_tinyNodePool)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -150,7 +150,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
}
|
||||
m_openList = new (dtAlloc(sizeof(dtNodeQueue), DT_ALLOC_PERM)) dtNodeQueue(maxNodes);
|
||||
if (!m_openList)
|
||||
return DT_FAILURE_OUT_OF_MEMORY;
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -166,16 +166,18 @@ dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, flo
|
||||
dtAssert(m_nav);
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(ref, &tile, &poly) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (!tile) return DT_FAILURE;
|
||||
if (closestPointOnPolyInTile(tile, poly, pos, closest) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (!tile)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
closestPointOnPolyInTile(tile, poly, pos, closest);
|
||||
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::closestPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly,
|
||||
const float* pos, float* closest) const
|
||||
void dtNavMeshQuery::closestPointOnPolyInTile(const dtMeshTile* tile, const dtPoly* poly,
|
||||
const float* pos, float* closest) const
|
||||
{
|
||||
const unsigned int ip = (unsigned int)(poly - tile->polys);
|
||||
const dtPolyDetail* pd = &tile->detailMeshes[ip];
|
||||
@ -253,8 +255,6 @@ dtStatus dtNavMeshQuery::closestPointOnPolyInTile(const dtMeshTile* tile, const
|
||||
closestDistSqr = d;
|
||||
}
|
||||
}
|
||||
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, float* closest) const
|
||||
@ -263,8 +263,8 @@ dtStatus dtNavMeshQuery::closestPointOnPolyBoundary(dtPolyRef ref, const float*
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(ref, &tile, &poly) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Collect vertices.
|
||||
float verts[DT_VERTS_PER_POLYGON*3];
|
||||
@ -311,8 +311,8 @@ dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* h
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(ref, &tile, &poly) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
@ -350,7 +350,7 @@ dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* h
|
||||
}
|
||||
}
|
||||
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* extents,
|
||||
@ -364,8 +364,8 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* exten
|
||||
// Get nearby polygons from proximity grid.
|
||||
dtPolyRef polys[128];
|
||||
int polyCount = 0;
|
||||
if (queryPolygons(center, extents, filter, polys, &polyCount, 128) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(queryPolygons(center, extents, filter, polys, &polyCount, 128)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Find nearest polygon amongst the nearby polygons.
|
||||
dtPolyRef nearest = 0;
|
||||
@ -374,8 +374,7 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* exten
|
||||
{
|
||||
dtPolyRef ref = polys[i];
|
||||
float closestPtPoly[3];
|
||||
if (closestPointOnPoly(ref, center, closestPtPoly) != DT_SUCCESS)
|
||||
continue;
|
||||
closestPointOnPoly(ref, center, closestPtPoly);
|
||||
float d = dtVdistSqr(center, closestPtPoly);
|
||||
if (d < nearestDistanceSqr)
|
||||
{
|
||||
@ -413,8 +412,7 @@ dtPolyRef dtNavMeshQuery::findNearestPolyInTile(const dtMeshTile* tile, const fl
|
||||
dtPolyRef ref = polys[i];
|
||||
const dtPoly* poly = &tile->polys[m_nav->decodePolyIdPoly(ref)];
|
||||
float closestPtPoly[3];
|
||||
if (closestPointOnPolyInTile(tile, poly, center, closestPtPoly) != DT_SUCCESS)
|
||||
continue;
|
||||
closestPointOnPolyInTile(tile, poly, center, closestPtPoly);
|
||||
|
||||
float d = dtVdistSqr(center, closestPtPoly);
|
||||
if (d < nearestDistanceSqr)
|
||||
@ -547,7 +545,7 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* extents
|
||||
if (n >= maxPolys)
|
||||
{
|
||||
*polyCount = n;
|
||||
return DT_SUCCESS;
|
||||
return DT_SUCCESS | DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -568,14 +566,14 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
*pathCount = 0;
|
||||
|
||||
if (!startRef || !endRef)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
if (!maxPath)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Validate input
|
||||
if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef))
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
if (startRef == endRef)
|
||||
{
|
||||
@ -599,6 +597,8 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
dtNode* lastBestNode = startNode;
|
||||
float lastBestNodeCost = startNode->total;
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
// Remove node from open list and put it in closed list.
|
||||
@ -648,7 +648,10 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
|
||||
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
|
||||
if (!neighbourNode)
|
||||
{
|
||||
status |= DT_OUT_OF_NODES;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the node is visited the first time, calculate node position.
|
||||
if (neighbourNode->flags == 0)
|
||||
@ -726,6 +729,9 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
}
|
||||
}
|
||||
|
||||
if (lastBestNode->id != endRef)
|
||||
status |= DT_PARTIAL_RESULT;
|
||||
|
||||
// Reverse the path.
|
||||
dtNode* prev = 0;
|
||||
dtNode* node = lastBestNode;
|
||||
@ -744,13 +750,18 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
do
|
||||
{
|
||||
path[n++] = node->id;
|
||||
if (n >= maxPath)
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
}
|
||||
node = m_nodePool->getNodeAtIdx(node->pidx);
|
||||
}
|
||||
while (node && n < maxPath);
|
||||
while (node);
|
||||
|
||||
*pathCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
@ -771,11 +782,11 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef
|
||||
m_query.filter = filter;
|
||||
|
||||
if (!startRef || !endRef)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Validate input
|
||||
if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef))
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
if (startRef == endRef)
|
||||
{
|
||||
@ -804,7 +815,7 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef
|
||||
|
||||
dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter)
|
||||
{
|
||||
if (m_query.status!= DT_IN_PROGRESS)
|
||||
if (!dtStatusInProgress(m_query.status))
|
||||
return m_query.status;
|
||||
|
||||
// Make sure the request is still valid.
|
||||
@ -828,7 +839,8 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter)
|
||||
if (bestNode->id == m_query.endRef)
|
||||
{
|
||||
m_query.lastBestNode = bestNode;
|
||||
m_query.status = DT_SUCCESS;
|
||||
const dtStatus details = m_query.status & DT_STATUS_DETAIL_MASK;
|
||||
m_query.status = DT_SUCCESS | details;
|
||||
return m_query.status;
|
||||
}
|
||||
|
||||
@ -837,7 +849,7 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter)
|
||||
const dtPolyRef bestRef = bestNode->id;
|
||||
const dtMeshTile* bestTile = 0;
|
||||
const dtPoly* bestPoly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(bestRef, &bestTile, &bestPoly) != DT_SUCCESS)
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(bestRef, &bestTile, &bestPoly)))
|
||||
{
|
||||
// The polygon has disappeared during the sliced query, fail.
|
||||
m_query.status = DT_FAILURE;
|
||||
@ -852,7 +864,7 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter)
|
||||
parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id;
|
||||
if (parentRef)
|
||||
{
|
||||
if (m_nav->getTileAndPolyByRef(parentRef, &parentTile, &parentPoly) != DT_SUCCESS)
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(parentRef, &parentTile, &parentPoly)))
|
||||
{
|
||||
// The polygon has disappeared during the sliced query, fail.
|
||||
m_query.status = DT_FAILURE;
|
||||
@ -879,7 +891,10 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter)
|
||||
|
||||
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
|
||||
if (!neighbourNode)
|
||||
{
|
||||
m_query.status |= DT_OUT_OF_NODES;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the node is visited the first time, calculate node position.
|
||||
if (neighbourNode->flags == 0)
|
||||
@ -959,7 +974,10 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter)
|
||||
|
||||
// Exhausted all nodes, but could not find path.
|
||||
if (m_openList->empty())
|
||||
m_query.status = DT_SUCCESS;
|
||||
{
|
||||
const dtStatus details = m_query.status & DT_STATUS_DETAIL_MASK;
|
||||
m_query.status = DT_SUCCESS | details;
|
||||
}
|
||||
|
||||
return m_query.status;
|
||||
}
|
||||
@ -968,7 +986,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount,
|
||||
{
|
||||
*pathCount = 0;
|
||||
|
||||
if (m_query.status != DT_SUCCESS)
|
||||
if (dtStatusFailed(m_query.status))
|
||||
{
|
||||
// Reset query.
|
||||
memset(&m_query, 0, sizeof(dtQueryData));
|
||||
@ -986,6 +1004,10 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount,
|
||||
{
|
||||
// Reverse the path.
|
||||
dtAssert(m_query.lastBestNode);
|
||||
|
||||
if (m_query.lastBestNode->id != m_query.endRef)
|
||||
m_query.status |= DT_PARTIAL_RESULT;
|
||||
|
||||
dtNode* prev = 0;
|
||||
dtNode* node = m_query.lastBestNode;
|
||||
do
|
||||
@ -1002,17 +1024,24 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount,
|
||||
do
|
||||
{
|
||||
path[n++] = node->id;
|
||||
if (n >= maxPath)
|
||||
{
|
||||
m_query.status |= DT_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
}
|
||||
node = m_nodePool->getNodeAtIdx(node->pidx);
|
||||
}
|
||||
while (node && n < maxPath);
|
||||
while (node);
|
||||
}
|
||||
|
||||
const dtStatus details = m_query.status & DT_STATUS_DETAIL_MASK;
|
||||
|
||||
// Reset query.
|
||||
memset(&m_query, 0, sizeof(dtQueryData));
|
||||
|
||||
*pathCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return DT_SUCCESS | details;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing, const int existingSize,
|
||||
@ -1025,7 +1054,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing
|
||||
return DT_FAILURE;
|
||||
}
|
||||
|
||||
if (m_query.status != DT_SUCCESS && m_query.status != DT_IN_PROGRESS)
|
||||
if (dtStatusFailed(m_query.status))
|
||||
{
|
||||
// Reset query.
|
||||
memset(&m_query, 0, sizeof(dtQueryData));
|
||||
@ -1071,17 +1100,24 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing
|
||||
do
|
||||
{
|
||||
path[n++] = node->id;
|
||||
if (n >= maxPath)
|
||||
{
|
||||
m_query.status |= DT_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
}
|
||||
node = m_nodePool->getNodeAtIdx(node->pidx);
|
||||
}
|
||||
while (node && n < maxPath);
|
||||
while (node);
|
||||
}
|
||||
|
||||
const dtStatus details = m_query.status & DT_STATUS_DETAIL_MASK;
|
||||
|
||||
// Reset query.
|
||||
memset(&m_query, 0, sizeof(dtQueryData));
|
||||
|
||||
*pathCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return DT_SUCCESS | details;
|
||||
}
|
||||
|
||||
|
||||
@ -1095,17 +1131,17 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
*straightPathCount = 0;
|
||||
|
||||
if (!maxStraightPath)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
if (!path[0])
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
int n = 0;
|
||||
|
||||
// TODO: Should this be callers responsibility?
|
||||
float closestStartPos[3];
|
||||
if (closestPointOnPolyBoundary(path[0], startPos, closestStartPos) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(closestPointOnPolyBoundary(path[0], startPos, closestStartPos)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Add start point.
|
||||
dtVcopy(&straightPath[n*3], closestStartPos);
|
||||
@ -1117,12 +1153,12 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
if (n >= maxStraightPath)
|
||||
{
|
||||
*straightPathCount = n;
|
||||
return DT_SUCCESS;
|
||||
return DT_SUCCESS | DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
float closestEndPos[3];
|
||||
if (closestPointOnPolyBoundary(path[pathSize-1], endPos, closestEndPos) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(closestPointOnPolyBoundary(path[pathSize-1], endPos, closestEndPos)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
if (pathSize > 1)
|
||||
{
|
||||
@ -1148,10 +1184,10 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
if (i+1 < pathSize)
|
||||
{
|
||||
// Next portal.
|
||||
if (getPortalPoints(path[i], path[i+1], left, right, fromType, toType) != DT_SUCCESS)
|
||||
if (dtStatusFailed(getPortalPoints(path[i], path[i+1], left, right, fromType, toType)))
|
||||
{
|
||||
if (closestPointOnPolyBoundary(path[i], endPos, closestEndPos) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(closestPointOnPolyBoundary(path[i], endPos, closestEndPos)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
dtVcopy(&straightPath[n*3], closestEndPos);
|
||||
if (straightPathFlags)
|
||||
@ -1215,7 +1251,7 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
if (flags == DT_STRAIGHTPATH_END || n >= maxStraightPath)
|
||||
{
|
||||
*straightPathCount = n;
|
||||
return DT_SUCCESS;
|
||||
return DT_SUCCESS | ((n >= maxStraightPath) ? DT_BUFFER_TOO_SMALL : 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1274,7 +1310,7 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
if (flags == DT_STRAIGHTPATH_END || n >= maxStraightPath)
|
||||
{
|
||||
*straightPathCount = n;
|
||||
return DT_SUCCESS;
|
||||
return DT_SUCCESS | ((n >= maxStraightPath) ? DT_BUFFER_TOO_SMALL : 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1316,7 +1352,8 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
}
|
||||
|
||||
*straightPathCount = n;
|
||||
return DT_SUCCESS;
|
||||
|
||||
return DT_SUCCESS | ((n >= maxStraightPath) ? DT_BUFFER_TOO_SMALL : 0);
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* startPos, const float* endPos,
|
||||
@ -1329,8 +1366,12 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start
|
||||
*visitedCount = 0;
|
||||
|
||||
// Validate input
|
||||
if (!startRef) return DT_FAILURE;
|
||||
if (!m_nav->isValidPolyRef(startRef)) return DT_FAILURE;
|
||||
if (!startRef)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
if (!m_nav->isValidPolyRef(startRef))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
static const int MAX_STACK = 48;
|
||||
dtNode* stack[MAX_STACK];
|
||||
@ -1495,16 +1536,21 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start
|
||||
do
|
||||
{
|
||||
visited[n++] = node->id;
|
||||
if (n >= maxVisitedSize)
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
}
|
||||
node = m_tinyNodePool->getNodeAtIdx(node->pidx);
|
||||
}
|
||||
while (node && n < maxVisitedSize);
|
||||
while (node);
|
||||
}
|
||||
|
||||
dtVcopy(resultPos, bestPos);
|
||||
|
||||
*visitedCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@ -1515,14 +1561,14 @@ dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, dtPolyRef to, float* le
|
||||
|
||||
const dtMeshTile* fromTile = 0;
|
||||
const dtPoly* fromPoly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(from, &fromTile, &fromPoly) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(from, &fromTile, &fromPoly)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
fromType = fromPoly->getType();
|
||||
|
||||
const dtMeshTile* toTile = 0;
|
||||
const dtPoly* toPoly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(to, &toTile, &toPoly) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(to, &toTile, &toPoly)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
toType = toPoly->getType();
|
||||
|
||||
return getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, left, right);
|
||||
@ -1544,7 +1590,7 @@ dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly,
|
||||
}
|
||||
}
|
||||
if (!link)
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
// Handle off-mesh connections.
|
||||
if (fromPoly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
@ -1560,7 +1606,7 @@ dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly,
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
}
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (toPoly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
@ -1575,7 +1621,7 @@ dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly,
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
}
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
// Find portal vertices.
|
||||
@ -1607,7 +1653,8 @@ dtStatus dtNavMeshQuery::getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mi
|
||||
{
|
||||
float left[3], right[3];
|
||||
unsigned char fromType, toType;
|
||||
if (!getPortalPoints(from, to, left,right, fromType, toType)) return DT_FAILURE;
|
||||
if (dtStatusFailed(getPortalPoints(from, to, left,right, fromType, toType)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
mid[0] = (left[0]+right[0])*0.5f;
|
||||
mid[1] = (left[1]+right[1])*0.5f;
|
||||
mid[2] = (left[2]+right[2])*0.5f;
|
||||
@ -1619,8 +1666,8 @@ dtStatus dtNavMeshQuery::getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly,
|
||||
float* mid) const
|
||||
{
|
||||
float left[3], right[3];
|
||||
if (getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, left, right) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, left, right)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
mid[0] = (left[0]+right[0])*0.5f;
|
||||
mid[1] = (left[1]+right[1])*0.5f;
|
||||
mid[2] = (left[2]+right[2])*0.5f;
|
||||
@ -1639,7 +1686,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
|
||||
// Validate input
|
||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
||||
return DT_FAILURE;
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
dtPolyRef curRef = startRef;
|
||||
float verts[DT_VERTS_PER_POLYGON*3];
|
||||
@ -1649,6 +1696,8 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
hitNormal[1] = 0;
|
||||
hitNormal[2] = 0;
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
while (curRef)
|
||||
{
|
||||
// Cast ray against current polygon.
|
||||
@ -1673,7 +1722,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
// Could not hit the polygon, keep the old t and report hit.
|
||||
if (pathCount)
|
||||
*pathCount = n;
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
// Keep track of furthest t so far.
|
||||
if (tmax > *t)
|
||||
@ -1682,6 +1731,8 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
// Store visited polygons.
|
||||
if (n < maxPath)
|
||||
path[n++] = curRef;
|
||||
else
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
|
||||
// Ray end is completely inside the polygon.
|
||||
if (segMax == -1)
|
||||
@ -1689,7 +1740,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
*t = FLT_MAX;
|
||||
if (pathCount)
|
||||
*pathCount = n;
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
// Follow neighbours.
|
||||
@ -1791,7 +1842,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
|
||||
if (pathCount)
|
||||
*pathCount = n;
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
// No hit, advance to neighbour polygon.
|
||||
@ -1801,7 +1852,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
if (pathCount)
|
||||
*pathCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float* centerPos, const float radius,
|
||||
@ -1816,8 +1867,8 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
*resultCount = 0;
|
||||
|
||||
// Validate input
|
||||
if (!startRef) return DT_FAILURE;
|
||||
if (!m_nav->isValidPolyRef(startRef)) return DT_FAILURE;
|
||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
m_nodePool->clear();
|
||||
m_openList->clear();
|
||||
@ -1831,6 +1882,8 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
startNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(startNode);
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
int n = 0;
|
||||
if (n < maxResult)
|
||||
{
|
||||
@ -1842,6 +1895,10 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
resultCost[n] = 0;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
const float radiusSqr = dtSqr(radius);
|
||||
|
||||
@ -1897,7 +1954,10 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
|
||||
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
|
||||
if (!neighbourNode)
|
||||
{
|
||||
status |= DT_OUT_OF_NODES;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbourNode->flags & DT_NODE_CLOSED)
|
||||
continue;
|
||||
@ -1933,6 +1993,10 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
resultCost[n] = neighbourNode->total;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
neighbourNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(neighbourNode);
|
||||
}
|
||||
@ -1941,7 +2005,7 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
|
||||
*resultCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* verts, const int nverts,
|
||||
@ -1956,8 +2020,8 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
*resultCount = 0;
|
||||
|
||||
// Validate input
|
||||
if (!startRef) return DT_FAILURE;
|
||||
if (!m_nav->isValidPolyRef(startRef)) return DT_FAILURE;
|
||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
m_nodePool->clear();
|
||||
m_openList->clear();
|
||||
@ -1976,6 +2040,8 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
startNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(startNode);
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
int n = 0;
|
||||
if (n < maxResult)
|
||||
{
|
||||
@ -1987,6 +2053,10 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
resultCost[n] = 0;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
@ -2042,7 +2112,10 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
|
||||
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
|
||||
if (!neighbourNode)
|
||||
{
|
||||
status |= DT_OUT_OF_NODES;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbourNode->flags & DT_NODE_CLOSED)
|
||||
continue;
|
||||
@ -2078,6 +2151,10 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
resultCost[n] = neighbourNode->total;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
neighbourNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(neighbourNode);
|
||||
}
|
||||
@ -2086,7 +2163,7 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
|
||||
*resultCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float* centerPos, const float radius,
|
||||
@ -2100,8 +2177,8 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
||||
*resultCount = 0;
|
||||
|
||||
// Validate input
|
||||
if (!startRef) return DT_FAILURE;
|
||||
if (!m_nav->isValidPolyRef(startRef)) return DT_FAILURE;
|
||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
static const int MAX_STACK = 48;
|
||||
dtNode* stack[MAX_STACK];
|
||||
@ -2120,6 +2197,8 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
||||
float pa[DT_VERTS_PER_POLYGON*3];
|
||||
float pb[DT_VERTS_PER_POLYGON*3];
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
int n = 0;
|
||||
if (n < maxResult)
|
||||
{
|
||||
@ -2128,6 +2207,10 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
||||
resultParent[n] = 0;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
while (nstack)
|
||||
{
|
||||
@ -2241,6 +2324,10 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
||||
resultParent[n] = curRef;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (nstack < MAX_STACK)
|
||||
{
|
||||
@ -2251,7 +2338,7 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
||||
|
||||
*resultCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@ -2290,14 +2377,16 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter*
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
if (m_nav->getTileAndPolyByRef(ref, &tile, &poly) != DT_SUCCESS)
|
||||
return DT_FAILURE;
|
||||
if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly)))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
int n = 0;
|
||||
static const int MAX_INTERVAL = 16;
|
||||
dtSegInterval ints[MAX_INTERVAL];
|
||||
int nints;
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
for (int i = 0, j = (int)poly->vertCount-1; i < (int)poly->vertCount; j = i++)
|
||||
{
|
||||
// Skip non-solid edges.
|
||||
@ -2354,6 +2443,10 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter*
|
||||
dtVcopy(seg+0, vj);
|
||||
dtVcopy(seg+3, vi);
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2366,13 +2459,17 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter*
|
||||
dtVlerp(seg+0, vj,vi, tmin);
|
||||
dtVlerp(seg+3, vj,vi, tmax);
|
||||
}
|
||||
else
|
||||
{
|
||||
status |= DT_BUFFER_TOO_SMALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*segmentCount = n;
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* centerPos, const float maxRadius,
|
||||
@ -2384,8 +2481,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
dtAssert(m_openList);
|
||||
|
||||
// Validate input
|
||||
if (!startRef) return DT_FAILURE;
|
||||
if (!m_nav->isValidPolyRef(startRef)) return DT_FAILURE;
|
||||
if (!startRef || !m_nav->isValidPolyRef(startRef))
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
||||
m_nodePool->clear();
|
||||
m_openList->clear();
|
||||
@ -2401,6 +2498,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
|
||||
float radiusSqr = dtSqr(maxRadius);
|
||||
|
||||
dtStatus status = DT_SUCCESS;
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
dtNode* bestNode = m_openList->pop();
|
||||
@ -2508,7 +2607,10 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
|
||||
dtNode* neighbourNode = m_nodePool->getNode(neighbourRef);
|
||||
if (!neighbourNode)
|
||||
{
|
||||
status |= DT_OUT_OF_NODES;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbourNode->flags & DT_NODE_CLOSED)
|
||||
continue;
|
||||
@ -2549,7 +2651,7 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
|
||||
*hitDist = sqrtf(radiusSqr);
|
||||
|
||||
return DT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
bool dtNavMeshQuery::isInClosedList(dtPolyRef ref) const
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -284,14 +284,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>34</integer>
|
||||
<integer>27</integer>
|
||||
<integer>15</integer>
|
||||
<integer>11</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 394}, {264, 622}}</string>
|
||||
<string>{{0, 0}, {264, 622}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -326,7 +326,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>RecastRegion.cpp</string>
|
||||
<string>DetourNavMesh.h</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -334,11 +334,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>RecastRegion.cpp</string>
|
||||
<string>DetourNavMesh.h</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B6BECAF129968E50077F7A4</string>
|
||||
<string>6B6BEDED129FD0F60077F7A4</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B8D565F127ADB0D0077C699</string>
|
||||
@ -353,39 +353,40 @@
|
||||
<string>6B74B627128314A500262888</string>
|
||||
<string>6B74B628128314A500262888</string>
|
||||
<string>6B74B62A128314A500262888</string>
|
||||
<string>6B74B62B128314A500262888</string>
|
||||
<string>6B74B6D81286ABC000262888</string>
|
||||
<string>6B74B7061286AEBD00262888</string>
|
||||
<string>6B74B7601286BB6900262888</string>
|
||||
<string>6B74B7611286BB6900262888</string>
|
||||
<string>6B74B76B1286F56B00262888</string>
|
||||
<string>6B74B76F1286F56B00262888</string>
|
||||
<string>6B74B7771286F61200262888</string>
|
||||
<string>6B74B7801286F72D00262888</string>
|
||||
<string>6B74B7811286F72D00262888</string>
|
||||
<string>6B74B7821286F72D00262888</string>
|
||||
<string>6B74B7901286F77500262888</string>
|
||||
<string>6B74B7991286F7CD00262888</string>
|
||||
<string>6B74B7AD1286F93000262888</string>
|
||||
<string>6B74B7B21286F99100262888</string>
|
||||
<string>6B74B7C01286FA5200262888</string>
|
||||
<string>6B74B7C51286FAB500262888</string>
|
||||
<string>6B74B7CD128D1BE600262888</string>
|
||||
<string>6B6BE685129152770077F7A4</string>
|
||||
<string>6B6BE686129152770077F7A4</string>
|
||||
<string>6B6BE687129152770077F7A4</string>
|
||||
<string>6B6BE689129152770077F7A4</string>
|
||||
<string>6B6BE68B129152770077F7A4</string>
|
||||
<string>6B6BE68C129152770077F7A4</string>
|
||||
<string>6B6BE68D129152770077F7A4</string>
|
||||
<string>6B6BEC2F12995D2A0077F7A4</string>
|
||||
<string>6B6BEC3012995D2A0077F7A4</string>
|
||||
<string>6B6BEC4712995DEA0077F7A4</string>
|
||||
<string>6B6BEC4812995DEA0077F7A4</string>
|
||||
<string>6B6BEC75129961C80077F7A4</string>
|
||||
<string>6B6BEC7E129962F50077F7A4</string>
|
||||
<string>6B6BECA51299680A0077F7A4</string>
|
||||
<string>6B6BECA61299680A0077F7A4</string>
|
||||
<string>6B6BECB5129970130077F7A4</string>
|
||||
<string>6B6BECB6129970130077F7A4</string>
|
||||
<string>6B6BED94129FC9550077F7A4</string>
|
||||
<string>6B6BEDB3129FCDB20077F7A4</string>
|
||||
<string>6B6BEDB4129FCDB20077F7A4</string>
|
||||
<string>6B6BEDB6129FCDB20077F7A4</string>
|
||||
<string>6B6BEDC4129FCF980077F7A4</string>
|
||||
<string>6B6BEDC6129FCF980077F7A4</string>
|
||||
<string>6B6BEDDB129FD0A10077F7A4</string>
|
||||
<string>6B6BEDE6129FD0C30077F7A4</string>
|
||||
<string>6B6BEDEB129FD0F60077F7A4</string>
|
||||
<string>6B6BEDEC129FD0F60077F7A4</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -399,18 +400,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {914, 533}}</string>
|
||||
<string>{{0, 0}, {914, 443}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>47 97 1200 681 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>533pt</string>
|
||||
<string>443pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>102pt</string>
|
||||
<string>192pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -424,9 +425,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {914, 75}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>47 97 1200 681 0 0 1280 778 </string>
|
||||
<string>{{10, 27}, {914, 78}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -442,7 +441,9 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {914, 66}}</string>
|
||||
<string>{{10, 27}, {914, 165}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>47 97 1200 681 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -508,11 +509,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B6BEC1A129959080077F7A4</string>
|
||||
<string>6B6BED8F129FB8670077F7A4</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>6B6BEC1B129959080077F7A4</string>
|
||||
<string>6B6BED90129FB8670077F7A4</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6B6BEC1C129959080077F7A4</string>
|
||||
<string>6B6BED91129FB8670077F7A4</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -660,14 +661,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B6BEC3312995D2A0077F7A4</string>
|
||||
<string>6B6BEDB9129FCDB20077F7A4</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>6B6BEC3412995D2A0077F7A4</string>
|
||||
<string>6B6BEC3512995D2A0077F7A4</string>
|
||||
<string>6B6BEC3612995D2A0077F7A4</string>
|
||||
<string>6B6BEC3712995D2A0077F7A4</string>
|
||||
<string>6B6BEC3812995D2A0077F7A4</string>
|
||||
<string>6B6BEDBA129FCDB20077F7A4</string>
|
||||
<string>6B6BEDBB129FCDB20077F7A4</string>
|
||||
<string>6B6BEDBC129FCDB20077F7A4</string>
|
||||
<string>6B6BEDBD129FCDB20077F7A4</string>
|
||||
<string>6B6BEDBE129FCDB20077F7A4</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@ -699,9 +700,9 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>6B6BECB0129968E50077F7A4</string>
|
||||
<string>6B6BEC3B12995D2A0077F7A4</string>
|
||||
<string>6B6BEC3A12995D2A0077F7A4</string>
|
||||
<string>6B6BEDEE129FD0F60077F7A4</string>
|
||||
<string>6B6BEDD0129FD0400077F7A4</string>
|
||||
<string>6B6BEDD1129FD0400077F7A4</string>
|
||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user