From 8b242b499d81ce8d03587c682761b490b297054d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morel=20B=C3=A9renger?= Date: Tue, 12 Sep 2023 12:15:25 +0200 Subject: [PATCH] fix -Wwarn-zero-as-nullptr --- DebugUtils/Source/DebugDraw.cpp | 6 +- DebugUtils/Source/DetourDebugDraw.cpp | 8 +- DebugUtils/Source/RecastDebugDraw.cpp | 3 +- Detour/Include/DetourAssert.h | 2 +- Detour/Include/DetourModernCpp.h | 5 +- Detour/Include/DetourNavMesh.h | 14 +- Detour/Include/DetourNode.h | 6 +- Detour/Source/DetourAssert.cpp | 4 +- Detour/Source/DetourNavMesh.cpp | 86 ++++---- Detour/Source/DetourNavMeshBuilder.cpp | 3 +- Detour/Source/DetourNavMeshQuery.cpp | 186 +++++++++--------- Detour/Source/DetourNode.cpp | 14 +- DetourCrowd/Include/DetourCrowd.h | 5 +- DetourCrowd/Include/DetourObstacleAvoidance.h | 6 +- DetourCrowd/Source/DetourCrowd.cpp | 47 ++--- DetourCrowd/Source/DetourLocalBoundary.cpp | 7 +- .../Source/DetourObstacleAvoidance.cpp | 23 +-- DetourCrowd/Source/DetourPathCorridor.cpp | 5 +- DetourCrowd/Source/DetourPathQueue.cpp | 9 +- DetourCrowd/Source/DetourProximityGrid.cpp | 7 +- DetourTileCache/Include/DetourTileCache.h | 3 +- DetourTileCache/Source/DetourTileCache.cpp | 89 ++++----- .../Source/DetourTileCacheBuilder.cpp | 3 +- Recast/Include/RecastAlloc.h | 12 +- Recast/Include/RecastAssert.h | 2 +- Recast/Include/RecastModernCpp.h | 5 +- Recast/Source/RecastAssert.cpp | 3 +- Recast/Source/RecastContour.cpp | 6 +- Recast/Source/RecastFilter.cpp | 5 +- Recast/Source/RecastLayers.cpp | 2 +- Recast/Source/RecastMesh.cpp | 10 +- Recast/Source/RecastMeshDetail.cpp | 2 +- Recast/Source/RecastRegion.cpp | 2 +- RecastDemo/Include/ChunkyTriMesh.h | 4 +- RecastDemo/Include/InputGeom.h | 2 +- RecastDemo/Include/TestCase.h | 7 +- RecastDemo/Source/ConvexVolumeTool.cpp | 2 +- RecastDemo/Source/CrowdTool.cpp | 16 +- RecastDemo/Source/Filelist.cpp | 6 +- RecastDemo/Source/InputGeom.cpp | 12 +- RecastDemo/Source/MeshLoaderObj.cpp | 10 +- RecastDemo/Source/NavMeshPruneTool.cpp | 18 +- RecastDemo/Source/NavMeshTesterTool.cpp | 38 ++-- RecastDemo/Source/OffMeshConnectionTool.cpp | 2 +- RecastDemo/Source/PerfTimer.cpp | 3 +- RecastDemo/Source/Sample.cpp | 34 ++-- RecastDemo/Source/SampleInterfaces.cpp | 2 +- RecastDemo/Source/Sample_Debug.cpp | 12 +- RecastDemo/Source/Sample_SoloMesh.cpp | 70 +++---- RecastDemo/Source/Sample_TempObstacles.cpp | 60 +++--- RecastDemo/Source/Sample_TileMesh.cpp | 130 ++++++------ RecastDemo/Source/TestCase.cpp | 10 +- RecastDemo/Source/imgui.cpp | 5 +- RecastDemo/Source/imguiRenderGL.cpp | 3 +- RecastDemo/Source/main.cpp | 42 ++-- 55 files changed, 549 insertions(+), 529 deletions(-) diff --git a/DebugUtils/Source/DebugDraw.cpp b/DebugUtils/Source/DebugDraw.cpp index 33b4dd9c1..162ee7932 100644 --- a/DebugUtils/Source/DebugDraw.cpp +++ b/DebugUtils/Source/DebugDraw.cpp @@ -20,7 +20,7 @@ #include "DebugDraw.h" #include "DetourMath.h" #include "DetourNavMesh.h" - +#include "DetourModernCpp.h" duDebugDraw::~duDebugDraw() { @@ -525,8 +525,8 @@ void duAppendCross(struct duDebugDraw* dd, const float x, const float y, const f } duDisplayList::duDisplayList(int cap) : - m_pos(0), - m_color(0), + m_pos(DT_NULL), + m_color(DT_NULL), m_size(0), m_cap(0), m_prim(DU_DRAW_LINES), diff --git a/DebugUtils/Source/DetourDebugDraw.cpp b/DebugUtils/Source/DetourDebugDraw.cpp index 4ca0581c7..4781f5d32 100644 --- a/DebugUtils/Source/DetourDebugDraw.cpp +++ b/DebugUtils/Source/DetourDebugDraw.cpp @@ -242,7 +242,7 @@ void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, unsigned char fl { const dtMeshTile* tile = mesh.getTile(i); if (!tile->header) continue; - drawMeshTile(dd, mesh, 0, tile, flags); + drawMeshTile(dd, mesh, DT_NULL, tile, flags); } } @@ -250,7 +250,7 @@ void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& m { if (!dd) return; - const dtNavMeshQuery* q = (flags & DU_DRAWNAVMESH_CLOSEDLIST) ? &query : 0; + const dtNavMeshQuery* q = (flags & DU_DRAWNAVMESH_CLOSEDLIST) ? &query : DT_NULL; for (int i = 0; i < mesh.getMaxTiles(); ++i) { @@ -440,8 +440,8 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re { if (!dd) return; - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = DT_NULL; + const dtPoly* poly = DT_NULL; if (dtStatusFailed(mesh.getTileAndPolyByRef(ref, &tile, &poly))) return; diff --git a/DebugUtils/Source/RecastDebugDraw.cpp b/DebugUtils/Source/RecastDebugDraw.cpp index 466c5b17b..5b7683487 100644 --- a/DebugUtils/Source/RecastDebugDraw.cpp +++ b/DebugUtils/Source/RecastDebugDraw.cpp @@ -20,6 +20,7 @@ #include "DebugDraw.h" #include "RecastDebugDraw.h" #include "Recast.h" +#include "DetourModernCpp.h" void duDebugDrawTriMesh(duDebugDraw* dd, const float* verts, int /*nverts*/, const int* tris, const float* normals, int ntris, @@ -675,7 +676,7 @@ static const rcContour* findContourFromSet(const rcContourSet& cset, unsigned sh if (cset.conts[i].reg == reg) return &cset.conts[i]; } - return 0; + return DT_NULL; } void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, const float alpha) diff --git a/Detour/Include/DetourAssert.h b/Detour/Include/DetourAssert.h index ea58dd9a0..8106110e7 100644 --- a/Detour/Include/DetourAssert.h +++ b/Detour/Include/DetourAssert.h @@ -47,7 +47,7 @@ dtAssertFailFunc* dtAssertFailGetCustom(); # define dtAssert(expression) \ { \ dtAssertFailFunc* failFunc = dtAssertFailGetCustom(); \ - if(failFunc == NULL) { assert(expression); } \ + if(failFunc == DT_NULL) { assert(expression); } \ else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \ } diff --git a/Detour/Include/DetourModernCpp.h b/Detour/Include/DetourModernCpp.h index 475c05a2d..4cf6f49c3 100644 --- a/Detour/Include/DetourModernCpp.h +++ b/Detour/Include/DetourModernCpp.h @@ -6,10 +6,7 @@ #include "DetourAssert.h" #if __cplusplus and __cplusplus >= 201103L -#ifdef NULL -#undef NULL -#endif -#define NULL nullptr +#define DT_NULL nullptr #define DT_OVERRIDE override #else #include diff --git a/Detour/Include/DetourNavMesh.h b/Detour/Include/DetourNavMesh.h index 3c3118756..53060ebe6 100644 --- a/Detour/Include/DetourNavMesh.h +++ b/Detour/Include/DetourNavMesh.h @@ -19,6 +19,13 @@ #ifndef DETOURNAVMESH_H #define DETOURNAVMESH_H +#ifdef DT_POLYREF64 +// TODO: figure out a multiplatform version of uint64_t +// - maybe: https://code.google.com/p/msinttypes/ +// - or: http://www.azillionmonkeys.com/qed/pstdint.h +#include +#endif + #include "DetourAlloc.h" #include "DetourStatus.h" @@ -27,13 +34,6 @@ // Note: tiles build using 32bit refs are not compatible with 64bit refs! //#define DT_POLYREF64 1 -#ifdef DT_POLYREF64 -// TODO: figure out a multiplatform version of uint64_t -// - maybe: https://code.google.com/p/msinttypes/ -// - or: http://www.azillionmonkeys.com/qed/pstdint.h -#include -#endif - // Note: If you want to use 64-bit refs, change the types of both dtPolyRef & dtTileRef. // It is also recommended that you change dtHashRef() to a proper 64-bit hash. diff --git a/Detour/Include/DetourNode.h b/Detour/Include/DetourNode.h index ed7f2ddd3..75c33b0af 100644 --- a/Detour/Include/DetourNode.h +++ b/Detour/Include/DetourNode.h @@ -21,8 +21,8 @@ #include -#include "DetourModernCpp.h" #include "DetourNavMesh.h" +#include "DetourModernCpp.h" enum dtNodeFlags { @@ -70,13 +70,13 @@ class dtNodePool inline dtNode* getNodeAtIdx(unsigned int idx) { - if (!idx) return 0; + if (!idx) return DT_NULL; return &m_nodes[idx - 1]; } inline const dtNode* getNodeAtIdx(unsigned int idx) const { - if (!idx) return 0; + if (!idx) return DT_NULL; return &m_nodes[idx - 1]; } diff --git a/Detour/Source/DetourAssert.cpp b/Detour/Source/DetourAssert.cpp index 22bac3edb..a50b84f2a 100644 --- a/Detour/Source/DetourAssert.cpp +++ b/Detour/Source/DetourAssert.cpp @@ -16,12 +16,12 @@ // 3. This notice may not be removed or altered from any source distribution. // -#include "DetourModernCpp.h" #include "DetourAssert.h" +#include "DetourModernCpp.h" #ifndef RC_DISABLE_ASSERTS -static dtAssertFailFunc* sAssertFailFunc = 0; +static dtAssertFailFunc* sAssertFailFunc = DT_NULL; void dtAssertFailSetCustom(dtAssertFailFunc *assertFailFunc) { diff --git a/Detour/Source/DetourNavMesh.cpp b/Detour/Source/DetourNavMesh.cpp index 2240526eb..8d9d7b814 100644 --- a/Detour/Source/DetourNavMesh.cpp +++ b/Detour/Source/DetourNavMesh.cpp @@ -138,7 +138,7 @@ inline void freeLink(dtMeshTile* tile, unsigned int link) dtNavMesh* dtAllocNavMesh() { void* mem = dtAlloc(sizeof(dtNavMesh), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtNavMesh; } @@ -191,9 +191,9 @@ dtNavMesh::dtNavMesh() : m_maxTiles(0), m_tileLutSize(0), m_tileLutMask(0), - m_posLookup(0), - m_nextFree(0), - m_tiles(0) + m_posLookup(DT_NULL), + m_nextFree(DT_NULL), + m_tiles(DT_NULL) { #ifndef DT_POLYREF64 m_saltBits = 0; @@ -213,7 +213,7 @@ dtNavMesh::~dtNavMesh() if (m_tiles[i].flags & DT_TILE_FREE_DATA) { dtFree(m_tiles[i].data); - m_tiles[i].data = 0; + m_tiles[i].data = DT_NULL; m_tiles[i].dataSize = 0; } } @@ -242,7 +242,7 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params) 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; + m_nextFree = DT_NULL; for (int i = m_maxTiles-1; i >= 0; --i) { m_tiles[i].salt = 1; @@ -284,7 +284,7 @@ dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int flag if (dtStatusFailed(status)) return status; - return addTile(data, dataSize, flags, 0, 0); + return addTile(data, dataSize, flags, 0, DT_NULL); } /// @par @@ -626,8 +626,8 @@ namespace float dmin = FLT_MAX; float tmin = 0; - const float* pmin = 0; - const float* pmax = 0; + const float* pmin = DT_NULL; + const float* pmax = DT_NULL; for (int i = 0; i < pd->triCount; i++) { @@ -727,8 +727,8 @@ bool dtNavMesh::getPolyHeight(const dtMeshTile* tile, const dtPoly* poly, const void dtNavMesh::closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const { - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = DT_NULL; + const dtPoly* poly = DT_NULL; getTileAndPolyByRefUnsafe(ref, &tile, &poly); dtVcopy(closest, pos); @@ -927,14 +927,14 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, return DT_FAILURE | DT_ALREADY_OCCUPIED; // Allocate a tile. - dtMeshTile* tile = 0; + dtMeshTile* tile = DT_NULL; if (!lastRef) { if (m_nextFree) { tile = m_nextFree; m_nextFree = tile->next; - tile->next = 0; + tile->next = DT_NULL; } } else @@ -945,7 +945,7 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, 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; + dtMeshTile* prev = DT_NULL; tile = m_nextFree; while (tile && tile != target) { @@ -997,7 +997,7 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, // If there are no items in the bvtree, reset the tree pointer. if (!bvtreeSize) - tile->bvTree = 0; + tile->bvTree = DT_NULL; // Build links freelist tile->linksFreeList = 0; @@ -1070,7 +1070,7 @@ const dtMeshTile* dtNavMesh::getTileAt(const int x, const int y, const int layer } tile = tile->next; } - return 0; + return DT_NULL; } int dtNavMesh::getNeighbourTilesAt(const int x, const int y, const int side, dtMeshTile** tiles, const int maxTiles) const @@ -1162,14 +1162,14 @@ dtTileRef dtNavMesh::getTileRefAt(const int x, const int y, const int layer) con const dtMeshTile* dtNavMesh::getTileByRef(dtTileRef ref) const { if (!ref) - return 0; + return DT_NULL; unsigned int tileIndex = decodePolyIdTile((dtPolyRef)ref); unsigned int tileSalt = decodePolyIdSalt((dtPolyRef)ref); if ((int)tileIndex >= m_maxTiles) - return 0; + return DT_NULL; const dtMeshTile* tile = &m_tiles[tileIndex]; if (tile->salt != tileSalt) - return 0; + return DT_NULL; return tile; } @@ -1200,7 +1200,7 @@ dtStatus dtNavMesh::getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile** unsigned int salt, it, ip; decodePolyId(ref, salt, it, ip); 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 (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) 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]; @@ -1226,7 +1226,7 @@ bool dtNavMesh::isValidPolyRef(dtPolyRef ref) const unsigned int salt, it, ip; decodePolyId(ref, salt, it, ip); if (it >= (unsigned int)m_maxTiles) return false; - if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false; + if (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return false; if (ip >= (unsigned int)m_tiles[it].header->polyCount) return false; return true; } @@ -1251,7 +1251,7 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz // Remove tile from hash lookup. int h = computeTileHash(tile->header->x,tile->header->y,m_tileLutMask); - dtMeshTile* prev = 0; + dtMeshTile* prev = DT_NULL; dtMeshTile* cur = m_posLookup[h]; while (cur) { @@ -1293,9 +1293,9 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz { // Owns data dtFree(tile->data); - tile->data = 0; + tile->data = DT_NULL; tile->dataSize = 0; - if (data) *data = 0; + if (data) *data = DT_NULL; if (dataSize) *dataSize = 0; } else @@ -1304,17 +1304,17 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz if (dataSize) *dataSize = tile->dataSize; } - tile->header = 0; + tile->header = DT_NULL; tile->flags = 0; tile->linksFreeList = 0; - tile->polys = 0; - tile->verts = 0; - tile->links = 0; - tile->detailMeshes = 0; - tile->detailVerts = 0; - tile->detailTris = 0; - tile->bvTree = 0; - tile->offMeshCons = 0; + tile->polys = DT_NULL; + tile->verts = DT_NULL; + tile->links = DT_NULL; + tile->detailMeshes = DT_NULL; + tile->detailVerts = DT_NULL; + tile->detailTris = DT_NULL; + tile->bvTree = DT_NULL; + tile->offMeshCons = DT_NULL; // Update salt, salt should never be zero. #ifdef DT_POLYREF64 @@ -1466,7 +1466,7 @@ dtStatus dtNavMesh::getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyR // Get current polygon decodePolyId(polyRef, salt, it, ip); 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 (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return DT_FAILURE | DT_INVALID_PARAM; const dtMeshTile* tile = &m_tiles[it]; if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM; const dtPoly* poly = &tile->polys[ip]; @@ -1504,19 +1504,19 @@ const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef(dtPolyRef ref) c unsigned int salt, it, ip; if (!ref) - return 0; + return DT_NULL; // Get current polygon decodePolyId(ref, salt, it, ip); - if (it >= (unsigned int)m_maxTiles) return 0; - if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0; + if (it >= (unsigned int)m_maxTiles) return DT_NULL; + if (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return DT_NULL; const dtMeshTile* tile = &m_tiles[it]; - if (ip >= (unsigned int)tile->header->polyCount) return 0; + if (ip >= (unsigned int)tile->header->polyCount) return DT_NULL; const dtPoly* poly = &tile->polys[ip]; // Make sure that the current poly is indeed off-mesh link. if (poly->getType() != DT_POLYTYPE_OFFMESH_CONNECTION) - return 0; + return DT_NULL; const unsigned int idx = ip - tile->header->offMeshBase; dtAssert(idx < (unsigned int)tile->header->offMeshConCount); @@ -1530,7 +1530,7 @@ dtStatus dtNavMesh::setPolyFlags(dtPolyRef ref, unsigned short flags) unsigned int salt, it, ip; decodePolyId(ref, salt, it, ip); 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 (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return DT_FAILURE | DT_INVALID_PARAM; dtMeshTile* tile = &m_tiles[it]; if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM; dtPoly* poly = &tile->polys[ip]; @@ -1547,7 +1547,7 @@ dtStatus dtNavMesh::getPolyFlags(dtPolyRef ref, unsigned short* resultFlags) con unsigned int salt, it, ip; decodePolyId(ref, salt, it, ip); 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 (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return DT_FAILURE | DT_INVALID_PARAM; const dtMeshTile* tile = &m_tiles[it]; if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM; const dtPoly* poly = &tile->polys[ip]; @@ -1563,7 +1563,7 @@ dtStatus dtNavMesh::setPolyArea(dtPolyRef ref, unsigned char area) unsigned int salt, it, ip; decodePolyId(ref, salt, it, ip); 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 (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return DT_FAILURE | DT_INVALID_PARAM; dtMeshTile* tile = &m_tiles[it]; if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM; dtPoly* poly = &tile->polys[ip]; @@ -1579,7 +1579,7 @@ dtStatus dtNavMesh::getPolyArea(dtPolyRef ref, unsigned char* resultArea) const unsigned int salt, it, ip; decodePolyId(ref, salt, it, ip); 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 (m_tiles[it].salt != salt || m_tiles[it].header == DT_NULL) return DT_FAILURE | DT_INVALID_PARAM; const dtMeshTile* tile = &m_tiles[it]; if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM; const dtPoly* poly = &tile->polys[ip]; diff --git a/Detour/Source/DetourNavMeshBuilder.cpp b/Detour/Source/DetourNavMeshBuilder.cpp index 07ba86311..73b20d095 100644 --- a/Detour/Source/DetourNavMeshBuilder.cpp +++ b/Detour/Source/DetourNavMeshBuilder.cpp @@ -26,6 +26,7 @@ #include "DetourNavMeshBuilder.h" #include "DetourAlloc.h" #include "DetourAssert.h" +#include "DetourModernCpp.h" static unsigned short MESH_NULL_IDX = 0xffff; @@ -292,7 +293,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData, // Classify off-mesh connection points. We store only the connections // whose start point is inside the tile. - unsigned char* offMeshConClass = 0; + unsigned char* offMeshConClass = DT_NULL; int storedOffMeshConCount = 0; int offMeshConLinkCount = 0; diff --git a/Detour/Source/DetourNavMeshQuery.cpp b/Detour/Source/DetourNavMeshQuery.cpp index 27a704752..5fe279d1b 100644 --- a/Detour/Source/DetourNavMeshQuery.cpp +++ b/Detour/Source/DetourNavMeshQuery.cpp @@ -25,8 +25,8 @@ #include "DetourMath.h" #include "DetourAlloc.h" #include "DetourAssert.h" -#include "DetourModernCpp.h" #include +#include "DetourModernCpp.h" /// @class dtQueryFilter /// @@ -107,7 +107,7 @@ static const float H_SCALE = 0.999f; // Search heuristic scale. dtNavMeshQuery* dtAllocNavMeshQuery() { void* mem = dtAlloc(sizeof(dtNavMeshQuery), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtNavMeshQuery; } @@ -142,10 +142,10 @@ dtPolyQuery::~dtPolyQuery() /// @see dtNavMesh, dtQueryFilter, #dtAllocNavMeshQuery(), #dtAllocNavMeshQuery() dtNavMeshQuery::dtNavMeshQuery() : - m_nav(0), - m_tinyNodePool(0), - m_nodePool(0), - m_openList(0) + m_nav(DT_NULL), + m_tinyNodePool(DT_NULL), + m_nodePool(DT_NULL), + m_openList(DT_NULL) { memset(&m_query, 0, sizeof(dtQueryData)); } @@ -182,7 +182,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes) { m_nodePool->~dtNodePool(); dtFree(m_nodePool); - m_nodePool = 0; + m_nodePool = DT_NULL; } m_nodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(maxNodes, dtNextPow2(maxNodes/4)); if (!m_nodePool) @@ -210,7 +210,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes) { m_openList->~dtNodeQueue(); dtFree(m_openList); - m_openList = 0; + m_openList = DT_NULL; } m_openList = new (dtAlloc(sizeof(dtNodeQueue), DT_ALLOC_PERM)) dtNodeQueue(maxNodes); if (!m_openList) @@ -233,7 +233,7 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr return DT_FAILURE | DT_INVALID_PARAM; // Randomly pick one tile. Assume that all tiles cover roughly the same area. - const dtMeshTile* tile = 0; + const dtMeshTile* tile = DT_NULL; float tsum = 0.0f; for (int i = 0; i < m_nav->getMaxTiles(); i++) { @@ -251,7 +251,7 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr return DT_FAILURE; // Randomly pick one polygon weighted by polygon area. - const dtPoly* poly = 0; + const dtPoly* poly = DT_NULL; dtPolyRef polyRef = 0; const dtPolyRef base = m_nav->getPolyRefBase(tile); @@ -332,8 +332,8 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f return DT_FAILURE | DT_INVALID_PARAM; } - const dtMeshTile* startTile = 0; - const dtPoly* startPoly = 0; + const dtMeshTile* startTile = DT_NULL; + const dtPoly* startPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(startRef, &startTile, &startPoly); if (!filter->passFilter(startRef, startTile, startPoly)) return DT_FAILURE | DT_INVALID_PARAM; @@ -355,8 +355,8 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f const float radiusSqr = dtSqr(maxRadius); float areaSum = 0.0f; - const dtMeshTile* randomTile = 0; - const dtPoly* randomPoly = 0; + const dtMeshTile* randomTile = DT_NULL; + const dtPoly* randomPoly = DT_NULL; dtPolyRef randomPolyRef = 0; while (!m_openList->empty()) @@ -368,8 +368,8 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f // Get poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef bestRef = bestNode->id; - const dtMeshTile* bestTile = 0; - const dtPoly* bestPoly = 0; + const dtMeshTile* bestTile = DT_NULL; + const dtPoly* bestPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); // Place random locations on on ground. @@ -398,8 +398,8 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f // Get parent poly and tile. dtPolyRef parentRef = 0; - const dtMeshTile* parentTile = 0; - const dtPoly* parentPoly = 0; + const dtMeshTile* parentTile = DT_NULL; + const dtPoly* parentPoly = DT_NULL; if (bestNode->pidx) parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id; if (parentRef) @@ -414,8 +414,8 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f continue; // Expand to neighbour - const dtMeshTile* neighbourTile = 0; - const dtPoly* neighbourPoly = 0; + const dtMeshTile* neighbourTile = DT_NULL; + const dtPoly* neighbourPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); // Do not advance if the polygon is excluded by the filter. @@ -538,8 +538,8 @@ dtStatus dtNavMeshQuery::closestPointOnPolyBoundary(dtPolyRef ref, const float* { dtAssert(m_nav); - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = DT_NULL; + const dtPoly* poly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly))) return DT_FAILURE | DT_INVALID_PARAM; @@ -593,8 +593,8 @@ dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* h { dtAssert(m_nav); - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = DT_NULL; + const dtPoly* poly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly))) return DT_FAILURE | DT_INVALID_PARAM; @@ -695,7 +695,7 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* halfE const dtQueryFilter* filter, dtPolyRef* nearestRef, float* nearestPt) const { - return findNearestPoly(center, halfExtents, filter, nearestRef, nearestPt, NULL); + return findNearestPoly(center, halfExtents, filter, nearestRef, nearestPt, DT_NULL); } // If center and nearestPt point to an equal position, isOverPoly will be true; @@ -1035,14 +1035,14 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, // Get current poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef bestRef = bestNode->id; - const dtMeshTile* bestTile = 0; - const dtPoly* bestPoly = 0; + const dtMeshTile* bestTile = DT_NULL; + const dtPoly* bestPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); // Get parent poly and tile. dtPolyRef parentRef = 0; - const dtMeshTile* parentTile = 0; - const dtPoly* parentPoly = 0; + const dtMeshTile* parentTile = DT_NULL; + const dtPoly* parentPoly = DT_NULL; if (bestNode->pidx) parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id; if (parentRef) @@ -1058,8 +1058,8 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, // Get neighbour poly and tile. // The API input has been checked already, skip checking internal data. - const dtMeshTile* neighbourTile = 0; - const dtPoly* neighbourPoly = 0; + const dtMeshTile* neighbourTile = DT_NULL; + const dtPoly* neighbourPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); if (!filter->passFilter(neighbourRef, neighbourTile, neighbourPoly)) @@ -1101,7 +1101,7 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, const float endCost = filter->getCost(neighbourNode->pos, endPos, bestRef, bestTile, bestPoly, neighbourRef, neighbourTile, neighbourPoly, - 0, 0, 0); + 0, DT_NULL, DT_NULL); cost = bestNode->cost + curCost + endCost; heuristic = 0; @@ -1317,8 +1317,8 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters) // Get current poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef bestRef = bestNode->id; - const dtMeshTile* bestTile = 0; - const dtPoly* bestPoly = 0; + const dtMeshTile* bestTile = DT_NULL; + const dtPoly* bestPoly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(bestRef, &bestTile, &bestPoly))) { // The polygon has disappeared during the sliced query, fail. @@ -1330,9 +1330,9 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters) // Get parent and grand parent poly and tile. dtPolyRef parentRef = 0, grandpaRef = 0; - const dtMeshTile* parentTile = 0; - const dtPoly* parentPoly = 0; - dtNode* parentNode = 0; + const dtMeshTile* parentTile = DT_NULL; + const dtPoly* parentPoly = DT_NULL; + dtNode* parentNode = DT_NULL; if (bestNode->pidx) { parentNode = m_nodePool->getNodeAtIdx(bestNode->pidx); @@ -1433,7 +1433,7 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters) const float endCost = m_query.filter->getCost(neighbourNode->pos, m_query.endPos, bestRef, bestTile, bestPoly, neighbourRef, neighbourTile, neighbourPoly, - 0, 0, 0); + 0, DT_NULL, DT_NULL ); cost = cost + endCost; heuristic = 0; @@ -1527,7 +1527,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, if (m_query.lastBestNode->id != m_query.endRef) m_query.status |= DT_PARTIAL_RESULT; - dtNode* prev = 0; + dtNode* prev = DT_NULL; dtNode* node = m_query.lastBestNode; int prevRay = 0; do @@ -1613,8 +1613,8 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing else { // Find furthest existing node that was visited. - dtNode* prev = 0; - dtNode* node = 0; + dtNode* prev = DT_NULL; + dtNode* node = DT_NULL; for (int i = existingSize-1; i >= 0; --i) { m_nodePool->findNodes(existing[i], &node, 1); @@ -1735,14 +1735,14 @@ dtStatus dtNavMeshQuery::appendPortals(const int startIdx, const int endIdx, con { // Calculate portal const dtPolyRef from = path[i]; - const dtMeshTile* fromTile = 0; - const dtPoly* fromPoly = 0; + const dtMeshTile* fromTile = DT_NULL; + const dtPoly* fromPoly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(from, &fromTile, &fromPoly))) return DT_FAILURE | DT_INVALID_PARAM; const dtPolyRef to = path[i+1]; - const dtMeshTile* toTile = 0; - const dtPoly* toPoly = 0; + const dtMeshTile* toTile = DT_NULL; + const dtPoly* toPoly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(to, &toTile, &toPoly))) return DT_FAILURE | DT_INVALID_PARAM; @@ -2081,7 +2081,7 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start float bestPos[3]; float bestDist = FLT_MAX; - dtNode* bestNode = 0; + dtNode* bestNode = DT_NULL; dtVcopy(bestPos, startPos); // Search constraints @@ -2102,8 +2102,8 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start // Get poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef curRef = curNode->id; - const dtMeshTile* curTile = 0; - const dtPoly* curPoly = 0; + const dtMeshTile* curTile = DT_NULL; + const dtPoly* curPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(curRef, &curTile, &curPoly); // Collect vertices. @@ -2137,8 +2137,8 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start { if (link->ref != 0) { - const dtMeshTile* neiTile = 0; - const dtPoly* neiPoly = 0; + const dtMeshTile* neiTile = DT_NULL; + const dtPoly* neiPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(link->ref, &neiTile, &neiPoly); if (filter->passFilter(link->ref, neiTile, neiPoly)) { @@ -2212,7 +2212,7 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start if (bestNode) { // Reverse the path. - dtNode* prev = 0; + dtNode* prev = DT_NULL; dtNode* node = bestNode; do { @@ -2251,14 +2251,14 @@ dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, dtPolyRef to, float* le { dtAssert(m_nav); - const dtMeshTile* fromTile = 0; - const dtPoly* fromPoly = 0; + const dtMeshTile* fromTile = DT_NULL; + const dtPoly* fromPoly = DT_NULL; 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; + const dtMeshTile* toTile = DT_NULL; + const dtPoly* toPoly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(to, &toTile, &toPoly))) return DT_FAILURE | DT_INVALID_PARAM; toType = toPoly->getType(); @@ -2272,7 +2272,7 @@ dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, float* left, float* right) const { // Find the link that points to the 'to' polygon. - const dtLink* link = 0; + const dtLink* link = DT_NULL; for (unsigned int i = fromPoly->firstLink; i != DT_NULL_LINK; i = fromTile->links[i].next) { if (fromTile->links[i].ref == to) @@ -2503,8 +2503,8 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons // The API input has been checked already, skip checking internal data. curRef = startRef; - tile = 0; - poly = 0; + tile = DT_NULL; + poly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(curRef, &tile, &poly); nextTile = prevTile = tile; nextPoly = prevPoly = poly; @@ -2568,8 +2568,8 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons continue; // Get pointer to the next polygon. - nextTile = 0; - nextPoly = 0; + nextTile = DT_NULL; + nextPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(link->ref, &nextTile, &nextPoly); // Skip off-mesh connections. @@ -2767,14 +2767,14 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float* // Get poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef bestRef = bestNode->id; - const dtMeshTile* bestTile = 0; - const dtPoly* bestPoly = 0; + const dtMeshTile* bestTile = DT_NULL; + const dtPoly* bestPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); // Get parent poly and tile. dtPolyRef parentRef = 0; - const dtMeshTile* parentTile = 0; - const dtPoly* parentPoly = 0; + const dtMeshTile* parentTile = DT_NULL; + const dtPoly* parentPoly = DT_NULL; if (bestNode->pidx) parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id; if (parentRef) @@ -2804,8 +2804,8 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float* continue; // Expand to neighbour - const dtMeshTile* neighbourTile = 0; - const dtPoly* neighbourPoly = 0; + const dtMeshTile* neighbourTile = DT_NULL; + const dtPoly* neighbourPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); // Do not advance if the polygon is excluded by the filter. @@ -2947,14 +2947,14 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v // Get poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef bestRef = bestNode->id; - const dtMeshTile* bestTile = 0; - const dtPoly* bestPoly = 0; + const dtMeshTile* bestTile = DT_NULL; + const dtPoly* bestPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); // Get parent poly and tile. dtPolyRef parentRef = 0; - const dtMeshTile* parentTile = 0; - const dtPoly* parentPoly = 0; + const dtMeshTile* parentTile = DT_NULL; + const dtPoly* parentPoly = DT_NULL; if (bestNode->pidx) parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id; if (parentRef) @@ -2985,8 +2985,8 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v continue; // Expand to neighbour - const dtMeshTile* neighbourTile = 0; - const dtPoly* neighbourPoly = 0; + const dtMeshTile* neighbourTile = DT_NULL; + const dtPoly* neighbourPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); // Do not advance if the polygon is excluded by the filter. @@ -3154,8 +3154,8 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float* // Get poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef curRef = curNode->id; - const dtMeshTile* curTile = 0; - const dtPoly* curPoly = 0; + const dtMeshTile* curTile = DT_NULL; + const dtPoly* curPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(curRef, &curTile, &curPoly); for (unsigned int i = curPoly->firstLink; i != DT_NULL_LINK; i = curTile->links[i].next) @@ -3175,8 +3175,8 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float* continue; // Expand to neighbour - const dtMeshTile* neighbourTile = 0; - const dtPoly* neighbourPoly = 0; + const dtMeshTile* neighbourTile = DT_NULL; + const dtPoly* neighbourPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); // Skip off-mesh connections. @@ -3229,8 +3229,8 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float* continue; // Potentially overlapping. - const dtMeshTile* pastTile = 0; - const dtPoly* pastPoly = 0; + const dtMeshTile* pastTile = DT_NULL; + const dtPoly* pastPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(pastRef, &pastTile, &pastPoly); // Get vertices and test overlap @@ -3323,8 +3323,8 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* *segmentCount = 0; - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = DT_NULL; + const dtPoly* poly = DT_NULL; if (dtStatusFailed(m_nav->getTileAndPolyByRef(ref, &tile, &poly))) return DT_FAILURE | DT_INVALID_PARAM; @@ -3336,7 +3336,7 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* dtSegInterval ints[MAX_INTERVAL]; int nints; - const bool storePortals = segmentRefs != 0; + const bool storePortals = segmentRefs != DT_NULL; dtStatus status = DT_SUCCESS; @@ -3354,8 +3354,8 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* { if (link->ref != 0) { - const dtMeshTile* neiTile = 0; - const dtPoly* neiPoly = 0; + const dtMeshTile* neiTile = DT_NULL; + const dtPoly* neiPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(link->ref, &neiTile, &neiPoly); if (filter->passFilter(link->ref, neiTile, neiPoly)) { @@ -3510,14 +3510,14 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen // Get poly and tile. // The API input has been checked already, skip checking internal data. const dtPolyRef bestRef = bestNode->id; - const dtMeshTile* bestTile = 0; - const dtPoly* bestPoly = 0; + const dtMeshTile* bestTile = DT_NULL; + const dtPoly* bestPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(bestRef, &bestTile, &bestPoly); // Get parent poly and tile. dtPolyRef parentRef = 0; - const dtMeshTile* parentTile = 0; - const dtPoly* parentPoly = 0; + const dtMeshTile* parentTile = DT_NULL; + const dtPoly* parentPoly = DT_NULL; if (bestNode->pidx) parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id; if (parentRef) @@ -3538,8 +3538,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen { if (link->ref != 0) { - const dtMeshTile* neiTile = 0; - const dtPoly* neiPoly = 0; + const dtMeshTile* neiTile = DT_NULL; + const dtPoly* neiPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(link->ref, &neiTile, &neiPoly); if (filter->passFilter(link->ref, neiTile, neiPoly)) solid = false; @@ -3585,8 +3585,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen continue; // Expand to neighbour. - const dtMeshTile* neighbourTile = 0; - const dtPoly* neighbourPoly = 0; + const dtMeshTile* neighbourTile = DT_NULL; + const dtPoly* neighbourPoly = DT_NULL; m_nav->getTileAndPolyByRefUnsafe(neighbourRef, &neighbourTile, &neighbourPoly); // Skip off-mesh connections. @@ -3657,8 +3657,8 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen bool dtNavMeshQuery::isValidPolyRef(dtPolyRef ref, const dtQueryFilter* filter) const { - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = DT_NULL; + const dtPoly* poly = DT_NULL; dtStatus status = m_nav->getTileAndPolyByRef(ref, &tile, &poly); // If cannot get polygon, assume it does not exists and boundary is invalid. if (dtStatusFailed(status)) diff --git a/Detour/Source/DetourNode.cpp b/Detour/Source/DetourNode.cpp index 48abbba6b..e0a46f262 100644 --- a/Detour/Source/DetourNode.cpp +++ b/Detour/Source/DetourNode.cpp @@ -49,9 +49,9 @@ inline unsigned int dtHashRef(dtPolyRef a) ////////////////////////////////////////////////////////////////////////////////////////// dtNodePool::dtNodePool(int maxNodes, int hashSize) : - m_nodes(0), - m_first(0), - m_next(0), + m_nodes(DT_NULL), + m_first(DT_NULL), + m_next(DT_NULL), m_maxNodes(maxNodes), m_hashSize(hashSize), m_nodeCount(0) @@ -115,14 +115,14 @@ dtNode* dtNodePool::findNode(dtPolyRef id, unsigned char state) return &m_nodes[i]; i = m_next[i]; } - return 0; + return DT_NULL; } dtNode* dtNodePool::getNode(dtPolyRef id, unsigned char state) { unsigned int bucket = dtHashRef(id) & (m_hashSize-1); dtNodeIndex i = m_first[bucket]; - dtNode* node = 0; + dtNode* node = DT_NULL; while (i != DT_NULL_IDX) { if (m_nodes[i].id == id && m_nodes[i].state == state) @@ -131,7 +131,7 @@ dtNode* dtNodePool::getNode(dtPolyRef id, unsigned char state) } if (m_nodeCount >= m_maxNodes) - return 0; + return DT_NULL; i = (dtNodeIndex)m_nodeCount; m_nodeCount++; @@ -154,7 +154,7 @@ dtNode* dtNodePool::getNode(dtPolyRef id, unsigned char state) ////////////////////////////////////////////////////////////////////////////////////////// dtNodeQueue::dtNodeQueue(int n) : - m_heap(0), + m_heap(DT_NULL), m_capacity(n), m_size(0) { diff --git a/DetourCrowd/Include/DetourCrowd.h b/DetourCrowd/Include/DetourCrowd.h index 6360dfb3e..355938b33 100644 --- a/DetourCrowd/Include/DetourCrowd.h +++ b/DetourCrowd/Include/DetourCrowd.h @@ -25,6 +25,7 @@ #include "DetourPathCorridor.h" #include "DetourProximityGrid.h" #include "DetourPathQueue.h" +#include "DetourModernCpp.h" /// The maximum number of neighbors that a crowd agent can take into account /// for steering decisions. @@ -319,11 +320,11 @@ class dtCrowd /// Gets the filter used by the crowd. /// @return The filter used by the crowd. - inline const dtQueryFilter* getFilter(const int i) const { return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : 0; } + inline const dtQueryFilter* getFilter(const int i) const { return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : DT_NULL; } /// Gets the filter used by the crowd. /// @return The filter used by the crowd. - inline dtQueryFilter* getEditableFilter(const int i) { return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : 0; } + inline dtQueryFilter* getEditableFilter(const int i) { return (i >= 0 && i < DT_CROWD_MAX_QUERY_FILTER_TYPE) ? &m_filters[i] : DT_NULL; } /// Gets the search halfExtents [(x, y, z)] used by the crowd for query operations. /// @return The search halfExtents used by the crowd. [(x, y, z)] diff --git a/DetourCrowd/Include/DetourObstacleAvoidance.h b/DetourCrowd/Include/DetourObstacleAvoidance.h index cc46347a0..b3cdd4ada 100644 --- a/DetourCrowd/Include/DetourObstacleAvoidance.h +++ b/DetourCrowd/Include/DetourObstacleAvoidance.h @@ -19,6 +19,8 @@ #ifndef DETOUROBSTACLEAVOIDANCE_H #define DETOUROBSTACLEAVOIDANCE_H +#include "DetourModernCpp.h" + struct dtObstacleCircle { float p[3]; ///< Position of the obstacle @@ -112,12 +114,12 @@ class dtObstacleAvoidanceQuery int sampleVelocityGrid(const float* pos, const float rad, const float vmax, const float* vel, const float* dvel, float* nvel, const dtObstacleAvoidanceParams* params, - dtObstacleAvoidanceDebugData* debug = 0); + dtObstacleAvoidanceDebugData* debug = DT_NULL); int sampleVelocityAdaptive(const float* pos, const float rad, const float vmax, const float* vel, const float* dvel, float* nvel, const dtObstacleAvoidanceParams* params, - dtObstacleAvoidanceDebugData* debug = 0); + dtObstacleAvoidanceDebugData* debug = DT_NULL); inline int getObstacleCircleCount() const { return m_ncircles; } const dtObstacleCircle* getObstacleCircle(const int i) { return &m_circles[i]; } diff --git a/DetourCrowd/Source/DetourCrowd.cpp b/DetourCrowd/Source/DetourCrowd.cpp index d7cdae0b9..0e1e64dc8 100644 --- a/DetourCrowd/Source/DetourCrowd.cpp +++ b/DetourCrowd/Source/DetourCrowd.cpp @@ -28,12 +28,13 @@ #include "DetourMath.h" #include "DetourAssert.h" #include "DetourAlloc.h" +#include "DetourModernCpp.h" dtCrowd* dtAllocCrowd() { void* mem = dtAlloc(sizeof(dtCrowd), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtCrowd; } @@ -148,7 +149,7 @@ static int addNeighbour(const int idx, const float dist, dtCrowdNeighbour* neis, const int nneis, const int maxNeis) { // Insert neighbour based on the distance. - dtCrowdNeighbour* nei = 0; + dtCrowdNeighbour* nei = DT_NULL; if (!nneis) { nei = &neis[nneis]; @@ -330,16 +331,16 @@ must be fed back into the crowd, the agent must be removed and re-added. dtCrowd::dtCrowd() : m_maxAgents(0), - m_agents(0), - m_activeAgents(0), - m_agentAnims(0), - m_obstacleQuery(0), - m_grid(0), - m_pathResult(0), + m_agents(DT_NULL), + m_activeAgents(DT_NULL), + m_agentAnims(DT_NULL), + m_obstacleQuery(DT_NULL), + m_grid(DT_NULL), + m_pathResult(DT_NULL), m_maxPathResult(0), m_maxAgentRadius(0), m_velocitySampleCount(0), - m_navquery(0) + m_navquery(DT_NULL) { } @@ -353,26 +354,26 @@ void dtCrowd::purge() for (int i = 0; i < m_maxAgents; ++i) m_agents[i].~dtCrowdAgent(); dtFree(m_agents); - m_agents = 0; + m_agents = DT_NULL; m_maxAgents = 0; dtFree(m_activeAgents); - m_activeAgents = 0; + m_activeAgents = DT_NULL; dtFree(m_agentAnims); - m_agentAnims = 0; + m_agentAnims = DT_NULL; dtFree(m_pathResult); - m_pathResult = 0; + m_pathResult = DT_NULL; dtFreeProximityGrid(m_grid); - m_grid = 0; + m_grid = DT_NULL; dtFreeObstacleAvoidanceQuery(m_obstacleQuery); - m_obstacleQuery = 0; + m_obstacleQuery = DT_NULL; dtFreeNavMeshQuery(m_navquery); - m_navquery = 0; + m_navquery = DT_NULL; } /// @par @@ -471,7 +472,7 @@ const dtObstacleAvoidanceParams* dtCrowd::getObstacleAvoidanceParams(const int i { if (idx >= 0 && idx < DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS) return &m_obstacleQueryParams[idx]; - return 0; + return DT_NULL; } int dtCrowd::getAgentCount() const @@ -485,7 +486,7 @@ int dtCrowd::getAgentCount() const const dtCrowdAgent* dtCrowd::getAgent(const int idx) { if (idx < 0 || idx >= m_maxAgents) - return 0; + return DT_NULL; return &m_agents[idx]; } @@ -494,7 +495,7 @@ const dtCrowdAgent* dtCrowd::getAgent(const int idx) dtCrowdAgent* dtCrowd::getEditableAgent(const int idx) { if (idx < 0 || idx >= m_maxAgents) - return 0; + return DT_NULL; return &m_agents[idx]; } @@ -705,7 +706,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/) // Quick search towards the goal. static const int MAX_ITER = 20; m_navquery->initSlicedFindPath(path[0], ag->targetRef, ag->npos, ag->targetPos, &m_filters[ag->params.queryFilterType]); - m_navquery->updateSlicedFindPath(MAX_ITER, 0); + m_navquery->updateSlicedFindPath(MAX_ITER, DT_NULL); dtStatus status = 0; if (ag->targetReplan) // && npath > 10) { @@ -724,7 +725,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/) if (reqPath[reqPathCount-1] != ag->targetRef) { // Partial path, constrain target position inside the last polygon. - status = m_navquery->closestPointOnPoly(reqPath[reqPathCount-1], ag->targetPos, reqPos, 0); + status = m_navquery->closestPointOnPoly(reqPath[reqPathCount-1], ag->targetPos, reqPos, DT_NULL); if (dtStatusFailed(status)) reqPathCount = 0; } @@ -874,7 +875,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/) { // Partial path, constrain target position inside the last polygon. float nearest[3]; - status = m_navquery->closestPointOnPoly(res[nres-1], targetPos, nearest, 0); + status = m_navquery->closestPointOnPoly(res[nres-1], targetPos, nearest, DT_NULL); if (dtStatusSucceed(status)) dtVcopy(targetPos, nearest); else @@ -1282,7 +1283,7 @@ void dtCrowd::update(const float dt, dtCrowdAgentDebugInfo* debug) m_obstacleQuery->addSegment(s, s+3); } - dtObstacleAvoidanceDebugData* vod = 0; + dtObstacleAvoidanceDebugData* vod = DT_NULL; if (debugIdx == i) vod = debug->vod; diff --git a/DetourCrowd/Source/DetourLocalBoundary.cpp b/DetourCrowd/Source/DetourLocalBoundary.cpp index 79d432206..f838829e7 100644 --- a/DetourCrowd/Source/DetourLocalBoundary.cpp +++ b/DetourCrowd/Source/DetourLocalBoundary.cpp @@ -22,6 +22,7 @@ #include "DetourNavMeshQuery.h" #include "DetourCommon.h" #include "DetourAssert.h" +#include "DetourModernCpp.h" dtLocalBoundary::dtLocalBoundary() : @@ -45,7 +46,7 @@ void dtLocalBoundary::reset() void dtLocalBoundary::addSegment(const float dist, const float* s) { // Insert neighbour based on the distance. - Segment* seg = 0; + Segment* seg = DT_NULL; if (!m_nsegs) { // First, trivial accept. @@ -98,7 +99,7 @@ void dtLocalBoundary::update(dtPolyRef ref, const float* pos, const float collis // First query non-overlapping polygons. navquery->findLocalNeighbourhood(ref, pos, collisionQueryRange, - filter, m_polys, 0, &m_npolys, MAX_LOCAL_POLYS); + filter, m_polys, DT_NULL, &m_npolys, MAX_LOCAL_POLYS); // Secondly, store all polygon edges. m_nsegs = 0; @@ -106,7 +107,7 @@ void dtLocalBoundary::update(dtPolyRef ref, const float* pos, const float collis int nsegs = 0; for (int j = 0; j < m_npolys; ++j) { - navquery->getPolyWallSegments(m_polys[j], filter, segs, 0, &nsegs, MAX_SEGS_PER_POLY); + navquery->getPolyWallSegments(m_polys[j], filter, segs, DT_NULL, &nsegs, MAX_SEGS_PER_POLY); for (int k = 0; k < nsegs; ++k) { const float* s = &segs[k*6]; diff --git a/DetourCrowd/Source/DetourObstacleAvoidance.cpp b/DetourCrowd/Source/DetourObstacleAvoidance.cpp index f460c3d92..32827d3ca 100644 --- a/DetourCrowd/Source/DetourObstacleAvoidance.cpp +++ b/DetourCrowd/Source/DetourObstacleAvoidance.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "DetourModernCpp.h" static const float DT_PI = 3.14159265f; @@ -72,7 +73,7 @@ static int isectRaySeg(const float* ap, const float* u, dtObstacleAvoidanceDebugData* dtAllocObstacleAvoidanceDebugData() { void* mem = dtAlloc(sizeof(dtObstacleAvoidanceDebugData), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtObstacleAvoidanceDebugData; } @@ -87,13 +88,13 @@ void dtFreeObstacleAvoidanceDebugData(dtObstacleAvoidanceDebugData* ptr) dtObstacleAvoidanceDebugData::dtObstacleAvoidanceDebugData() : m_nsamples(0), m_maxSamples(0), - m_vel(0), - m_ssize(0), - m_pen(0), - m_vpen(0), - m_vcpen(0), - m_spen(0), - m_tpen(0) + m_vel(DT_NULL), + m_ssize(DT_NULL), + m_pen(DT_NULL), + m_vpen(DT_NULL), + m_vcpen(DT_NULL), + m_spen(DT_NULL), + m_tpen(DT_NULL) { } @@ -194,7 +195,7 @@ void dtObstacleAvoidanceDebugData::normalizeSamples() dtObstacleAvoidanceQuery* dtAllocObstacleAvoidanceQuery() { void* mem = dtAlloc(sizeof(dtObstacleAvoidanceQuery), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtObstacleAvoidanceQuery; } @@ -211,10 +212,10 @@ dtObstacleAvoidanceQuery::dtObstacleAvoidanceQuery() : m_vmax(0), m_invVmax(0), m_maxCircles(0), - m_circles(0), + m_circles(DT_NULL), m_ncircles(0), m_maxSegments(0), - m_segments(0), + m_segments(DT_NULL), m_nsegments(0) { } diff --git a/DetourCrowd/Source/DetourPathCorridor.cpp b/DetourCrowd/Source/DetourPathCorridor.cpp index 3835a389b..400ef36f1 100644 --- a/DetourCrowd/Source/DetourPathCorridor.cpp +++ b/DetourCrowd/Source/DetourPathCorridor.cpp @@ -22,6 +22,7 @@ #include "DetourCommon.h" #include "DetourAssert.h" #include "DetourAlloc.h" +#include "DetourModernCpp.h" int dtMergeCorridorStartMoved(dtPolyRef* path, const int npath, const int maxPath, @@ -198,7 +199,7 @@ may be needed. E.g. If you move the target, check #getLastPoly() to see if it i */ dtPathCorridor::dtPathCorridor() : - m_path(0), + m_path(DT_NULL), m_npath(0), m_maxPath(0) { @@ -365,7 +366,7 @@ bool dtPathCorridor::optimizePathTopology(dtNavMeshQuery* navquery, const dtQuer dtPolyRef res[MAX_RES]; int nres = 0; navquery->initSlicedFindPath(m_path[0], m_path[m_npath-1], m_pos, m_target, filter); - navquery->updateSlicedFindPath(MAX_ITER, 0); + navquery->updateSlicedFindPath(MAX_ITER, DT_NULL); dtStatus status = navquery->finalizeSlicedFindPathPartial(m_path, m_npath, res, &nres, MAX_RES); if (dtStatusSucceed(status) && nres > 0) diff --git a/DetourCrowd/Source/DetourPathQueue.cpp b/DetourCrowd/Source/DetourPathQueue.cpp index 1ed0cd7eb..c049537bb 100644 --- a/DetourCrowd/Source/DetourPathQueue.cpp +++ b/DetourCrowd/Source/DetourPathQueue.cpp @@ -22,16 +22,17 @@ #include "DetourNavMeshQuery.h" #include "DetourAlloc.h" #include "DetourCommon.h" +#include "DetourModernCpp.h" dtPathQueue::dtPathQueue() : m_nextHandle(1), m_maxPathSize(0), m_queueHead(0), - m_navquery(0) + m_navquery(DT_NULL) { for (int i = 0; i < MAX_QUEUE; ++i) - m_queue[i].path = 0; + m_queue[i].path = DT_NULL; } dtPathQueue::~dtPathQueue() @@ -42,11 +43,11 @@ dtPathQueue::~dtPathQueue() void dtPathQueue::purge() { dtFreeNavMeshQuery(m_navquery); - m_navquery = 0; + m_navquery = DT_NULL; for (int i = 0; i < MAX_QUEUE; ++i) { dtFree(m_queue[i].path); - m_queue[i].path = 0; + m_queue[i].path = DT_NULL; } } diff --git a/DetourCrowd/Source/DetourProximityGrid.cpp b/DetourCrowd/Source/DetourProximityGrid.cpp index fc1e2e136..136f1f081 100644 --- a/DetourCrowd/Source/DetourProximityGrid.cpp +++ b/DetourCrowd/Source/DetourProximityGrid.cpp @@ -23,12 +23,13 @@ #include "DetourMath.h" #include "DetourAlloc.h" #include "DetourAssert.h" +#include "DetourModernCpp.h" dtProximityGrid* dtAllocProximityGrid() { void* mem = dtAlloc(sizeof(dtProximityGrid), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtProximityGrid; } @@ -49,10 +50,10 @@ inline int hashPos2(int x, int y, int n) dtProximityGrid::dtProximityGrid() : m_cellSize(0), m_invCellSize(0), - m_pool(0), + m_pool(DT_NULL), m_poolHead(0), m_poolSize(0), - m_buckets(0), + m_buckets(DT_NULL), m_bucketsSize(0) { } diff --git a/DetourTileCache/Include/DetourTileCache.h b/DetourTileCache/Include/DetourTileCache.h index 0d346f17c..29e26244d 100644 --- a/DetourTileCache/Include/DetourTileCache.h +++ b/DetourTileCache/Include/DetourTileCache.h @@ -2,6 +2,7 @@ #define DETOURTILECACHE_H #include "DetourStatus.h" +#include "DetourModernCpp.h" typedef unsigned int dtObstacleRef; typedef unsigned int dtCompressedTileRef; @@ -153,7 +154,7 @@ class dtTileCache /// @param[out] upToDate Whether the tile cache is fully up to date with obstacle requests and tile rebuilds. /// If the tile cache is up to date another (immediate) call to update will have no effect; /// otherwise another call will continue processing obstacle requests and tile rebuilds. - dtStatus update(const float dt, class dtNavMesh* navmesh, bool* upToDate = 0); + dtStatus update(const float dt, class dtNavMesh* navmesh, bool* upToDate = DT_NULL); dtStatus buildNavMeshTilesAt(const int tx, const int ty, class dtNavMesh* navmesh); diff --git a/DetourTileCache/Source/DetourTileCache.cpp b/DetourTileCache/Source/DetourTileCache.cpp index 6f97ab5b7..3e647e63b 100644 --- a/DetourTileCache/Source/DetourTileCache.cpp +++ b/DetourTileCache/Source/DetourTileCache.cpp @@ -8,11 +8,12 @@ #include "DetourAssert.h" #include #include +#include "DetourModernCpp.h" dtTileCache* dtAllocTileCache() { void* mem = dtAlloc(sizeof(dtTileCache), DT_ALLOC_PERM); - if (!mem) return 0; + if (!mem) return DT_NULL; return new(mem) dtTileCache; } @@ -42,16 +43,16 @@ inline int computeTileHash(int x, int y, const int mask) struct NavMeshTileBuildContext { - inline NavMeshTileBuildContext(struct dtTileCacheAlloc* a) : layer(0), lcset(0), lmesh(0), alloc(a) {} + inline NavMeshTileBuildContext(struct dtTileCacheAlloc* a) : layer(DT_NULL), lcset(DT_NULL), lmesh(DT_NULL), alloc(a) {} inline ~NavMeshTileBuildContext() { purge(); } void purge() { dtFreeTileCacheLayer(alloc, layer); - layer = 0; + layer = DT_NULL; dtFreeTileCacheContourSet(alloc, lcset); - lcset = 0; + lcset = DT_NULL; dtFreeTileCachePolyMesh(alloc, lmesh); - lmesh = 0; + lmesh = DT_NULL; } struct dtTileCacheLayer* layer; struct dtTileCacheContourSet* lcset; @@ -63,16 +64,16 @@ struct NavMeshTileBuildContext dtTileCache::dtTileCache() : m_tileLutSize(0), m_tileLutMask(0), - m_posLookup(0), - m_nextFreeTile(0), - m_tiles(0), + m_posLookup(DT_NULL), + m_nextFreeTile(DT_NULL), + m_tiles(DT_NULL), m_saltBits(0), m_tileBits(0), - m_talloc(0), - m_tcomp(0), - m_tmproc(0), - m_obstacles(0), - m_nextFreeObstacle(0), + m_talloc(DT_NULL), + m_tcomp(DT_NULL), + m_tmproc(DT_NULL), + m_obstacles(DT_NULL), + m_nextFreeObstacle(DT_NULL), m_nreqs(0), m_nupdate(0) { @@ -87,15 +88,15 @@ dtTileCache::~dtTileCache() if (m_tiles[i].flags & DT_COMPRESSEDTILE_FREE_DATA) { dtFree(m_tiles[i].data); - m_tiles[i].data = 0; + m_tiles[i].data = DT_NULL; } } dtFree(m_obstacles); - m_obstacles = 0; + m_obstacles = DT_NULL; dtFree(m_posLookup); - m_posLookup = 0; + m_posLookup = DT_NULL; dtFree(m_tiles); - m_tiles = 0; + m_tiles = DT_NULL; m_nreqs = 0; m_nupdate = 0; } @@ -103,14 +104,14 @@ dtTileCache::~dtTileCache() const dtCompressedTile* dtTileCache::getTileByRef(dtCompressedTileRef ref) const { if (!ref) - return 0; + return DT_NULL; unsigned int tileIndex = decodeTileIdTile(ref); unsigned int tileSalt = decodeTileIdSalt(ref); if ((int)tileIndex >= m_params.maxTiles) - return 0; + return DT_NULL; const dtCompressedTile* tile = &m_tiles[tileIndex]; if (tile->salt != tileSalt) - return 0; + return DT_NULL; return tile; } @@ -131,7 +132,7 @@ dtStatus dtTileCache::init(const dtTileCacheParams* params, if (!m_obstacles) return DT_FAILURE | DT_OUT_OF_MEMORY; memset(m_obstacles, 0, sizeof(dtTileCacheObstacle)*m_params.maxObstacles); - m_nextFreeObstacle = 0; + m_nextFreeObstacle = DT_NULL; for (int i = m_params.maxObstacles-1; i >= 0; --i) { m_obstacles[i].salt = 1; @@ -152,7 +153,7 @@ dtStatus dtTileCache::init(const dtTileCacheParams* params, return DT_FAILURE | DT_OUT_OF_MEMORY; memset(m_tiles, 0, sizeof(dtCompressedTile)*m_params.maxTiles); memset(m_posLookup, 0, sizeof(dtCompressedTile*)*m_tileLutSize); - m_nextFreeTile = 0; + m_nextFreeTile = DT_NULL; for (int i = m_params.maxTiles-1; i >= 0; --i) { m_tiles[i].salt = 1; @@ -208,7 +209,7 @@ dtCompressedTile* dtTileCache::getTileAt(const int tx, const int ty, const int t } tile = tile->next; } - return 0; + return DT_NULL; } dtCompressedTileRef dtTileCache::getTileRef(const dtCompressedTile* tile) const @@ -228,14 +229,14 @@ dtObstacleRef dtTileCache::getObstacleRef(const dtTileCacheObstacle* ob) const const dtTileCacheObstacle* dtTileCache::getObstacleByRef(dtObstacleRef ref) { if (!ref) - return 0; + return DT_NULL; unsigned int idx = decodeObstacleIdObstacle(ref); if ((int)idx >= m_params.maxObstacles) - return 0; + return DT_NULL; const dtTileCacheObstacle* ob = &m_obstacles[idx]; unsigned int salt = decodeObstacleIdSalt(ref); if (ob->salt != salt) - return 0; + return DT_NULL; return ob; } @@ -258,12 +259,12 @@ dtStatus dtTileCache::addTile(unsigned char* data, const int dataSize, unsigned return DT_FAILURE; // Allocate a tile. - dtCompressedTile* tile = 0; + dtCompressedTile* tile = DT_NULL; if (m_nextFreeTile) { tile = m_nextFreeTile; m_nextFreeTile = tile->next; - tile->next = 0; + tile->next = DT_NULL; } // Make sure we could allocate a tile. @@ -304,7 +305,7 @@ dtStatus dtTileCache::removeTile(dtCompressedTileRef ref, unsigned char** data, // Remove tile from hash lookup. const int h = computeTileHash(tile->header->tx,tile->header->ty,m_tileLutMask); - dtCompressedTile* prev = 0; + dtCompressedTile* prev = DT_NULL; dtCompressedTile* cur = m_posLookup[h]; while (cur) { @@ -325,9 +326,9 @@ dtStatus dtTileCache::removeTile(dtCompressedTileRef ref, unsigned char** data, { // Owns data dtFree(tile->data); - tile->data = 0; + tile->data = DT_NULL; tile->dataSize = 0; - if (data) *data = 0; + if (data) *data = DT_NULL; if (dataSize) *dataSize = 0; } else @@ -336,10 +337,10 @@ dtStatus dtTileCache::removeTile(dtCompressedTileRef ref, unsigned char** data, if (dataSize) *dataSize = tile->dataSize; } - tile->header = 0; - tile->data = 0; + tile->header = DT_NULL; + tile->data = DT_NULL; tile->dataSize = 0; - tile->compressed = 0; + tile->compressed = DT_NULL; tile->compressedSize = 0; tile->flags = 0; @@ -361,12 +362,12 @@ dtStatus dtTileCache::addObstacle(const float* pos, const float radius, const fl if (m_nreqs >= MAX_REQUESTS) return DT_FAILURE | DT_BUFFER_TOO_SMALL; - dtTileCacheObstacle* ob = 0; + dtTileCacheObstacle* ob = DT_NULL; if (m_nextFreeObstacle) { ob = m_nextFreeObstacle; m_nextFreeObstacle = ob->next; - ob->next = 0; + ob->next = DT_NULL; } if (!ob) return DT_FAILURE | DT_OUT_OF_MEMORY; @@ -396,12 +397,12 @@ dtStatus dtTileCache::addBoxObstacle(const float* bmin, const float* bmax, dtObs if (m_nreqs >= MAX_REQUESTS) return DT_FAILURE | DT_BUFFER_TOO_SMALL; - dtTileCacheObstacle* ob = 0; + dtTileCacheObstacle* ob = DT_NULL; if (m_nextFreeObstacle) { ob = m_nextFreeObstacle; m_nextFreeObstacle = ob->next; - ob->next = 0; + ob->next = DT_NULL; } if (!ob) return DT_FAILURE | DT_OUT_OF_MEMORY; @@ -430,12 +431,12 @@ dtStatus dtTileCache::addBoxObstacle(const float* center, const float* halfExten if (m_nreqs >= MAX_REQUESTS) return DT_FAILURE | DT_BUFFER_TOO_SMALL; - dtTileCacheObstacle* ob = 0; + dtTileCacheObstacle* ob = DT_NULL; if (m_nextFreeObstacle) { ob = m_nextFreeObstacle; m_nextFreeObstacle = ob->next; - ob->next = 0; + ob->next = DT_NULL; } if (!ob) return DT_FAILURE | DT_OUT_OF_MEMORY; @@ -728,7 +729,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh* if (!bc.lmesh->npolys) { // Remove existing tile. - navmesh->removeTile(navmesh->getTileRefAt(tile->header->tx,tile->header->ty,tile->header->tlayer),0,0); + navmesh->removeTile(navmesh->getTileRefAt(tile->header->tx,tile->header->ty,tile->header->tlayer),DT_NULL,DT_NULL); return DT_SUCCESS; } @@ -758,19 +759,19 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh* m_tmproc->process(¶ms, bc.lmesh->areas, bc.lmesh->flags); } - unsigned char* navData = 0; + unsigned char* navData = DT_NULL; int navDataSize = 0; if (!dtCreateNavMeshData(¶ms, &navData, &navDataSize)) return DT_FAILURE; // Remove existing tile. - navmesh->removeTile(navmesh->getTileRefAt(tile->header->tx,tile->header->ty,tile->header->tlayer),0,0); + navmesh->removeTile(navmesh->getTileRefAt(tile->header->tx,tile->header->ty,tile->header->tlayer),DT_NULL,DT_NULL); // Add new tile, or leave the location empty. if (navData) { // Let the navmesh own the data. - status = navmesh->addTile(navData,navDataSize,DT_TILE_FREE_DATA,0,0); + status = navmesh->addTile(navData,navDataSize,DT_TILE_FREE_DATA,0,DT_NULL); if (dtStatusFailed(status)) { dtFree(navData); diff --git a/DetourTileCache/Source/DetourTileCacheBuilder.cpp b/DetourTileCache/Source/DetourTileCacheBuilder.cpp index dbc09eb48..da151d340 100644 --- a/DetourTileCache/Source/DetourTileCacheBuilder.cpp +++ b/DetourTileCache/Source/DetourTileCacheBuilder.cpp @@ -22,6 +22,7 @@ #include "DetourAssert.h" #include "DetourTileCacheBuilder.h" #include +#include "DetourModernCpp.h" dtTileCacheAlloc::~dtTileCacheAlloc() { @@ -2172,7 +2173,7 @@ dtStatus dtDecompressTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheCompress if (!compressed) return DT_FAILURE | DT_INVALID_PARAM; - *layerOut = 0; + *layerOut = DT_NULL; dtTileCacheLayerHeader* compressedHeader = (dtTileCacheLayerHeader*)compressed; if (compressedHeader->magic != DT_TILECACHE_MAGIC) diff --git a/Recast/Include/RecastAlloc.h b/Recast/Include/RecastAlloc.h index dfd3ab3b5..5daf00765 100644 --- a/Recast/Include/RecastAlloc.h +++ b/Recast/Include/RecastAlloc.h @@ -124,11 +124,11 @@ class rcVectorBase { typedef rcSizeType size_type; typedef T value_type; - rcVectorBase() : m_size(0), m_cap(0), m_data(0) {} - rcVectorBase(const rcVectorBase& other) : m_size(0), m_cap(0), m_data(0) { assign(other.begin(), other.end()); } - explicit rcVectorBase(rcSizeType count) : m_size(0), m_cap(0), m_data(0) { resize(count); } - rcVectorBase(rcSizeType count, const T& value) : m_size(0), m_cap(0), m_data(0) { resize(count, value); } - rcVectorBase(const T* begin, const T* end) : m_size(0), m_cap(0), m_data(0) { assign(begin, end); } + rcVectorBase() : m_size(0), m_cap(0), m_data(RC_NULL) {} + rcVectorBase(const rcVectorBase& other) : m_size(0), m_cap(0), m_data(RC_NULL) { assign(other.begin(), other.end()); } + explicit rcVectorBase(rcSizeType count) : m_size(0), m_cap(0), m_data(RC_NULL) { resize(count); } + rcVectorBase(rcSizeType count, const T& value) : m_size(0), m_cap(0), m_data(RC_NULL) { resize(count, value); } + rcVectorBase(const T* begin, const T* end) : m_size(0), m_cap(0), m_data(RC_NULL) { assign(begin, end); } ~rcVectorBase() { destroy_range(0, m_size); rcFree(m_data); } // Unlike in std::vector, we return a bool to indicate whether the alloc was successful. @@ -137,7 +137,7 @@ class rcVectorBase { void assign(rcSizeType count, const T& value) { clear(); resize(count, value); } void assign(const T* begin, const T* end); - void resize(rcSizeType size) { resize_impl(size, NULL); } + void resize(rcSizeType size) { resize_impl(size, RC_NULL); } void resize(rcSizeType size, const T& value) { resize_impl(size, &value); } // Not implemented as resize(0) because resize requires T to be default-constructible. void clear() { destroy_range(0, m_size); m_size = 0; } diff --git a/Recast/Include/RecastAssert.h b/Recast/Include/RecastAssert.h index 923b0ff56..9567374b4 100644 --- a/Recast/Include/RecastAssert.h +++ b/Recast/Include/RecastAssert.h @@ -44,7 +44,7 @@ rcAssertFailFunc* rcAssertFailGetCustom(); # define rcAssert(expression) \ { \ rcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \ - if (failFunc == NULL) { assert(expression); } \ + if (failFunc == RC_NULL) { assert(expression); } \ else if (!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \ } diff --git a/Recast/Include/RecastModernCpp.h b/Recast/Include/RecastModernCpp.h index 11db45c28..d3111eb32 100644 --- a/Recast/Include/RecastModernCpp.h +++ b/Recast/Include/RecastModernCpp.h @@ -6,10 +6,7 @@ #include "RecastAssert.h" #if __cplusplus and __cplusplus >= 201103L -#ifdef NULL -#undef NULL -#endif -#define NULL nullptr +#define RC_NULL nullptr #define RC_OVERRIDE override #else #include diff --git a/Recast/Source/RecastAssert.cpp b/Recast/Source/RecastAssert.cpp index 2d899ca40..79fef9a7f 100644 --- a/Recast/Source/RecastAssert.cpp +++ b/Recast/Source/RecastAssert.cpp @@ -17,10 +17,11 @@ // #include "RecastAssert.h" +#include "RecastModernCpp.h" #ifndef RC_DISABLE_ASSERTS -static rcAssertFailFunc* sRecastAssertFailFunc = 0; +static rcAssertFailFunc* sRecastAssertFailFunc = RC_NULL; void rcAssertFailSetCustom(rcAssertFailFunc* assertFailFunc) { diff --git a/Recast/Source/RecastContour.cpp b/Recast/Source/RecastContour.cpp index 39371f893..c6686874a 100644 --- a/Recast/Source/RecastContour.cpp +++ b/Recast/Source/RecastContour.cpp @@ -640,7 +640,7 @@ static bool mergeContours(rcContour& ca, rcContour& cb, int ia, int ib) ca.nverts = nv; rcFree(cb.verts); - cb.verts = 0; + cb.verts = RC_NULL; cb.nverts = 0; return true; @@ -948,8 +948,8 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf, { newConts[j] = cset.conts[j]; // Reset source pointers to prevent data deletion. - cset.conts[j].verts = 0; - cset.conts[j].rverts = 0; + cset.conts[j].verts = RC_NULL; + cset.conts[j].rverts = RC_NULL; } rcFree(cset.conts); cset.conts = newConts; diff --git a/Recast/Source/RecastFilter.cpp b/Recast/Source/RecastFilter.cpp index 7875040b9..cc56cae3b 100644 --- a/Recast/Source/RecastFilter.cpp +++ b/Recast/Source/RecastFilter.cpp @@ -18,6 +18,7 @@ #include "Recast.h" #include "RecastAssert.h" +#include "RecastModernCpp.h" #include @@ -39,12 +40,12 @@ void rcFilterLowHangingWalkableObstacles(rcContext* context, const int walkableC { for (int x = 0; x < xSize; ++x) { - rcSpan* previousSpan = NULL; + rcSpan* previousSpan = RC_NULL; bool previousWasWalkable = false; unsigned char previousAreaID = RC_NULL_AREA; // For each span in the column... - for (rcSpan* span = heightfield.spans[x + z * xSize]; span != NULL; previousSpan = span, span = span->next) + for (rcSpan* span = heightfield.spans[x + z * xSize]; span != RC_NULL; previousSpan = span, span = span->next) { const bool walkable = span->area != RC_NULL_AREA; diff --git a/Recast/Source/RecastLayers.cpp b/Recast/Source/RecastLayers.cpp index ca37ebba7..6a1428339 100644 --- a/Recast/Source/RecastLayers.cpp +++ b/Recast/Source/RecastLayers.cpp @@ -492,7 +492,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, const rcCompactHeightfield& chf, return true; // Create layers. - rcAssert(lset.layers == 0); + rcAssert(lset.layers == RC_NULL); const int lw = w - borderSize*2; const int lh = h - borderSize*2; diff --git a/Recast/Source/RecastMesh.cpp b/Recast/Source/RecastMesh.cpp index c9eb60a5d..8d10d5813 100644 --- a/Recast/Source/RecastMesh.cpp +++ b/Recast/Source/RecastMesh.cpp @@ -1489,11 +1489,11 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst) rcAssert(ctx); // Destination must be empty. - rcAssert(dst.verts == 0); - rcAssert(dst.polys == 0); - rcAssert(dst.regs == 0); - rcAssert(dst.areas == 0); - rcAssert(dst.flags == 0); + rcAssert(dst.verts == RC_NULL); + rcAssert(dst.polys == RC_NULL); + rcAssert(dst.regs == RC_NULL); + rcAssert(dst.areas == RC_NULL); + rcAssert(dst.flags == RC_NULL); dst.nverts = src.nverts; dst.npolys = src.npolys; diff --git a/Recast/Source/RecastMeshDetail.cpp b/Recast/Source/RecastMeshDetail.cpp index 957245cfb..c943fdf6c 100644 --- a/Recast/Source/RecastMeshDetail.cpp +++ b/Recast/Source/RecastMeshDetail.cpp @@ -30,7 +30,7 @@ static const unsigned RC_UNSET_HEIGHT = 0xffff; struct rcHeightPatch { - inline rcHeightPatch() : data(0), xmin(0), ymin(0), width(0), height(0) {} + inline rcHeightPatch() : data(RC_NULL), xmin(0), ymin(0), width(0), height(0) {} inline ~rcHeightPatch() { rcFree(data); } unsigned short* data; int xmin, ymin, width, height; diff --git a/Recast/Source/RecastRegion.cpp b/Recast/Source/RecastRegion.cpp index 684987ef7..26a27ebc6 100644 --- a/Recast/Source/RecastRegion.cpp +++ b/Recast/Source/RecastRegion.cpp @@ -1264,7 +1264,7 @@ bool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf) if (chf.dist) { rcFree(chf.dist); - chf.dist = 0; + chf.dist = RC_NULL; } unsigned short* src = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP); diff --git a/RecastDemo/Include/ChunkyTriMesh.h b/RecastDemo/Include/ChunkyTriMesh.h index 0870d64ef..d6d809b7f 100644 --- a/RecastDemo/Include/ChunkyTriMesh.h +++ b/RecastDemo/Include/ChunkyTriMesh.h @@ -19,6 +19,8 @@ #ifndef CHUNKYTRIMESH_H #define CHUNKYTRIMESH_H +#include "RecastModernCpp.h" + struct rcChunkyTriMeshNode { float bmin[2]; @@ -29,7 +31,7 @@ struct rcChunkyTriMeshNode struct rcChunkyTriMesh { - inline rcChunkyTriMesh() : nodes(0), nnodes(0), tris(0), ntris(0), maxTrisPerChunk(0) {} + inline rcChunkyTriMesh() : nodes(RC_NULL), nnodes(0), tris(RC_NULL), ntris(0), maxTrisPerChunk(0) {}; inline ~rcChunkyTriMesh() { delete [] nodes; delete [] tris; } rcChunkyTriMeshNode* nodes; diff --git a/RecastDemo/Include/InputGeom.h b/RecastDemo/Include/InputGeom.h index edc129579..e938c063c 100644 --- a/RecastDemo/Include/InputGeom.h +++ b/RecastDemo/Include/InputGeom.h @@ -113,7 +113,7 @@ class InputGeom const float* getNavMeshBoundsMin() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMin : m_meshBMin; } const float* getNavMeshBoundsMax() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMax : m_meshBMax; } const rcChunkyTriMesh* getChunkyMesh() const { return m_chunkyMesh; } - const BuildSettings* getBuildSettings() const { return m_hasBuildSettings ? &m_buildSettings : 0; } + const BuildSettings* getBuildSettings() const { return m_hasBuildSettings ? &m_buildSettings : RC_NULL; } bool raycastMesh(float* src, float* dst, float& tmin); /// @name Off-Mesh connections. diff --git a/RecastDemo/Include/TestCase.h b/RecastDemo/Include/TestCase.h index 8991e576f..6402e7489 100644 --- a/RecastDemo/Include/TestCase.h +++ b/RecastDemo/Include/TestCase.h @@ -21,6 +21,7 @@ #include #include "DetourNavMesh.h" +#include "RecastModernCpp.h" class TestCase { @@ -42,14 +43,14 @@ class TestCase includeFlags(0), excludeFlags(0), expand(false), - straight(0), + straight(RC_NULL), nstraight(0), - polys(0), + polys(RC_NULL), npolys(0), findNearestPolyTime(0), findPathTime(0), findStraightPathTime(0), - next(0) + next(RC_NULL) { } diff --git a/RecastDemo/Source/ConvexVolumeTool.cpp b/RecastDemo/Source/ConvexVolumeTool.cpp index 61c6fbd2e..2df4bf4cc 100644 --- a/RecastDemo/Source/ConvexVolumeTool.cpp +++ b/RecastDemo/Source/ConvexVolumeTool.cpp @@ -98,7 +98,7 @@ static int pointInPoly(int nvert, const float* verts, const float* p) ConvexVolumeTool::ConvexVolumeTool() : - m_sample(0), + m_sample(RC_NULL), m_areaType(SAMPLE_POLYAREA_GRASS), m_polyOffset(0.0f), m_boxHeight(6.0f), diff --git a/RecastDemo/Source/CrowdTool.cpp b/RecastDemo/Source/CrowdTool.cpp index 7f9f78432..c68e11ad7 100644 --- a/RecastDemo/Source/CrowdTool.cpp +++ b/RecastDemo/Source/CrowdTool.cpp @@ -95,9 +95,9 @@ static void getAgentBounds(const dtCrowdAgent* ag, float* bmin, float* bmax) } CrowdToolState::CrowdToolState() : - m_sample(0), - m_nav(0), - m_crowd(0), + m_sample(RC_NULL), + m_nav(RC_NULL), + m_crowd(RC_NULL), m_targetRef(0), m_run(true) { @@ -858,8 +858,8 @@ void CrowdToolState::updateTick(const float dt) CrowdTool::CrowdTool() : - m_sample(0), - m_state(0), + m_sample(RC_NULL), + m_state(RC_NULL), m_mode(TOOLMODE_CREATE) { } @@ -904,7 +904,7 @@ void CrowdTool::handleMenu() imguiSeparatorLine(); - if (imguiCollapse("Options", 0, params->m_expandOptions)) + if (imguiCollapse("Options", RC_NULL, params->m_expandOptions)) params->m_expandOptions = !params->m_expandOptions; if (params->m_expandOptions) @@ -947,7 +947,7 @@ void CrowdTool::handleMenu() imguiUnindent(); } - if (imguiCollapse("Selected Debug Draw", 0, params->m_expandSelectedDebugDraw)) + if (imguiCollapse("Selected Debug Draw", RC_NULL, params->m_expandSelectedDebugDraw)) params->m_expandSelectedDebugDraw = !params->m_expandSelectedDebugDraw; if (params->m_expandSelectedDebugDraw) @@ -968,7 +968,7 @@ void CrowdTool::handleMenu() imguiUnindent(); } - if (imguiCollapse("Debug Draw", 0, params->m_expandDebugDraw)) + if (imguiCollapse("Debug Draw", RC_NULL, params->m_expandDebugDraw)) params->m_expandDebugDraw = !params->m_expandDebugDraw; if (params->m_expandDebugDraw) diff --git a/RecastDemo/Source/Filelist.cpp b/RecastDemo/Source/Filelist.cpp index bd715c47b..85f0f2183 100644 --- a/RecastDemo/Source/Filelist.cpp +++ b/RecastDemo/Source/Filelist.cpp @@ -26,6 +26,8 @@ # include #endif +#include "RecastModernCpp.h" + using std::vector; using std::string; @@ -48,7 +50,7 @@ void scanDirectoryAppend(const string& path, const string& ext, vector& while (_findnext(fh, &dir) == 0); _findclose(fh); #else - dirent* current = 0; + dirent* current = RC_NULL; DIR* dp = opendir(path.c_str()); if (!dp) { @@ -56,7 +58,7 @@ void scanDirectoryAppend(const string& path, const string& ext, vector& } size_t extLen = strlen(ext.c_str()); - while ((current = readdir(dp)) != 0) + while ((current = readdir(dp)) != RC_NULL) { size_t len = strlen(current->d_name); if (len > extLen && strncmp(current->d_name + len - extLen, ext.c_str(), extLen) == 0) diff --git a/RecastDemo/Source/InputGeom.cpp b/RecastDemo/Source/InputGeom.cpp index 50b72c16c..cd0b1a141 100644 --- a/RecastDemo/Source/InputGeom.cpp +++ b/RecastDemo/Source/InputGeom.cpp @@ -107,8 +107,8 @@ static char* parseRow(char* buf, char* bufEnd, char* row, int len) InputGeom::InputGeom() : - m_chunkyMesh(0), - m_mesh(0), + m_chunkyMesh(RC_NULL), + m_mesh(RC_NULL), m_hasBuildSettings(false), m_offMeshConCount(0), m_volumeCount(0) @@ -126,9 +126,9 @@ bool InputGeom::loadMesh(rcContext* ctx, const std::string& filepath) if (m_mesh) { delete m_chunkyMesh; - m_chunkyMesh = 0; + m_chunkyMesh = RC_NULL; delete m_mesh; - m_mesh = 0; + m_mesh = RC_NULL; } m_offMeshConCount = 0; m_volumeCount = 0; @@ -164,7 +164,7 @@ bool InputGeom::loadMesh(rcContext* ctx, const std::string& filepath) bool InputGeom::loadGeomSet(rcContext* ctx, const std::string& filepath) { - char* buf = 0; + char* buf = RC_NULL; FILE* fp = fopen(filepath.c_str(), "rb"); if (!fp) { @@ -204,7 +204,7 @@ bool InputGeom::loadGeomSet(rcContext* ctx, const std::string& filepath) m_offMeshConCount = 0; m_volumeCount = 0; delete m_mesh; - m_mesh = 0; + m_mesh = RC_NULL; char* src = buf; char* srcEnd = buf + bufSize; diff --git a/RecastDemo/Source/MeshLoaderObj.cpp b/RecastDemo/Source/MeshLoaderObj.cpp index 21959ced2..f8417aaca 100644 --- a/RecastDemo/Source/MeshLoaderObj.cpp +++ b/RecastDemo/Source/MeshLoaderObj.cpp @@ -22,11 +22,13 @@ #include #include +#include "RecastModernCpp.h" + rcMeshLoaderObj::rcMeshLoaderObj() : m_scale(1.0f), - m_verts(0), - m_tris(0), - m_normals(0), + m_verts(RC_NULL), + m_tris(RC_NULL), + m_normals(RC_NULL), m_vertCount(0), m_triCount(0) { @@ -137,7 +139,7 @@ static int parseFace(char* row, int* data, int n, int vcnt) bool rcMeshLoaderObj::load(const std::string& filename) { - char* buf = 0; + char* buf = RC_NULL; FILE* fp = fopen(filename.c_str(), "rb"); if (!fp) return false; diff --git a/RecastDemo/Source/NavMeshPruneTool.cpp b/RecastDemo/Source/NavMeshPruneTool.cpp index c775e5f92..e3cdbc4d9 100644 --- a/RecastDemo/Source/NavMeshPruneTool.cpp +++ b/RecastDemo/Source/NavMeshPruneTool.cpp @@ -52,7 +52,7 @@ class NavmeshFlags public: NavmeshFlags() : - m_nav(0), m_tiles(0), m_ntiles(0) + m_nav(RC_NULL), m_tiles(RC_NULL), m_ntiles(0) { } @@ -146,9 +146,9 @@ static void floodNavmesh(dtNavMesh* nav, NavmeshFlags* flags, dtPolyRef start, u openList.pop_back(); // Get current poly and tile. - // The API input has been checked already, skip checking internal data. - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + // The API input has been cheked already, skip checking internal data. + const dtMeshTile* tile = RC_NULL; + const dtPoly* poly = RC_NULL; nav->getTileAndPolyByRefUnsafe(ref, &tile, &poly); // Visit linked polygons. @@ -187,8 +187,8 @@ static void disableUnvisitedPolys(dtNavMesh* nav, NavmeshFlags* flags) } NavMeshPruneTool::NavMeshPruneTool() : - m_sample(0), - m_flags(0), + m_sample(RC_NULL), + m_flags(RC_NULL), m_hitPosSet(false) { } @@ -207,7 +207,7 @@ void NavMeshPruneTool::reset() { m_hitPosSet = false; delete m_flags; - m_flags = 0; + m_flags = RC_NULL; } void NavMeshPruneTool::handleMenu() @@ -225,7 +225,7 @@ void NavMeshPruneTool::handleMenu() { disableUnvisitedPolys(nav, m_flags); delete m_flags; - m_flags = 0; + m_flags = RC_NULL; } } @@ -254,7 +254,7 @@ void NavMeshPruneTool::handleClick(const float* s, const float* p, bool shift) const float halfExtents[3] = { 2, 4, 2 }; dtQueryFilter filter; dtPolyRef ref = 0; - query->findNearestPoly(p, halfExtents, &filter, &ref, 0); + query->findNearestPoly(p, halfExtents, &filter, &ref, RC_NULL); floodNavmesh(nav, m_flags, ref, 1); } diff --git a/RecastDemo/Source/NavMeshTesterTool.cpp b/RecastDemo/Source/NavMeshTesterTool.cpp index cff9def41..dfe81d0a7 100644 --- a/RecastDemo/Source/NavMeshTesterTool.cpp +++ b/RecastDemo/Source/NavMeshTesterTool.cpp @@ -81,8 +81,8 @@ static int fixupShortcuts(dtPolyRef* path, int npath, dtNavMeshQuery* navQuery) dtPolyRef neis[maxNeis]; int nneis = 0; - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = RC_NULL; + const dtPoly* poly = RC_NULL; if (dtStatusFailed(navQuery->getAttachedNavMesh()->getTileAndPolyByRef(path[0], &tile, &poly))) return npath; @@ -124,7 +124,7 @@ static bool getSteerTarget(dtNavMeshQuery* navQuery, const float* startPos, cons const float minTargetDist, const dtPolyRef* path, const int pathSize, float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef, - float* outPoints = 0, int* outPointCount = 0) + float* outPoints = RC_NULL, int* outPointCount = RC_NULL) { // Find steer target. static const int MAX_STEER_POINTS = 3; @@ -169,9 +169,9 @@ static bool getSteerTarget(dtNavMeshQuery* navQuery, const float* startPos, cons NavMeshTesterTool::NavMeshTesterTool() : - m_sample(0), - m_navMesh(0), - m_navQuery(0), + m_sample(RC_NULL), + m_navMesh(RC_NULL), + m_navQuery(RC_NULL), m_pathFindStatus(DT_FAILURE), m_toolMode(TOOLMODE_PATHFIND_FOLLOW), m_straightPathOptions(0), @@ -462,8 +462,8 @@ void NavMeshTesterTool::handleToggle() if (m_pathIterPolyCount) { // Iterate over the path to find smooth path on the detail mesh surface. - m_navQuery->closestPointOnPoly(m_startRef, m_spos, m_iterPos, 0); - m_navQuery->closestPointOnPoly(m_pathIterPolys[m_pathIterPolyCount-1], m_epos, m_targetPos, 0); + m_navQuery->closestPointOnPoly(m_startRef, m_spos, m_iterPos, RC_NULL); + m_navQuery->closestPointOnPoly(m_pathIterPolys[m_pathIterPolyCount-1], m_epos, m_targetPos, RC_NULL); m_nsmoothPath = 0; @@ -595,7 +595,7 @@ void NavMeshTesterTool::handleUpdate(const float /*dt*/) { if (dtStatusInProgress(m_pathFindStatus)) { - m_pathFindStatus = m_navQuery->updateSlicedFindPath(1,0); + m_pathFindStatus = m_navQuery->updateSlicedFindPath(1,RC_NULL); } if (dtStatusSucceed(m_pathFindStatus)) { @@ -607,7 +607,7 @@ void NavMeshTesterTool::handleUpdate(const float /*dt*/) float epos[3]; dtVcopy(epos, m_epos); if (m_polys[m_npolys-1] != m_endRef) - m_navQuery->closestPointOnPoly(m_polys[m_npolys-1], m_epos, epos, 0); + m_navQuery->closestPointOnPoly(m_polys[m_npolys-1], m_epos, epos, RC_NULL); m_navQuery->findStraightPath(m_spos, epos, m_polys, m_npolys, m_straightPath, m_straightPathFlags, @@ -638,12 +638,12 @@ void NavMeshTesterTool::recalc() return; if (m_sposSet) - m_navQuery->findNearestPoly(m_spos, m_polyPickExt, &m_filter, &m_startRef, 0); + m_navQuery->findNearestPoly(m_spos, m_polyPickExt, &m_filter, &m_startRef, RC_NULL); else m_startRef = 0; if (m_eposSet) - m_navQuery->findNearestPoly(m_epos, m_polyPickExt, &m_filter, &m_endRef, 0); + m_navQuery->findNearestPoly(m_epos, m_polyPickExt, &m_filter, &m_endRef, RC_NULL); else m_endRef = 0; @@ -672,8 +672,8 @@ void NavMeshTesterTool::recalc() int npolys = m_npolys; float iterPos[3], targetPos[3]; - m_navQuery->closestPointOnPoly(m_startRef, m_spos, iterPos, 0); - m_navQuery->closestPointOnPoly(polys[npolys-1], m_epos, targetPos, 0); + m_navQuery->closestPointOnPoly(m_startRef, m_spos, iterPos, RC_NULL); + m_navQuery->closestPointOnPoly(polys[npolys-1], m_epos, targetPos, RC_NULL); static const float STEP_SIZE = 0.5f; static const float SLOP = 0.01f; @@ -812,7 +812,7 @@ void NavMeshTesterTool::recalc() float epos[3]; dtVcopy(epos, m_epos); if (m_polys[m_npolys-1] != m_endRef) - m_navQuery->closestPointOnPoly(m_polys[m_npolys-1], m_epos, epos, 0); + m_navQuery->closestPointOnPoly(m_polys[m_npolys-1], m_epos, epos, RC_NULL); m_navQuery->findStraightPath(m_spos, epos, m_polys, m_npolys, m_straightPath, m_straightPathFlags, @@ -911,7 +911,7 @@ void NavMeshTesterTool::recalc() m_filter.getIncludeFlags(), m_filter.getExcludeFlags()); #endif m_navQuery->findPolysAroundCircle(m_startRef, m_spos, dist, &m_filter, - m_polys, m_parent, 0, &m_npolys, MAX_POLYS); + m_polys, m_parent, RC_NULL, &m_npolys, MAX_POLYS); } } @@ -948,7 +948,7 @@ void NavMeshTesterTool::recalc() m_filter.getIncludeFlags(), m_filter.getExcludeFlags()); #endif m_navQuery->findPolysAroundShape(m_startRef, m_queryPoly, 4, &m_filter, - m_polys, m_parent, 0, &m_npolys, MAX_POLYS); + m_polys, m_parent, RC_NULL, &m_npolys, MAX_POLYS); } } else if (m_toolMode == TOOLMODE_FIND_LOCAL_NEIGHBOURHOOD) @@ -972,8 +972,8 @@ static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center) center[1] = 0; center[2] = 0; - const dtMeshTile* tile = 0; - const dtPoly* poly = 0; + const dtMeshTile* tile = RC_NULL; + const dtPoly* poly = RC_NULL; dtStatus status = navMesh->getTileAndPolyByRef(ref, &tile, &poly); if (dtStatusFailed(status)) return; diff --git a/RecastDemo/Source/OffMeshConnectionTool.cpp b/RecastDemo/Source/OffMeshConnectionTool.cpp index 99b814c84..6eed0d52b 100644 --- a/RecastDemo/Source/OffMeshConnectionTool.cpp +++ b/RecastDemo/Source/OffMeshConnectionTool.cpp @@ -40,7 +40,7 @@ #endif OffMeshConnectionTool::OffMeshConnectionTool() : - m_sample(0), + m_sample(RC_NULL), m_hitPosSet(0), m_bidir(true), m_oldFlags(0) diff --git a/RecastDemo/Source/PerfTimer.cpp b/RecastDemo/Source/PerfTimer.cpp index a8c86bd26..65db80ddb 100644 --- a/RecastDemo/Source/PerfTimer.cpp +++ b/RecastDemo/Source/PerfTimer.cpp @@ -43,11 +43,12 @@ int getPerfTimeUsec(const TimeVal duration) // Linux, BSD, OSX #include +#include "RecastModernCpp.h" TimeVal getPerfTime() { timeval now; - gettimeofday(&now, 0); + gettimeofday(&now, RC_NULL); return (TimeVal)now.tv_sec*1000000L + (TimeVal)now.tv_usec; } diff --git a/RecastDemo/Source/Sample.cpp b/RecastDemo/Source/Sample.cpp index 2cafa9c63..3524efab8 100644 --- a/RecastDemo/Source/Sample.cpp +++ b/RecastDemo/Source/Sample.cpp @@ -66,23 +66,23 @@ unsigned int SampleDebugDraw::areaToCol(unsigned int area) } Sample::Sample() : - m_geom(0), - m_navMesh(0), - m_navQuery(0), - m_crowd(0), + m_geom(RC_NULL), + m_navMesh(RC_NULL), + m_navQuery(RC_NULL), + m_crowd(RC_NULL), m_navMeshDrawFlags(DU_DRAWNAVMESH_OFFMESHCONS|DU_DRAWNAVMESH_CLOSEDLIST), m_filterLowHangingObstacles(true), m_filterLedgeSpans(true), m_filterWalkableLowHeightSpans(true), - m_tool(0), - m_ctx(0) + m_tool(RC_NULL), + m_ctx(RC_NULL) { resetCommonSettings(); m_navQuery = dtAllocNavMeshQuery(); m_crowd = dtAllocCrowd(); for (int i = 0; i < MAX_TOOLS; i++) - m_toolStates[i] = 0; + m_toolStates[i] = RC_NULL; } Sample::~Sample() @@ -122,7 +122,7 @@ void Sample::handleRender() // Draw mesh duDebugDrawTriMesh(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(), - m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0, 1.0f); + m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), RC_NULL, 1.0f); // Draw bounds const float* bmin = m_geom->getMeshBoundsMin(); const float* bmax = m_geom->getMeshBoundsMax(); @@ -351,7 +351,7 @@ struct NavMeshTileHeader dtNavMesh* Sample::loadAll(const char* path) { FILE* fp = fopen(path, "rb"); - if (!fp) return 0; + if (!fp) return RC_NULL; // Read header. NavMeshSetHeader header; @@ -359,30 +359,30 @@ dtNavMesh* Sample::loadAll(const char* path) if (readLen != 1) { fclose(fp); - return 0; + return RC_NULL; } if (header.magic != NAVMESHSET_MAGIC) { fclose(fp); - return 0; + return RC_NULL; } if (header.version != NAVMESHSET_VERSION) { fclose(fp); - return 0; + return RC_NULL; } dtNavMesh* mesh = dtAllocNavMesh(); if (!mesh) { fclose(fp); - return 0; + return RC_NULL; } dtStatus status = mesh->init(&header.params); if (dtStatusFailed(status)) { fclose(fp); - return 0; + return RC_NULL; } // Read tiles. @@ -393,7 +393,7 @@ dtNavMesh* Sample::loadAll(const char* path) if (readLen != 1) { fclose(fp); - return 0; + return RC_NULL; } if (!tileHeader.tileRef || !tileHeader.dataSize) @@ -407,10 +407,10 @@ dtNavMesh* Sample::loadAll(const char* path) { dtFree(data); fclose(fp); - return 0; + return RC_NULL; } - mesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, 0); + mesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, RC_NULL); } fclose(fp); diff --git a/RecastDemo/Source/SampleInterfaces.cpp b/RecastDemo/Source/SampleInterfaces.cpp index 24f6ea120..d056eb237 100644 --- a/RecastDemo/Source/SampleInterfaces.cpp +++ b/RecastDemo/Source/SampleInterfaces.cpp @@ -261,7 +261,7 @@ void DebugDrawGL::end() //////////////////////////////////////////////////////////////////////////////////////////////////// FileIO::FileIO() : - m_fp(0), + m_fp(RC_NULL), m_mode(-1) { } diff --git a/RecastDemo/Source/Sample_Debug.cpp b/RecastDemo/Source/Sample_Debug.cpp index 6dc6c1418..69f699e7f 100644 --- a/RecastDemo/Source/Sample_Debug.cpp +++ b/RecastDemo/Source/Sample_Debug.cpp @@ -49,9 +49,9 @@ static int loadBin(const char* path, unsigned char** data) */ Sample_Debug::Sample_Debug() : - m_chf(0), - m_cset(0), - m_pmesh(0) + m_chf(RC_NULL), + m_cset(RC_NULL), + m_pmesh(RC_NULL) { resetCommonSettings(); @@ -334,7 +334,7 @@ const float* Sample_Debug::getBoundsMin() return m_chf->bmin; if (m_navMesh) return m_bmin; - return 0; + return RC_NULL; } const float* Sample_Debug::getBoundsMax() @@ -345,7 +345,7 @@ const float* Sample_Debug::getBoundsMax() return m_chf->bmax; if (m_navMesh) return m_bmax; - return 0; + return RC_NULL; } void Sample_Debug::handleClick(const float* s, const float* p, bool shift) @@ -366,7 +366,7 @@ bool Sample_Debug::handleBuild() if (m_chf) { rcFreeContourSet(m_cset); - m_cset = 0; + m_cset = RC_NULL; // Create contours. m_cset = rcAllocContourSet(); diff --git a/RecastDemo/Source/Sample_SoloMesh.cpp b/RecastDemo/Source/Sample_SoloMesh.cpp index 174a4e152..d7738db2b 100644 --- a/RecastDemo/Source/Sample_SoloMesh.cpp +++ b/RecastDemo/Source/Sample_SoloMesh.cpp @@ -45,12 +45,12 @@ Sample_SoloMesh::Sample_SoloMesh() : m_keepInterResults(true), m_totalBuildTimeMs(0), - m_triareas(0), - m_solid(0), - m_chf(0), - m_cset(0), - m_pmesh(0), - m_dmesh(0), + m_triareas(RC_NULL), + m_solid(RC_NULL), + m_chf(RC_NULL), + m_cset(RC_NULL), + m_pmesh(RC_NULL), + m_dmesh(RC_NULL), m_drawMode(DRAWMODE_NAVMESH) { setTool(new NavMeshTesterTool); @@ -64,19 +64,19 @@ Sample_SoloMesh::~Sample_SoloMesh() void Sample_SoloMesh::cleanup() { delete [] m_triareas; - m_triareas = 0; + m_triareas = RC_NULL; rcFreeHeightField(m_solid); - m_solid = 0; + m_solid = RC_NULL; rcFreeCompactHeightfield(m_chf); - m_chf = 0; + m_chf = RC_NULL; rcFreeContourSet(m_cset); - m_cset = 0; + m_cset = RC_NULL; rcFreePolyMesh(m_pmesh); - m_pmesh = 0; + m_pmesh = RC_NULL; rcFreePolyMeshDetail(m_dmesh); - m_dmesh = 0; + m_dmesh = RC_NULL; dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + m_navMesh = RC_NULL; } void Sample_SoloMesh::handleSettings() @@ -158,23 +158,23 @@ void Sample_SoloMesh::handleDebugMode() if (m_geom) { - valid[DRAWMODE_NAVMESH] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != 0; - valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != 0; + valid[DRAWMODE_NAVMESH] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != RC_NULL; + valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != RC_NULL; valid[DRAWMODE_MESH] = true; - valid[DRAWMODE_VOXELS] = m_solid != 0; - valid[DRAWMODE_VOXELS_WALKABLE] = m_solid != 0; - valid[DRAWMODE_COMPACT] = m_chf != 0; - valid[DRAWMODE_COMPACT_DISTANCE] = m_chf != 0; - valid[DRAWMODE_COMPACT_REGIONS] = m_chf != 0; - valid[DRAWMODE_REGION_CONNECTIONS] = m_cset != 0; - valid[DRAWMODE_RAW_CONTOURS] = m_cset != 0; - valid[DRAWMODE_BOTH_CONTOURS] = m_cset != 0; - valid[DRAWMODE_CONTOURS] = m_cset != 0; - valid[DRAWMODE_POLYMESH] = m_pmesh != 0; - valid[DRAWMODE_POLYMESH_DETAIL] = m_dmesh != 0; + valid[DRAWMODE_VOXELS] = m_solid != RC_NULL; + valid[DRAWMODE_VOXELS_WALKABLE] = m_solid != RC_NULL; + valid[DRAWMODE_COMPACT] = m_chf != RC_NULL; + valid[DRAWMODE_COMPACT_DISTANCE] = m_chf != RC_NULL; + valid[DRAWMODE_COMPACT_REGIONS] = m_chf != RC_NULL; + valid[DRAWMODE_REGION_CONNECTIONS] = m_cset != RC_NULL; + valid[DRAWMODE_RAW_CONTOURS] = m_cset != RC_NULL; + valid[DRAWMODE_BOTH_CONTOURS] = m_cset != RC_NULL; + valid[DRAWMODE_CONTOURS] = m_cset != RC_NULL; + valid[DRAWMODE_POLYMESH] = m_pmesh != RC_NULL; + valid[DRAWMODE_POLYMESH_DETAIL] = m_dmesh != RC_NULL; } int unavail = 0; @@ -355,7 +355,7 @@ void Sample_SoloMesh::handleMeshChanged(class InputGeom* geom) Sample::handleMeshChanged(geom); dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + m_navMesh = RC_NULL; if (m_tool) { @@ -462,7 +462,7 @@ bool Sample_SoloMesh::handleBuild() if (!m_keepInterResults) { delete [] m_triareas; - m_triareas = 0; + m_triareas = RC_NULL; } // @@ -502,7 +502,7 @@ bool Sample_SoloMesh::handleBuild() if (!m_keepInterResults) { rcFreeHeightField(m_solid); - m_solid = 0; + m_solid = RC_NULL; } // Erode the walkable area by agent radius. @@ -634,9 +634,9 @@ bool Sample_SoloMesh::handleBuild() if (!m_keepInterResults) { rcFreeCompactHeightfield(m_chf); - m_chf = 0; + m_chf = RC_NULL; rcFreeContourSet(m_cset); - m_cset = 0; + m_cset = RC_NULL; } // At this point the navigation mesh data is ready, you can access it from m_pmesh. @@ -650,7 +650,7 @@ bool Sample_SoloMesh::handleBuild() // Only build the detour navmesh if we do not exceed the limit. if (m_cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON) { - unsigned char* navData = 0; + unsigned char* navData = RC_NULL; int navDataSize = 0; // Update poly flags from areas. diff --git a/RecastDemo/Source/Sample_TempObstacles.cpp b/RecastDemo/Source/Sample_TempObstacles.cpp index 919ebb2d4..da3a66936 100644 --- a/RecastDemo/Source/Sample_TempObstacles.cpp +++ b/RecastDemo/Source/Sample_TempObstacles.cpp @@ -142,7 +142,7 @@ struct LinearAllocator : public dtTileCacheAlloc size_t top; size_t high; - LinearAllocator(const size_t cap) : buffer(0), capacity(0), top(0), high(0) + LinearAllocator(const size_t cap) : buffer(RC_NULL), capacity(0), top(0), high(0) { resize(cap); } @@ -165,9 +165,9 @@ struct LinearAllocator : public dtTileCacheAlloc virtual void* alloc(const size_t size) RC_OVERRIDE { if (!buffer) - return 0; + return RC_NULL; if (top+size > capacity) - return 0; + return RC_NULL; unsigned char* mem = &buffer[top]; top += size; return mem; @@ -189,7 +189,7 @@ struct MeshProcess : public dtTileCacheMeshProcess { InputGeom* m_geom; - inline MeshProcess() : m_geom(0) + inline MeshProcess() : m_geom(RC_NULL) { } @@ -255,10 +255,10 @@ struct TileCacheData struct RasterizationContext { RasterizationContext() : - solid(0), - triareas(0), - lset(0), - chf(0), + solid(RC_NULL), + triareas(RC_NULL), + lset(RC_NULL), + chf(RC_NULL), ntiles(0) { memset(tiles, 0, sizeof(TileCacheData)*MAX_LAYERS); @@ -273,7 +273,7 @@ struct RasterizationContext for (int i = 0; i < MAX_LAYERS; ++i) { dtFree(tiles[i].data); - tiles[i].data = 0; + tiles[i].data = RC_NULL; } } @@ -462,7 +462,7 @@ int Sample_TempObstacles::rasterizeTileLayers( for (int i = 0; i < rcMin(rc.ntiles, maxTiles); ++i) { tiles[n++] = rc.tiles[i]; - rc.tiles[i].data = 0; + rc.tiles[i].data = RC_NULL; rc.tiles[i].dataSize = 0; } @@ -514,16 +514,16 @@ static void drawDetail(duDebugDraw* dd, dtTileCache* tc, const int tx, const int { struct TileCacheBuildContext { - inline TileCacheBuildContext(struct dtTileCacheAlloc* a) : layer(0), lcset(0), lmesh(0), alloc(a) {} + inline TileCacheBuildContext(struct dtTileCacheAlloc* a) : layer(RC_NULL), lcset(RC_NULL), lmesh(RC_NULL), alloc(a) {} inline ~TileCacheBuildContext() { purge(); } void purge() { dtFreeTileCacheLayer(alloc, layer); - layer = 0; + layer = RC_NULL; dtFreeTileCacheContourSet(alloc, lcset); - lcset = 0; + lcset = RC_NULL; dtFreeTileCachePolyMesh(alloc, lmesh); - lmesh = 0; + lmesh = RC_NULL; } struct dtTileCacheLayer* layer; struct dtTileCacheContourSet* lcset; @@ -635,7 +635,7 @@ static void drawDetailOverlay(const dtTileCache* tc, const int tx, const int ty, static dtObstacleRef hitTestObstacle(const dtTileCache* tc, const float* sp, const float* sq) { float tmin = FLT_MAX; - const dtTileCacheObstacle* obmin = 0; + const dtTileCacheObstacle* obmin = RC_NULL; for (int i = 0; i < tc->getObstacleCount(); ++i) { const dtTileCacheObstacle* ob = tc->getObstacle(i); @@ -690,7 +690,7 @@ class TempObstacleHilightTool : public SampleTool public: TempObstacleHilightTool() : - m_sample(0), + m_sample(RC_NULL), m_hitPosSet(false), m_drawType(DRAWDETAIL_AREAS) { @@ -783,7 +783,7 @@ class TempObstacleCreateTool : public SampleTool public: - TempObstacleCreateTool() : m_sample(0) + TempObstacleCreateTool() : m_sample(RC_NULL) { } @@ -836,7 +836,7 @@ TempObstacleCreateTool::~TempObstacleCreateTool() Sample_TempObstacles::Sample_TempObstacles() : m_keepInterResults(false), - m_tileCache(0), + m_tileCache(RC_NULL), m_cacheBuildTimeMs(0), m_cacheCompressedSize(0), m_cacheRawSize(0), @@ -859,7 +859,7 @@ Sample_TempObstacles::Sample_TempObstacles() : Sample_TempObstacles::~Sample_TempObstacles() { dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + m_navMesh = RC_NULL; dtFreeTileCache(m_tileCache); } @@ -997,12 +997,12 @@ void Sample_TempObstacles::handleDebugMode() if (m_geom) { - valid[DRAWMODE_NAVMESH] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != 0; - valid[DRAWMODE_NAVMESH_PORTALS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != 0; + valid[DRAWMODE_NAVMESH] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != RC_NULL; + valid[DRAWMODE_NAVMESH_PORTALS] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != RC_NULL; valid[DRAWMODE_MESH] = true; valid[DRAWMODE_CACHE_BOUNDS] = true; } @@ -1157,10 +1157,10 @@ void Sample_TempObstacles::handleMeshChanged(class InputGeom* geom) Sample::handleMeshChanged(geom); dtFreeTileCache(m_tileCache); - m_tileCache = 0; + m_tileCache = RC_NULL; dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + m_navMesh = RC_NULL; if (m_tool) { @@ -1179,7 +1179,7 @@ void Sample_TempObstacles::addTempObstacle(const float* pos) float p[3]; dtVcopy(p, pos); p[1] -= 0.5f; - m_tileCache->addObstacle(p, 1.0f, 2.0f, 0); + m_tileCache->addObstacle(p, 1.0f, 2.0f, RC_NULL); } void Sample_TempObstacles::removeTempObstacle(const float* sp, const float* sq) @@ -1327,11 +1327,11 @@ bool Sample_TempObstacles::handleBuild() for (int i = 0; i < ntiles; ++i) { TileCacheData* tile = &tiles[i]; - status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, 0); + status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, RC_NULL); if (dtStatusFailed(status)) { dtFree(tile->data); - tile->data = 0; + tile->data = RC_NULL; continue; } diff --git a/RecastDemo/Source/Sample_TileMesh.cpp b/RecastDemo/Source/Sample_TileMesh.cpp index 78ad9a00b..bbf4303c6 100644 --- a/RecastDemo/Source/Sample_TileMesh.cpp +++ b/RecastDemo/Source/Sample_TileMesh.cpp @@ -80,7 +80,7 @@ class NavMeshTileTool : public SampleTool public: NavMeshTileTool() : - m_sample(0), + m_sample(RC_NULL), m_hitPosSet(false) { m_hitPos[0] = m_hitPos[1] = m_hitPos[2] = 0; @@ -178,12 +178,12 @@ Sample_TileMesh::Sample_TileMesh() : m_keepInterResults(false), m_buildAll(true), m_totalBuildTimeMs(0), - m_triareas(0), - m_solid(0), - m_chf(0), - m_cset(0), - m_pmesh(0), - m_dmesh(0), + m_triareas(RC_NULL), + m_solid(RC_NULL), + m_chf(RC_NULL), + m_cset(RC_NULL), + m_pmesh(RC_NULL), + m_dmesh(RC_NULL), m_drawMode(DRAWMODE_NAVMESH), m_maxTiles(0), m_maxPolysPerTile(0), @@ -204,23 +204,23 @@ Sample_TileMesh::~Sample_TileMesh() { cleanup(); dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + m_navMesh = RC_NULL; } void Sample_TileMesh::cleanup() { delete [] m_triareas; - m_triareas = 0; + m_triareas = RC_NULL; rcFreeHeightField(m_solid); - m_solid = 0; + m_solid = RC_NULL; rcFreeCompactHeightfield(m_chf); - m_chf = 0; + m_chf = RC_NULL; rcFreeContourSet(m_cset); - m_cset = 0; + m_cset = RC_NULL; rcFreePolyMesh(m_pmesh); - m_pmesh = 0; + m_pmesh = RC_NULL; rcFreePolyMeshDetail(m_dmesh); - m_dmesh = 0; + m_dmesh = RC_NULL; } void Sample_TileMesh::handleSettings() @@ -345,24 +345,24 @@ void Sample_TileMesh::handleDebugMode() if (m_geom) { - valid[DRAWMODE_NAVMESH] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != 0; - valid[DRAWMODE_NAVMESH_PORTALS] = m_navMesh != 0; - valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != 0; + valid[DRAWMODE_NAVMESH] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_TRANS] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_BVTREE] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_NODES] = m_navQuery != RC_NULL; + valid[DRAWMODE_NAVMESH_PORTALS] = m_navMesh != RC_NULL; + valid[DRAWMODE_NAVMESH_INVIS] = m_navMesh != RC_NULL; valid[DRAWMODE_MESH] = true; - valid[DRAWMODE_VOXELS] = m_solid != 0; - valid[DRAWMODE_VOXELS_WALKABLE] = m_solid != 0; - valid[DRAWMODE_COMPACT] = m_chf != 0; - valid[DRAWMODE_COMPACT_DISTANCE] = m_chf != 0; - valid[DRAWMODE_COMPACT_REGIONS] = m_chf != 0; - valid[DRAWMODE_REGION_CONNECTIONS] = m_cset != 0; - valid[DRAWMODE_RAW_CONTOURS] = m_cset != 0; - valid[DRAWMODE_BOTH_CONTOURS] = m_cset != 0; - valid[DRAWMODE_CONTOURS] = m_cset != 0; - valid[DRAWMODE_POLYMESH] = m_pmesh != 0; - valid[DRAWMODE_POLYMESH_DETAIL] = m_dmesh != 0; + valid[DRAWMODE_VOXELS] = m_solid != RC_NULL; + valid[DRAWMODE_VOXELS_WALKABLE] = m_solid != RC_NULL; + valid[DRAWMODE_COMPACT] = m_chf != RC_NULL; + valid[DRAWMODE_COMPACT_DISTANCE] = m_chf != RC_NULL; + valid[DRAWMODE_COMPACT_REGIONS] = m_chf != RC_NULL; + valid[DRAWMODE_REGION_CONNECTIONS] = m_cset != RC_NULL; + valid[DRAWMODE_RAW_CONTOURS] = m_cset != RC_NULL; + valid[DRAWMODE_BOTH_CONTOURS] = m_cset != RC_NULL; + valid[DRAWMODE_CONTOURS] = m_cset != RC_NULL; + valid[DRAWMODE_POLYMESH] = m_pmesh != RC_NULL; + valid[DRAWMODE_POLYMESH_DETAIL] = m_dmesh != RC_NULL; } int unavail = 0; @@ -575,7 +575,7 @@ void Sample_TileMesh::handleMeshChanged(InputGeom* geom) cleanup(); dtFreeNavMesh(m_navMesh); - m_navMesh = 0; + m_navMesh = RC_NULL; if (m_tool) { @@ -671,13 +671,13 @@ void Sample_TileMesh::buildTile(const float* pos) unsigned char* data = buildTileMesh(tx, ty, m_lastBuiltTileBmin, m_lastBuiltTileBmax, dataSize); // Remove any previous data (navmesh owns and deletes the data). - m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),0,0); + m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),RC_NULL,RC_NULL); // Add tile, or leave the location empty. if (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,RC_NULL); if (dtStatusFailed(status)) dtFree(data); } @@ -718,7 +718,7 @@ void Sample_TileMesh::removeTile(const float* pos) m_tileCol = duRGBA(128,32,16,64); - m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),0,0); + m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),RC_NULL,RC_NULL); } void Sample_TileMesh::buildAllTiles() @@ -756,9 +756,9 @@ void Sample_TileMesh::buildAllTiles() if (data) { // Remove any previous data (navmesh owns and deletes the data). - m_navMesh->removeTile(m_navMesh->getTileRefAt(x,y,0),0,0); + m_navMesh->removeTile(m_navMesh->getTileRefAt(x,y,0),RC_NULL,RC_NULL); // 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,RC_NULL); if (dtStatusFailed(status)) dtFree(data); } @@ -787,7 +787,7 @@ void Sample_TileMesh::removeAllTiles() for (int y = 0; y < th; ++y) for (int x = 0; x < tw; ++x) - m_navMesh->removeTile(m_navMesh->getTileRefAt(x,y,0),0,0); + m_navMesh->removeTile(m_navMesh->getTileRefAt(x,y,0),RC_NULL,RC_NULL); } @@ -796,7 +796,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_geom || !m_geom->getMesh() || !m_geom->getChunkyMesh()) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Input mesh is not specified."); - return 0; + return RC_NULL; } m_tileMemUsage = 0; @@ -872,12 +872,12 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_solid) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'."); - return 0; + return RC_NULL; } if (!rcCreateHeightfield(m_ctx, *m_solid, m_cfg.width, m_cfg.height, m_cfg.bmin, m_cfg.bmax, m_cfg.cs, m_cfg.ch)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not create solid heightfield."); - return 0; + return RC_NULL; } // Allocate array that can hold triangle flags. @@ -887,7 +887,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_triareas) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk); - return 0; + return RC_NULL; } float tbmin[2], tbmax[2]; @@ -898,7 +898,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const int cid[512];// TODO: Make grow when returning too many items. const int ncid = rcGetChunksOverlappingRect(chunkyMesh, tbmin, tbmax, cid, 512); if (!ncid) - return 0; + return RC_NULL; m_tileTriCount = 0; @@ -915,13 +915,13 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const verts, nverts, ctris, nctris, m_triareas); if (!rcRasterizeTriangles(m_ctx, verts, nverts, ctris, m_triareas, nctris, *m_solid, m_cfg.walkableClimb)) - return 0; + return RC_NULL; } if (!m_keepInterResults) { delete [] m_triareas; - m_triareas = 0; + m_triareas = RC_NULL; } // Once all geometry is rasterized, we do initial pass of filtering to @@ -941,25 +941,25 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_chf) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'."); - return 0; + return RC_NULL; } if (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data."); - return 0; + return RC_NULL; } if (!m_keepInterResults) { rcFreeHeightField(m_solid); - m_solid = 0; + m_solid = RC_NULL; } // Erode the walkable area by agent radius. if (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode."); - return 0; + return RC_NULL; } // (Optional) Mark areas. @@ -1000,14 +1000,14 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!rcBuildDistanceField(m_ctx, *m_chf)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field."); - return 0; + return RC_NULL; } // Partition the walkable surface into simple regions without holes. if (!rcBuildRegions(m_ctx, *m_chf, m_cfg.borderSize, m_cfg.minRegionArea, m_cfg.mergeRegionArea)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build watershed regions."); - return 0; + return RC_NULL; } } else if (m_partitionType == SAMPLE_PARTITION_MONOTONE) @@ -1017,7 +1017,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!rcBuildRegionsMonotone(m_ctx, *m_chf, m_cfg.borderSize, m_cfg.minRegionArea, m_cfg.mergeRegionArea)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build monotone regions."); - return 0; + return RC_NULL; } } else // SAMPLE_PARTITION_LAYERS @@ -1026,7 +1026,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!rcBuildLayerRegions(m_ctx, *m_chf, m_cfg.borderSize, m_cfg.minRegionArea)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build layer regions."); - return 0; + return RC_NULL; } } @@ -1035,17 +1035,17 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_cset) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'."); - return 0; + return RC_NULL; } if (!rcBuildContours(m_ctx, *m_chf, m_cfg.maxSimplificationError, m_cfg.maxEdgeLen, *m_cset)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not create contours."); - return 0; + return RC_NULL; } if (m_cset->nconts == 0) { - return 0; + return RC_NULL; } // Build polygon navmesh from the contours. @@ -1053,12 +1053,12 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_pmesh) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'."); - return 0; + return RC_NULL; } if (!rcBuildPolyMesh(m_ctx, *m_cset, m_cfg.maxVertsPerPoly, *m_pmesh)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not triangulate contours."); - return 0; + return RC_NULL; } // Build detail mesh. @@ -1066,7 +1066,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!m_dmesh) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'dmesh'."); - return 0; + return RC_NULL; } if (!rcBuildPolyMeshDetail(m_ctx, *m_pmesh, *m_chf, @@ -1074,18 +1074,18 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const *m_dmesh)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could build polymesh detail."); - return 0; + return RC_NULL; } if (!m_keepInterResults) { rcFreeCompactHeightfield(m_chf); - m_chf = 0; + m_chf = RC_NULL; rcFreeContourSet(m_cset); - m_cset = 0; + m_cset = RC_NULL; } - unsigned char* navData = 0; + unsigned char* navData = RC_NULL; int navDataSize = 0; if (m_cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON) { @@ -1093,7 +1093,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const { // The vertex indices are ushorts, and cannot point to more than 0xffff vertices. m_ctx->log(RC_LOG_ERROR, "Too many vertices per tile %d (max: %d).", m_pmesh->nverts, 0xffff); - return 0; + return RC_NULL; } // Update poly flags from areas. @@ -1154,7 +1154,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const if (!dtCreateNavMeshData(¶ms, &navData, &navDataSize)) { m_ctx->log(RC_LOG_ERROR, "Could not build Detour navmesh."); - return 0; + return RC_NULL; } } m_tileMemUsage = navDataSize/1024.0f; diff --git a/RecastDemo/Source/TestCase.cpp b/RecastDemo/Source/TestCase.cpp index 5ce42623f..dbcfb9eca 100644 --- a/RecastDemo/Source/TestCase.cpp +++ b/RecastDemo/Source/TestCase.cpp @@ -39,7 +39,7 @@ #endif TestCase::TestCase() : - m_tests(0) + m_tests(RC_NULL) { } @@ -99,7 +99,7 @@ static void copyName(std::string& dst, const char* src) bool TestCase::load(const std::string& filePath) { - char* buf = 0; + char* buf = RC_NULL; FILE* fp = fopen(filePath.c_str(), "rb"); if (!fp) return false; @@ -209,10 +209,10 @@ void TestCase::doTests(dtNavMesh* navmesh, dtNavMeshQuery* navquery) for (Test* iter = m_tests; iter; iter = iter->next) { delete [] iter->polys; - iter->polys = 0; + iter->polys = RC_NULL; iter->npolys = 0; delete [] iter->straight; - iter->straight = 0; + iter->straight = RC_NULL; iter->nstraight = 0; dtQueryFilter filter; @@ -248,7 +248,7 @@ void TestCase::doTests(dtNavMesh* navmesh, dtNavMeshQuery* navquery) TimeVal findStraightPathStart = getPerfTime(); navquery->findStraightPath(iter->spos, iter->epos, polys, iter->npolys, - straight, 0, 0, &iter->nstraight, MAX_POLYS); + straight, RC_NULL, RC_NULL, &iter->nstraight, MAX_POLYS); TimeVal findStraightPathEnd = getPerfTime(); iter->findStraightPathTime += getPerfTimeUsec(findStraightPathEnd - findStraightPathStart); } diff --git a/RecastDemo/Source/imgui.cpp b/RecastDemo/Source/imgui.cpp index 840220123..3b65ff839 100644 --- a/RecastDemo/Source/imgui.cpp +++ b/RecastDemo/Source/imgui.cpp @@ -20,6 +20,7 @@ #include #include #include "imgui.h" +#include "RecastModernCpp.h" #ifdef WIN32 # define snprintf _snprintf @@ -34,7 +35,7 @@ static const char* allocText(const char* text) { unsigned len = static_cast(strlen(text)+1); if (g_textPoolSize + len >= TEXT_POOL_SIZE) - return 0; + return RC_NULL; char* dst = &g_textPool[g_textPoolSize]; memcpy(dst, text, len); g_textPoolSize += len; @@ -314,7 +315,7 @@ static int g_scrollTop = 0; static int g_scrollBottom = 0; static int g_scrollRight = 0; static int g_scrollAreaTop = 0; -static int* g_scrollVal = 0; +static int* g_scrollVal = RC_NULL; static int g_focusTop = 0; static int g_focusBottom = 0; static unsigned int g_scrollId = 0; diff --git a/RecastDemo/Source/imguiRenderGL.cpp b/RecastDemo/Source/imguiRenderGL.cpp index 0d0eeb938..f9d0a9fa4 100644 --- a/RecastDemo/Source/imguiRenderGL.cpp +++ b/RecastDemo/Source/imguiRenderGL.cpp @@ -22,6 +22,7 @@ #include "SDL.h" #include "SDL_opengl.h" #include "imguiRenderGL.h" +#include "RecastModernCpp.h" // Some math headers don't have PI defined. static const float PI = 3.14159265f; @@ -279,7 +280,7 @@ bool imguiRenderGLInit(const char* fontpath) return false; } - fp = 0; + fp = RC_NULL; unsigned char* bmap = (unsigned char*)malloc(512*512); if (!bmap) diff --git a/RecastDemo/Source/main.cpp b/RecastDemo/Source/main.cpp index 0e33b278c..4d00f2855 100644 --- a/RecastDemo/Source/main.cpp +++ b/RecastDemo/Source/main.cpp @@ -174,11 +174,11 @@ int main(int /*argc*/, char** /*argv*/) float markerPosition[3] = {0, 0, 0}; bool markerPositionSet = false; - InputGeom* geom = 0; - Sample* sample = 0; + InputGeom* geom = RC_NULL; + Sample* sample = RC_NULL; const string testCasesFolder = "TestCases"; - TestCase* test = 0; + TestCase* test = RC_NULL; BuildContext ctx; @@ -344,9 +344,9 @@ int main(int /*argc*/, char** /*argv*/) } unsigned char mouseButtonMask = 0; - if (SDL_GetMouseState(0, 0) & SDL_BUTTON_LMASK) + if (SDL_GetMouseState(RC_NULL, RC_NULL) & SDL_BUTTON_LMASK) mouseButtonMask |= IMGUI_MBUT_LEFT; - if (SDL_GetMouseState(0, 0) & SDL_BUTTON_RMASK) + if (SDL_GetMouseState(RC_NULL, RC_NULL) & SDL_BUTTON_RMASK) mouseButtonMask |= IMGUI_MBUT_RIGHT; Uint32 time = SDL_GetTicks(); @@ -453,7 +453,7 @@ int main(int /*argc*/, char** /*argv*/) rayEnd[2] = (float)z; // Handle keyboard movement. - const Uint8* keystate = SDL_GetKeyboardState(NULL); + const Uint8* keystate = SDL_GetKeyboardState(RC_NULL); moveFront = rcClamp(moveFront + dt * 4 * ((keystate[SDL_SCANCODE_W] || keystate[SDL_SCANCODE_UP ]) ? 1 : -1), 0.0f, 1.0f); moveLeft = rcClamp(moveLeft + dt * 4 * ((keystate[SDL_SCANCODE_A] || keystate[SDL_SCANCODE_LEFT ]) ? 1 : -1), 0.0f, 1.0f); moveBack = rcClamp(moveBack + dt * 4 * ((keystate[SDL_SCANCODE_S] || keystate[SDL_SCANCODE_DOWN ]) ? 1 : -1), 0.0f, 1.0f); @@ -590,7 +590,7 @@ int main(int /*argc*/, char** /*argv*/) // Clear test. delete test; - test = 0; + test = RC_NULL; } imguiSeparator(); @@ -612,7 +612,7 @@ int main(int /*argc*/, char** /*argv*/) if (imguiBeginScrollArea("Choose Sample", width-10-250-10-200, height-10-250, 200, 250, &levelScroll)) mouseOverMenu = true; - Sample* newSample = 0; + Sample* newSample = RC_NULL; for (int i = 0; i < g_nsamples; ++i) { if (imguiItem(g_samples[i].name.c_str())) @@ -636,8 +636,8 @@ int main(int /*argc*/, char** /*argv*/) if (geom || sample) { - const float* bmin = 0; - const float* bmax = 0; + const float* bmin = RC_NULL; + const float* bmax = RC_NULL; if (geom) { bmin = geom->getNavMeshBoundsMin(); @@ -687,7 +687,7 @@ int main(int /*argc*/, char** /*argv*/) showLevels = false; delete geom; - geom = 0; + geom = RC_NULL; string path = meshesFolder + "/" + meshName; @@ -695,13 +695,13 @@ int main(int /*argc*/, char** /*argv*/) if (!geom->load(&ctx, path)) { delete geom; - geom = 0; + geom = RC_NULL; // Destroy the sample if it already had geometry loaded, as we've just deleted it! if (sample && sample->getInputGeom()) { delete sample; - sample = 0; + sample = RC_NULL; } showLog = true; @@ -715,8 +715,8 @@ int main(int /*argc*/, char** /*argv*/) if (geom || sample) { - const float* bmin = 0; - const float* bmax = 0; + const float* bmin = RC_NULL; + const float* bmax = RC_NULL; if (geom) { bmin = geom->getNavMeshBoundsMin(); @@ -772,11 +772,11 @@ int main(int /*argc*/, char** /*argv*/) if (!test->load(path)) { delete test; - test = 0; + test = RC_NULL; } // Create sample - Sample* newSample = 0; + Sample* newSample = RC_NULL; for (int i = 0; i < g_nsamples; ++i) { if (g_samples[i].name == test->getSampleName()) @@ -807,9 +807,9 @@ int main(int /*argc*/, char** /*argv*/) if (!geom || !geom->load(&ctx, path)) { delete geom; - geom = 0; + geom = RC_NULL; delete sample; - sample = 0; + sample = RC_NULL; showLog = true; logScroll = 0; ctx.dumpLog("Geom load log %s:", meshName.c_str()); @@ -831,8 +831,8 @@ int main(int /*argc*/, char** /*argv*/) if (geom || sample) { - const float* bmin = 0; - const float* bmax = 0; + const float* bmin = RC_NULL; + const float* bmax = RC_NULL; if (geom) { bmin = geom->getNavMeshBoundsMin();