mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: make assert and allocation code shared
All recast/detour allocation and assertion code were identical, with the exception of their names (rc* for recast, dt* for detour). We want to use Recast's rcVectorBase class in Detour code, as there is no Detour equivalent, but copying it in its whole isn't good practice (especially considering there is more boilerplate code we want to get rid of in the future). Moved these to Shared so Detour could use it as well under the name rdVectorBase (rd stands for Recast Detour). No changes to the logic of the code were made in this patch.
This commit is contained in:
parent
8b8e193348
commit
fa8d89d287
@ -113,7 +113,7 @@ CrowdToolState::CrowdToolState() :
|
||||
|
||||
memset(m_trails, 0, sizeof(m_trails));
|
||||
|
||||
m_vod = dtAllocObstacleAvoidanceDebugData();
|
||||
m_vod = rdAllocObstacleAvoidanceDebugData();
|
||||
m_vod->init(2048);
|
||||
|
||||
memset(&m_agentDebug, 0, sizeof(m_agentDebug));
|
||||
@ -123,7 +123,7 @@ CrowdToolState::CrowdToolState() :
|
||||
|
||||
CrowdToolState::~CrowdToolState()
|
||||
{
|
||||
dtFreeObstacleAvoidanceDebugData(m_vod);
|
||||
rdFreeObstacleAvoidanceDebugData(m_vod);
|
||||
}
|
||||
|
||||
void CrowdToolState::init(class Editor* editor)
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "Pch.h"
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include "Detour/Include/DetourNavMesh.h"
|
||||
#include "Detour/Include/DetourNavMeshQuery.h"
|
||||
#include "DetourCrowd/Include/DetourCrowd.h"
|
||||
@ -63,8 +63,8 @@ Editor::Editor() :
|
||||
m_ctx(0)
|
||||
{
|
||||
resetCommonSettings();
|
||||
m_navQuery = dtAllocNavMeshQuery();
|
||||
m_crowd = dtAllocCrowd();
|
||||
m_navQuery = rdAllocNavMeshQuery();
|
||||
m_crowd = rdAllocCrowd();
|
||||
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
m_toolStates[i] = 0;
|
||||
@ -72,9 +72,9 @@ Editor::Editor() :
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
dtFreeNavMeshQuery(m_navQuery);
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
dtFreeCrowd(m_crowd);
|
||||
rdFreeNavMeshQuery(m_navQuery);
|
||||
rdFreeNavMesh(m_navMesh);
|
||||
rdFreeCrowd(m_crowd);
|
||||
delete m_tool;
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
delete m_toolStates[i];
|
||||
@ -349,7 +349,7 @@ dtNavMesh* Editor::loadAll(std::string path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
dtNavMesh* mesh = dtAllocNavMesh();
|
||||
dtNavMesh* mesh = rdAllocNavMesh();
|
||||
if (!mesh)
|
||||
{
|
||||
fclose(fp);
|
||||
@ -378,7 +378,7 @@ dtNavMesh* Editor::loadAll(std::string path)
|
||||
if (!tileHeader.tileRef || !tileHeader.dataSize)
|
||||
break;
|
||||
|
||||
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
|
||||
unsigned char* data = (unsigned char*)rdAlloc(tileHeader.dataSize, RD_ALLOC_PERM);
|
||||
if (!data)
|
||||
break;
|
||||
|
||||
@ -387,7 +387,7 @@ dtNavMesh* Editor::loadAll(std::string path)
|
||||
|
||||
if (readLen != 1)
|
||||
{
|
||||
dtFree(data);
|
||||
rdFree(data);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
@ -400,7 +400,7 @@ dtNavMesh* Editor::loadAll(std::string path)
|
||||
{
|
||||
for (int i = 0; i < header.params.reachabilityTableCount; i++)
|
||||
{
|
||||
int* reachabilityTable = (int*)dtAlloc(header.params.reachabilityTableSize, DT_ALLOC_PERM);
|
||||
int* reachabilityTable = (int*)rdAlloc(header.params.reachabilityTableSize, RD_ALLOC_PERM);
|
||||
if (!reachabilityTable)
|
||||
break;
|
||||
|
||||
@ -409,7 +409,7 @@ dtNavMesh* Editor::loadAll(std::string path)
|
||||
|
||||
if (readLen != 1)
|
||||
{
|
||||
dtFree(reachabilityTable);
|
||||
rdFree(reachabilityTable);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
@ -476,12 +476,12 @@ void Editor::saveAll(std::string path, const dtNavMesh* mesh)
|
||||
// Only store if we have 3 or more poly groups.
|
||||
if (mesh->m_params.disjointPolyGroupCount >= DT_MIN_POLY_GROUP_COUNT)
|
||||
{
|
||||
dtAssert(mesh->m_setTables);
|
||||
rdAssert(mesh->m_setTables);
|
||||
|
||||
for (int i = 0; i < header.params.reachabilityTableCount; i++)
|
||||
{
|
||||
const int* const tableData = mesh->m_setTables[i];
|
||||
dtAssert(tableData);
|
||||
rdAssert(tableData);
|
||||
|
||||
fwrite(tableData, sizeof(int), (header.params.reachabilityTableSize/4), fp);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ Editor_Debug::Editor_Debug() :
|
||||
resetCommonSettings();
|
||||
|
||||
// Test
|
||||
/* m_chf = rcAllocCompactHeightfield();
|
||||
/* m_chf = rdAllocCompactHeightfield();
|
||||
FileIO io;
|
||||
if (!io.openForRead("test.chf"))
|
||||
{
|
||||
@ -125,7 +125,7 @@ Editor_Debug::Editor_Debug() :
|
||||
|
||||
|
||||
{
|
||||
m_cset = rcAllocContourSet();
|
||||
m_cset = rdAllocContourSet();
|
||||
if (m_cset)
|
||||
{
|
||||
FileIO io;
|
||||
@ -151,7 +151,7 @@ Editor_Debug::Editor_Debug() :
|
||||
|
||||
/* if (m_cset)
|
||||
{
|
||||
m_pmesh = rcAllocPolyMesh();
|
||||
m_pmesh = rdAllocPolyMesh();
|
||||
if (m_pmesh)
|
||||
{
|
||||
rcBuildPolyMesh(m_ctx, *m_cset, 6, *m_pmesh);
|
||||
@ -163,9 +163,9 @@ Editor_Debug::Editor_Debug() :
|
||||
|
||||
Editor_Debug::~Editor_Debug()
|
||||
{
|
||||
rcFreeCompactHeightfield(m_chf);
|
||||
rcFreeContourSet(m_cset);
|
||||
rcFreePolyMesh(m_pmesh);
|
||||
rdFreeCompactHeightfield(m_chf);
|
||||
rdFreeContourSet(m_cset);
|
||||
rdFreePolyMesh(m_pmesh);
|
||||
}
|
||||
|
||||
void Editor_Debug::handleSettings()
|
||||
@ -357,11 +357,11 @@ bool Editor_Debug::handleBuild()
|
||||
|
||||
if (m_chf)
|
||||
{
|
||||
rcFreeContourSet(m_cset);
|
||||
rdFreeContourSet(m_cset);
|
||||
m_cset = 0;
|
||||
|
||||
// Create contours.
|
||||
m_cset = rcAllocContourSet();
|
||||
m_cset = rdAllocContourSet();
|
||||
if (!m_cset)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'.");
|
||||
|
@ -189,7 +189,7 @@ Editor_TileMesh::Editor_TileMesh() :
|
||||
Editor_TileMesh::~Editor_TileMesh()
|
||||
{
|
||||
cleanup();
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
rdFreeNavMesh(m_navMesh);
|
||||
m_navMesh = 0;
|
||||
}
|
||||
|
||||
@ -197,15 +197,15 @@ void Editor_TileMesh::cleanup()
|
||||
{
|
||||
delete [] m_triareas;
|
||||
m_triareas = 0;
|
||||
rcFreeHeightField(m_solid);
|
||||
rdFreeHeightField(m_solid);
|
||||
m_solid = 0;
|
||||
rcFreeCompactHeightfield(m_chf);
|
||||
rdFreeCompactHeightfield(m_chf);
|
||||
m_chf = 0;
|
||||
rcFreeContourSet(m_cset);
|
||||
rdFreeContourSet(m_cset);
|
||||
m_cset = 0;
|
||||
rcFreePolyMesh(m_pmesh);
|
||||
rdFreePolyMesh(m_pmesh);
|
||||
m_pmesh = 0;
|
||||
rcFreePolyMeshDetail(m_dmesh);
|
||||
rdFreePolyMeshDetail(m_dmesh);
|
||||
m_dmesh = 0;
|
||||
}
|
||||
const hulldef hulls[5] = {
|
||||
@ -277,7 +277,7 @@ void Editor_TileMesh::handleSettings()
|
||||
|
||||
if (imguiButton("Load"))
|
||||
{
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
rdFreeNavMesh(m_navMesh);
|
||||
m_navMesh = Editor::loadAll(m_modelName.c_str());
|
||||
m_navQuery->init(m_navMesh, 2048);
|
||||
}
|
||||
@ -577,7 +577,7 @@ void Editor_TileMesh::handleMeshChanged(InputGeom* geom)
|
||||
|
||||
cleanup();
|
||||
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
rdFreeNavMesh(m_navMesh);
|
||||
m_navMesh = 0;
|
||||
|
||||
if (m_tool)
|
||||
@ -597,9 +597,9 @@ bool Editor_TileMesh::handleBuild()
|
||||
return false;
|
||||
}
|
||||
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
rdFreeNavMesh(m_navMesh);
|
||||
|
||||
m_navMesh = dtAllocNavMesh();
|
||||
m_navMesh = rdAllocNavMesh();
|
||||
if (!m_navMesh)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildTiledNavigation: Could not allocate navmesh.");
|
||||
@ -678,7 +678,7 @@ void Editor_TileMesh::buildTile(const float* pos)
|
||||
// Let the navmesh own the data.
|
||||
dtStatus status = m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0);
|
||||
if (dtStatusFailed(status))
|
||||
dtFree(data);
|
||||
rdFree(data);
|
||||
}
|
||||
|
||||
m_ctx->dumpLog("Build Tile (%d,%d):", tx,ty);
|
||||
@ -754,7 +754,7 @@ void Editor_TileMesh::buildAllTiles()
|
||||
// Let the navmesh own the data.
|
||||
dtStatus status = m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA,0,0);
|
||||
if (dtStatusFailed(status))
|
||||
dtFree(data);
|
||||
rdFree(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -886,7 +886,7 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
m_ctx->log(RC_LOG_PROGRESS, " - %.1fK verts, %.1fK tris", nverts/1000.0f, ntris/1000.0f);
|
||||
|
||||
// Allocate voxel heightfield where we rasterize our input data to.
|
||||
m_solid = rcAllocHeightfield();
|
||||
m_solid = rdAllocHeightfield();
|
||||
if (!m_solid)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'solid'.");
|
||||
@ -984,7 +984,7 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
// Compact the heightfield so that it is faster to handle from now on.
|
||||
// This will result more cache coherent data as well as the neighbours
|
||||
// between walkable cells will be calculated.
|
||||
m_chf = rcAllocCompactHeightfield();
|
||||
m_chf = rdAllocCompactHeightfield();
|
||||
if (!m_chf)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
|
||||
@ -998,7 +998,7 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
|
||||
if (!m_keepInterResults)
|
||||
{
|
||||
rcFreeHeightField(m_solid);
|
||||
rdFreeHeightField(m_solid);
|
||||
m_solid = 0;
|
||||
}
|
||||
|
||||
@ -1078,7 +1078,7 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
}
|
||||
|
||||
// Create contours.
|
||||
m_cset = rcAllocContourSet();
|
||||
m_cset = rdAllocContourSet();
|
||||
if (!m_cset)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'cset'.");
|
||||
@ -1096,7 +1096,7 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
}
|
||||
|
||||
// Build polygon navmesh from the contours.
|
||||
m_pmesh = rcAllocPolyMesh();
|
||||
m_pmesh = rdAllocPolyMesh();
|
||||
if (!m_pmesh)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'pmesh'.");
|
||||
@ -1109,7 +1109,7 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
}
|
||||
|
||||
// Build detail mesh.
|
||||
m_dmesh = rcAllocPolyMeshDetail();
|
||||
m_dmesh = rdAllocPolyMeshDetail();
|
||||
if (!m_dmesh)
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'dmesh'.");
|
||||
@ -1128,9 +1128,9 @@ unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
//rcFlipPolyMeshDetail(*m_dmesh,m_pmesh->nverts);
|
||||
if (!m_keepInterResults)
|
||||
{
|
||||
rcFreeCompactHeightfield(m_chf);
|
||||
rdFreeCompactHeightfield(m_chf);
|
||||
m_chf = 0;
|
||||
rcFreeContourSet(m_cset);
|
||||
rdFreeContourSet(m_cset);
|
||||
m_cset = 0;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "Pch.h"
|
||||
#include "Detour/Include/DetourNavMesh.h"
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "DebugUtils/Include/DetourDebugDraw.h"
|
||||
#include "NavEditor/Include/NavMeshPruneTool.h"
|
||||
#include "NavEditor/Include/InputGeom.h"
|
||||
@ -33,7 +32,7 @@ class NavmeshFlags
|
||||
{
|
||||
struct TileFlags
|
||||
{
|
||||
inline void purge() { dtFree(flags); }
|
||||
inline void purge() { rdFree(flags); }
|
||||
unsigned char* flags;
|
||||
int nflags;
|
||||
dtPolyRef base;
|
||||
@ -53,7 +52,7 @@ public:
|
||||
{
|
||||
for (int i = 0; i < m_ntiles; ++i)
|
||||
m_tiles[i].purge();
|
||||
dtFree(m_tiles);
|
||||
rdFree(m_tiles);
|
||||
}
|
||||
|
||||
bool init(const dtNavMesh* nav)
|
||||
@ -61,7 +60,7 @@ public:
|
||||
m_ntiles = nav->getMaxTiles();
|
||||
if (!m_ntiles)
|
||||
return true;
|
||||
m_tiles = (TileFlags*)dtAlloc(sizeof(TileFlags)*m_ntiles, DT_ALLOC_TEMP);
|
||||
m_tiles = (TileFlags*)rdAlloc(sizeof(TileFlags)*m_ntiles, RD_ALLOC_TEMP);
|
||||
if (!m_tiles)
|
||||
{
|
||||
return false;
|
||||
@ -78,7 +77,7 @@ public:
|
||||
tf->base = nav->getPolyRefBase(tile);
|
||||
if (tf->nflags)
|
||||
{
|
||||
tf->flags = (unsigned char*)dtAlloc(tf->nflags, DT_ALLOC_TEMP);
|
||||
tf->flags = (unsigned char*)rdAlloc(tf->nflags, RD_ALLOC_TEMP);
|
||||
if (!tf->flags)
|
||||
return false;
|
||||
memset(tf->flags, 0, tf->nflags);
|
||||
@ -102,8 +101,8 @@ public:
|
||||
|
||||
inline unsigned char getFlags(dtPolyRef ref)
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_ntiles);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_ntiles);
|
||||
// Assume the ref is valid, no bounds checks.
|
||||
unsigned int salt, it, ip;
|
||||
m_nav->decodePolyId(ref, salt, it, ip);
|
||||
@ -112,8 +111,8 @@ public:
|
||||
|
||||
inline void setFlags(dtPolyRef ref, unsigned char flags)
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_ntiles);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_ntiles);
|
||||
// Assume the ref is valid, no bounds checks.
|
||||
unsigned int salt, it, ip;
|
||||
m_nav->decodePolyId(ref, salt, it, ip);
|
||||
@ -139,7 +138,7 @@ static void floodNavmesh(dtNavMesh* nav, NavmeshFlags* flags, dtPolyRef start, u
|
||||
openList.pop_back();
|
||||
|
||||
// Get current poly and tile.
|
||||
// The API input has been cheked already, skip checking internal data.
|
||||
// The API input has been checked already, skip checking internal data.
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
nav->getTileAndPolyByRefUnsafe(ref, &tile, &poly);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "Pch.h"
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "DebugUtils/Include/RecastDebugDraw.h"
|
||||
#include "NavEditor/Include/InputGeom.h"
|
||||
#include "NavEditor/Include/TestCase.h"
|
||||
@ -38,7 +38,7 @@ struct SampleItem
|
||||
Editor* createTile() { return new Editor_TileMesh(); }
|
||||
Editor* createDebug() { return new Editor_Debug(); }
|
||||
|
||||
void save_ply(std::vector<float>& pts,std::vector<int>& colors,rcIntArray& tris)
|
||||
void save_ply(std::vector<float>& pts,std::vector<int>& colors,rdIntArray& tris)
|
||||
{
|
||||
static int counter = 0;
|
||||
char fname[255];
|
||||
@ -247,7 +247,7 @@ int main(int argc, char** argv)
|
||||
|
||||
extern void delaunayHull(rcContext* ctx, const int npts, const float* pts,
|
||||
const int nhull, const int* hull,
|
||||
rcIntArray& tris, rcIntArray& edges);
|
||||
rdIntArray& tris, rdIntArray& edges);
|
||||
|
||||
int main_test_delaunay(int /*argc*/, char** /*argv*/)
|
||||
{
|
||||
@ -263,15 +263,15 @@ int main_test_delaunay(int /*argc*/, char** /*argv*/)
|
||||
for (auto h : hull)
|
||||
colors[h] = 0xffff0000;
|
||||
|
||||
rcIntArray tris;
|
||||
rdIntArray tris;
|
||||
save_ply(pts, colors, tris);
|
||||
|
||||
rcIntArray edges;
|
||||
rdIntArray edges;
|
||||
delaunayHull(&ctx, pts.size()/3, pts.data(), hull.size(), hull.data(), tris, edges);
|
||||
save_ply(pts, colors, tris);
|
||||
return 0;
|
||||
}
|
||||
void compact_tris(rcIntArray& tris)
|
||||
void compact_tris(rdIntArray& tris)
|
||||
{
|
||||
int j = 3;
|
||||
for (int i = 4; i < tris.size(); i++)
|
||||
@ -297,10 +297,10 @@ int main(int argc, char** argv)
|
||||
for (auto h : hull)
|
||||
colors[h] = 0xffff0000;
|
||||
|
||||
rcIntArray tris;
|
||||
rdIntArray tris;
|
||||
//save_ply(pts, colors, tris);
|
||||
|
||||
rcIntArray edges;
|
||||
rdIntArray edges;
|
||||
delaunayHull(&ctx, pts.size() / 3, pts.data(), hull.size(), hull.data(), tris, edges);
|
||||
compact_tris(tris);
|
||||
save_ply(pts, colors, tris);
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "DebugUtils/Include/RecastDump.h"
|
||||
|
||||
|
||||
@ -211,7 +211,7 @@ bool duReadContourSet(struct rcContourSet& cset, duFileIO* io)
|
||||
|
||||
io->read(&cset.nconts, sizeof(cset.nconts));
|
||||
|
||||
cset.conts = (rcContour*)rcAlloc(sizeof(rcContour)*cset.nconts, RC_ALLOC_PERM);
|
||||
cset.conts = (rcContour*)rdAlloc(sizeof(rcContour)*cset.nconts, RD_ALLOC_PERM);
|
||||
if (!cset.conts)
|
||||
{
|
||||
printf("duReadContourSet: Could not alloc contours (%d)\n", cset.nconts);
|
||||
@ -237,13 +237,13 @@ bool duReadContourSet(struct rcContourSet& cset, duFileIO* io)
|
||||
io->read(&cont.reg, sizeof(cont.reg));
|
||||
io->read(&cont.area, sizeof(cont.area));
|
||||
|
||||
cont.verts = (int*)rcAlloc(sizeof(int)*4*cont.nverts, RC_ALLOC_PERM);
|
||||
cont.verts = (int*)rdAlloc(sizeof(int)*4*cont.nverts, RD_ALLOC_PERM);
|
||||
if (!cont.verts)
|
||||
{
|
||||
printf("duReadContourSet: Could not alloc contour verts (%d)\n", cont.nverts);
|
||||
return false;
|
||||
}
|
||||
cont.rverts = (int*)rcAlloc(sizeof(int)*4*cont.nrverts, RC_ALLOC_PERM);
|
||||
cont.rverts = (int*)rdAlloc(sizeof(int)*4*cont.nrverts, RD_ALLOC_PERM);
|
||||
if (!cont.rverts)
|
||||
{
|
||||
printf("duReadContourSet: Could not alloc contour rverts (%d)\n", cont.nrverts);
|
||||
@ -366,7 +366,7 @@ bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, duFileIO* io)
|
||||
|
||||
if (tmp & 1)
|
||||
{
|
||||
chf.cells = (rcCompactCell*)rcAlloc(sizeof(rcCompactCell)*chf.width*chf.height, RC_ALLOC_PERM);
|
||||
chf.cells = (rcCompactCell*)rdAlloc(sizeof(rcCompactCell)*chf.width*chf.height, RD_ALLOC_PERM);
|
||||
if (!chf.cells)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc cells (%d)\n", chf.width*chf.height);
|
||||
@ -376,7 +376,7 @@ bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, duFileIO* io)
|
||||
}
|
||||
if (tmp & 2)
|
||||
{
|
||||
chf.spans = (rcCompactSpan*)rcAlloc(sizeof(rcCompactSpan)*chf.spanCount, RC_ALLOC_PERM);
|
||||
chf.spans = (rcCompactSpan*)rdAlloc(sizeof(rcCompactSpan)*chf.spanCount, RD_ALLOC_PERM);
|
||||
if (!chf.spans)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc spans (%d)\n", chf.spanCount);
|
||||
@ -386,7 +386,7 @@ bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, duFileIO* io)
|
||||
}
|
||||
if (tmp & 4)
|
||||
{
|
||||
chf.dist = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_PERM);
|
||||
chf.dist = (unsigned short*)rdAlloc(sizeof(unsigned short)*chf.spanCount, RD_ALLOC_PERM);
|
||||
if (!chf.dist)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc dist (%d)\n", chf.spanCount);
|
||||
@ -396,7 +396,7 @@ bool duReadCompactHeightfield(struct rcCompactHeightfield& chf, duFileIO* io)
|
||||
}
|
||||
if (tmp & 8)
|
||||
{
|
||||
chf.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_PERM);
|
||||
chf.areas = (unsigned char*)rdAlloc(sizeof(unsigned char)*chf.spanCount, RD_ALLOC_PERM);
|
||||
if (!chf.areas)
|
||||
{
|
||||
printf("duReadCompactHeightfield: Could not alloc areas (%d)\n", chf.spanCount);
|
||||
|
@ -1,61 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef DETOURALLOCATOR_H
|
||||
#define DETOURALLOCATOR_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/// Provides hint values to the memory allocator on how long the
|
||||
/// memory is expected to be used.
|
||||
enum dtAllocHint
|
||||
{
|
||||
DT_ALLOC_PERM, ///< Memory persist after a function call.
|
||||
DT_ALLOC_TEMP ///< Memory used temporarily within a function.
|
||||
};
|
||||
|
||||
/// A memory allocation function.
|
||||
// @param[in] size The size, in bytes of memory, to allocate.
|
||||
// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
||||
// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||
/// @see dtAllocSetCustom
|
||||
typedef void* (dtAllocFunc)(size_t size, dtAllocHint hint);
|
||||
|
||||
/// A memory deallocation function.
|
||||
/// @param[in] ptr A pointer to a memory block previously allocated using #dtAllocFunc.
|
||||
/// @see dtAllocSetCustom
|
||||
typedef void (dtFreeFunc)(void* ptr);
|
||||
|
||||
/// Sets the base custom allocation functions to be used by Detour.
|
||||
/// @param[in] allocFunc The memory allocation function to be used by #dtAlloc
|
||||
/// @param[in] freeFunc The memory de-allocation function to be used by #dtFree
|
||||
void dtAllocSetCustom(dtAllocFunc *allocFunc, dtFreeFunc *freeFunc);
|
||||
|
||||
/// Allocates a memory block.
|
||||
/// @param[in] size The size, in bytes of memory, to allocate.
|
||||
/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
|
||||
/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||
/// @see dtFree
|
||||
void* dtAlloc(size_t size, dtAllocHint hint);
|
||||
|
||||
/// Deallocates a memory block.
|
||||
/// @param[in] ptr A pointer to a memory block previously allocated using #dtAlloc.
|
||||
/// @see dtAlloc
|
||||
void dtFree(void* ptr);
|
||||
|
||||
#endif
|
@ -21,7 +21,7 @@
|
||||
|
||||
// Only use types for function prototypes
|
||||
#ifndef GAMESDK
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Detour/Include/DetourStatus.h"
|
||||
#endif // !GAMESDK
|
||||
|
||||
@ -765,12 +765,12 @@ inline int calcStaticPathingTableSize(const int numPolyGroups)
|
||||
/// Allocates a navigation mesh object using the Detour allocator.
|
||||
/// @return A navigation mesh that is ready for initialization, or null on failure.
|
||||
/// @ingroup detour
|
||||
dtNavMesh* dtAllocNavMesh();
|
||||
dtNavMesh* rdAllocNavMesh();
|
||||
|
||||
/// Frees the specified navigation mesh object using the Detour allocator.
|
||||
/// @param[in] navmesh A navigation mesh allocated using #dtAllocNavMesh
|
||||
/// @param[in] navmesh A navigation mesh allocated using #rdAllocNavMesh
|
||||
/// @ingroup detour
|
||||
void dtFreeNavMesh(dtNavMesh* navmesh);
|
||||
void rdFreeNavMesh(dtNavMesh* navmesh);
|
||||
|
||||
#endif // DETOURNAVMESH_H
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef DETOURNAVMESHBUILDER_H
|
||||
#define DETOURNAVMESHBUILDER_H
|
||||
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
|
||||
/// Represents the source data used to build an navigation mesh tile.
|
||||
/// @ingroup detour
|
||||
|
@ -583,11 +583,11 @@ private:
|
||||
/// Allocates a query object using the Detour allocator.
|
||||
/// @return An allocated query object, or null on failure.
|
||||
/// @ingroup detour
|
||||
dtNavMeshQuery* dtAllocNavMeshQuery();
|
||||
dtNavMeshQuery* rdAllocNavMeshQuery();
|
||||
|
||||
/// Frees the specified query object using the Detour allocator.
|
||||
/// @param[in] query A query object allocated using #dtAllocNavMeshQuery
|
||||
/// @param[in] query A query object allocated using #rdAllocNavMeshQuery
|
||||
/// @ingroup detour
|
||||
void dtFreeNavMeshQuery(dtNavMeshQuery* query);
|
||||
void rdFreeNavMeshQuery(dtNavMeshQuery* query);
|
||||
|
||||
#endif // DETOURNAVMESHQUERY_H
|
||||
|
@ -17,33 +17,33 @@
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
|
||||
static void *dtAllocDefault(size_t size, dtAllocHint)
|
||||
static void *rdAllocDefault(size_t size, rdAllocHint)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void dtFreeDefault(void *ptr)
|
||||
static void rdFreeDefault(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static dtAllocFunc* sAllocFunc = dtAllocDefault;
|
||||
static dtFreeFunc* sFreeFunc = dtFreeDefault;
|
||||
static rdAllocFunc* sAllocFunc = rdAllocDefault;
|
||||
static rdFreeFunc* sFreeFunc = rdFreeDefault;
|
||||
|
||||
void dtAllocSetCustom(dtAllocFunc *allocFunc, dtFreeFunc *freeFunc)
|
||||
void rdAllocSetCustom(rdAllocFunc *allocFunc, rdFreeFunc *freeFunc)
|
||||
{
|
||||
sAllocFunc = allocFunc ? allocFunc : dtAllocDefault;
|
||||
sFreeFunc = freeFunc ? freeFunc : dtFreeDefault;
|
||||
sAllocFunc = allocFunc ? allocFunc : rdAllocDefault;
|
||||
sFreeFunc = freeFunc ? freeFunc : rdFreeDefault;
|
||||
}
|
||||
|
||||
void* dtAlloc(size_t size, dtAllocHint hint)
|
||||
void* rdAlloc(size_t size, rdAllocHint hint)
|
||||
{
|
||||
return sAllocFunc(size, hint);
|
||||
}
|
||||
|
||||
void dtFree(void* ptr)
|
||||
void rdFree(void* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
sFreeFunc(ptr);
|
||||
|
@ -16,18 +16,18 @@
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
static dtAssertFailFunc* sAssertFailFunc = 0;
|
||||
static rdAssertFailFunc* sAssertFailFunc = 0;
|
||||
|
||||
void dtAssertFailSetCustom(dtAssertFailFunc *assertFailFunc)
|
||||
void rdAssertFailSetCustom(rdAssertFailFunc *assertFailFunc)
|
||||
{
|
||||
sAssertFailFunc = assertFailFunc;
|
||||
}
|
||||
|
||||
dtAssertFailFunc* dtAssertFailGetCustom()
|
||||
rdAssertFailFunc* rdAssertFailGetCustom()
|
||||
{
|
||||
return sAssertFailFunc;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "Detour/Include/DetourNode.h"
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include "Detour/Include/DetourMath.h"
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include <new>
|
||||
|
||||
|
||||
@ -135,9 +135,9 @@ inline void freeLink(dtMeshTile* tile, unsigned int link)
|
||||
}
|
||||
|
||||
|
||||
dtNavMesh* dtAllocNavMesh()
|
||||
dtNavMesh* rdAllocNavMesh()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtNavMesh), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtNavMesh), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtNavMesh;
|
||||
}
|
||||
@ -146,11 +146,11 @@ dtNavMesh* dtAllocNavMesh()
|
||||
///
|
||||
/// This function will only free the memory for tiles with the #DT_TILE_FREE_DATA
|
||||
/// flag set.
|
||||
void dtFreeNavMesh(dtNavMesh* navmesh)
|
||||
void rdFreeNavMesh(dtNavMesh* navmesh)
|
||||
{
|
||||
if (!navmesh) return;
|
||||
navmesh->~dtNavMesh();
|
||||
dtFree(navmesh);
|
||||
rdFree(navmesh);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -182,7 +182,7 @@ Notes:
|
||||
- This class does not implement any asynchronous methods. So the ::dtStatus result of all methods will
|
||||
always contain either a success or failure flag.
|
||||
|
||||
@see dtNavMeshQuery, dtCreateNavMeshData, dtNavMeshCreateParams, #dtAllocNavMesh, #dtFreeNavMesh
|
||||
@see dtNavMeshQuery, dtCreateNavMeshData, dtNavMeshCreateParams, #rdAllocNavMesh, #rdFreeNavMesh
|
||||
*/
|
||||
|
||||
dtNavMesh::dtNavMesh() :
|
||||
@ -217,24 +217,24 @@ dtNavMesh::~dtNavMesh() // TODO: see [r5apex_ds + F43720] to re-implement this c
|
||||
{
|
||||
if (m_tiles[i].flags & DT_TILE_FREE_DATA)
|
||||
{
|
||||
dtFree(m_tiles[i].data);
|
||||
rdFree(m_tiles[i].data);
|
||||
m_tiles[i].data = 0;
|
||||
m_tiles[i].dataSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dtFree(m_posLookup);
|
||||
dtFree(m_tiles);
|
||||
rdFree(m_posLookup);
|
||||
rdFree(m_tiles);
|
||||
|
||||
for (int i = 0; i < m_params.reachabilityTableCount; i++)
|
||||
{
|
||||
int* reachabilityTable = m_setTables[i];
|
||||
|
||||
if (reachabilityTable)
|
||||
dtFree(reachabilityTable);
|
||||
rdFree(reachabilityTable);
|
||||
}
|
||||
|
||||
dtFree(m_setTables);
|
||||
rdFree(m_setTables);
|
||||
}
|
||||
|
||||
dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
@ -251,10 +251,10 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
if (!m_tileLutSize) m_tileLutSize = 1;
|
||||
m_tileLutMask = m_tileLutSize-1;
|
||||
|
||||
m_tiles = (dtMeshTile*)dtAlloc(sizeof(dtMeshTile)*m_maxTiles, DT_ALLOC_PERM);
|
||||
m_tiles = (dtMeshTile*)rdAlloc(sizeof(dtMeshTile)*m_maxTiles, RD_ALLOC_PERM);
|
||||
if (!m_tiles)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
m_posLookup = (dtMeshTile**)dtAlloc(sizeof(dtMeshTile*)*m_tileLutSize, DT_ALLOC_PERM);
|
||||
m_posLookup = (dtMeshTile**)rdAlloc(sizeof(dtMeshTile*)*m_tileLutSize, RD_ALLOC_PERM);
|
||||
if (!m_posLookup)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
memset(m_tiles, 0, sizeof(dtMeshTile) * m_maxTiles);
|
||||
@ -265,7 +265,7 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
{
|
||||
const int setTableBufSize = sizeof(int**)*reachabilityTableCount;
|
||||
|
||||
m_setTables = (int**)dtAlloc(setTableBufSize, DT_ALLOC_PERM);
|
||||
m_setTables = (int**)rdAlloc(setTableBufSize, RD_ALLOC_PERM);
|
||||
if (!m_setTables)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
|
||||
@ -1346,7 +1346,7 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz
|
||||
if (tile->flags & DT_TILE_FREE_DATA)
|
||||
{
|
||||
// Owns data
|
||||
dtFree(tile->data);
|
||||
rdFree(tile->data);
|
||||
tile->data = 0;
|
||||
tile->dataSize = 0;
|
||||
if (data) *data = 0;
|
||||
@ -1573,7 +1573,7 @@ const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef(dtPolyRef ref) c
|
||||
return 0;
|
||||
|
||||
const unsigned int idx = ip - tile->header->offMeshBase;
|
||||
dtAssert(idx < (unsigned int)tile->header->offMeshConCount);
|
||||
rdAssert(idx < (unsigned int)tile->header->offMeshConCount);
|
||||
return &tile->offMeshCons[idx];
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include "Detour/Include/DetourMath.h"
|
||||
#include "Detour/Include/DetourNavMeshBuilder.h"
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
static unsigned short MESH_NULL_IDX = 0xffff;
|
||||
|
||||
@ -172,7 +172,7 @@ static int createBVTree(dtNavMeshCreateParams* params, dtBVNode* nodes, int /*nn
|
||||
{
|
||||
// Build tree
|
||||
float quantFactor = 1 / params->cs;
|
||||
BVItem* items = (BVItem*)dtAlloc(sizeof(BVItem)*params->polyCount, DT_ALLOC_TEMP);
|
||||
BVItem* items = (BVItem*)rdAlloc(sizeof(BVItem)*params->polyCount, RD_ALLOC_TEMP);
|
||||
for (int i = 0; i < params->polyCount; i++)
|
||||
{
|
||||
BVItem& it = items[i];
|
||||
@ -235,7 +235,7 @@ static int createBVTree(dtNavMeshCreateParams* params, dtBVNode* nodes, int /*nn
|
||||
int curNode = 0;
|
||||
subdivide(items, params->polyCount, 0, params->polyCount, curNode, nodes);
|
||||
|
||||
dtFree(items);
|
||||
rdFree(items);
|
||||
|
||||
return curNode;
|
||||
}
|
||||
@ -283,7 +283,7 @@ static void setReachable(int* const tableData, const int numPolyGroups,
|
||||
|
||||
bool dtBuildStaticPathingData(dtNavMesh* mesh)
|
||||
{
|
||||
dtAssert(mesh);
|
||||
rdAssert(mesh);
|
||||
|
||||
// Reserve the first 2 poly groups
|
||||
// 0 = technically usable for normal poly groups, but for simplicity we reserve it for now.
|
||||
@ -365,7 +365,7 @@ bool dtBuildStaticPathingData(dtNavMesh* mesh)
|
||||
const int tableSize = calcStaticPathingTableSize(numPolyGroups);
|
||||
const int tableCount = DT_NUM_REACHABILITY_TABLES;
|
||||
|
||||
dtAssert(mesh->m_setTables);
|
||||
rdAssert(mesh->m_setTables);
|
||||
|
||||
// NOTE: the game allocates 4 reachability table buffers, original
|
||||
// navmeshes have slightly different data per table. Currently ours are all
|
||||
@ -373,7 +373,7 @@ bool dtBuildStaticPathingData(dtNavMesh* mesh)
|
||||
// figure out why we need 4 tables and what the differences are.
|
||||
for (int i = 0; i < tableCount; i++)
|
||||
{
|
||||
int* const reachabilityTable = (int*)dtAlloc(sizeof(int)*tableSize, DT_ALLOC_PERM);
|
||||
int* const reachabilityTable = (int*)rdAlloc(sizeof(int)*tableSize, RD_ALLOC_PERM);
|
||||
|
||||
if (!reachabilityTable)
|
||||
return false;
|
||||
@ -396,7 +396,7 @@ bool dtBuildStaticPathingData(dtNavMesh* mesh)
|
||||
|
||||
/// @par
|
||||
///
|
||||
/// The output data array is allocated using the detour allocator (dtAlloc()). The method
|
||||
/// The output data array is allocated using the detour allocator (rdAlloc()). The method
|
||||
/// used to free the memory will be determined by how the tile is added to the navigation
|
||||
/// mesh.
|
||||
///
|
||||
@ -422,7 +422,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
|
||||
if (params->offMeshConCount > 0)
|
||||
{
|
||||
offMeshConClass = (unsigned char*)dtAlloc(sizeof(unsigned char)*params->offMeshConCount*2, DT_ALLOC_TEMP);
|
||||
offMeshConClass = (unsigned char*)rdAlloc(sizeof(unsigned char)*params->offMeshConCount*2, RD_ALLOC_TEMP);
|
||||
if (!offMeshConClass)
|
||||
return false;
|
||||
|
||||
@ -567,10 +567,10 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
//printf("%i %i %i %i(%i links) %i %i %i %i %i\n", headerSize, vertsSize, polysSize, linksSize, maxLinkCount, detailMeshesSize, detailVertsSize, detailTrisSize, bvTreeSize, offMeshConsSize);
|
||||
//printf("%i\n", dataSize);
|
||||
|
||||
unsigned char* data = (unsigned char*)dtAlloc(sizeof(unsigned char)*dataSize, DT_ALLOC_PERM);
|
||||
unsigned char* data = (unsigned char*)rdAlloc(sizeof(unsigned char)*dataSize, RD_ALLOC_PERM);
|
||||
if (!data)
|
||||
{
|
||||
dtFree(offMeshConClass);
|
||||
rdFree(offMeshConClass);
|
||||
return false;
|
||||
}
|
||||
memset(data, 0, dataSize);
|
||||
@ -797,7 +797,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
}
|
||||
}
|
||||
|
||||
dtFree(offMeshConClass);
|
||||
rdFree(offMeshConClass);
|
||||
|
||||
*outData = data;
|
||||
*outDataSize = dataSize;
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "Detour/Include/DetourNode.h"
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include "Detour/Include/DetourMath.h"
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include <new>
|
||||
|
||||
/// @class dtQueryFilter
|
||||
@ -103,18 +103,18 @@ inline float dtQueryFilter::getCost(const float* pa, const float* pb,
|
||||
static const float H_SCALE = 0.999f; // Search heuristic scale.
|
||||
|
||||
|
||||
dtNavMeshQuery* dtAllocNavMeshQuery()
|
||||
dtNavMeshQuery* rdAllocNavMeshQuery()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtNavMeshQuery), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtNavMeshQuery), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtNavMeshQuery;
|
||||
}
|
||||
|
||||
void dtFreeNavMeshQuery(dtNavMeshQuery* navmesh)
|
||||
void rdFreeNavMeshQuery(dtNavMeshQuery* navmesh)
|
||||
{
|
||||
if (!navmesh) return;
|
||||
navmesh->~dtNavMeshQuery();
|
||||
dtFree(navmesh);
|
||||
rdFree(navmesh);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -133,7 +133,7 @@ void dtFreeNavMeshQuery(dtNavMeshQuery* navmesh)
|
||||
/// considered impassable. A @e portal is a passable segment between polygons.
|
||||
/// A portal may be treated as a wall based on the dtQueryFilter used for a query.
|
||||
///
|
||||
/// @see dtNavMesh, dtQueryFilter, #dtAllocNavMeshQuery(), #dtAllocNavMeshQuery()
|
||||
/// @see dtNavMesh, dtQueryFilter, #rdAllocNavMeshQuery(), #rdAllocNavMeshQuery()
|
||||
|
||||
dtNavMeshQuery::dtNavMeshQuery() :
|
||||
m_nav(0),
|
||||
@ -153,9 +153,9 @@ dtNavMeshQuery::~dtNavMeshQuery()
|
||||
if (m_openList)
|
||||
m_openList->~dtNodeQueue();
|
||||
|
||||
dtFree(m_tinyNodePool);
|
||||
dtFree(m_nodePool);
|
||||
dtFree(m_openList);
|
||||
rdFree(m_tinyNodePool);
|
||||
rdFree(m_nodePool);
|
||||
rdFree(m_openList);
|
||||
}
|
||||
|
||||
/// @par
|
||||
@ -176,10 +176,10 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
if (m_nodePool)
|
||||
{
|
||||
m_nodePool->~dtNodePool();
|
||||
dtFree(m_nodePool);
|
||||
rdFree(m_nodePool);
|
||||
m_nodePool = 0;
|
||||
}
|
||||
m_nodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(maxNodes, dtNextPow2(maxNodes/4));
|
||||
m_nodePool = new (rdAlloc(sizeof(dtNodePool), RD_ALLOC_PERM)) dtNodePool(maxNodes, dtNextPow2(maxNodes/4));
|
||||
if (!m_nodePool)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -190,7 +190,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
|
||||
if (!m_tinyNodePool)
|
||||
{
|
||||
m_tinyNodePool = new (dtAlloc(sizeof(dtNodePool), DT_ALLOC_PERM)) dtNodePool(64, 32);
|
||||
m_tinyNodePool = new (rdAlloc(sizeof(dtNodePool), RD_ALLOC_PERM)) dtNodePool(64, 32);
|
||||
if (!m_tinyNodePool)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -204,10 +204,10 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
if (m_openList)
|
||||
{
|
||||
m_openList->~dtNodeQueue();
|
||||
dtFree(m_openList);
|
||||
rdFree(m_openList);
|
||||
m_openList = 0;
|
||||
}
|
||||
m_openList = new (dtAlloc(sizeof(dtNodeQueue), DT_ALLOC_PERM)) dtNodeQueue(maxNodes);
|
||||
m_openList = new (rdAlloc(sizeof(dtNodeQueue), RD_ALLOC_PERM)) dtNodeQueue(maxNodes);
|
||||
if (!m_openList)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -222,7 +222,7 @@ dtStatus dtNavMeshQuery::init(const dtNavMesh* nav, const int maxNodes)
|
||||
dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*frand)(),
|
||||
dtPolyRef* randomRef, float* randomPt) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
if (!m_nav || !filter || !frand || !randomRef || !randomPt)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -314,9 +314,9 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f
|
||||
const dtQueryFilter* filter, float (*frand)(),
|
||||
dtPolyRef* randomRef, float* randomPt) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_nodePool);
|
||||
dtAssert(m_openList);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_nodePool);
|
||||
rdAssert(m_openList);
|
||||
|
||||
// Validate input
|
||||
if (!m_nav->isValidPolyRef(startRef) ||
|
||||
@ -506,7 +506,7 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f
|
||||
///
|
||||
dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
if (!m_nav->isValidPolyRef(ref) ||
|
||||
!pos || !dtVisfinite(pos) ||
|
||||
!closest)
|
||||
@ -531,7 +531,7 @@ dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, flo
|
||||
///
|
||||
dtStatus dtNavMeshQuery::closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, float* closest) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
@ -586,7 +586,7 @@ dtStatus dtNavMeshQuery::closestPointOnPolyBoundary(dtPolyRef ref, const float*
|
||||
///
|
||||
dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* height) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
const dtMeshTile* tile = 0;
|
||||
const dtPoly* poly = 0;
|
||||
@ -692,7 +692,7 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* halfE
|
||||
const dtQueryFilter* filter,
|
||||
dtPolyRef* nearestRef, float* nearestPt, bool* isOverPoly) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
if (!nearestRef)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -721,7 +721,7 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* halfE
|
||||
void dtNavMeshQuery::queryPolygonsInTile(const dtMeshTile* tile, const float* qmin, const float* qmax,
|
||||
const dtQueryFilter* filter, dtPolyQuery* query) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
static const int batchSize = 32;
|
||||
dtPolyRef polyRefs[batchSize];
|
||||
dtPoly* polys[batchSize];
|
||||
@ -905,7 +905,7 @@ dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExt
|
||||
dtStatus dtNavMeshQuery::queryPolygons(const float* center, const float* halfExtents,
|
||||
const dtQueryFilter* filter, dtPolyQuery* query) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
if (!center || !dtVisfinite(center) ||
|
||||
!halfExtents || !dtVisfinite(halfExtents) ||
|
||||
@ -957,9 +957,9 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
const dtQueryFilter* filter,
|
||||
dtPolyRef* path, int* pathCount, const int maxPath) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_nodePool);
|
||||
dtAssert(m_openList);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_nodePool);
|
||||
rdAssert(m_openList);
|
||||
|
||||
if (!pathCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -1162,7 +1162,7 @@ dtStatus dtNavMeshQuery::getPathToNode(dtNode* endNode, dtPolyRef* path, int* pa
|
||||
int writeCount;
|
||||
for (writeCount = length; writeCount > maxPath; writeCount--)
|
||||
{
|
||||
dtAssert(curNode);
|
||||
rdAssert(curNode);
|
||||
|
||||
curNode = m_nodePool->getNodeAtIdx(curNode->pidx);
|
||||
}
|
||||
@ -1170,13 +1170,13 @@ dtStatus dtNavMeshQuery::getPathToNode(dtNode* endNode, dtPolyRef* path, int* pa
|
||||
// Write path
|
||||
for (int i = writeCount - 1; i >= 0; i--)
|
||||
{
|
||||
dtAssert(curNode);
|
||||
rdAssert(curNode);
|
||||
|
||||
path[i] = curNode->id;
|
||||
curNode = m_nodePool->getNodeAtIdx(curNode->pidx);
|
||||
}
|
||||
|
||||
dtAssert(!curNode);
|
||||
rdAssert(!curNode);
|
||||
|
||||
*pathCount = dtMin(length, maxPath);
|
||||
|
||||
@ -1199,9 +1199,9 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef
|
||||
const float* startPos, const float* endPos,
|
||||
const unsigned int options)
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_nodePool);
|
||||
dtAssert(m_openList);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_nodePool);
|
||||
rdAssert(m_openList);
|
||||
|
||||
// Init path state.
|
||||
memset(&m_query, 0, sizeof(dtQueryData));
|
||||
@ -1260,7 +1260,7 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef
|
||||
|
||||
dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(filter);
|
||||
rdAssert(filter);
|
||||
|
||||
if (!dtStatusInProgress(m_query.status))
|
||||
return m_query.status;
|
||||
@ -1487,8 +1487,8 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters,
|
||||
|
||||
dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const int maxPath, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(filter);
|
||||
dtAssert(pathCount);
|
||||
rdAssert(filter);
|
||||
rdAssert(pathCount);
|
||||
|
||||
if (!filter || !pathCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -1515,7 +1515,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount,
|
||||
else
|
||||
{
|
||||
// Reverse the path.
|
||||
dtAssert(m_query.lastBestNode);
|
||||
rdAssert(m_query.lastBestNode);
|
||||
|
||||
if (m_query.lastBestNode->id != m_query.endRef)
|
||||
m_query.status |= DT_PARTIAL_RESULT;
|
||||
@ -1619,7 +1619,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing
|
||||
if (!node)
|
||||
{
|
||||
m_query.status |= DT_PARTIAL_RESULT;
|
||||
dtAssert(m_query.lastBestNode);
|
||||
rdAssert(m_query.lastBestNode);
|
||||
node = m_query.lastBestNode;
|
||||
}
|
||||
|
||||
@ -1790,7 +1790,7 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
|
||||
float* straightPath, unsigned char* straightPathFlags, dtPolyRef* straightPathRefs,
|
||||
int* straightPathCount, const int maxStraightPath, const int options) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
if (!straightPathCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -2040,8 +2040,8 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start
|
||||
const dtQueryFilter* filter,
|
||||
float* resultPos, dtPolyRef* visited, int* visitedCount, const int maxVisitedSize) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_tinyNodePool);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_tinyNodePool);
|
||||
|
||||
if (!visitedCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -2243,7 +2243,7 @@ dtStatus dtNavMeshQuery::moveAlongSurface(dtPolyRef startRef, const float* start
|
||||
dtStatus dtNavMeshQuery::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
|
||||
unsigned char& fromType, unsigned char& toType) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
const dtMeshTile* fromTile = 0;
|
||||
const dtPoly* fromPoly = 0;
|
||||
@ -2462,7 +2462,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
const dtQueryFilter* filter, const unsigned int options,
|
||||
dtRaycastHit* hit, dtPolyRef prevRef) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
if (!hit)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -2717,9 +2717,9 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
int* resultCount, const int maxResult) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_nodePool);
|
||||
dtAssert(m_openList);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_nodePool);
|
||||
rdAssert(m_openList);
|
||||
|
||||
if (!resultCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -2891,9 +2891,9 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
int* resultCount, const int maxResult) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_nodePool);
|
||||
dtAssert(m_openList);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_nodePool);
|
||||
rdAssert(m_openList);
|
||||
|
||||
if (!resultCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -3089,8 +3089,8 @@ dtStatus dtNavMeshQuery::findLocalNeighbourhood(dtPolyRef startRef, const float*
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent,
|
||||
int* resultCount, const int maxResult) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_tinyNodePool);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_tinyNodePool);
|
||||
|
||||
if (!resultCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -3310,7 +3310,7 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter*
|
||||
float* segmentVerts, dtPolyRef* segmentRefs, int* segmentCount,
|
||||
const int maxSegments) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
rdAssert(m_nav);
|
||||
|
||||
if (!segmentCount)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
@ -3466,9 +3466,9 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
const dtQueryFilter* filter,
|
||||
float* hitDist, float* hitPos, float* hitNormal) const
|
||||
{
|
||||
dtAssert(m_nav);
|
||||
dtAssert(m_nodePool);
|
||||
dtAssert(m_openList);
|
||||
rdAssert(m_nav);
|
||||
rdAssert(m_nodePool);
|
||||
rdAssert(m_openList);
|
||||
|
||||
// Validate input
|
||||
if (!m_nav->isValidPolyRef(startRef) ||
|
||||
|
@ -17,8 +17,8 @@
|
||||
//
|
||||
|
||||
#include "Detour/Include/DetourNode.h"
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -56,18 +56,18 @@ dtNodePool::dtNodePool(int maxNodes, int hashSize) :
|
||||
m_hashSize(hashSize),
|
||||
m_nodeCount(0)
|
||||
{
|
||||
dtAssert(dtNextPow2(m_hashSize) == (unsigned int)m_hashSize);
|
||||
rdAssert(dtNextPow2(m_hashSize) == (unsigned int)m_hashSize);
|
||||
// pidx is special as 0 means "none" and 1 is the first node. For that reason
|
||||
// we have 1 fewer nodes available than the number of values it can contain.
|
||||
dtAssert(m_maxNodes > 0 && m_maxNodes <= DT_NULL_IDX && m_maxNodes <= (1 << DT_NODE_PARENT_BITS) - 1);
|
||||
rdAssert(m_maxNodes > 0 && m_maxNodes <= DT_NULL_IDX && m_maxNodes <= (1 << DT_NODE_PARENT_BITS) - 1);
|
||||
|
||||
m_nodes = (dtNode*)dtAlloc(sizeof(dtNode)*m_maxNodes, DT_ALLOC_PERM);
|
||||
m_next = (dtNodeIndex*)dtAlloc(sizeof(dtNodeIndex)*m_maxNodes, DT_ALLOC_PERM);
|
||||
m_first = (dtNodeIndex*)dtAlloc(sizeof(dtNodeIndex)*hashSize, DT_ALLOC_PERM);
|
||||
m_nodes = (dtNode*)rdAlloc(sizeof(dtNode)*m_maxNodes, RD_ALLOC_PERM);
|
||||
m_next = (dtNodeIndex*)rdAlloc(sizeof(dtNodeIndex)*m_maxNodes, RD_ALLOC_PERM);
|
||||
m_first = (dtNodeIndex*)rdAlloc(sizeof(dtNodeIndex)*hashSize, RD_ALLOC_PERM);
|
||||
|
||||
dtAssert(m_nodes);
|
||||
dtAssert(m_next);
|
||||
dtAssert(m_first);
|
||||
rdAssert(m_nodes);
|
||||
rdAssert(m_next);
|
||||
rdAssert(m_first);
|
||||
|
||||
memset(m_first, 0xff, sizeof(dtNodeIndex)*m_hashSize);
|
||||
memset(m_next, 0xff, sizeof(dtNodeIndex)*m_maxNodes);
|
||||
@ -75,9 +75,9 @@ dtNodePool::dtNodePool(int maxNodes, int hashSize) :
|
||||
|
||||
dtNodePool::~dtNodePool()
|
||||
{
|
||||
dtFree(m_nodes);
|
||||
dtFree(m_next);
|
||||
dtFree(m_first);
|
||||
rdFree(m_nodes);
|
||||
rdFree(m_next);
|
||||
rdFree(m_first);
|
||||
}
|
||||
|
||||
void dtNodePool::clear()
|
||||
@ -158,15 +158,15 @@ dtNodeQueue::dtNodeQueue(int n) :
|
||||
m_capacity(n),
|
||||
m_size(0)
|
||||
{
|
||||
dtAssert(m_capacity > 0);
|
||||
rdAssert(m_capacity > 0);
|
||||
|
||||
m_heap = (dtNode**)dtAlloc(sizeof(dtNode*)*(m_capacity+1), DT_ALLOC_PERM);
|
||||
dtAssert(m_heap);
|
||||
m_heap = (dtNode**)rdAlloc(sizeof(dtNode*)*(m_capacity+1), RD_ALLOC_PERM);
|
||||
rdAssert(m_heap);
|
||||
}
|
||||
|
||||
dtNodeQueue::~dtNodeQueue()
|
||||
{
|
||||
dtFree(m_heap);
|
||||
rdFree(m_heap);
|
||||
}
|
||||
|
||||
void dtNodeQueue::bubbleUp(int i, dtNode* node)
|
||||
|
@ -357,12 +357,12 @@ private:
|
||||
/// Allocates a crowd object using the Detour allocator.
|
||||
/// @return A crowd object that is ready for initialization, or null on failure.
|
||||
/// @ingroup crowd
|
||||
dtCrowd* dtAllocCrowd();
|
||||
dtCrowd* rdAllocCrowd();
|
||||
|
||||
/// Frees the specified crowd object using the Detour allocator.
|
||||
/// @param[in] ptr A crowd object allocated using #dtAllocCrowd
|
||||
/// @param[in] ptr A crowd object allocated using #rdAllocCrowd
|
||||
/// @ingroup crowd
|
||||
void dtFreeCrowd(dtCrowd* ptr);
|
||||
void rdFreeCrowd(dtCrowd* ptr);
|
||||
|
||||
|
||||
#endif // DETOURCROWD_H
|
||||
|
@ -73,8 +73,8 @@ private:
|
||||
float* m_tpen;
|
||||
};
|
||||
|
||||
dtObstacleAvoidanceDebugData* dtAllocObstacleAvoidanceDebugData();
|
||||
void dtFreeObstacleAvoidanceDebugData(dtObstacleAvoidanceDebugData* ptr);
|
||||
dtObstacleAvoidanceDebugData* rdAllocObstacleAvoidanceDebugData();
|
||||
void rdFreeObstacleAvoidanceDebugData(dtObstacleAvoidanceDebugData* ptr);
|
||||
|
||||
|
||||
static const int DT_MAX_PATTERN_DIVS = 32; ///< Max numver of adaptive divs.
|
||||
@ -152,8 +152,8 @@ private:
|
||||
int m_nsegments;
|
||||
};
|
||||
|
||||
dtObstacleAvoidanceQuery* dtAllocObstacleAvoidanceQuery();
|
||||
void dtFreeObstacleAvoidanceQuery(dtObstacleAvoidanceQuery* ptr);
|
||||
dtObstacleAvoidanceQuery* rdAllocObstacleAvoidanceQuery();
|
||||
void rdFreeObstacleAvoidanceQuery(dtObstacleAvoidanceQuery* ptr);
|
||||
|
||||
|
||||
#endif // DETOUROBSTACLEAVOIDANCE_H
|
||||
|
@ -66,8 +66,8 @@ private:
|
||||
dtProximityGrid& operator=(const dtProximityGrid&);
|
||||
};
|
||||
|
||||
dtProximityGrid* dtAllocProximityGrid();
|
||||
void dtFreeProximityGrid(dtProximityGrid* ptr);
|
||||
dtProximityGrid* rdAllocProximityGrid();
|
||||
void rdFreeProximityGrid(dtProximityGrid* ptr);
|
||||
|
||||
|
||||
#endif // DETOURPROXIMITYGRID_H
|
||||
|
@ -28,22 +28,22 @@
|
||||
#include "Detour\Include\DetourNavMeshQuery.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
#include "Detour\Include\DetourMath.h"
|
||||
#include "Detour\Include\DetourAssert.h"
|
||||
#include "Detour\Include\DetourAlloc.h"
|
||||
#include "Shared\Include\SharedAssert.h"
|
||||
#include "Shared\Include\SharedAlloc.h"
|
||||
|
||||
|
||||
dtCrowd* dtAllocCrowd()
|
||||
dtCrowd* rdAllocCrowd()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtCrowd), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtCrowd), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtCrowd;
|
||||
}
|
||||
|
||||
void dtFreeCrowd(dtCrowd* ptr)
|
||||
void rdFreeCrowd(dtCrowd* ptr)
|
||||
{
|
||||
if (!ptr) return;
|
||||
ptr->~dtCrowd();
|
||||
dtFree(ptr);
|
||||
rdFree(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ of the crowd features.
|
||||
|
||||
A common method for setting up the crowd is as follows:
|
||||
|
||||
-# Allocate the crowd using #dtAllocCrowd.
|
||||
-# Allocate the crowd using #rdAllocCrowd.
|
||||
-# Initialize the crowd using #init().
|
||||
-# Set the avoidance configurations using #setObstacleAvoidanceParams().
|
||||
-# Add agents using #addAgent() and make an initial movement request using #requestMoveTarget().
|
||||
@ -92,7 +92,7 @@ Notes:
|
||||
- This class is meant to provide 'local' movement. There is a limit of 256 polygons in the path corridor.
|
||||
So it is not meant to provide automatic pathfinding services over long distances.
|
||||
|
||||
@see dtAllocCrowd(), dtFreeCrowd(), init(), dtCrowdAgent
|
||||
@see rdAllocCrowd(), rdFreeCrowd(), init(), dtCrowdAgent
|
||||
|
||||
*/
|
||||
|
||||
@ -120,26 +120,26 @@ void dtCrowd::purge()
|
||||
{
|
||||
for (int i = 0; i < m_maxAgents; ++i)
|
||||
m_agents[i].~dtCrowdAgent();
|
||||
dtFree(m_agents);
|
||||
rdFree(m_agents);
|
||||
m_agents = 0;
|
||||
m_maxAgents = 0;
|
||||
|
||||
dtFree(m_activeAgents);
|
||||
rdFree(m_activeAgents);
|
||||
m_activeAgents = 0;
|
||||
|
||||
dtFree(m_agentAnims);
|
||||
rdFree(m_agentAnims);
|
||||
m_agentAnims = 0;
|
||||
|
||||
dtFree(m_pathResult);
|
||||
rdFree(m_pathResult);
|
||||
m_pathResult = 0;
|
||||
|
||||
dtFreeProximityGrid(m_grid);
|
||||
rdFreeProximityGrid(m_grid);
|
||||
m_grid = 0;
|
||||
|
||||
dtFreeObstacleAvoidanceQuery(m_obstacleQuery);
|
||||
rdFreeObstacleAvoidanceQuery(m_obstacleQuery);
|
||||
m_obstacleQuery = 0;
|
||||
|
||||
dtFreeNavMeshQuery(m_navquery);
|
||||
rdFreeNavMeshQuery(m_navquery);
|
||||
m_navquery = 0;
|
||||
}
|
||||
|
||||
@ -156,13 +156,13 @@ bool dtCrowd::init(const int maxAgents, const float maxAgentRadius, dtNavMesh* n
|
||||
// Larger than agent radius because it is also used for agent recovery.
|
||||
dtVset(m_agentPlacementHalfExtents, m_maxAgentRadius*2.0f, m_maxAgentRadius*1.5f, m_maxAgentRadius*2.0f);
|
||||
|
||||
m_grid = dtAllocProximityGrid();
|
||||
m_grid = rdAllocProximityGrid();
|
||||
if (!m_grid)
|
||||
return false;
|
||||
if (!m_grid->init(m_maxAgents*4, maxAgentRadius*3))
|
||||
return false;
|
||||
|
||||
m_obstacleQuery = dtAllocObstacleAvoidanceQuery();
|
||||
m_obstacleQuery = rdAllocObstacleAvoidanceQuery();
|
||||
if (!m_obstacleQuery)
|
||||
return false;
|
||||
if (!m_obstacleQuery->init(6, 8))
|
||||
@ -187,22 +187,22 @@ bool dtCrowd::init(const int maxAgents, const float maxAgentRadius, dtNavMesh* n
|
||||
|
||||
// Allocate temp buffer for merging paths.
|
||||
m_maxPathResult = 256;
|
||||
m_pathResult = (dtPolyRef*)dtAlloc(sizeof(dtPolyRef)*m_maxPathResult, DT_ALLOC_PERM);
|
||||
m_pathResult = (dtPolyRef*)rdAlloc(sizeof(dtPolyRef)*m_maxPathResult, RD_ALLOC_PERM);
|
||||
if (!m_pathResult)
|
||||
return false;
|
||||
|
||||
if (!m_pathq.init(m_maxPathResult, MAX_PATHQUEUE_NODES, nav))
|
||||
return false;
|
||||
|
||||
m_agents = (dtCrowdAgent*)dtAlloc(sizeof(dtCrowdAgent)*m_maxAgents, DT_ALLOC_PERM);
|
||||
m_agents = (dtCrowdAgent*)rdAlloc(sizeof(dtCrowdAgent)*m_maxAgents, RD_ALLOC_PERM);
|
||||
if (!m_agents)
|
||||
return false;
|
||||
|
||||
m_activeAgents = (dtCrowdAgent**)dtAlloc(sizeof(dtCrowdAgent*)*m_maxAgents, DT_ALLOC_PERM);
|
||||
m_activeAgents = (dtCrowdAgent**)rdAlloc(sizeof(dtCrowdAgent*)*m_maxAgents, RD_ALLOC_PERM);
|
||||
if (!m_activeAgents)
|
||||
return false;
|
||||
|
||||
m_agentAnims = (dtCrowdAgentAnimation*)dtAlloc(sizeof(dtCrowdAgentAnimation)*m_maxAgents, DT_ALLOC_PERM);
|
||||
m_agentAnims = (dtCrowdAgentAnimation*)rdAlloc(sizeof(dtCrowdAgentAnimation)*m_maxAgents, RD_ALLOC_PERM);
|
||||
if (!m_agentAnims)
|
||||
return false;
|
||||
|
||||
@ -220,7 +220,7 @@ bool dtCrowd::init(const int maxAgents, const float maxAgentRadius, dtNavMesh* n
|
||||
}
|
||||
|
||||
// The navquery is mostly used for local searches, no need for large node pool.
|
||||
m_navquery = dtAllocNavMeshQuery();
|
||||
m_navquery = rdAllocNavMeshQuery();
|
||||
if (!m_navquery)
|
||||
return false;
|
||||
if (dtStatusFailed(m_navquery->init(nav, MAX_COMMON_NODES)))
|
||||
@ -463,7 +463,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/)
|
||||
{
|
||||
const dtPolyRef* path = ag->corridor.getPath();
|
||||
const int npath = ag->corridor.getPathCount();
|
||||
dtAssert(npath);
|
||||
rdAssert(npath);
|
||||
|
||||
static const int MAX_RES = 32;
|
||||
float reqPos[3];
|
||||
@ -579,7 +579,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/)
|
||||
{
|
||||
const dtPolyRef* path = ag->corridor.getPath();
|
||||
const int npath = ag->corridor.getPathCount();
|
||||
dtAssert(npath);
|
||||
rdAssert(npath);
|
||||
|
||||
// Apply results.
|
||||
float targetPos[3];
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "Detour\Include\DetourNavMeshQuery.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
#include "Detour\Include\DetourMath.h"
|
||||
#include "Detour\Include\DetourAssert.h"
|
||||
#include "Detour\Include\DetourAlloc.h"
|
||||
#include "Shared\Include\SharedAssert.h"
|
||||
#include "Shared\Include\SharedAlloc.h"
|
||||
|
||||
|
||||
void integrate(dtCrowdAgent* ag, const float dt)
|
||||
@ -146,7 +146,7 @@ int addNeighbour(const int idx, const float dist,
|
||||
const int tgt = i+1;
|
||||
const int n = dtMin(nneis-i, maxNeis-tgt);
|
||||
|
||||
dtAssert(tgt+n <= maxNeis);
|
||||
rdAssert(tgt+n <= maxNeis);
|
||||
|
||||
if (n > 0)
|
||||
memmove(&neis[tgt], &neis[i], sizeof(dtCrowdNeighbour)*n);
|
||||
@ -218,7 +218,7 @@ int addToOptQueue(dtCrowdAgent* newag, dtCrowdAgent** agents, const int nagents,
|
||||
const int tgt = i+1;
|
||||
const int n = dtMin(nagents-i, maxAgents-tgt);
|
||||
|
||||
dtAssert(tgt+n <= maxAgents);
|
||||
rdAssert(tgt+n <= maxAgents);
|
||||
|
||||
if (n > 0)
|
||||
memmove(&agents[tgt], &agents[i], sizeof(dtCrowdAgent*)*n);
|
||||
@ -254,7 +254,7 @@ int addToPathQueue(dtCrowdAgent* newag, dtCrowdAgent** agents, const int nagents
|
||||
const int tgt = i+1;
|
||||
const int n = dtMin(nagents-i, maxAgents-tgt);
|
||||
|
||||
dtAssert(tgt+n <= maxAgents);
|
||||
rdAssert(tgt+n <= maxAgents);
|
||||
|
||||
if (n > 0)
|
||||
memmove(&agents[tgt], &agents[i], sizeof(dtCrowdAgent*)*n);
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "DetourCrowd\Include\DetourLocalBoundary.h"
|
||||
#include "Detour\Include\DetourNavMeshQuery.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
#include "Detour\Include\DetourAssert.h"
|
||||
#include "Shared\Include\SharedAssert.h"
|
||||
|
||||
|
||||
dtLocalBoundary::dtLocalBoundary() :
|
||||
@ -68,7 +68,7 @@ void dtLocalBoundary::addSegment(const float dist, const float* s)
|
||||
break;
|
||||
const int tgt = i+1;
|
||||
const int n = dtMin(m_nsegs-i, MAX_LOCAL_SEGS-tgt);
|
||||
dtAssert(tgt+n <= MAX_LOCAL_SEGS);
|
||||
rdAssert(tgt+n <= MAX_LOCAL_SEGS);
|
||||
if (n > 0)
|
||||
memmove(&m_segs[tgt], &m_segs[i], sizeof(Segment)*n);
|
||||
seg = &m_segs[i];
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "DetourCrowd\Include\DetourObstacleAvoidance.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
#include "Detour\Include\DetourMath.h"
|
||||
#include "Detour\Include\DetourAlloc.h"
|
||||
#include "Detour\Include\DetourAssert.h"
|
||||
#include "Shared\Include\SharedAlloc.h"
|
||||
#include "Shared\Include\SharedAssert.h"
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
#include <new>
|
||||
@ -67,18 +67,18 @@ static int isectRaySeg(const float* ap, const float* u,
|
||||
|
||||
|
||||
|
||||
dtObstacleAvoidanceDebugData* dtAllocObstacleAvoidanceDebugData()
|
||||
dtObstacleAvoidanceDebugData* rdAllocObstacleAvoidanceDebugData()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtObstacleAvoidanceDebugData), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtObstacleAvoidanceDebugData), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtObstacleAvoidanceDebugData;
|
||||
}
|
||||
|
||||
void dtFreeObstacleAvoidanceDebugData(dtObstacleAvoidanceDebugData* ptr)
|
||||
void rdFreeObstacleAvoidanceDebugData(dtObstacleAvoidanceDebugData* ptr)
|
||||
{
|
||||
if (!ptr) return;
|
||||
ptr->~dtObstacleAvoidanceDebugData();
|
||||
dtFree(ptr);
|
||||
rdFree(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -97,39 +97,39 @@ dtObstacleAvoidanceDebugData::dtObstacleAvoidanceDebugData() :
|
||||
|
||||
dtObstacleAvoidanceDebugData::~dtObstacleAvoidanceDebugData()
|
||||
{
|
||||
dtFree(m_vel);
|
||||
dtFree(m_ssize);
|
||||
dtFree(m_pen);
|
||||
dtFree(m_vpen);
|
||||
dtFree(m_vcpen);
|
||||
dtFree(m_spen);
|
||||
dtFree(m_tpen);
|
||||
rdFree(m_vel);
|
||||
rdFree(m_ssize);
|
||||
rdFree(m_pen);
|
||||
rdFree(m_vpen);
|
||||
rdFree(m_vcpen);
|
||||
rdFree(m_spen);
|
||||
rdFree(m_tpen);
|
||||
}
|
||||
|
||||
bool dtObstacleAvoidanceDebugData::init(const int maxSamples)
|
||||
{
|
||||
dtAssert(maxSamples);
|
||||
rdAssert(maxSamples);
|
||||
m_maxSamples = maxSamples;
|
||||
|
||||
m_vel = (float*)dtAlloc(sizeof(float)*3*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_vel = (float*)rdAlloc(sizeof(float)*3*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_vel)
|
||||
return false;
|
||||
m_pen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_pen = (float*)rdAlloc(sizeof(float)*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_pen)
|
||||
return false;
|
||||
m_ssize = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_ssize = (float*)rdAlloc(sizeof(float)*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_ssize)
|
||||
return false;
|
||||
m_vpen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_vpen = (float*)rdAlloc(sizeof(float)*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_vpen)
|
||||
return false;
|
||||
m_vcpen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_vcpen = (float*)rdAlloc(sizeof(float)*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_vcpen)
|
||||
return false;
|
||||
m_spen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_spen = (float*)rdAlloc(sizeof(float)*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_spen)
|
||||
return false;
|
||||
m_tpen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
|
||||
m_tpen = (float*)rdAlloc(sizeof(float)*m_maxSamples, RD_ALLOC_PERM);
|
||||
if (!m_tpen)
|
||||
return false;
|
||||
|
||||
@ -146,13 +146,13 @@ void dtObstacleAvoidanceDebugData::addSample(const float* vel, const float ssize
|
||||
{
|
||||
if (m_nsamples >= m_maxSamples)
|
||||
return;
|
||||
dtAssert(m_vel);
|
||||
dtAssert(m_ssize);
|
||||
dtAssert(m_pen);
|
||||
dtAssert(m_vpen);
|
||||
dtAssert(m_vcpen);
|
||||
dtAssert(m_spen);
|
||||
dtAssert(m_tpen);
|
||||
rdAssert(m_vel);
|
||||
rdAssert(m_ssize);
|
||||
rdAssert(m_pen);
|
||||
rdAssert(m_vpen);
|
||||
rdAssert(m_vcpen);
|
||||
rdAssert(m_spen);
|
||||
rdAssert(m_tpen);
|
||||
dtVcopy(&m_vel[m_nsamples*3], vel);
|
||||
m_ssize[m_nsamples] = ssize;
|
||||
m_pen[m_nsamples] = pen;
|
||||
@ -189,18 +189,18 @@ void dtObstacleAvoidanceDebugData::normalizeSamples()
|
||||
}
|
||||
|
||||
|
||||
dtObstacleAvoidanceQuery* dtAllocObstacleAvoidanceQuery()
|
||||
dtObstacleAvoidanceQuery* rdAllocObstacleAvoidanceQuery()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtObstacleAvoidanceQuery), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtObstacleAvoidanceQuery), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtObstacleAvoidanceQuery;
|
||||
}
|
||||
|
||||
void dtFreeObstacleAvoidanceQuery(dtObstacleAvoidanceQuery* ptr)
|
||||
void rdFreeObstacleAvoidanceQuery(dtObstacleAvoidanceQuery* ptr)
|
||||
{
|
||||
if (!ptr) return;
|
||||
ptr->~dtObstacleAvoidanceQuery();
|
||||
dtFree(ptr);
|
||||
rdFree(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -219,22 +219,22 @@ dtObstacleAvoidanceQuery::dtObstacleAvoidanceQuery() :
|
||||
|
||||
dtObstacleAvoidanceQuery::~dtObstacleAvoidanceQuery()
|
||||
{
|
||||
dtFree(m_circles);
|
||||
dtFree(m_segments);
|
||||
rdFree(m_circles);
|
||||
rdFree(m_segments);
|
||||
}
|
||||
|
||||
bool dtObstacleAvoidanceQuery::init(const int maxCircles, const int maxSegments)
|
||||
{
|
||||
m_maxCircles = maxCircles;
|
||||
m_ncircles = 0;
|
||||
m_circles = (dtObstacleCircle*)dtAlloc(sizeof(dtObstacleCircle)*m_maxCircles, DT_ALLOC_PERM);
|
||||
m_circles = (dtObstacleCircle*)rdAlloc(sizeof(dtObstacleCircle)*m_maxCircles, RD_ALLOC_PERM);
|
||||
if (!m_circles)
|
||||
return false;
|
||||
memset(m_circles, 0, sizeof(dtObstacleCircle)*m_maxCircles);
|
||||
|
||||
m_maxSegments = maxSegments;
|
||||
m_nsegments = 0;
|
||||
m_segments = (dtObstacleSegment*)dtAlloc(sizeof(dtObstacleSegment)*m_maxSegments, DT_ALLOC_PERM);
|
||||
m_segments = (dtObstacleSegment*)rdAlloc(sizeof(dtObstacleSegment)*m_maxSegments, RD_ALLOC_PERM);
|
||||
if (!m_segments)
|
||||
return false;
|
||||
memset(m_segments, 0, sizeof(dtObstacleSegment)*m_maxSegments);
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "DetourCrowd\Include\DetourPathCorridor.h"
|
||||
#include "Detour\Include\DetourNavMeshQuery.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
#include "Detour\Include\DetourAssert.h"
|
||||
#include "Detour\Include\DetourAlloc.h"
|
||||
#include "Shared\Include\SharedAssert.h"
|
||||
#include "Shared\Include\SharedAlloc.h"
|
||||
|
||||
|
||||
int dtMergeCorridorStartMoved(dtPolyRef* path, const int npath, const int maxPath,
|
||||
@ -100,7 +100,7 @@ int dtMergeCorridorEndMoved(dtPolyRef* path, const int npath, const int maxPath,
|
||||
const int ppos = furthestPath+1;
|
||||
const int vpos = furthestVisited+1;
|
||||
const int count = dtMin(nvisited-vpos, maxPath-ppos);
|
||||
dtAssert(ppos+count <= maxPath);
|
||||
rdAssert(ppos+count <= maxPath);
|
||||
if (count)
|
||||
memcpy(path+ppos, visited+vpos, sizeof(dtPolyRef)*count);
|
||||
|
||||
@ -206,7 +206,7 @@ dtPathCorridor::dtPathCorridor() :
|
||||
|
||||
dtPathCorridor::~dtPathCorridor()
|
||||
{
|
||||
dtFree(m_path);
|
||||
rdFree(m_path);
|
||||
}
|
||||
|
||||
/// @par
|
||||
@ -214,8 +214,8 @@ dtPathCorridor::~dtPathCorridor()
|
||||
/// @warning Cannot be called more than once.
|
||||
bool dtPathCorridor::init(const int maxPath)
|
||||
{
|
||||
dtAssert(!m_path);
|
||||
m_path = (dtPolyRef*)dtAlloc(sizeof(dtPolyRef)*maxPath, DT_ALLOC_PERM);
|
||||
rdAssert(!m_path);
|
||||
m_path = (dtPolyRef*)rdAlloc(sizeof(dtPolyRef)*maxPath, RD_ALLOC_PERM);
|
||||
if (!m_path)
|
||||
return false;
|
||||
m_npath = 0;
|
||||
@ -229,7 +229,7 @@ bool dtPathCorridor::init(const int maxPath)
|
||||
/// equal to the position.
|
||||
void dtPathCorridor::reset(dtPolyRef ref, const float* pos)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
rdAssert(m_path);
|
||||
dtVcopy(m_pos, pos);
|
||||
dtVcopy(m_target, pos);
|
||||
m_path[0] = ref;
|
||||
@ -252,8 +252,8 @@ int dtPathCorridor::findCorners(float* cornerVerts, unsigned char* cornerFlags,
|
||||
dtPolyRef* cornerPolys, const int maxCorners,
|
||||
dtNavMeshQuery* navquery, const dtQueryFilter* /*filter*/)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
dtAssert(m_npath);
|
||||
rdAssert(m_path);
|
||||
rdAssert(m_npath);
|
||||
|
||||
static const float MIN_TARGET_DIST = 0.01f;
|
||||
|
||||
@ -310,7 +310,7 @@ This function is not suitable for long distance searches.
|
||||
void dtPathCorridor::optimizePathVisibility(const float* next, const float pathOptimizationRange,
|
||||
dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
rdAssert(m_path);
|
||||
|
||||
// Clamp the ray to max distance.
|
||||
float goal[3];
|
||||
@ -352,9 +352,9 @@ the call to match the needs to the agent.
|
||||
*/
|
||||
bool dtPathCorridor::optimizePathTopology(dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(navquery);
|
||||
dtAssert(filter);
|
||||
dtAssert(m_path);
|
||||
rdAssert(navquery);
|
||||
rdAssert(filter);
|
||||
rdAssert(m_path);
|
||||
|
||||
if (m_npath < 3)
|
||||
return false;
|
||||
@ -381,9 +381,9 @@ bool dtPathCorridor::moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRe
|
||||
float* startPos, float* endPos,
|
||||
dtNavMeshQuery* navquery)
|
||||
{
|
||||
dtAssert(navquery);
|
||||
dtAssert(m_path);
|
||||
dtAssert(m_npath);
|
||||
rdAssert(navquery);
|
||||
rdAssert(m_path);
|
||||
rdAssert(m_npath);
|
||||
|
||||
// Advance the path up to and over the off-mesh connection.
|
||||
dtPolyRef prevRef = 0, polyRef = m_path[0];
|
||||
@ -409,7 +409,7 @@ bool dtPathCorridor::moveOverOffmeshConnection(dtPolyRef offMeshConRef, dtPolyRe
|
||||
refs[1] = polyRef;
|
||||
|
||||
const dtNavMesh* nav = navquery->getAttachedNavMesh();
|
||||
dtAssert(nav);
|
||||
rdAssert(nav);
|
||||
|
||||
dtStatus status = nav->getOffMeshConnectionPolyEndPoints(refs[0], refs[1], startPos, endPos);
|
||||
if (dtStatusSucceed(status))
|
||||
@ -438,8 +438,8 @@ or it can't be reached using a local search.
|
||||
*/
|
||||
bool dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
dtAssert(m_npath);
|
||||
rdAssert(m_path);
|
||||
rdAssert(m_npath);
|
||||
|
||||
// Move along navmesh and update new position.
|
||||
float result[3];
|
||||
@ -476,8 +476,8 @@ The resulting target will differ from the desired target if the desired target i
|
||||
*/
|
||||
bool dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
dtAssert(m_npath);
|
||||
rdAssert(m_path);
|
||||
rdAssert(m_npath);
|
||||
|
||||
// Move along navmesh and update new position.
|
||||
float result[3];
|
||||
@ -510,9 +510,9 @@ bool dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navqu
|
||||
/// @warning The size of the path must not exceed the size of corridor's path buffer set during #init().
|
||||
void dtPathCorridor::setCorridor(const float* target, const dtPolyRef* path, const int npath)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
dtAssert(npath > 0);
|
||||
dtAssert(npath <= m_maxPath);
|
||||
rdAssert(m_path);
|
||||
rdAssert(npath > 0);
|
||||
rdAssert(npath <= m_maxPath);
|
||||
|
||||
dtVcopy(m_target, target);
|
||||
memcpy(m_path, path, sizeof(dtPolyRef)*npath);
|
||||
@ -521,7 +521,7 @@ void dtPathCorridor::setCorridor(const float* target, const dtPolyRef* path, con
|
||||
|
||||
bool dtPathCorridor::fixPathStart(dtPolyRef safeRef, const float* safePos)
|
||||
{
|
||||
dtAssert(m_path);
|
||||
rdAssert(m_path);
|
||||
|
||||
dtVcopy(m_pos, safePos);
|
||||
if (m_npath < 3 && m_npath > 0)
|
||||
@ -543,9 +543,9 @@ bool dtPathCorridor::fixPathStart(dtPolyRef safeRef, const float* safePos)
|
||||
bool dtPathCorridor::trimInvalidPath(dtPolyRef safeRef, const float* safePos,
|
||||
dtNavMeshQuery* navquery, const dtQueryFilter* filter)
|
||||
{
|
||||
dtAssert(navquery);
|
||||
dtAssert(filter);
|
||||
dtAssert(m_path);
|
||||
rdAssert(navquery);
|
||||
rdAssert(filter);
|
||||
rdAssert(m_path);
|
||||
|
||||
// Keep valid path as far as possible.
|
||||
int n = 0;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "DetourCrowd\Include\DetourPathQueue.h"
|
||||
#include "Detour\Include\DetourNavMesh.h"
|
||||
#include "Detour\Include\DetourNavMeshQuery.h"
|
||||
#include "Detour\Include\DetourAlloc.h"
|
||||
#include "Shared\Include\SharedAlloc.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
|
||||
|
||||
@ -41,11 +41,11 @@ dtPathQueue::~dtPathQueue()
|
||||
|
||||
void dtPathQueue::purge()
|
||||
{
|
||||
dtFreeNavMeshQuery(m_navquery);
|
||||
rdFreeNavMeshQuery(m_navquery);
|
||||
m_navquery = 0;
|
||||
for (int i = 0; i < MAX_QUEUE; ++i)
|
||||
{
|
||||
dtFree(m_queue[i].path);
|
||||
rdFree(m_queue[i].path);
|
||||
m_queue[i].path = 0;
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ bool dtPathQueue::init(const int maxPathSize, const int maxSearchNodeCount, dtNa
|
||||
{
|
||||
purge();
|
||||
|
||||
m_navquery = dtAllocNavMeshQuery();
|
||||
m_navquery = rdAllocNavMeshQuery();
|
||||
if (!m_navquery)
|
||||
return false;
|
||||
if (dtStatusFailed(m_navquery->init(nav, maxSearchNodeCount)))
|
||||
@ -64,7 +64,7 @@ bool dtPathQueue::init(const int maxPathSize, const int maxSearchNodeCount, dtNa
|
||||
for (int i = 0; i < MAX_QUEUE; ++i)
|
||||
{
|
||||
m_queue[i].ref = DT_PATHQ_INVALID;
|
||||
m_queue[i].path = (dtPolyRef*)dtAlloc(sizeof(dtPolyRef)*m_maxPathSize, DT_ALLOC_PERM);
|
||||
m_queue[i].path = (dtPolyRef*)rdAlloc(sizeof(dtPolyRef)*m_maxPathSize, RD_ALLOC_PERM);
|
||||
if (!m_queue[i].path)
|
||||
return false;
|
||||
}
|
||||
|
@ -21,22 +21,22 @@
|
||||
#include "DetourCrowd\Include\DetourProximityGrid.h"
|
||||
#include "Detour\Include\DetourCommon.h"
|
||||
#include "Detour\Include\DetourMath.h"
|
||||
#include "Detour\Include\DetourAlloc.h"
|
||||
#include "Detour\Include\DetourAssert.h"
|
||||
#include "Shared\Include\SharedAlloc.h"
|
||||
#include "Shared\Include\SharedAssert.h"
|
||||
|
||||
|
||||
dtProximityGrid* dtAllocProximityGrid()
|
||||
dtProximityGrid* rdAllocProximityGrid()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtProximityGrid), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtProximityGrid), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtProximityGrid;
|
||||
}
|
||||
|
||||
void dtFreeProximityGrid(dtProximityGrid* ptr)
|
||||
void rdFreeProximityGrid(dtProximityGrid* ptr)
|
||||
{
|
||||
if (!ptr) return;
|
||||
ptr->~dtProximityGrid();
|
||||
dtFree(ptr);
|
||||
rdFree(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -59,28 +59,28 @@ dtProximityGrid::dtProximityGrid() :
|
||||
|
||||
dtProximityGrid::~dtProximityGrid()
|
||||
{
|
||||
dtFree(m_buckets);
|
||||
dtFree(m_pool);
|
||||
rdFree(m_buckets);
|
||||
rdFree(m_pool);
|
||||
}
|
||||
|
||||
bool dtProximityGrid::init(const int poolSize, const float cellSize)
|
||||
{
|
||||
dtAssert(poolSize > 0);
|
||||
dtAssert(cellSize > 0.0f);
|
||||
rdAssert(poolSize > 0);
|
||||
rdAssert(cellSize > 0.0f);
|
||||
|
||||
m_cellSize = cellSize;
|
||||
m_invCellSize = 1.0f / m_cellSize;
|
||||
|
||||
// Allocate hashs buckets
|
||||
m_bucketsSize = dtNextPow2(poolSize);
|
||||
m_buckets = (unsigned short*)dtAlloc(sizeof(unsigned short)*m_bucketsSize, DT_ALLOC_PERM);
|
||||
m_buckets = (unsigned short*)rdAlloc(sizeof(unsigned short)*m_bucketsSize, RD_ALLOC_PERM);
|
||||
if (!m_buckets)
|
||||
return false;
|
||||
|
||||
// Allocate pool of items.
|
||||
m_poolSize = poolSize;
|
||||
m_poolHead = 0;
|
||||
m_pool = (Item*)dtAlloc(sizeof(Item)*m_poolSize, DT_ALLOC_PERM);
|
||||
m_pool = (Item*)rdAlloc(sizeof(Item)*m_poolSize, RD_ALLOC_PERM);
|
||||
if (!m_pool)
|
||||
return false;
|
||||
|
||||
|
@ -256,7 +256,7 @@ private:
|
||||
int m_nupdate;
|
||||
};
|
||||
|
||||
dtTileCache* dtAllocTileCache();
|
||||
void dtFreeTileCache(dtTileCache* tc);
|
||||
dtTileCache* rdAllocTileCache();
|
||||
void rdFreeTileCache(dtTileCache* tc);
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef DETOURTILECACHEBUILDER_H
|
||||
#define DETOURTILECACHEBUILDER_H
|
||||
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Detour/Include/DetourStatus.h"
|
||||
|
||||
static const int DT_TILECACHE_MAGIC = 'D'<<24 | 'T'<<16 | 'L'<<8 | 'R'; ///< 'DTLR';
|
||||
@ -84,12 +84,12 @@ struct dtTileCacheAlloc
|
||||
|
||||
virtual void* alloc(const size_t size)
|
||||
{
|
||||
return dtAlloc(size, DT_ALLOC_TEMP);
|
||||
return rdAlloc(size, RD_ALLOC_TEMP);
|
||||
}
|
||||
|
||||
virtual void free(void* ptr)
|
||||
{
|
||||
dtFree(ptr);
|
||||
rdFree(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
@ -112,17 +112,17 @@ dtStatus dtBuildTileCacheLayer(dtTileCacheCompressor* comp,
|
||||
const unsigned char* cons,
|
||||
unsigned char** outData, int* outDataSize);
|
||||
|
||||
void dtFreeTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheLayer* layer);
|
||||
void rdFreeTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheLayer* layer);
|
||||
|
||||
dtStatus dtDecompressTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheCompressor* comp,
|
||||
unsigned char* compressed, const int compressedSize,
|
||||
dtTileCacheLayer** layerOut);
|
||||
|
||||
dtTileCacheContourSet* dtAllocTileCacheContourSet(dtTileCacheAlloc* alloc);
|
||||
void dtFreeTileCacheContourSet(dtTileCacheAlloc* alloc, dtTileCacheContourSet* cset);
|
||||
dtTileCacheContourSet* rdAllocTileCacheContourSet(dtTileCacheAlloc* alloc);
|
||||
void rdFreeTileCacheContourSet(dtTileCacheAlloc* alloc, dtTileCacheContourSet* cset);
|
||||
|
||||
dtTileCachePolyMesh* dtAllocTileCachePolyMesh(dtTileCacheAlloc* alloc);
|
||||
void dtFreeTileCachePolyMesh(dtTileCacheAlloc* alloc, dtTileCachePolyMesh* lmesh);
|
||||
dtTileCachePolyMesh* rdAllocTileCachePolyMesh(dtTileCacheAlloc* alloc);
|
||||
void rdFreeTileCachePolyMesh(dtTileCacheAlloc* alloc, dtTileCachePolyMesh* lmesh);
|
||||
|
||||
dtStatus dtMarkCylinderArea(dtTileCacheLayer& layer, const float* orig, const float cs, const float ch,
|
||||
const float* pos, const float radius, const float height, const unsigned char areaId);
|
||||
|
@ -4,23 +4,23 @@
|
||||
#include "Detour/Include/DetourNavMesh.h"
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include "Detour/Include/DetourMath.h"
|
||||
#include "Detour/Include/DetourAlloc.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
|
||||
dtTileCache* dtAllocTileCache()
|
||||
dtTileCache* rdAllocTileCache()
|
||||
{
|
||||
void* mem = dtAlloc(sizeof(dtTileCache), DT_ALLOC_PERM);
|
||||
void* mem = rdAlloc(sizeof(dtTileCache), RD_ALLOC_PERM);
|
||||
if (!mem) return 0;
|
||||
return new(mem) dtTileCache;
|
||||
}
|
||||
|
||||
void dtFreeTileCache(dtTileCache* tc)
|
||||
void rdFreeTileCache(dtTileCache* tc)
|
||||
{
|
||||
if (!tc) return;
|
||||
tc->~dtTileCache();
|
||||
dtFree(tc);
|
||||
rdFree(tc);
|
||||
}
|
||||
|
||||
static bool contains(const dtCompressedTileRef* a, const int n, const dtCompressedTileRef v)
|
||||
@ -46,11 +46,11 @@ struct NavMeshTileBuildContext
|
||||
inline ~NavMeshTileBuildContext() { purge(); }
|
||||
void purge()
|
||||
{
|
||||
dtFreeTileCacheLayer(alloc, layer);
|
||||
rdFreeTileCacheLayer(alloc, layer);
|
||||
layer = 0;
|
||||
dtFreeTileCacheContourSet(alloc, lcset);
|
||||
rdFreeTileCacheContourSet(alloc, lcset);
|
||||
lcset = 0;
|
||||
dtFreeTileCachePolyMesh(alloc, lmesh);
|
||||
rdFreeTileCachePolyMesh(alloc, lmesh);
|
||||
lmesh = 0;
|
||||
}
|
||||
struct dtTileCacheLayer* layer;
|
||||
@ -86,15 +86,15 @@ dtTileCache::~dtTileCache()
|
||||
{
|
||||
if (m_tiles[i].flags & DT_COMPRESSEDTILE_FREE_DATA)
|
||||
{
|
||||
dtFree(m_tiles[i].data);
|
||||
rdFree(m_tiles[i].data);
|
||||
m_tiles[i].data = 0;
|
||||
}
|
||||
}
|
||||
dtFree(m_obstacles);
|
||||
rdFree(m_obstacles);
|
||||
m_obstacles = 0;
|
||||
dtFree(m_posLookup);
|
||||
rdFree(m_posLookup);
|
||||
m_posLookup = 0;
|
||||
dtFree(m_tiles);
|
||||
rdFree(m_tiles);
|
||||
m_tiles = 0;
|
||||
m_nreqs = 0;
|
||||
m_nupdate = 0;
|
||||
@ -127,7 +127,7 @@ dtStatus dtTileCache::init(const dtTileCacheParams* params,
|
||||
memcpy(&m_params, params, sizeof(m_params));
|
||||
|
||||
// Alloc space for obstacles.
|
||||
m_obstacles = (dtTileCacheObstacle*)dtAlloc(sizeof(dtTileCacheObstacle)*m_params.maxObstacles, DT_ALLOC_PERM);
|
||||
m_obstacles = (dtTileCacheObstacle*)rdAlloc(sizeof(dtTileCacheObstacle)*m_params.maxObstacles, RD_ALLOC_PERM);
|
||||
if (!m_obstacles)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
memset(m_obstacles, 0, sizeof(dtTileCacheObstacle)*m_params.maxObstacles);
|
||||
@ -144,10 +144,10 @@ dtStatus dtTileCache::init(const dtTileCacheParams* params,
|
||||
if (!m_tileLutSize) m_tileLutSize = 1;
|
||||
m_tileLutMask = m_tileLutSize-1;
|
||||
|
||||
m_tiles = (dtCompressedTile*)dtAlloc(sizeof(dtCompressedTile)*m_params.maxTiles, DT_ALLOC_PERM);
|
||||
m_tiles = (dtCompressedTile*)rdAlloc(sizeof(dtCompressedTile)*m_params.maxTiles, RD_ALLOC_PERM);
|
||||
if (!m_tiles)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
m_posLookup = (dtCompressedTile**)dtAlloc(sizeof(dtCompressedTile*)*m_tileLutSize, DT_ALLOC_PERM);
|
||||
m_posLookup = (dtCompressedTile**)rdAlloc(sizeof(dtCompressedTile*)*m_tileLutSize, RD_ALLOC_PERM);
|
||||
if (!m_posLookup)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
memset(m_tiles, 0, sizeof(dtCompressedTile)*m_params.maxTiles);
|
||||
@ -316,7 +316,7 @@ dtStatus dtTileCache::removeTile(dtCompressedTileRef ref, unsigned char** data,
|
||||
if (tile->flags & DT_COMPRESSEDTILE_FREE_DATA)
|
||||
{
|
||||
// Owns data
|
||||
dtFree(tile->data);
|
||||
rdFree(tile->data);
|
||||
tile->data = 0;
|
||||
tile->dataSize = 0;
|
||||
if (data) *data = 0;
|
||||
@ -648,8 +648,8 @@ dtStatus dtTileCache::buildNavMeshTilesAt(const int tx, const int ty, dtNavMesh*
|
||||
|
||||
dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh* navmesh)
|
||||
{
|
||||
dtAssert(m_talloc);
|
||||
dtAssert(m_tcomp);
|
||||
rdAssert(m_talloc);
|
||||
rdAssert(m_tcomp);
|
||||
|
||||
unsigned int idx = decodeTileIdTile(ref);
|
||||
if (idx > (unsigned int)m_params.maxTiles)
|
||||
@ -701,7 +701,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh*
|
||||
if (dtStatusFailed(status))
|
||||
return status;
|
||||
|
||||
bc.lcset = dtAllocTileCacheContourSet(m_talloc);
|
||||
bc.lcset = rdAllocTileCacheContourSet(m_talloc);
|
||||
if (!bc.lcset)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
status = dtBuildTileCacheContours(m_talloc, *bc.layer, walkableClimbVx,
|
||||
@ -709,7 +709,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh*
|
||||
if (dtStatusFailed(status))
|
||||
return status;
|
||||
|
||||
bc.lmesh = dtAllocTileCachePolyMesh(m_talloc);
|
||||
bc.lmesh = rdAllocTileCachePolyMesh(m_talloc);
|
||||
if (!bc.lmesh)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
status = dtBuildTileCachePolyMesh(m_talloc, *bc.lcset, *bc.lmesh);
|
||||
@ -765,7 +765,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh*
|
||||
status = navmesh->addTile(navData,navDataSize,DT_TILE_FREE_DATA,0,0);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
dtFree(navData);
|
||||
rdFree(navData);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "Detour/Include/DetourCommon.h"
|
||||
#include "Detour/Include/DetourMath.h"
|
||||
#include "Detour/Include/DetourStatus.h"
|
||||
#include "Detour/Include/DetourAssert.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include "DetourTileCache/Include/DetourTileCacheBuilder.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -54,18 +54,18 @@ static const int MAX_REM_EDGES = 48; // TODO: make this an expression.
|
||||
|
||||
|
||||
|
||||
dtTileCacheContourSet* dtAllocTileCacheContourSet(dtTileCacheAlloc* alloc)
|
||||
dtTileCacheContourSet* rdAllocTileCacheContourSet(dtTileCacheAlloc* alloc)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
dtTileCacheContourSet* cset = (dtTileCacheContourSet*)alloc->alloc(sizeof(dtTileCacheContourSet));
|
||||
memset(cset, 0, sizeof(dtTileCacheContourSet));
|
||||
return cset;
|
||||
}
|
||||
|
||||
void dtFreeTileCacheContourSet(dtTileCacheAlloc* alloc, dtTileCacheContourSet* cset)
|
||||
void rdFreeTileCacheContourSet(dtTileCacheAlloc* alloc, dtTileCacheContourSet* cset)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
if (!cset) return;
|
||||
for (int i = 0; i < cset->nconts; ++i)
|
||||
@ -74,18 +74,18 @@ void dtFreeTileCacheContourSet(dtTileCacheAlloc* alloc, dtTileCacheContourSet* c
|
||||
alloc->free(cset);
|
||||
}
|
||||
|
||||
dtTileCachePolyMesh* dtAllocTileCachePolyMesh(dtTileCacheAlloc* alloc)
|
||||
dtTileCachePolyMesh* rdAllocTileCachePolyMesh(dtTileCacheAlloc* alloc)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
dtTileCachePolyMesh* lmesh = (dtTileCachePolyMesh*)alloc->alloc(sizeof(dtTileCachePolyMesh));
|
||||
memset(lmesh, 0, sizeof(dtTileCachePolyMesh));
|
||||
return lmesh;
|
||||
}
|
||||
|
||||
void dtFreeTileCachePolyMesh(dtTileCacheAlloc* alloc, dtTileCachePolyMesh* lmesh)
|
||||
void rdFreeTileCachePolyMesh(dtTileCacheAlloc* alloc, dtTileCachePolyMesh* lmesh)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
if (!lmesh) return;
|
||||
alloc->free(lmesh->verts);
|
||||
@ -178,7 +178,7 @@ dtStatus dtBuildTileCacheRegions(dtTileCacheAlloc* alloc,
|
||||
dtTileCacheLayer& layer,
|
||||
const int walkableClimb)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
const int w = (int)layer.header->width;
|
||||
const int h = (int)layer.header->height;
|
||||
@ -741,7 +741,7 @@ dtStatus dtBuildTileCacheContours(dtTileCacheAlloc* alloc,
|
||||
const int walkableClimb, const float maxError,
|
||||
dtTileCacheContourSet& lcset)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
const int w = (int)layer.header->width;
|
||||
const int h = (int)layer.header->height;
|
||||
@ -1741,7 +1741,7 @@ dtStatus dtBuildTileCachePolyMesh(dtTileCacheAlloc* alloc,
|
||||
dtTileCacheContourSet& lcset,
|
||||
dtTileCachePolyMesh& mesh)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
|
||||
int maxVertices = 0;
|
||||
int maxTris = 0;
|
||||
@ -2104,7 +2104,7 @@ dtStatus dtBuildTileCacheLayer(dtTileCacheCompressor* comp,
|
||||
const int headerSize = dtAlign4(sizeof(dtTileCacheLayerHeader));
|
||||
const int gridSize = (int)header->width * (int)header->height;
|
||||
const int maxDataSize = headerSize + comp->maxCompressedSize(gridSize*3);
|
||||
unsigned char* data = (unsigned char*)dtAlloc(maxDataSize, DT_ALLOC_PERM);
|
||||
unsigned char* data = (unsigned char*)rdAlloc(maxDataSize, RD_ALLOC_PERM);
|
||||
if (!data)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
memset(data, 0, maxDataSize);
|
||||
@ -2114,10 +2114,10 @@ dtStatus dtBuildTileCacheLayer(dtTileCacheCompressor* comp,
|
||||
|
||||
// Concatenate grid data for compression.
|
||||
const int bufferSize = gridSize*3;
|
||||
unsigned char* buffer = (unsigned char*)dtAlloc(bufferSize, DT_ALLOC_TEMP);
|
||||
unsigned char* buffer = (unsigned char*)rdAlloc(bufferSize, RD_ALLOC_TEMP);
|
||||
if (!buffer)
|
||||
{
|
||||
dtFree(data);
|
||||
rdFree(data);
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -2132,22 +2132,22 @@ dtStatus dtBuildTileCacheLayer(dtTileCacheCompressor* comp,
|
||||
dtStatus status = comp->compress(buffer, bufferSize, compressed, maxCompressedSize, &compressedSize);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
dtFree(buffer);
|
||||
dtFree(data);
|
||||
rdFree(buffer);
|
||||
rdFree(data);
|
||||
return status;
|
||||
}
|
||||
|
||||
*outData = data;
|
||||
*outDataSize = headerSize + compressedSize;
|
||||
|
||||
dtFree(buffer);
|
||||
rdFree(buffer);
|
||||
|
||||
return DT_SUCCESS;
|
||||
}
|
||||
|
||||
void dtFreeTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheLayer* layer)
|
||||
void rdFreeTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheLayer* layer)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
rdAssert(alloc);
|
||||
// The layer is allocated as one conitguous blob of data.
|
||||
alloc->free(layer);
|
||||
}
|
||||
@ -2156,8 +2156,8 @@ dtStatus dtDecompressTileCacheLayer(dtTileCacheAlloc* alloc, dtTileCacheCompress
|
||||
unsigned char* compressed, const int compressedSize,
|
||||
dtTileCacheLayer** layerOut)
|
||||
{
|
||||
dtAssert(alloc);
|
||||
dtAssert(comp);
|
||||
rdAssert(alloc);
|
||||
rdAssert(comp);
|
||||
|
||||
if (!layerOut)
|
||||
return DT_FAILURE | DT_INVALID_PARAM;
|
||||
|
68
src/thirdparty/recast/Recast/Include/Recast.h
vendored
68
src/thirdparty/recast/Recast/Include/Recast.h
vendored
@ -399,7 +399,7 @@ struct rcHeightfieldLayer
|
||||
|
||||
/// Represents a set of heightfield layers.
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocHeightfieldLayerSet, rcFreeHeightfieldLayerSet
|
||||
/// @see rdAllocHeightfieldLayerSet, rdFreeHeightfieldLayerSet
|
||||
struct rcHeightfieldLayerSet
|
||||
{
|
||||
rcHeightfieldLayerSet();
|
||||
@ -500,80 +500,80 @@ private:
|
||||
|
||||
/// @name Allocation Functions
|
||||
/// Functions used to allocate and de-allocate Recast objects.
|
||||
/// @see rcAllocSetCustom
|
||||
/// @see rdAllocSetCustom
|
||||
/// @{
|
||||
|
||||
/// Allocates a heightfield object using the Recast allocator.
|
||||
/// @return A heightfield that is ready for initialization, or null on failure.
|
||||
/// @ingroup recast
|
||||
/// @see rcCreateHeightfield, rcFreeHeightField
|
||||
rcHeightfield* rcAllocHeightfield();
|
||||
/// @see rcCreateHeightfield, rdFreeHeightField
|
||||
rcHeightfield* rdAllocHeightfield();
|
||||
|
||||
/// Frees the specified heightfield object using the Recast allocator.
|
||||
/// @param[in] heightfield A heightfield allocated using #rcAllocHeightfield
|
||||
/// @param[in] heightfield A heightfield allocated using #rdAllocHeightfield
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocHeightfield
|
||||
void rcFreeHeightField(rcHeightfield* heightfield);
|
||||
/// @see rdAllocHeightfield
|
||||
void rdFreeHeightField(rcHeightfield* heightfield);
|
||||
|
||||
/// Allocates a compact heightfield object using the Recast allocator.
|
||||
/// @return A compact heightfield that is ready for initialization, or null on failure.
|
||||
/// @ingroup recast
|
||||
/// @see rcBuildCompactHeightfield, rcFreeCompactHeightfield
|
||||
rcCompactHeightfield* rcAllocCompactHeightfield();
|
||||
/// @see rcBuildCompactHeightfield, rdFreeCompactHeightfield
|
||||
rcCompactHeightfield* rdAllocCompactHeightfield();
|
||||
|
||||
/// Frees the specified compact heightfield object using the Recast allocator.
|
||||
/// @param[in] compactHeightfield A compact heightfield allocated using #rcAllocCompactHeightfield
|
||||
/// @param[in] compactHeightfield A compact heightfield allocated using #rdAllocCompactHeightfield
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocCompactHeightfield
|
||||
void rcFreeCompactHeightfield(rcCompactHeightfield* compactHeightfield);
|
||||
/// @see rdAllocCompactHeightfield
|
||||
void rdFreeCompactHeightfield(rcCompactHeightfield* compactHeightfield);
|
||||
|
||||
/// Allocates a heightfield layer set using the Recast allocator.
|
||||
/// @return A heightfield layer set that is ready for initialization, or null on failure.
|
||||
/// @ingroup recast
|
||||
/// @see rcBuildHeightfieldLayers, rcFreeHeightfieldLayerSet
|
||||
rcHeightfieldLayerSet* rcAllocHeightfieldLayerSet();
|
||||
/// @see rcBuildHeightfieldLayers, rdFreeHeightfieldLayerSet
|
||||
rcHeightfieldLayerSet* rdAllocHeightfieldLayerSet();
|
||||
|
||||
/// Frees the specified heightfield layer set using the Recast allocator.
|
||||
/// @param[in] layerSet A heightfield layer set allocated using #rcAllocHeightfieldLayerSet
|
||||
/// @param[in] layerSet A heightfield layer set allocated using #rdAllocHeightfieldLayerSet
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocHeightfieldLayerSet
|
||||
void rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet* layerSet);
|
||||
/// @see rdAllocHeightfieldLayerSet
|
||||
void rdFreeHeightfieldLayerSet(rcHeightfieldLayerSet* layerSet);
|
||||
|
||||
/// Allocates a contour set object using the Recast allocator.
|
||||
/// @return A contour set that is ready for initialization, or null on failure.
|
||||
/// @ingroup recast
|
||||
/// @see rcBuildContours, rcFreeContourSet
|
||||
rcContourSet* rcAllocContourSet();
|
||||
/// @see rcBuildContours, rdFreeContourSet
|
||||
rcContourSet* rdAllocContourSet();
|
||||
|
||||
/// Frees the specified contour set using the Recast allocator.
|
||||
/// @param[in] contourSet A contour set allocated using #rcAllocContourSet
|
||||
/// @param[in] contourSet A contour set allocated using #rdAllocContourSet
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocContourSet
|
||||
void rcFreeContourSet(rcContourSet* contourSet);
|
||||
/// @see rdAllocContourSet
|
||||
void rdFreeContourSet(rcContourSet* contourSet);
|
||||
|
||||
/// Allocates a polygon mesh object using the Recast allocator.
|
||||
/// @return A polygon mesh that is ready for initialization, or null on failure.
|
||||
/// @ingroup recast
|
||||
/// @see rcBuildPolyMesh, rcFreePolyMesh
|
||||
rcPolyMesh* rcAllocPolyMesh();
|
||||
/// @see rcBuildPolyMesh, rdFreePolyMesh
|
||||
rcPolyMesh* rdAllocPolyMesh();
|
||||
|
||||
/// Frees the specified polygon mesh using the Recast allocator.
|
||||
/// @param[in] polyMesh A polygon mesh allocated using #rcAllocPolyMesh
|
||||
/// @param[in] polyMesh A polygon mesh allocated using #rdAllocPolyMesh
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocPolyMesh
|
||||
void rcFreePolyMesh(rcPolyMesh* polyMesh);
|
||||
/// @see rdAllocPolyMesh
|
||||
void rdFreePolyMesh(rcPolyMesh* polyMesh);
|
||||
|
||||
/// Allocates a detail mesh object using the Recast allocator.
|
||||
/// @return A detail mesh that is ready for initialization, or null on failure.
|
||||
/// @ingroup recast
|
||||
/// @see rcBuildPolyMeshDetail, rcFreePolyMeshDetail
|
||||
rcPolyMeshDetail* rcAllocPolyMeshDetail();
|
||||
/// @see rcBuildPolyMeshDetail, rdFreePolyMeshDetail
|
||||
rcPolyMeshDetail* rdAllocPolyMeshDetail();
|
||||
|
||||
/// Frees the specified detail mesh using the Recast allocator.
|
||||
/// @param[in] detailMesh A detail mesh allocated using #rcAllocPolyMeshDetail
|
||||
/// @param[in] detailMesh A detail mesh allocated using #rdAllocPolyMeshDetail
|
||||
/// @ingroup recast
|
||||
/// @see rcAllocPolyMeshDetail
|
||||
void rcFreePolyMeshDetail(rcPolyMeshDetail* detailMesh);
|
||||
/// @see rdAllocPolyMeshDetail
|
||||
void rdFreePolyMeshDetail(rcPolyMeshDetail* detailMesh);
|
||||
|
||||
/// @}
|
||||
|
||||
@ -843,7 +843,7 @@ void rcCalcGridSize(const float* minBounds, const float* maxBounds, float cellSi
|
||||
/// Initializes a new heightfield.
|
||||
/// See the #rcConfig documentation for more information on the configuration parameters.
|
||||
///
|
||||
/// @see rcAllocHeightfield, rcHeightfield
|
||||
/// @see rdAllocHeightfield, rcHeightfield
|
||||
/// @ingroup recast
|
||||
///
|
||||
/// @param[in,out] context The build context to use during the operation.
|
||||
@ -1081,7 +1081,7 @@ int rcGetHeightFieldSpanCount(rcContext* context, const rcHeightfield& heightfie
|
||||
///
|
||||
/// See the #rcConfig documentation for more information on the configuration parameters.
|
||||
///
|
||||
/// @see rcAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig
|
||||
/// @see rdAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig
|
||||
/// @ingroup recast
|
||||
///
|
||||
/// @param[in,out] context The build context to use during the operation.
|
||||
|
@ -1,53 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would be
|
||||
// appreciated but is not required.
|
||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||
// misrepresented as being the original software.
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef RECASTASSERT_H
|
||||
#define RECASTASSERT_H
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
|
||||
# define rcAssert(x) do { (void)sizeof(x); } while ((void)(__LINE__==-1), false)
|
||||
|
||||
#else
|
||||
|
||||
/// An assertion failure function.
|
||||
// @param[in] expression asserted expression.
|
||||
// @param[in] file Filename of the failed assertion.
|
||||
// @param[in] line Line number of the failed assertion.
|
||||
/// @see rcAssertFailSetCustom
|
||||
typedef void (rcAssertFailFunc)(const char* expression, const char* file, int line);
|
||||
|
||||
/// Sets the base custom assertion failure function to be used by Recast.
|
||||
/// @param[in] assertFailFunc The function to be used in case of failure of #dtAssert
|
||||
void rcAssertFailSetCustom(rcAssertFailFunc* assertFailFunc);
|
||||
|
||||
/// Gets the base custom assertion failure function to be used by Recast.
|
||||
rcAssertFailFunc* rcAssertFailGetCustom();
|
||||
|
||||
# include <assert.h>
|
||||
# define rcAssert(expression) \
|
||||
{ \
|
||||
rcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \
|
||||
if (failFunc == NULL) { assert(expression); } \
|
||||
else if (!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // RECASTASSERT_H
|
102
src/thirdparty/recast/Recast/Source/Recast.cpp
vendored
102
src/thirdparty/recast/Recast/Source/Recast.cpp
vendored
@ -17,8 +17,8 @@
|
||||
//
|
||||
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
@ -30,10 +30,10 @@ namespace
|
||||
/// Allocates and constructs an object of the given type, returning a pointer.
|
||||
/// @param[in] allocLifetime Allocation lifetime hint
|
||||
template<typename T>
|
||||
T* rcNew(const rcAllocHint allocLifetime)
|
||||
T* rcNew(const rdAllocHint allocLifetime)
|
||||
{
|
||||
T* ptr = (T*)rcAlloc(sizeof(T), allocLifetime);
|
||||
::new(rcNewTag(), (void*)ptr) T();
|
||||
T* ptr = (T*)rdAlloc(sizeof(T), allocLifetime);
|
||||
::new(rdNewTag(), (void*)ptr) T();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ void rcDelete(T* ptr)
|
||||
if (ptr)
|
||||
{
|
||||
ptr->~T();
|
||||
rcFree((void*)ptr);
|
||||
rdFree((void*)ptr);
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
@ -83,12 +83,12 @@ void rcContext::doResetLog()
|
||||
// Defined out of line to fix the weak v-tables warning
|
||||
}
|
||||
|
||||
rcHeightfield* rcAllocHeightfield()
|
||||
rcHeightfield* rdAllocHeightfield()
|
||||
{
|
||||
return rcNew<rcHeightfield>(RC_ALLOC_PERM);
|
||||
return rcNew<rcHeightfield>(RD_ALLOC_PERM);
|
||||
}
|
||||
|
||||
void rcFreeHeightField(rcHeightfield* heightfield)
|
||||
void rdFreeHeightField(rcHeightfield* heightfield)
|
||||
{
|
||||
rcDelete(heightfield);
|
||||
}
|
||||
@ -109,22 +109,22 @@ rcHeightfield::rcHeightfield()
|
||||
rcHeightfield::~rcHeightfield()
|
||||
{
|
||||
// Delete span array.
|
||||
rcFree(spans);
|
||||
rdFree(spans);
|
||||
// Delete span pools.
|
||||
while (pools)
|
||||
{
|
||||
rcSpanPool* next = pools->next;
|
||||
rcFree(pools);
|
||||
rdFree(pools);
|
||||
pools = next;
|
||||
}
|
||||
}
|
||||
|
||||
rcCompactHeightfield* rcAllocCompactHeightfield()
|
||||
rcCompactHeightfield* rdAllocCompactHeightfield()
|
||||
{
|
||||
return rcNew<rcCompactHeightfield>(RC_ALLOC_PERM);
|
||||
return rcNew<rcCompactHeightfield>(RD_ALLOC_PERM);
|
||||
}
|
||||
|
||||
void rcFreeCompactHeightfield(rcCompactHeightfield* compactHeightfield)
|
||||
void rdFreeCompactHeightfield(rcCompactHeightfield* compactHeightfield)
|
||||
{
|
||||
rcDelete(compactHeightfield);
|
||||
}
|
||||
@ -151,18 +151,18 @@ rcCompactHeightfield::rcCompactHeightfield()
|
||||
|
||||
rcCompactHeightfield::~rcCompactHeightfield()
|
||||
{
|
||||
rcFree(cells);
|
||||
rcFree(spans);
|
||||
rcFree(dist);
|
||||
rcFree(areas);
|
||||
rdFree(cells);
|
||||
rdFree(spans);
|
||||
rdFree(dist);
|
||||
rdFree(areas);
|
||||
}
|
||||
|
||||
rcHeightfieldLayerSet* rcAllocHeightfieldLayerSet()
|
||||
rcHeightfieldLayerSet* rdAllocHeightfieldLayerSet()
|
||||
{
|
||||
return rcNew<rcHeightfieldLayerSet>(RC_ALLOC_PERM);
|
||||
return rcNew<rcHeightfieldLayerSet>(RD_ALLOC_PERM);
|
||||
}
|
||||
|
||||
void rcFreeHeightfieldLayerSet(rcHeightfieldLayerSet* layerSet)
|
||||
void rdFreeHeightfieldLayerSet(rcHeightfieldLayerSet* layerSet)
|
||||
{
|
||||
rcDelete(layerSet);
|
||||
}
|
||||
@ -177,20 +177,20 @@ rcHeightfieldLayerSet::~rcHeightfieldLayerSet()
|
||||
{
|
||||
for (int i = 0; i < nlayers; ++i)
|
||||
{
|
||||
rcFree(layers[i].heights);
|
||||
rcFree(layers[i].areas);
|
||||
rcFree(layers[i].cons);
|
||||
rdFree(layers[i].heights);
|
||||
rdFree(layers[i].areas);
|
||||
rdFree(layers[i].cons);
|
||||
}
|
||||
rcFree(layers);
|
||||
rdFree(layers);
|
||||
}
|
||||
|
||||
|
||||
rcContourSet* rcAllocContourSet()
|
||||
rcContourSet* rdAllocContourSet()
|
||||
{
|
||||
return rcNew<rcContourSet>(RC_ALLOC_PERM);
|
||||
return rcNew<rcContourSet>(RD_ALLOC_PERM);
|
||||
}
|
||||
|
||||
void rcFreeContourSet(rcContourSet* contourSet)
|
||||
void rdFreeContourSet(rcContourSet* contourSet)
|
||||
{
|
||||
rcDelete(contourSet);
|
||||
}
|
||||
@ -213,18 +213,18 @@ rcContourSet::~rcContourSet()
|
||||
{
|
||||
for (int i = 0; i < nconts; ++i)
|
||||
{
|
||||
rcFree(conts[i].verts);
|
||||
rcFree(conts[i].rverts);
|
||||
rdFree(conts[i].verts);
|
||||
rdFree(conts[i].rverts);
|
||||
}
|
||||
rcFree(conts);
|
||||
rdFree(conts);
|
||||
}
|
||||
|
||||
rcPolyMesh* rcAllocPolyMesh()
|
||||
rcPolyMesh* rdAllocPolyMesh()
|
||||
{
|
||||
return rcNew<rcPolyMesh>(RC_ALLOC_PERM);
|
||||
return rcNew<rcPolyMesh>(RD_ALLOC_PERM);
|
||||
}
|
||||
|
||||
void rcFreePolyMesh(rcPolyMesh* polyMesh)
|
||||
void rdFreePolyMesh(rcPolyMesh* polyMesh)
|
||||
{
|
||||
rcDelete(polyMesh);
|
||||
}
|
||||
@ -250,28 +250,28 @@ rcPolyMesh::rcPolyMesh()
|
||||
|
||||
rcPolyMesh::~rcPolyMesh()
|
||||
{
|
||||
rcFree(verts);
|
||||
rcFree(polys);
|
||||
rcFree(regs);
|
||||
rcFree(flags);
|
||||
rcFree(areas);
|
||||
rdFree(verts);
|
||||
rdFree(polys);
|
||||
rdFree(regs);
|
||||
rdFree(flags);
|
||||
rdFree(areas);
|
||||
}
|
||||
|
||||
rcPolyMeshDetail* rcAllocPolyMeshDetail()
|
||||
rcPolyMeshDetail* rdAllocPolyMeshDetail()
|
||||
{
|
||||
return rcNew<rcPolyMeshDetail>(RC_ALLOC_PERM);
|
||||
return rcNew<rcPolyMeshDetail>(RD_ALLOC_PERM);
|
||||
}
|
||||
|
||||
void rcFreePolyMeshDetail(rcPolyMeshDetail* detailMesh)
|
||||
void rdFreePolyMeshDetail(rcPolyMeshDetail* detailMesh)
|
||||
{
|
||||
if (detailMesh == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
rcFree(detailMesh->meshes);
|
||||
rcFree(detailMesh->verts);
|
||||
rcFree(detailMesh->tris);
|
||||
rcFree(detailMesh);
|
||||
rdFree(detailMesh->meshes);
|
||||
rdFree(detailMesh->verts);
|
||||
rdFree(detailMesh->tris);
|
||||
rdFree(detailMesh);
|
||||
}
|
||||
|
||||
rcPolyMeshDetail::rcPolyMeshDetail()
|
||||
@ -315,7 +315,7 @@ bool rcCreateHeightfield(rcContext* context, rcHeightfield& heightfield, int siz
|
||||
rcVcopy(heightfield.bmax, maxBounds);
|
||||
heightfield.cs = cellSize;
|
||||
heightfield.ch = cellHeight;
|
||||
heightfield.spans = (rcSpan**)rcAlloc(sizeof(rcSpan*) * heightfield.width * heightfield.height, RC_ALLOC_PERM);
|
||||
heightfield.spans = (rcSpan**)rdAlloc(sizeof(rcSpan*) * heightfield.width * heightfield.height, RD_ALLOC_PERM);
|
||||
if (!heightfield.spans)
|
||||
{
|
||||
return false;
|
||||
@ -403,7 +403,7 @@ int rcGetHeightFieldSpanCount(rcContext* context, const rcHeightfield& heightfie
|
||||
bool rcBuildCompactHeightfield(rcContext* context, const int walkableHeight, const int walkableClimb,
|
||||
const rcHeightfield& heightfield, rcCompactHeightfield& compactHeightfield)
|
||||
{
|
||||
rcAssert(context);
|
||||
rdAssert(context);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_BUILD_COMPACTHEIGHTFIELD);
|
||||
|
||||
@ -423,21 +423,21 @@ bool rcBuildCompactHeightfield(rcContext* context, const int walkableHeight, con
|
||||
compactHeightfield.bmax[2] += walkableHeight * heightfield.ch;
|
||||
compactHeightfield.cs = heightfield.cs;
|
||||
compactHeightfield.ch = heightfield.ch;
|
||||
compactHeightfield.cells = (rcCompactCell*)rcAlloc(sizeof(rcCompactCell) * xSize * ySize, RC_ALLOC_PERM);
|
||||
compactHeightfield.cells = (rcCompactCell*)rdAlloc(sizeof(rcCompactCell) * xSize * ySize, RD_ALLOC_PERM);
|
||||
if (!compactHeightfield.cells)
|
||||
{
|
||||
context->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Out of memory 'chf.cells' (%d)", xSize * ySize);
|
||||
return false;
|
||||
}
|
||||
memset(compactHeightfield.cells, 0, sizeof(rcCompactCell) * xSize * ySize);
|
||||
compactHeightfield.spans = (rcCompactSpan*)rcAlloc(sizeof(rcCompactSpan) * spanCount, RC_ALLOC_PERM);
|
||||
compactHeightfield.spans = (rcCompactSpan*)rdAlloc(sizeof(rcCompactSpan) * spanCount, RD_ALLOC_PERM);
|
||||
if (!compactHeightfield.spans)
|
||||
{
|
||||
context->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Out of memory 'chf.spans' (%d)", spanCount);
|
||||
return false;
|
||||
}
|
||||
memset(compactHeightfield.spans, 0, sizeof(rcCompactSpan) * spanCount);
|
||||
compactHeightfield.areas = (unsigned char*)rcAlloc(sizeof(unsigned char) * spanCount, RC_ALLOC_PERM);
|
||||
compactHeightfield.areas = (unsigned char*)rdAlloc(sizeof(unsigned char) * spanCount, RD_ALLOC_PERM);
|
||||
if (!compactHeightfield.areas)
|
||||
{
|
||||
context->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Out of memory 'chf.areas' (%d)", spanCount);
|
||||
|
@ -16,33 +16,33 @@
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
|
||||
static void* rcAllocDefault(size_t size, rcAllocHint)
|
||||
static void* rdAllocDefault(size_t size, rdAllocHint)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void rcFreeDefault(void *ptr)
|
||||
static void rdFreeDefault(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static rcAllocFunc* sRecastAllocFunc = rcAllocDefault;
|
||||
static rcFreeFunc* sRecastFreeFunc = rcFreeDefault;
|
||||
static rdAllocFunc* sRecastAllocFunc = rdAllocDefault;
|
||||
static rdFreeFunc* sRecastFreeFunc = rdFreeDefault;
|
||||
|
||||
void rcAllocSetCustom(rcAllocFunc* allocFunc, rcFreeFunc* freeFunc)
|
||||
void rdAllocSetCustom(rdAllocFunc* allocFunc, rdFreeFunc* freeFunc)
|
||||
{
|
||||
sRecastAllocFunc = allocFunc ? allocFunc : rcAllocDefault;
|
||||
sRecastFreeFunc = freeFunc ? freeFunc : rcFreeDefault;
|
||||
sRecastAllocFunc = allocFunc ? allocFunc : rdAllocDefault;
|
||||
sRecastFreeFunc = freeFunc ? freeFunc : rdFreeDefault;
|
||||
}
|
||||
|
||||
void* rcAlloc(size_t size, rcAllocHint hint)
|
||||
void* rdAlloc(size_t size, rdAllocHint hint)
|
||||
{
|
||||
return sRecastAllocFunc(size, hint);
|
||||
}
|
||||
|
||||
void rcFree(void* ptr)
|
||||
void rdFree(void* ptr)
|
||||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
/// @par
|
||||
///
|
||||
@ -36,14 +36,14 @@
|
||||
/// @see rcCompactHeightfield, rcBuildCompactHeightfield, rcConfig::walkableRadius
|
||||
bool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_ERODE_AREA);
|
||||
|
||||
unsigned char* dist = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP);
|
||||
unsigned char* dist = (unsigned char*)rdAlloc(sizeof(unsigned char)*chf.spanCount, RD_ALLOC_TEMP);
|
||||
if (!dist)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "erodeWalkableArea: Out of memory 'dist' (%d).", chf.spanCount);
|
||||
@ -213,7 +213,7 @@ bool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf)
|
||||
if (dist[i] < thr)
|
||||
chf.areas[i] = RC_NULL_AREA;
|
||||
|
||||
rcFree(dist);
|
||||
rdFree(dist);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -238,14 +238,14 @@ static void insertSort(unsigned char* a, const int n)
|
||||
/// @see rcCompactHeightfield
|
||||
bool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_MEDIAN_AREA);
|
||||
|
||||
unsigned char* areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP);
|
||||
unsigned char* areas = (unsigned char*)rdAlloc(sizeof(unsigned char)*chf.spanCount, RD_ALLOC_TEMP);
|
||||
if (!areas)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "medianFilterWalkableArea: Out of memory 'areas' (%d).", chf.spanCount);
|
||||
@ -303,7 +303,7 @@ bool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf)
|
||||
|
||||
memcpy(chf.areas, areas, sizeof(unsigned char)*chf.spanCount);
|
||||
|
||||
rcFree(areas);
|
||||
rdFree(areas);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -316,7 +316,7 @@ bool rcMedianFilterWalkableArea(rcContext* ctx, rcCompactHeightfield& chf)
|
||||
void rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId,
|
||||
rcCompactHeightfield& chf)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_MARK_BOX_AREA);
|
||||
|
||||
@ -382,7 +382,7 @@ void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
|
||||
const float hmin, const float hmax, unsigned char areaId,
|
||||
rcCompactHeightfield& chf)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_MARK_CONVEXPOLY_AREA);
|
||||
|
||||
@ -530,7 +530,7 @@ void rcMarkCylinderArea(rcContext* ctx, const float* pos,
|
||||
const float r, const float h, unsigned char areaId,
|
||||
rcCompactHeightfield& chf)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_MARK_CYLINDER_AREA);
|
||||
|
||||
|
@ -16,18 +16,18 @@
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
static rcAssertFailFunc* sRecastAssertFailFunc = 0;
|
||||
static rdAssertFailFunc* sRecastAssertFailFunc = 0;
|
||||
|
||||
void rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc)
|
||||
void rdAssertFailSetCustom(rdAssertFailFunc *assertFailFunc)
|
||||
{
|
||||
sRecastAssertFailFunc = assertFailFunc;
|
||||
}
|
||||
|
||||
rcAssertFailFunc* rcAssertFailGetCustom()
|
||||
rdAssertFailFunc* rdAssertFailGetCustom()
|
||||
{
|
||||
return sRecastAssertFailFunc;
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
|
||||
static int getCornerHeight(int x, int y, int i, int dir,
|
||||
@ -102,7 +102,7 @@ static int getCornerHeight(int x, int y, int i, int dir,
|
||||
|
||||
static void walkContour(int x, int y, int i,
|
||||
const rcCompactHeightfield& chf,
|
||||
unsigned char* flags, rcIntArray& points)
|
||||
unsigned char* flags, rdIntArray& points)
|
||||
{
|
||||
// Choose the first non-connected edge
|
||||
unsigned char dir = 0;
|
||||
@ -206,7 +206,7 @@ static float distancePtSeg(const int x, const int y,
|
||||
return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
static void simplifyContour(rcIntArray& points, rcIntArray& simplified,
|
||||
static void simplifyContour(rdIntArray& points, rdIntArray& simplified,
|
||||
const float maxError, const int maxEdgeLen, const int buildFlags)
|
||||
{
|
||||
// Add initial points.
|
||||
@ -576,7 +576,7 @@ static bool inCone(int i, int n, const int* verts, const int* pj)
|
||||
}
|
||||
|
||||
|
||||
static void removeDegenerateSegments(rcIntArray& simplified)
|
||||
static void removeDegenerateSegments(rdIntArray& simplified)
|
||||
{
|
||||
// Remove adjacent vertices which are equal on xy-plane,
|
||||
// or else the triangulator will get confused.
|
||||
@ -605,7 +605,7 @@ static void removeDegenerateSegments(rcIntArray& simplified)
|
||||
static bool mergeContours(rcContour& ca, rcContour& cb, int ia, int ib)
|
||||
{
|
||||
const int maxVerts = ca.nverts + cb.nverts + 2;
|
||||
int* verts = (int*)rcAlloc(sizeof(int)*maxVerts*4, RC_ALLOC_PERM);
|
||||
int* verts = (int*)rdAlloc(sizeof(int)*maxVerts*4, RD_ALLOC_PERM);
|
||||
if (!verts)
|
||||
return false;
|
||||
|
||||
@ -635,11 +635,11 @@ static bool mergeContours(rcContour& ca, rcContour& cb, int ia, int ib)
|
||||
nv++;
|
||||
}
|
||||
|
||||
rcFree(ca.verts);
|
||||
rdFree(ca.verts);
|
||||
ca.verts = verts;
|
||||
ca.nverts = nv;
|
||||
|
||||
rcFree(cb.verts);
|
||||
rdFree(cb.verts);
|
||||
cb.verts = 0;
|
||||
cb.nverts = 0;
|
||||
|
||||
@ -730,7 +730,7 @@ static void mergeRegionHoles(rcContext* ctx, rcContourRegion& region)
|
||||
for (int i = 0; i < region.nholes; i++)
|
||||
maxVerts += region.holes[i].contour->nverts;
|
||||
|
||||
rcScopedDelete<rcPotentialDiagonal> diags((rcPotentialDiagonal*)rcAlloc(sizeof(rcPotentialDiagonal)*maxVerts, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcPotentialDiagonal> diags((rcPotentialDiagonal*)rdAlloc(sizeof(rcPotentialDiagonal)*maxVerts, RD_ALLOC_TEMP));
|
||||
if (!diags)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "mergeRegionHoles: Failed to allocated diags %d.", maxVerts);
|
||||
@ -819,12 +819,12 @@ static void mergeRegionHoles(rcContext* ctx, rcContourRegion& region)
|
||||
///
|
||||
/// See the #rcConfig documentation for more information on the configuration parameters.
|
||||
///
|
||||
/// @see rcAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig
|
||||
/// @see rdAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig
|
||||
bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
const float maxError, const int maxEdgeLen,
|
||||
rcContourSet& cset, const int buildFlags)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
@ -851,12 +851,12 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
cset.maxError = maxError;
|
||||
|
||||
int maxContours = rcMax((int)chf.maxRegions, 8);
|
||||
cset.conts = (rcContour*)rcAlloc(sizeof(rcContour)*maxContours, RC_ALLOC_PERM);
|
||||
cset.conts = (rcContour*)rdAlloc(sizeof(rcContour)*maxContours, RD_ALLOC_PERM);
|
||||
if (!cset.conts)
|
||||
return false;
|
||||
cset.nconts = 0;
|
||||
|
||||
rcScopedDelete<unsigned char> flags((unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned char> flags((unsigned char*)rdAlloc(sizeof(unsigned char)*chf.spanCount, RD_ALLOC_TEMP));
|
||||
if (!flags)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'flags' (%d).", chf.spanCount);
|
||||
@ -900,8 +900,8 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
|
||||
ctx->stopTimer(RC_TIMER_BUILD_CONTOURS_TRACE);
|
||||
|
||||
rcIntArray verts(256);
|
||||
rcIntArray simplified(64);
|
||||
rdIntArray verts(256);
|
||||
rdIntArray simplified(64);
|
||||
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
@ -943,7 +943,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
// This happens when a region has holes.
|
||||
const int oldMax = maxContours;
|
||||
maxContours *= 2;
|
||||
rcContour* newConts = (rcContour*)rcAlloc(sizeof(rcContour)*maxContours, RC_ALLOC_PERM);
|
||||
rcContour* newConts = (rcContour*)rdAlloc(sizeof(rcContour)*maxContours, RD_ALLOC_PERM);
|
||||
for (int j = 0; j < cset.nconts; ++j)
|
||||
{
|
||||
newConts[j] = cset.conts[j];
|
||||
@ -951,7 +951,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
cset.conts[j].verts = 0;
|
||||
cset.conts[j].rverts = 0;
|
||||
}
|
||||
rcFree(cset.conts);
|
||||
rdFree(cset.conts);
|
||||
cset.conts = newConts;
|
||||
|
||||
ctx->log(RC_LOG_WARNING, "rcBuildContours: Expanding max contours from %d to %d.", oldMax, maxContours);
|
||||
@ -960,7 +960,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
rcContour* cont = &cset.conts[cset.nconts++];
|
||||
|
||||
cont->nverts = simplified.size()/4;
|
||||
cont->verts = (int*)rcAlloc(sizeof(int)*cont->nverts*4, RC_ALLOC_PERM);
|
||||
cont->verts = (int*)rdAlloc(sizeof(int)*cont->nverts*4, RD_ALLOC_PERM);
|
||||
if (!cont->verts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'verts' (%d).", cont->nverts);
|
||||
@ -979,7 +979,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
}
|
||||
|
||||
cont->nrverts = verts.size()/4;
|
||||
cont->rverts = (int*)rcAlloc(sizeof(int)*cont->nrverts*4, RC_ALLOC_PERM);
|
||||
cont->rverts = (int*)rdAlloc(sizeof(int)*cont->nrverts*4, RD_ALLOC_PERM);
|
||||
if (!cont->rverts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'rverts' (%d).", cont->nrverts);
|
||||
@ -1008,7 +1008,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
if (cset.nconts > 0)
|
||||
{
|
||||
// Calculate winding of all polygons.
|
||||
rcScopedDelete<signed char> winding((signed char*)rcAlloc(sizeof(signed char)*cset.nconts, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<signed char> winding((signed char*)rdAlloc(sizeof(signed char)*cset.nconts, RD_ALLOC_TEMP));
|
||||
if (!winding)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'hole' (%d).", cset.nconts);
|
||||
@ -1029,7 +1029,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
// Collect outline contour and holes contours per region.
|
||||
// We assume that there is one outline and multiple holes.
|
||||
const int nregions = chf.maxRegions+1;
|
||||
rcScopedDelete<rcContourRegion> regions((rcContourRegion*)rcAlloc(sizeof(rcContourRegion)*nregions, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcContourRegion> regions((rcContourRegion*)rdAlloc(sizeof(rcContourRegion)*nregions, RD_ALLOC_TEMP));
|
||||
if (!regions)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'regions' (%d).", nregions);
|
||||
@ -1037,7 +1037,7 @@ bool rcBuildContours(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
}
|
||||
memset(regions, 0, sizeof(rcContourRegion)*nregions);
|
||||
|
||||
rcScopedDelete<rcContourHole> holes((rcContourHole*)rcAlloc(sizeof(rcContourHole)*cset.nconts, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcContourHole> holes((rcContourHole*)rdAlloc(sizeof(rcContourHole)*cset.nconts, RD_ALLOC_TEMP));
|
||||
if (!holes)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildContours: Out of memory 'holes' (%d).", cset.nconts);
|
||||
|
@ -17,13 +17,13 @@
|
||||
//
|
||||
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void rcFilterLowHangingWalkableObstacles(rcContext* context, const int walkableClimb, rcHeightfield& heightfield)
|
||||
{
|
||||
rcAssert(context);
|
||||
rdAssert(context);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_FILTER_LOW_OBSTACLES);
|
||||
|
||||
@ -62,7 +62,7 @@ void rcFilterLowHangingWalkableObstacles(rcContext* context, const int walkableC
|
||||
void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int walkableClimb,
|
||||
rcHeightfield& heightfield)
|
||||
{
|
||||
rcAssert(context);
|
||||
rdAssert(context);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_FILTER_BORDER);
|
||||
|
||||
@ -156,7 +156,7 @@ void rcFilterLedgeSpans(rcContext* context, const int walkableHeight, const int
|
||||
|
||||
void rcFilterWalkableLowHeightSpans(rcContext* context, const int walkableHeight, rcHeightfield& heightfield)
|
||||
{
|
||||
rcAssert(context);
|
||||
rdAssert(context);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_FILTER_WALKABLE);
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
|
||||
// Must be 255 or smaller (not 256) because layer IDs are stored as
|
||||
@ -88,19 +88,19 @@ struct rcLayerSweepSpan
|
||||
///
|
||||
/// See the #rcConfig documentation for more information on the configuration parameters.
|
||||
///
|
||||
/// @see rcAllocHeightfieldLayerSet, rcCompactHeightfield, rcHeightfieldLayerSet, rcConfig
|
||||
/// @see rdAllocHeightfieldLayerSet, rcCompactHeightfield, rcHeightfieldLayerSet, rcConfig
|
||||
bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
const int borderSize, const int walkableHeight,
|
||||
rcHeightfieldLayerSet& lset)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_LAYERS);
|
||||
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
|
||||
rcScopedDelete<unsigned char> srcReg((unsigned char*)rcAlloc(sizeof(unsigned char)*chf.spanCount, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned char> srcReg((unsigned char*)rdAlloc(sizeof(unsigned char)*chf.spanCount, RD_ALLOC_TEMP));
|
||||
if (!srcReg)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'srcReg' (%d).", chf.spanCount);
|
||||
@ -109,7 +109,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
memset(srcReg,0xff,sizeof(unsigned char)*chf.spanCount);
|
||||
|
||||
const int nsweeps = chf.width;
|
||||
rcScopedDelete<rcLayerSweepSpan> sweeps((rcLayerSweepSpan*)rcAlloc(sizeof(rcLayerSweepSpan)*nsweeps, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcLayerSweepSpan> sweeps((rcLayerSweepSpan*)rdAlloc(sizeof(rcLayerSweepSpan)*nsweeps, RD_ALLOC_TEMP));
|
||||
if (!sweeps)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'sweeps' (%d).", nsweeps);
|
||||
@ -220,7 +220,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
|
||||
// Allocate and init layer regions.
|
||||
const int nregs = (int)regId;
|
||||
rcScopedDelete<rcLayerRegion> regs((rcLayerRegion*)rcAlloc(sizeof(rcLayerRegion)*nregs, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcLayerRegion> regs((rcLayerRegion*)rdAlloc(sizeof(rcLayerRegion)*nregs, RD_ALLOC_TEMP));
|
||||
if (!regs)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'regs' (%d).", nregs);
|
||||
@ -480,7 +480,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
return true;
|
||||
|
||||
// Create layers.
|
||||
rcAssert(lset.layers == 0);
|
||||
rdAssert(lset.layers == 0);
|
||||
|
||||
const int lw = w - borderSize*2;
|
||||
const int lh = h - borderSize*2;
|
||||
@ -496,7 +496,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
|
||||
lset.nlayers = (int)layerId;
|
||||
|
||||
lset.layers = (rcHeightfieldLayer*)rcAlloc(sizeof(rcHeightfieldLayer)*lset.nlayers, RC_ALLOC_PERM);
|
||||
lset.layers = (rcHeightfieldLayer*)rdAlloc(sizeof(rcHeightfieldLayer)*lset.nlayers, RD_ALLOC_PERM);
|
||||
if (!lset.layers)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'layers' (%d).", lset.nlayers);
|
||||
@ -514,7 +514,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
|
||||
const int gridSize = sizeof(unsigned char)*lw*lh;
|
||||
|
||||
layer->heights = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);
|
||||
layer->heights = (unsigned char*)rdAlloc(gridSize, RD_ALLOC_PERM);
|
||||
if (!layer->heights)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'heights' (%d).", gridSize);
|
||||
@ -522,7 +522,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
}
|
||||
memset(layer->heights, 0xff, gridSize);
|
||||
|
||||
layer->areas = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);
|
||||
layer->areas = (unsigned char*)rdAlloc(gridSize, RD_ALLOC_PERM);
|
||||
if (!layer->areas)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'areas' (%d).", gridSize);
|
||||
@ -530,7 +530,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
}
|
||||
memset(layer->areas, 0, gridSize);
|
||||
|
||||
layer->cons = (unsigned char*)rcAlloc(gridSize, RC_ALLOC_PERM);
|
||||
layer->cons = (unsigned char*)rdAlloc(gridSize, RD_ALLOC_PERM);
|
||||
if (!layer->cons)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildHeightfieldLayers: Out of memory 'cons' (%d).", gridSize);
|
||||
|
104
src/thirdparty/recast/Recast/Source/RecastMesh.cpp
vendored
104
src/thirdparty/recast/Recast/Source/RecastMesh.cpp
vendored
@ -21,8 +21,8 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include <algorithm>
|
||||
struct rcEdge
|
||||
{
|
||||
@ -38,16 +38,16 @@ static bool buildMeshAdjacency(unsigned short* polys, const int npolys,
|
||||
// https://web.archive.org/web/20080704083314/http://www.terathon.com/code/edges.php
|
||||
|
||||
int maxEdgeCount = npolys*vertsPerPoly;
|
||||
unsigned short* firstEdge = (unsigned short*)rcAlloc(sizeof(unsigned short)*(nverts + maxEdgeCount), RC_ALLOC_TEMP);
|
||||
unsigned short* firstEdge = (unsigned short*)rdAlloc(sizeof(unsigned short)*(nverts + maxEdgeCount), RD_ALLOC_TEMP);
|
||||
if (!firstEdge)
|
||||
return false;
|
||||
unsigned short* nextEdge = firstEdge + nverts;
|
||||
int edgeCount = 0;
|
||||
|
||||
rcEdge* edges = (rcEdge*)rcAlloc(sizeof(rcEdge)*maxEdgeCount, RC_ALLOC_TEMP);
|
||||
rcEdge* edges = (rcEdge*)rdAlloc(sizeof(rcEdge)*maxEdgeCount, RD_ALLOC_TEMP);
|
||||
if (!edges)
|
||||
{
|
||||
rcFree(firstEdge);
|
||||
rdFree(firstEdge);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -116,8 +116,8 @@ static bool buildMeshAdjacency(unsigned short* polys, const int npolys,
|
||||
}
|
||||
}
|
||||
|
||||
rcFree(firstEdge);
|
||||
rcFree(edges);
|
||||
rdFree(firstEdge);
|
||||
rdFree(edges);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -654,7 +654,7 @@ static bool canRemoveVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned sho
|
||||
// Find edges which share the removed vertex.
|
||||
const int maxEdges = numTouchedVerts*2;
|
||||
int nedges = 0;
|
||||
rcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*maxEdges*3, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> edges((int*)rdAlloc(sizeof(int)*maxEdges*3, RD_ALLOC_TEMP));
|
||||
if (!edges)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "canRemoveVertex: Out of memory 'edges' (%d).", maxEdges*3);
|
||||
@ -743,7 +743,7 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
}
|
||||
|
||||
int nedges = 0;
|
||||
rcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp*4, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> edges((int*)rdAlloc(sizeof(int)*numRemovedVerts*nvp*4, RD_ALLOC_TEMP));
|
||||
if (!edges)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'edges' (%d).", numRemovedVerts*nvp*4);
|
||||
@ -751,7 +751,7 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
}
|
||||
|
||||
int nhole = 0;
|
||||
rcScopedDelete<int> hole((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> hole((int*)rdAlloc(sizeof(int)*numRemovedVerts*nvp, RD_ALLOC_TEMP));
|
||||
if (!hole)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'hole' (%d).", numRemovedVerts*nvp);
|
||||
@ -759,7 +759,7 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
}
|
||||
|
||||
int nhreg = 0;
|
||||
rcScopedDelete<int> hreg((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> hreg((int*)rdAlloc(sizeof(int)*numRemovedVerts*nvp, RD_ALLOC_TEMP));
|
||||
if (!hreg)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'hreg' (%d).", numRemovedVerts*nvp);
|
||||
@ -767,7 +767,7 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
}
|
||||
|
||||
int nharea = 0;
|
||||
rcScopedDelete<int> harea((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> harea((int*)rdAlloc(sizeof(int)*numRemovedVerts*nvp, RD_ALLOC_TEMP));
|
||||
if (!harea)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'harea' (%d).", numRemovedVerts*nvp);
|
||||
@ -884,21 +884,21 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
break;
|
||||
}
|
||||
|
||||
rcScopedDelete<int> tris((int*)rcAlloc(sizeof(int)*nhole*3, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> tris((int*)rdAlloc(sizeof(int)*nhole*3, RD_ALLOC_TEMP));
|
||||
if (!tris)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'tris' (%d).", nhole*3);
|
||||
return false;
|
||||
}
|
||||
|
||||
rcScopedDelete<int> tverts((int*)rcAlloc(sizeof(int)*nhole*4, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> tverts((int*)rdAlloc(sizeof(int)*nhole*4, RD_ALLOC_TEMP));
|
||||
if (!tverts)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'tverts' (%d).", nhole*4);
|
||||
return false;
|
||||
}
|
||||
|
||||
rcScopedDelete<int> thole((int*)rcAlloc(sizeof(int)*nhole, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> thole((int*)rdAlloc(sizeof(int)*nhole, RD_ALLOC_TEMP));
|
||||
if (!thole)
|
||||
{
|
||||
ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'thole' (%d).", nhole);
|
||||
@ -925,19 +925,19 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
}
|
||||
|
||||
// Merge the hole triangles back to polygons.
|
||||
rcScopedDelete<unsigned short> polys((unsigned short*)rcAlloc(sizeof(unsigned short)*(ntris+1)*nvp, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned short> polys((unsigned short*)rdAlloc(sizeof(unsigned short)*(ntris+1)*nvp, RD_ALLOC_TEMP));
|
||||
if (!polys)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "removeVertex: Out of memory 'polys' (%d).", (ntris+1)*nvp);
|
||||
return false;
|
||||
}
|
||||
rcScopedDelete<unsigned short> pregs((unsigned short*)rcAlloc(sizeof(unsigned short)*ntris, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned short> pregs((unsigned short*)rdAlloc(sizeof(unsigned short)*ntris, RD_ALLOC_TEMP));
|
||||
if (!pregs)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "removeVertex: Out of memory 'pregs' (%d).", ntris);
|
||||
return false;
|
||||
}
|
||||
rcScopedDelete<unsigned char> pareas((unsigned char*)rcAlloc(sizeof(unsigned char)*ntris, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned char> pareas((unsigned char*)rdAlloc(sizeof(unsigned char)*ntris, RD_ALLOC_TEMP));
|
||||
if (!pareas)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "removeVertex: Out of memory 'pareas' (%d).", ntris);
|
||||
@ -1050,10 +1050,10 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
|
||||
/// @note If the mesh data is to be used to construct a Detour navigation mesh, then the upper
|
||||
/// limit must be restricted to <= #DT_VERTS_PER_POLYGON.
|
||||
///
|
||||
/// @see rcAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig
|
||||
/// @see rdAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig
|
||||
bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMesh& mesh)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_POLYMESH);
|
||||
|
||||
@ -1082,7 +1082,7 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
return false;
|
||||
}
|
||||
|
||||
rcScopedDelete<unsigned char> vflags((unsigned char*)rcAlloc(sizeof(unsigned char)*maxVertices, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned char> vflags((unsigned char*)rdAlloc(sizeof(unsigned char)*maxVertices, RD_ALLOC_TEMP));
|
||||
if (!vflags)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'vflags' (%d).", maxVertices);
|
||||
@ -1090,25 +1090,25 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
}
|
||||
memset(vflags, 0, maxVertices);
|
||||
|
||||
mesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertices*3, RC_ALLOC_PERM);
|
||||
mesh.verts = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxVertices*3, RD_ALLOC_PERM);
|
||||
if (!mesh.verts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.verts' (%d).", maxVertices);
|
||||
return false;
|
||||
}
|
||||
mesh.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxTris*nvp*2, RC_ALLOC_PERM);
|
||||
mesh.polys = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxTris*nvp*2, RD_ALLOC_PERM);
|
||||
if (!mesh.polys)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.polys' (%d).", maxTris*nvp*2);
|
||||
return false;
|
||||
}
|
||||
mesh.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxTris, RC_ALLOC_PERM);
|
||||
mesh.regs = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxTris, RD_ALLOC_PERM);
|
||||
if (!mesh.regs)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.regs' (%d).", maxTris);
|
||||
return false;
|
||||
}
|
||||
mesh.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxTris, RC_ALLOC_PERM);
|
||||
mesh.areas = (unsigned char*)rdAlloc(sizeof(unsigned char)*maxTris, RD_ALLOC_PERM);
|
||||
if (!mesh.areas)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.areas' (%d).", maxTris);
|
||||
@ -1125,7 +1125,7 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
memset(mesh.regs, 0, sizeof(unsigned short)*maxTris);
|
||||
memset(mesh.areas, 0, sizeof(unsigned char)*maxTris);
|
||||
|
||||
rcScopedDelete<int> nextVert((int*)rcAlloc(sizeof(int)*maxVertices, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> nextVert((int*)rdAlloc(sizeof(int)*maxVertices, RD_ALLOC_TEMP));
|
||||
if (!nextVert)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'nextVert' (%d).", maxVertices);
|
||||
@ -1133,7 +1133,7 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
}
|
||||
memset(nextVert, 0, sizeof(int)*maxVertices);
|
||||
|
||||
rcScopedDelete<int> firstVert((int*)rcAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> firstVert((int*)rdAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RD_ALLOC_TEMP));
|
||||
if (!firstVert)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'firstVert' (%d).", VERTEX_BUCKET_COUNT);
|
||||
@ -1142,19 +1142,19 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
for (int i = 0; i < VERTEX_BUCKET_COUNT; ++i)
|
||||
firstVert[i] = -1;
|
||||
|
||||
rcScopedDelete<int> indices((int*)rcAlloc(sizeof(int)*maxVertsPerCont, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> indices((int*)rdAlloc(sizeof(int)*maxVertsPerCont, RD_ALLOC_TEMP));
|
||||
if (!indices)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'indices' (%d).", maxVertsPerCont);
|
||||
return false;
|
||||
}
|
||||
rcScopedDelete<int> tris((int*)rcAlloc(sizeof(int)*maxVertsPerCont*3, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> tris((int*)rdAlloc(sizeof(int)*maxVertsPerCont*3, RD_ALLOC_TEMP));
|
||||
if (!tris)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'tris' (%d).", maxVertsPerCont*3);
|
||||
return false;
|
||||
}
|
||||
rcScopedDelete<unsigned short> polys((unsigned short*)rcAlloc(sizeof(unsigned short)*(maxVertsPerCont+1)*nvp, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned short> polys((unsigned short*)rdAlloc(sizeof(unsigned short)*(maxVertsPerCont+1)*nvp, RD_ALLOC_TEMP));
|
||||
if (!polys)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'polys' (%d).", maxVertsPerCont*nvp);
|
||||
@ -1360,7 +1360,7 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
}
|
||||
|
||||
// Just allocate the mesh flags array. The user is resposible to fill it.
|
||||
mesh.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*mesh.npolys, RC_ALLOC_PERM);
|
||||
mesh.flags = (unsigned short*)rdAlloc(sizeof(unsigned short)*mesh.npolys, RD_ALLOC_PERM);
|
||||
if (!mesh.flags)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.flags' (%d).", mesh.npolys);
|
||||
@ -1380,10 +1380,10 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @see rcAllocPolyMesh, rcPolyMesh
|
||||
/// @see rdAllocPolyMesh, rcPolyMesh
|
||||
bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
if (!nmeshes || !meshes)
|
||||
return true;
|
||||
@ -1409,7 +1409,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
|
||||
mesh.nverts = 0;
|
||||
mesh.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxVerts*3, RC_ALLOC_PERM);
|
||||
mesh.verts = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxVerts*3, RD_ALLOC_PERM);
|
||||
if (!mesh.verts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.verts' (%d).", maxVerts*3);
|
||||
@ -1417,7 +1417,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
|
||||
mesh.npolys = 0;
|
||||
mesh.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys*2*mesh.nvp, RC_ALLOC_PERM);
|
||||
mesh.polys = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxPolys*2*mesh.nvp, RD_ALLOC_PERM);
|
||||
if (!mesh.polys)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.polys' (%d).", maxPolys*2*mesh.nvp);
|
||||
@ -1425,7 +1425,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
memset(mesh.polys, 0xff, sizeof(unsigned short)*maxPolys*2*mesh.nvp);
|
||||
|
||||
mesh.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys, RC_ALLOC_PERM);
|
||||
mesh.regs = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxPolys, RD_ALLOC_PERM);
|
||||
if (!mesh.regs)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.regs' (%d).", maxPolys);
|
||||
@ -1433,7 +1433,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
memset(mesh.regs, 0, sizeof(unsigned short)*maxPolys);
|
||||
|
||||
mesh.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxPolys, RC_ALLOC_PERM);
|
||||
mesh.areas = (unsigned char*)rdAlloc(sizeof(unsigned char)*maxPolys, RD_ALLOC_PERM);
|
||||
if (!mesh.areas)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.areas' (%d).", maxPolys);
|
||||
@ -1441,7 +1441,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
memset(mesh.areas, 0, sizeof(unsigned char)*maxPolys);
|
||||
|
||||
mesh.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxPolys, RC_ALLOC_PERM);
|
||||
mesh.flags = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxPolys, RD_ALLOC_PERM);
|
||||
if (!mesh.flags)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'mesh.flags' (%d).", maxPolys);
|
||||
@ -1449,7 +1449,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
memset(mesh.flags, 0, sizeof(unsigned short)*maxPolys);
|
||||
|
||||
rcScopedDelete<int> nextVert((int*)rcAlloc(sizeof(int)*maxVerts, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> nextVert((int*)rdAlloc(sizeof(int)*maxVerts, RD_ALLOC_TEMP));
|
||||
if (!nextVert)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'nextVert' (%d).", maxVerts);
|
||||
@ -1457,7 +1457,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
}
|
||||
memset(nextVert, 0, sizeof(int)*maxVerts);
|
||||
|
||||
rcScopedDelete<int> firstVert((int*)rcAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> firstVert((int*)rdAlloc(sizeof(int)*VERTEX_BUCKET_COUNT, RD_ALLOC_TEMP));
|
||||
if (!firstVert)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'firstVert' (%d).", VERTEX_BUCKET_COUNT);
|
||||
@ -1466,7 +1466,7 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
for (int i = 0; i < VERTEX_BUCKET_COUNT; ++i)
|
||||
firstVert[i] = -1;
|
||||
|
||||
rcScopedDelete<unsigned short> vremap((unsigned short*)rcAlloc(sizeof(unsigned short)*maxVertsPerMesh, RC_ALLOC_PERM));
|
||||
rdScopedDelete<unsigned short> vremap((unsigned short*)rdAlloc(sizeof(unsigned short)*maxVertsPerMesh, RD_ALLOC_PERM));
|
||||
if (!vremap)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcMergePolyMeshes: Out of memory 'vremap' (%d).", maxVertsPerMesh);
|
||||
@ -1561,14 +1561,14 @@ bool rcMergePolyMeshes(rcContext* ctx, rcPolyMesh** meshes, const int nmeshes, r
|
||||
|
||||
bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(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);
|
||||
rdAssert(dst.verts == 0);
|
||||
rdAssert(dst.polys == 0);
|
||||
rdAssert(dst.regs == 0);
|
||||
rdAssert(dst.areas == 0);
|
||||
rdAssert(dst.flags == 0);
|
||||
|
||||
dst.nverts = src.nverts;
|
||||
dst.npolys = src.npolys;
|
||||
@ -1581,7 +1581,7 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
|
||||
dst.borderSize = src.borderSize;
|
||||
dst.maxEdgeError = src.maxEdgeError;
|
||||
|
||||
dst.verts = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.nverts*3, RC_ALLOC_PERM);
|
||||
dst.verts = (unsigned short*)rdAlloc(sizeof(unsigned short)*src.nverts*3, RD_ALLOC_PERM);
|
||||
if (!dst.verts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.verts' (%d).", src.nverts*3);
|
||||
@ -1589,7 +1589,7 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
|
||||
}
|
||||
memcpy(dst.verts, src.verts, sizeof(unsigned short)*src.nverts*3);
|
||||
|
||||
dst.polys = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys*2*src.nvp, RC_ALLOC_PERM);
|
||||
dst.polys = (unsigned short*)rdAlloc(sizeof(unsigned short)*src.npolys*2*src.nvp, RD_ALLOC_PERM);
|
||||
if (!dst.polys)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.polys' (%d).", src.npolys*2*src.nvp);
|
||||
@ -1597,7 +1597,7 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
|
||||
}
|
||||
memcpy(dst.polys, src.polys, sizeof(unsigned short)*src.npolys*2*src.nvp);
|
||||
|
||||
dst.regs = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys, RC_ALLOC_PERM);
|
||||
dst.regs = (unsigned short*)rdAlloc(sizeof(unsigned short)*src.npolys, RD_ALLOC_PERM);
|
||||
if (!dst.regs)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.regs' (%d).", src.npolys);
|
||||
@ -1605,7 +1605,7 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
|
||||
}
|
||||
memcpy(dst.regs, src.regs, sizeof(unsigned short)*src.npolys);
|
||||
|
||||
dst.areas = (unsigned char*)rcAlloc(sizeof(unsigned char)*src.npolys, RC_ALLOC_PERM);
|
||||
dst.areas = (unsigned char*)rdAlloc(sizeof(unsigned char)*src.npolys, RD_ALLOC_PERM);
|
||||
if (!dst.areas)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.areas' (%d).", src.npolys);
|
||||
@ -1613,7 +1613,7 @@ bool rcCopyPolyMesh(rcContext* ctx, const rcPolyMesh& src, rcPolyMesh& dst)
|
||||
}
|
||||
memcpy(dst.areas, src.areas, sizeof(unsigned char)*src.npolys);
|
||||
|
||||
dst.flags = (unsigned short*)rcAlloc(sizeof(unsigned short)*src.npolys, RC_ALLOC_PERM);
|
||||
dst.flags = (unsigned short*)rdAlloc(sizeof(unsigned short)*src.npolys, RD_ALLOC_PERM);
|
||||
if (!dst.flags)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcCopyPolyMesh: Out of memory 'dst.flags' (%d).", src.npolys);
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
#include <algorithm>
|
||||
|
||||
static const unsigned RC_UNSET_HEIGHT = 0xffff;
|
||||
@ -33,7 +33,7 @@ static const unsigned RC_UNSET_HEIGHT = 0xffff;
|
||||
struct rcHeightPatch
|
||||
{
|
||||
inline rcHeightPatch() : data(0), xmin(0), ymin(0), width(0), height(0) {}
|
||||
inline ~rcHeightPatch() { rcFree(data); }
|
||||
inline ~rcHeightPatch() { rdFree(data); }
|
||||
unsigned short* data;
|
||||
int xmin, ymin, width, height;
|
||||
};
|
||||
@ -523,7 +523,7 @@ static void completeFacet(rcContext* ctx, const float* pts, int npts, int* edges
|
||||
#undef addEdgeN
|
||||
void delaunayHull(rcContext* ctx, const int npts, const float* pts,
|
||||
const int nhull, const int* hull,
|
||||
rcIntArray& tris, rcIntArray& edges)
|
||||
rdIntArray& tris, rdIntArray& edges)
|
||||
{
|
||||
int nfaces = 0;
|
||||
int nedges = 0;
|
||||
@ -662,7 +662,7 @@ inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
|
||||
#define STEP_DIR next
|
||||
#define REV_STEP_DIR prev
|
||||
#endif
|
||||
static void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, const int nin, rcIntArray& tris)
|
||||
static void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, const int nin, rdIntArray& tris)
|
||||
{
|
||||
int start = 0, left = 1, right = nhull-1;
|
||||
|
||||
@ -756,7 +756,7 @@ static bool onHull(int a, int b, int nhull, int* hull)
|
||||
}
|
||||
|
||||
// Find edges that lie on hull and mark them as such.
|
||||
static void setTriFlags(rcIntArray& tris, int nhull, int* hull)
|
||||
static void setTriFlags(rdIntArray& tris, int nhull, int* hull)
|
||||
{
|
||||
// Matches DT_DETAIL_EDGE_BOUNDARY
|
||||
const int DETAIL_EDGE_BOUNDARY = 0x1;
|
||||
@ -778,7 +778,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
||||
const float sampleDist, const float sampleMaxError,
|
||||
const int heightSearchRadius, const rcCompactHeightfield& chf,
|
||||
const rcHeightPatch& hp, float* verts, int& nverts,
|
||||
rcIntArray& tris, rcIntArray& edges, rcIntArray& samples)
|
||||
rdIntArray& tris, rdIntArray& edges, rdIntArray& samples)
|
||||
{
|
||||
static const int MAX_VERTS = 127;
|
||||
static const int MAX_TRIS = 255; // Max tris for delaunay is 2n-2-k (n=num verts, k=num hull verts).
|
||||
@ -1025,7 +1025,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
|
||||
static void seedArrayWithPolyCenter(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
const unsigned short* poly, const int npoly,
|
||||
const unsigned short* verts, const int bs,
|
||||
rcHeightPatch& hp, rcIntArray& array)
|
||||
rcHeightPatch& hp, rdIntArray& array)
|
||||
{
|
||||
// Note: Reads to the compact heightfield are offset by border size (bs)
|
||||
// since border size offset is already removed from the polymesh vertices.
|
||||
@ -1065,7 +1065,7 @@ static void seedArrayWithPolyCenter(rcContext* ctx, const rcCompactHeightfield&
|
||||
}
|
||||
}
|
||||
|
||||
rcAssert(startSpanIndex != -1);
|
||||
rdAssert(startSpanIndex != -1);
|
||||
// Find center of the polygon
|
||||
int pcx = 0, pcy = 0;
|
||||
for (int j = 0; j < npoly; ++j)
|
||||
@ -1155,7 +1155,7 @@ static void seedArrayWithPolyCenter(rcContext* ctx, const rcCompactHeightfield&
|
||||
}
|
||||
|
||||
|
||||
static void push3(rcIntArray& queue, int v1, int v2, int v3)
|
||||
static void push3(rdIntArray& queue, int v1, int v2, int v3)
|
||||
{
|
||||
queue.resize(queue.size() + 3);
|
||||
queue[queue.size() - 3] = v1;
|
||||
@ -1166,7 +1166,7 @@ static void push3(rcIntArray& queue, int v1, int v2, int v3)
|
||||
static void getHeightData(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
const unsigned short* poly, const int npoly,
|
||||
const unsigned short* verts, const int bs,
|
||||
rcHeightPatch& hp, rcIntArray& queue,
|
||||
rcHeightPatch& hp, rdIntArray& queue,
|
||||
int region)
|
||||
{
|
||||
// Note: Reads to the compact heightfield are offset by border size (bs)
|
||||
@ -1284,12 +1284,12 @@ static void getHeightData(rcContext* ctx, const rcCompactHeightfield& chf,
|
||||
///
|
||||
/// See the #rcConfig documentation for more information on the configuration parameters.
|
||||
///
|
||||
/// @see rcAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig
|
||||
/// @see rdAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig
|
||||
bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompactHeightfield& chf,
|
||||
const float sampleDist, const float sampleMaxError,
|
||||
rcPolyMeshDetail& dmesh)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_POLYMESHDETAIL);
|
||||
|
||||
@ -1303,22 +1303,22 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
const int borderSize = mesh.borderSize;
|
||||
const int heightSearchRadius = rcMax(1, (int)ceilf(mesh.maxEdgeError));
|
||||
|
||||
rcIntArray edges(64);
|
||||
rcIntArray tris(512);
|
||||
rcIntArray arr(512);
|
||||
rcIntArray samples(512);
|
||||
rdIntArray edges(64);
|
||||
rdIntArray tris(512);
|
||||
rdIntArray arr(512);
|
||||
rdIntArray samples(512);
|
||||
float verts[256*3];
|
||||
rcHeightPatch hp;
|
||||
int nPolyVerts = 0;
|
||||
int maxhw = 0, maxhh = 0;
|
||||
|
||||
rcScopedDelete<int> bounds((int*)rcAlloc(sizeof(int)*mesh.npolys*4, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<int> bounds((int*)rdAlloc(sizeof(int)*mesh.npolys*4, RD_ALLOC_TEMP));
|
||||
if (!bounds)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'bounds' (%d).", mesh.npolys*4);
|
||||
return false;
|
||||
}
|
||||
rcScopedDelete<float> poly((float*)rcAlloc(sizeof(float)*nvp*3, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<float> poly((float*)rdAlloc(sizeof(float)*nvp*3, RD_ALLOC_TEMP));
|
||||
if (!poly)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'poly' (%d).", nvp*3);
|
||||
@ -1356,7 +1356,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
maxhh = rcMax(maxhh, ymax-ymin);
|
||||
}
|
||||
|
||||
hp.data = (unsigned short*)rcAlloc(sizeof(unsigned short)*maxhw*maxhh, RC_ALLOC_TEMP);
|
||||
hp.data = (unsigned short*)rdAlloc(sizeof(unsigned short)*maxhw*maxhh, RD_ALLOC_TEMP);
|
||||
if (!hp.data)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'hp.data' (%d).", maxhw*maxhh);
|
||||
@ -1366,7 +1366,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
dmesh.nmeshes = mesh.npolys;
|
||||
dmesh.nverts = 0;
|
||||
dmesh.ntris = 0;
|
||||
dmesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*dmesh.nmeshes*4, RC_ALLOC_PERM);
|
||||
dmesh.meshes = (unsigned int*)rdAlloc(sizeof(unsigned int)*dmesh.nmeshes*4, RD_ALLOC_PERM);
|
||||
if (!dmesh.meshes)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.meshes' (%d).", dmesh.nmeshes*4);
|
||||
@ -1377,14 +1377,14 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
int tcap = vcap*2;
|
||||
|
||||
dmesh.nverts = 0;
|
||||
dmesh.verts = (float*)rcAlloc(sizeof(float)*vcap*3, RC_ALLOC_PERM);
|
||||
dmesh.verts = (float*)rdAlloc(sizeof(float)*vcap*3, RD_ALLOC_PERM);
|
||||
if (!dmesh.verts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.verts' (%d).", vcap*3);
|
||||
return false;
|
||||
}
|
||||
dmesh.ntris = 0;
|
||||
dmesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM);
|
||||
dmesh.tris = (unsigned char*)rdAlloc(sizeof(unsigned char)*tcap*4, RD_ALLOC_PERM);
|
||||
if (!dmesh.tris)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).", tcap*4);
|
||||
@ -1454,7 +1454,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
while (dmesh.nverts+nverts > vcap)
|
||||
vcap += 256;
|
||||
|
||||
float* newv = (float*)rcAlloc(sizeof(float)*vcap*3, RC_ALLOC_PERM);
|
||||
float* newv = (float*)rdAlloc(sizeof(float)*vcap*3, RD_ALLOC_PERM);
|
||||
if (!newv)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'newv' (%d).", vcap*3);
|
||||
@ -1462,7 +1462,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
}
|
||||
if (dmesh.nverts)
|
||||
memcpy(newv, dmesh.verts, sizeof(float)*3*dmesh.nverts);
|
||||
rcFree(dmesh.verts);
|
||||
rdFree(dmesh.verts);
|
||||
dmesh.verts = newv;
|
||||
}
|
||||
for (int j = 0; j < nverts; ++j)
|
||||
@ -1478,7 +1478,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
{
|
||||
while (dmesh.ntris+ntris > tcap)
|
||||
tcap += 256;
|
||||
unsigned char* newt = (unsigned char*)rcAlloc(sizeof(unsigned char)*tcap*4, RC_ALLOC_PERM);
|
||||
unsigned char* newt = (unsigned char*)rdAlloc(sizeof(unsigned char)*tcap*4, RD_ALLOC_PERM);
|
||||
if (!newt)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'newt' (%d).", tcap*4);
|
||||
@ -1486,7 +1486,7 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
}
|
||||
if (dmesh.ntris)
|
||||
memcpy(newt, dmesh.tris, sizeof(unsigned char)*4*dmesh.ntris);
|
||||
rcFree(dmesh.tris);
|
||||
rdFree(dmesh.tris);
|
||||
dmesh.tris = newt;
|
||||
}
|
||||
for (int j = 0; j < ntris; ++j)
|
||||
@ -1504,10 +1504,10 @@ bool rcBuildPolyMeshDetail(rcContext* ctx, const rcPolyMesh& mesh, const rcCompa
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @see rcAllocPolyMeshDetail, rcPolyMeshDetail
|
||||
/// @see rdAllocPolyMeshDetail, rcPolyMeshDetail
|
||||
bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int nmeshes, rcPolyMeshDetail& mesh)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_MERGE_POLYMESHDETAIL);
|
||||
|
||||
@ -1524,7 +1524,7 @@ bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int
|
||||
}
|
||||
|
||||
mesh.nmeshes = 0;
|
||||
mesh.meshes = (unsigned int*)rcAlloc(sizeof(unsigned int)*maxMeshes*4, RC_ALLOC_PERM);
|
||||
mesh.meshes = (unsigned int*)rdAlloc(sizeof(unsigned int)*maxMeshes*4, RD_ALLOC_PERM);
|
||||
if (!mesh.meshes)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'pmdtl.meshes' (%d).", maxMeshes*4);
|
||||
@ -1532,7 +1532,7 @@ bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int
|
||||
}
|
||||
|
||||
mesh.ntris = 0;
|
||||
mesh.tris = (unsigned char*)rcAlloc(sizeof(unsigned char)*maxTris*4, RC_ALLOC_PERM);
|
||||
mesh.tris = (unsigned char*)rdAlloc(sizeof(unsigned char)*maxTris*4, RD_ALLOC_PERM);
|
||||
if (!mesh.tris)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.tris' (%d).", maxTris*4);
|
||||
@ -1540,7 +1540,7 @@ bool rcMergePolyMeshDetails(rcContext* ctx, rcPolyMeshDetail** meshes, const int
|
||||
}
|
||||
|
||||
mesh.nverts = 0;
|
||||
mesh.verts = (float*)rcAlloc(sizeof(float)*maxVerts*3, RC_ALLOC_PERM);
|
||||
mesh.verts = (float*)rdAlloc(sizeof(float)*maxVerts*3, RD_ALLOC_PERM);
|
||||
if (!mesh.verts)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildPolyMeshDetail: Out of memory 'dmesh.verts' (%d).", maxVerts*3);
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
/// Check whether two bounding boxes overlap
|
||||
///
|
||||
@ -49,7 +49,7 @@ static rcSpan* allocSpan(rcHeightfield& hf)
|
||||
{
|
||||
// Create new page.
|
||||
// Allocate memory for the new pool.
|
||||
rcSpanPool* spanPool = (rcSpanPool*)rcAlloc(sizeof(rcSpanPool), RC_ALLOC_PERM);
|
||||
rcSpanPool* spanPool = (rcSpanPool*)rdAlloc(sizeof(rcSpanPool), RD_ALLOC_PERM);
|
||||
if (spanPool == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@ -194,7 +194,7 @@ bool rcAddSpan(rcContext* context, rcHeightfield& heightfield,
|
||||
const unsigned short spanMin, const unsigned short spanMax,
|
||||
const unsigned char areaID, const int flagMergeThreshold)
|
||||
{
|
||||
rcAssert(context);
|
||||
rdAssert(context);
|
||||
|
||||
if (!addSpan(heightfield, x, z, spanMin, spanMax, areaID, flagMergeThreshold))
|
||||
{
|
||||
@ -228,7 +228,7 @@ static void dividePoly(const float* inVerts, int inVertsCount,
|
||||
float* outVerts2, int* outVerts2Count,
|
||||
float axisOffset, rcAxis axis)
|
||||
{
|
||||
rcAssert(inVertsCount <= 12);
|
||||
rdAssert(inVertsCount <= 12);
|
||||
|
||||
// How far positive or negative away from the separating axis is each vertex.
|
||||
float inVertAxisDelta[12];
|
||||
@ -459,7 +459,7 @@ bool rcRasterizeTriangle(rcContext* context,
|
||||
const float* v0, const float* v1, const float* v2,
|
||||
const unsigned char areaID, rcHeightfield& heightfield, const int flagMergeThreshold)
|
||||
{
|
||||
rcAssert(context != NULL);
|
||||
rdAssert(context != NULL);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_RASTERIZE_TRIANGLES);
|
||||
|
||||
@ -480,7 +480,7 @@ bool rcRasterizeTriangles(rcContext* context,
|
||||
const int* tris, const unsigned char* triAreaIDs, const int numTris,
|
||||
rcHeightfield& heightfield, const int flagMergeThreshold)
|
||||
{
|
||||
rcAssert(context != NULL);
|
||||
rdAssert(context != NULL);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_RASTERIZE_TRIANGLES);
|
||||
|
||||
@ -507,7 +507,7 @@ bool rcRasterizeTriangles(rcContext* context,
|
||||
const unsigned short* tris, const unsigned char* triAreaIDs, const int numTris,
|
||||
rcHeightfield& heightfield, const int flagMergeThreshold)
|
||||
{
|
||||
rcAssert(context != NULL);
|
||||
rdAssert(context != NULL);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_RASTERIZE_TRIANGLES);
|
||||
|
||||
@ -533,7 +533,7 @@ bool rcRasterizeTriangles(rcContext* context,
|
||||
const float* verts, const unsigned char* triAreaIDs, const int numTris,
|
||||
rcHeightfield& heightfield, const int flagMergeThreshold)
|
||||
{
|
||||
rcAssert(context != NULL);
|
||||
rdAssert(context != NULL);
|
||||
|
||||
rcScopedTimer timer(context, RC_TIMER_RASTERIZE_TRIANGLES);
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "Recast/Include/Recast.h"
|
||||
#include "Recast/Include/RecastAlloc.h"
|
||||
#include "Recast/Include/RecastAssert.h"
|
||||
#include "Shared/Include/SharedAlloc.h"
|
||||
#include "Shared/Include/SharedAssert.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -254,7 +254,7 @@ static bool floodRegion(int x, int y, int i,
|
||||
unsigned short level, unsigned short r,
|
||||
rcCompactHeightfield& chf,
|
||||
unsigned short* srcReg, unsigned short* srcDist,
|
||||
rcTempVector<LevelStackEntry>& stack)
|
||||
rdTempVector<LevelStackEntry>& stack)
|
||||
{
|
||||
const int w = chf.width;
|
||||
|
||||
@ -362,7 +362,7 @@ struct DirtyEntry
|
||||
static void expandRegions(int maxIter, unsigned short level,
|
||||
rcCompactHeightfield& chf,
|
||||
unsigned short* srcReg, unsigned short* srcDist,
|
||||
rcTempVector<LevelStackEntry>& stack,
|
||||
rdTempVector<LevelStackEntry>& stack,
|
||||
bool fillStack)
|
||||
{
|
||||
const int w = chf.width;
|
||||
@ -398,7 +398,7 @@ static void expandRegions(int maxIter, unsigned short level,
|
||||
}
|
||||
}
|
||||
|
||||
rcTempVector<DirtyEntry> dirtyEntries;
|
||||
rdTempVector<DirtyEntry> dirtyEntries;
|
||||
int iter = 0;
|
||||
while (stack.size() > 0)
|
||||
{
|
||||
@ -471,7 +471,7 @@ static void expandRegions(int maxIter, unsigned short level,
|
||||
static void sortCellsByLevel(unsigned short startLevel,
|
||||
rcCompactHeightfield& chf,
|
||||
const unsigned short* srcReg,
|
||||
unsigned int nbStacks, rcTempVector<LevelStackEntry>* stacks,
|
||||
unsigned int nbStacks, rdTempVector<LevelStackEntry>* stacks,
|
||||
unsigned short loglevelsPerStack) // the levels per stack (2 in our case) as a bit shift
|
||||
{
|
||||
const int w = chf.width;
|
||||
@ -506,8 +506,8 @@ static void sortCellsByLevel(unsigned short startLevel,
|
||||
}
|
||||
|
||||
|
||||
static void appendStacks(const rcTempVector<LevelStackEntry>& srcStack,
|
||||
rcTempVector<LevelStackEntry>& dstStack,
|
||||
static void appendStacks(const rdTempVector<LevelStackEntry>& srcStack,
|
||||
rdTempVector<LevelStackEntry>& dstStack,
|
||||
const unsigned short* srcReg)
|
||||
{
|
||||
for (int j=0; j<srcStack.size(); j++)
|
||||
@ -541,8 +541,8 @@ struct rcRegion
|
||||
bool overlap;
|
||||
bool connectsToBorder;
|
||||
unsigned short zmin, zmax;
|
||||
rcIntArray connections;
|
||||
rcIntArray floors;
|
||||
rdIntArray connections;
|
||||
rdIntArray floors;
|
||||
};
|
||||
|
||||
static void removeAdjacentNeighbours(rcRegion& reg)
|
||||
@ -617,11 +617,11 @@ static bool mergeRegions(rcRegion& rega, rcRegion& regb)
|
||||
unsigned short bid = regb.id;
|
||||
|
||||
// Duplicate current neighbourhood.
|
||||
rcIntArray acon;
|
||||
rdIntArray acon;
|
||||
acon.resize(rega.connections.size());
|
||||
for (int i = 0; i < rega.connections.size(); ++i)
|
||||
acon[i] = rega.connections[i];
|
||||
rcIntArray& bcon = regb.connections;
|
||||
rdIntArray& bcon = regb.connections;
|
||||
|
||||
// Find insertion point on A.
|
||||
int insa = -1;
|
||||
@ -700,7 +700,7 @@ static bool isSolidEdge(rcCompactHeightfield& chf, const unsigned short* srcReg,
|
||||
static void walkContour(int x, int y, int i, int dir,
|
||||
rcCompactHeightfield& chf,
|
||||
const unsigned short* srcReg,
|
||||
rcIntArray& cont)
|
||||
rdIntArray& cont)
|
||||
{
|
||||
int startDir = dir;
|
||||
int starti = i;
|
||||
@ -789,13 +789,13 @@ static void walkContour(int x, int y, int i, int dir,
|
||||
static bool mergeAndFilterRegions(rcContext* ctx, int minRegionArea, int mergeRegionSize,
|
||||
unsigned short& maxRegionId,
|
||||
rcCompactHeightfield& chf,
|
||||
unsigned short* srcReg, rcIntArray& overlaps)
|
||||
unsigned short* srcReg, rdIntArray& overlaps)
|
||||
{
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
|
||||
const int nreg = maxRegionId+1;
|
||||
rcTempVector<rcRegion> regions;
|
||||
rdTempVector<rcRegion> regions;
|
||||
if (!regions.reserve(nreg)) {
|
||||
ctx->log(RC_LOG_ERROR, "mergeAndFilterRegions: Out of memory 'regions' (%d).", nreg);
|
||||
return false;
|
||||
@ -860,8 +860,8 @@ static bool mergeAndFilterRegions(rcContext* ctx, int minRegionArea, int mergeRe
|
||||
}
|
||||
|
||||
// Remove too small regions.
|
||||
rcIntArray stack(32);
|
||||
rcIntArray trace(32);
|
||||
rdIntArray stack(32);
|
||||
rdIntArray trace(32);
|
||||
for (int i = 0; i < nreg; ++i)
|
||||
{
|
||||
rcRegion& reg = regions[i];
|
||||
@ -1050,7 +1050,7 @@ static bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,
|
||||
const int h = chf.height;
|
||||
|
||||
const int nreg = maxRegionId+1;
|
||||
rcTempVector<rcRegion> regions;
|
||||
rdTempVector<rcRegion> regions;
|
||||
|
||||
// Construct regions
|
||||
if (!regions.reserve(nreg)) {
|
||||
@ -1061,7 +1061,7 @@ static bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,
|
||||
regions.push_back(rcRegion((unsigned short) i));
|
||||
|
||||
// Find region neighbours and overlapping regions.
|
||||
rcIntArray lregs(32);
|
||||
rdIntArray lregs(32);
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
for (int x = 0; x < w; ++x)
|
||||
@ -1130,7 +1130,7 @@ static bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,
|
||||
regions[i].id = 0;
|
||||
|
||||
// Merge montone regions to create non-overlapping areas.
|
||||
rcIntArray stack(32);
|
||||
rdIntArray stack(32);
|
||||
for (int i = 1; i < nreg; ++i)
|
||||
{
|
||||
rcRegion& root = regions[i];
|
||||
@ -1258,27 +1258,27 @@ static bool mergeAndFilterLayerRegions(rcContext* ctx, int minRegionArea,
|
||||
/// @see rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone
|
||||
bool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_DISTANCEFIELD);
|
||||
|
||||
if (chf.dist)
|
||||
{
|
||||
rcFree(chf.dist);
|
||||
rdFree(chf.dist);
|
||||
chf.dist = 0;
|
||||
}
|
||||
|
||||
unsigned short* src = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);
|
||||
unsigned short* src = (unsigned short*)rdAlloc(sizeof(unsigned short)*chf.spanCount, RD_ALLOC_TEMP);
|
||||
if (!src)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildDistanceField: Out of memory 'src' (%d).", chf.spanCount);
|
||||
return false;
|
||||
}
|
||||
unsigned short* dst = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);
|
||||
unsigned short* dst = (unsigned short*)rdAlloc(sizeof(unsigned short)*chf.spanCount, RD_ALLOC_TEMP);
|
||||
if (!dst)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildDistanceField: Out of memory 'dst' (%d).", chf.spanCount);
|
||||
rcFree(src);
|
||||
rdFree(src);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1302,7 +1302,7 @@ bool rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf)
|
||||
chf.dist = src;
|
||||
}
|
||||
|
||||
rcFree(dst);
|
||||
rdFree(dst);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1358,7 +1358,7 @@ struct rcSweepSpan
|
||||
bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
const int borderSize, const int minRegionArea, const int mergeRegionArea)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);
|
||||
|
||||
@ -1366,7 +1366,7 @@ bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
const int h = chf.height;
|
||||
unsigned short id = 1;
|
||||
|
||||
rcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned short> srcReg((unsigned short*)rdAlloc(sizeof(unsigned short)*chf.spanCount, RD_ALLOC_TEMP));
|
||||
if (!srcReg)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'src' (%d).", chf.spanCount);
|
||||
@ -1375,7 +1375,7 @@ bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
memset(srcReg,0,sizeof(unsigned short)*chf.spanCount);
|
||||
|
||||
const int nsweeps = rcMax(chf.width,chf.height);
|
||||
rcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rdAlloc(sizeof(rcSweepSpan)*nsweeps, RD_ALLOC_TEMP));
|
||||
if (!sweeps)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildRegionsMonotone: Out of memory 'sweeps' (%d).", nsweeps);
|
||||
@ -1398,7 +1398,7 @@ bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
|
||||
chf.borderSize = borderSize;
|
||||
|
||||
rcIntArray prev(256);
|
||||
rdIntArray prev(256);
|
||||
|
||||
// Sweep one line at a time.
|
||||
for (int y = borderSize; y < h-borderSize; ++y)
|
||||
@ -1494,7 +1494,7 @@ bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
rcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);
|
||||
|
||||
// Merge regions and filter out small regions.
|
||||
rcIntArray overlaps;
|
||||
rdIntArray overlaps;
|
||||
chf.maxRegions = id;
|
||||
if (!mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, chf.maxRegions, chf, srcReg, overlaps))
|
||||
return false;
|
||||
@ -1531,14 +1531,14 @@ bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
const int borderSize, const int minRegionArea, const int mergeRegionArea)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);
|
||||
|
||||
const int w = chf.width;
|
||||
const int h = chf.height;
|
||||
|
||||
rcScopedDelete<unsigned short> buf((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount*2, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned short> buf((unsigned short*)rdAlloc(sizeof(unsigned short)*chf.spanCount*2, RD_ALLOC_TEMP));
|
||||
if (!buf)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildRegions: Out of memory 'tmp' (%d).", chf.spanCount*4);
|
||||
@ -1549,11 +1549,11 @@ bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
|
||||
const int LOG_NB_STACKS = 3;
|
||||
const int NB_STACKS = 1 << LOG_NB_STACKS;
|
||||
rcTempVector<LevelStackEntry> lvlStacks[NB_STACKS];
|
||||
rdTempVector<LevelStackEntry> lvlStacks[NB_STACKS];
|
||||
for (int i=0; i<NB_STACKS; ++i)
|
||||
lvlStacks[i].reserve(256);
|
||||
|
||||
rcTempVector<LevelStackEntry> stack;
|
||||
rdTempVector<LevelStackEntry> stack;
|
||||
stack.reserve(256);
|
||||
|
||||
unsigned short* srcReg = buf;
|
||||
@ -1644,7 +1644,7 @@ bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
rcScopedTimer timerFilter(ctx, RC_TIMER_BUILD_REGIONS_FILTER);
|
||||
|
||||
// Merge regions and filter out small regions.
|
||||
rcIntArray overlaps;
|
||||
rdIntArray overlaps;
|
||||
chf.maxRegions = regionId;
|
||||
if (!mergeAndFilterRegions(ctx, minRegionArea, mergeRegionArea, chf.maxRegions, chf, srcReg, overlaps))
|
||||
return false;
|
||||
@ -1667,7 +1667,7 @@ bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
const int borderSize, const int minRegionArea)
|
||||
{
|
||||
rcAssert(ctx);
|
||||
rdAssert(ctx);
|
||||
|
||||
rcScopedTimer timer(ctx, RC_TIMER_BUILD_REGIONS);
|
||||
|
||||
@ -1675,7 +1675,7 @@ bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
const int h = chf.height;
|
||||
unsigned short id = 1;
|
||||
|
||||
rcScopedDelete<unsigned short> srcReg((unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<unsigned short> srcReg((unsigned short*)rdAlloc(sizeof(unsigned short)*chf.spanCount, RD_ALLOC_TEMP));
|
||||
if (!srcReg)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildLayerRegions: Out of memory 'src' (%d).", chf.spanCount);
|
||||
@ -1684,7 +1684,7 @@ bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
memset(srcReg,0,sizeof(unsigned short)*chf.spanCount);
|
||||
|
||||
const int nsweeps = rcMax(chf.width,chf.height);
|
||||
rcScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rcAlloc(sizeof(rcSweepSpan)*nsweeps, RC_ALLOC_TEMP));
|
||||
rdScopedDelete<rcSweepSpan> sweeps((rcSweepSpan*)rdAlloc(sizeof(rcSweepSpan)*nsweeps, RD_ALLOC_TEMP));
|
||||
if (!sweeps)
|
||||
{
|
||||
ctx->log(RC_LOG_ERROR, "rcBuildLayerRegions: Out of memory 'sweeps' (%d).", nsweeps);
|
||||
@ -1707,7 +1707,7 @@ bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
|
||||
chf.borderSize = borderSize;
|
||||
|
||||
rcIntArray prev(256);
|
||||
rdIntArray prev(256);
|
||||
|
||||
// Sweep one line at a time.
|
||||
for (int y = borderSize; y < h-borderSize; ++y)
|
||||
|
@ -16,40 +16,37 @@
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef RECASTALLOC_H
|
||||
#define RECASTALLOC_H
|
||||
#ifndef RECASTDETOURALLOC_H
|
||||
#define RECASTDETOURALLOC_H
|
||||
|
||||
#include "RecastAssert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "SharedAssert.h"
|
||||
|
||||
/// Provides hint values to the memory allocator on how long the
|
||||
/// memory is expected to be used.
|
||||
enum rcAllocHint
|
||||
enum rdAllocHint
|
||||
{
|
||||
RC_ALLOC_PERM, ///< Memory will persist after a function call.
|
||||
RC_ALLOC_TEMP ///< Memory used temporarily within a function.
|
||||
RD_ALLOC_PERM, ///< Memory will persist after a function call.
|
||||
RD_ALLOC_TEMP ///< Memory used temporarily within a function.
|
||||
};
|
||||
|
||||
/// A memory allocation function.
|
||||
// @param[in] size The size, in bytes of memory, to allocate.
|
||||
// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
||||
// @param[in] rdAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
||||
// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||
/// @see rcAllocSetCustom
|
||||
typedef void* (rcAllocFunc)(size_t size, rcAllocHint hint);
|
||||
/// @see rdAllocSetCustom
|
||||
typedef void* (rdAllocFunc)(size_t size, rdAllocHint hint);
|
||||
|
||||
/// A memory deallocation function.
|
||||
/// @param[in] ptr A pointer to a memory block previously allocated using #rcAllocFunc.
|
||||
/// @see rcAllocSetCustom
|
||||
typedef void (rcFreeFunc)(void* ptr);
|
||||
/// @param[in] ptr A pointer to a memory block previously allocated using #rdAllocFunc.
|
||||
/// @see rdAllocSetCustom
|
||||
typedef void (rdFreeFunc)(void* ptr);
|
||||
|
||||
/// Sets the base custom allocation functions to be used by Recast.
|
||||
/// @param[in] allocFunc The memory allocation function to be used by #rcAlloc
|
||||
/// @param[in] freeFunc The memory de-allocation function to be used by #rcFree
|
||||
/// @param[in] allocFunc The memory allocation function to be used by #rdAlloc
|
||||
/// @param[in] freeFunc The memory de-allocation function to be used by #rdFree
|
||||
///
|
||||
/// @see rcAlloc, rcFree
|
||||
void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc);
|
||||
/// @see rdAlloc, rdFree
|
||||
void rdAllocSetCustom(rdAllocFunc *allocFunc, rdFreeFunc *freeFunc);
|
||||
|
||||
/// Allocates a memory block.
|
||||
///
|
||||
@ -57,102 +54,102 @@ void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc);
|
||||
/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
|
||||
/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||
///
|
||||
/// @see rcFree, rcAllocSetCustom
|
||||
void* rcAlloc(size_t size, rcAllocHint hint);
|
||||
/// @see rdFree, rdAllocSetCustom
|
||||
void* rdAlloc(size_t size, rdAllocHint hint);
|
||||
|
||||
/// Deallocates a memory block. If @p ptr is NULL, this does nothing.
|
||||
///
|
||||
/// @warning This function leaves the value of @p ptr unchanged. So it still
|
||||
/// points to the same (now invalid) location, and not to null.
|
||||
///
|
||||
/// @param[in] ptr A pointer to a memory block previously allocated using #rcAlloc.
|
||||
/// @param[in] ptr A pointer to a memory block previously allocated using #rdAlloc.
|
||||
///
|
||||
/// @see rcAlloc, rcAllocSetCustom
|
||||
void rcFree(void* ptr);
|
||||
/// @see rdAlloc, rdAllocSetCustom
|
||||
void rdFree(void* ptr);
|
||||
|
||||
/// An implementation of operator new usable for placement new. The default one is part of STL (which we don't use).
|
||||
/// rcNewTag is a dummy type used to differentiate our operator from the STL one, in case users import both Recast
|
||||
/// rdNewTag is a dummy type used to differentiate our operator from the STL one, in case users import both Recast
|
||||
/// and STL.
|
||||
struct rcNewTag {};
|
||||
inline void* operator new(size_t, const rcNewTag&, void* p) { return p; }
|
||||
inline void operator delete(void*, const rcNewTag&, void*) {}
|
||||
struct rdNewTag {};
|
||||
inline void* operator new(size_t, const rdNewTag&, void* p) { return p; }
|
||||
inline void operator delete(void*, const rdNewTag&, void*) {}
|
||||
|
||||
/// Signed to avoid warnnings when comparing to int loop indexes, and common error with comparing to zero.
|
||||
/// Signed to avoid warnings when comparing to int loop indexes, and common error with comparing to zero.
|
||||
/// MSVC2010 has a bug where ssize_t is unsigned (!!!).
|
||||
typedef intptr_t rcSizeType;
|
||||
#define RC_SIZE_MAX INTPTR_MAX
|
||||
typedef intptr_t rdSizeType;
|
||||
#define RD_SIZE_MAX INTPTR_MAX
|
||||
|
||||
/// Macros to hint to the compiler about the likeliest branch. Please add a benchmark that demonstrates a performance
|
||||
/// improvement before introducing use cases.
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define rcLikely(x) __builtin_expect((x), true)
|
||||
#define rcUnlikely(x) __builtin_expect((x), false)
|
||||
#define rdLikely(x) __builtin_expect((x), true)
|
||||
#define rdUnlikely(x) __builtin_expect((x), false)
|
||||
#else
|
||||
#define rcLikely(x) (x)
|
||||
#define rcUnlikely(x) (x)
|
||||
#define rdLikely(x) (x)
|
||||
#define rdUnlikely(x) (x)
|
||||
#endif
|
||||
|
||||
/// Variable-sized storage type. Mimics the interface of std::vector<T> with some notable differences:
|
||||
/// * Uses rcAlloc()/rcFree() to handle storage.
|
||||
/// * Uses rdAlloc()/rdFree() to handle storage.
|
||||
/// * No support for a custom allocator.
|
||||
/// * Uses signed size instead of size_t to avoid warnings in for loops: "for (int i = 0; i < foo.size(); i++)"
|
||||
/// * Omits methods of limited utility: insert/erase, (bad performance), at (we don't use exceptions), operator=.
|
||||
/// * assign() and the pre-sizing constructor follow C++11 semantics -- they don't construct a temporary if no value is provided.
|
||||
/// * push_back() and resize() support adding values from the current vector. Range-based constructors and assign(begin, end) do not.
|
||||
/// * No specialization for bool.
|
||||
template <typename T, rcAllocHint H>
|
||||
class rcVectorBase {
|
||||
rcSizeType m_size;
|
||||
rcSizeType m_cap;
|
||||
template <typename T, rdAllocHint H>
|
||||
class rdVectorBase {
|
||||
rdSizeType m_size;
|
||||
rdSizeType m_cap;
|
||||
T* m_data;
|
||||
// Constructs a T at the give address with either the copy constructor or the default.
|
||||
static void construct(T* p, const T& v) { ::new(rcNewTag(), (void*)p) T(v); }
|
||||
static void construct(T* p) { ::new(rcNewTag(), (void*)p) T; }
|
||||
static void construct(T* p, const T& v) { ::new(rdNewTag(), (void*)p) T(v); }
|
||||
static void construct(T* p) { ::new(rdNewTag(), (void*)p) T; }
|
||||
static void construct_range(T* begin, T* end);
|
||||
static void construct_range(T* begin, T* end, const T& value);
|
||||
static void copy_range(T* dst, const T* begin, const T* end);
|
||||
void destroy_range(rcSizeType begin, rcSizeType end);
|
||||
void destroy_range(rdSizeType begin, rdSizeType end);
|
||||
// Creates an array of the given size, copies all of this vector's data into it, and returns it.
|
||||
T* allocate_and_copy(rcSizeType size);
|
||||
void resize_impl(rcSizeType size, const T* value);
|
||||
T* allocate_and_copy(rdSizeType size);
|
||||
void resize_impl(rdSizeType size, const T* value);
|
||||
// Requires: min_capacity > m_cap.
|
||||
rcSizeType get_new_capacity(rcSizeType min_capacity);
|
||||
rdSizeType get_new_capacity(rdSizeType min_capacity);
|
||||
public:
|
||||
typedef rcSizeType size_type;
|
||||
typedef rdSizeType size_type;
|
||||
typedef T value_type;
|
||||
|
||||
rcVectorBase() : m_size(0), m_cap(0), m_data(0) {}
|
||||
rcVectorBase(const rcVectorBase<T, H>& 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() { destroy_range(0, m_size); rcFree(m_data); }
|
||||
rdVectorBase() : m_size(0), m_cap(0), m_data(0) {}
|
||||
rdVectorBase(const rdVectorBase<T, H>& other) : m_size(0), m_cap(0), m_data(0) { assign(other.begin(), other.end()); }
|
||||
explicit rdVectorBase(rdSizeType count) : m_size(0), m_cap(0), m_data(0) { resize(count); }
|
||||
rdVectorBase(rdSizeType count, const T& value) : m_size(0), m_cap(0), m_data(0) { resize(count, value); }
|
||||
rdVectorBase(const T* begin, const T* end) : m_size(0), m_cap(0), m_data(0) { assign(begin, end); }
|
||||
~rdVectorBase() { destroy_range(0, m_size); rdFree(m_data); }
|
||||
|
||||
// Unlike in std::vector, we return a bool to indicate whether the alloc was successful.
|
||||
bool reserve(rcSizeType size);
|
||||
bool reserve(rdSizeType size);
|
||||
|
||||
void assign(rcSizeType count, const T& value) { clear(); resize(count, value); }
|
||||
void assign(rdSizeType 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, const T& value) { resize_impl(size, &value); }
|
||||
void resize(rdSizeType size) { resize_impl(size, NULL); }
|
||||
void resize(rdSizeType 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; }
|
||||
|
||||
void push_back(const T& value);
|
||||
void pop_back() { rcAssert(m_size > 0); back().~T(); m_size--; }
|
||||
void pop_back() { rdAssert(m_size > 0); back().~T(); m_size--; }
|
||||
|
||||
rcSizeType size() const { return m_size; }
|
||||
rcSizeType capacity() const { return m_cap; }
|
||||
rdSizeType size() const { return m_size; }
|
||||
rdSizeType capacity() const { return m_cap; }
|
||||
bool empty() const { return size() == 0; }
|
||||
|
||||
const T& operator[](rcSizeType i) const { rcAssert(i >= 0 && i < m_size); return m_data[i]; }
|
||||
T& operator[](rcSizeType i) { rcAssert(i >= 0 && i < m_size); return m_data[i]; }
|
||||
const T& operator[](rdSizeType i) const { rdAssert(i >= 0 && i < m_size); return m_data[i]; }
|
||||
T& operator[](rdSizeType i) { rdAssert(i >= 0 && i < m_size); return m_data[i]; }
|
||||
|
||||
const T& front() const { rcAssert(m_size); return m_data[0]; }
|
||||
T& front() { rcAssert(m_size); return m_data[0]; }
|
||||
const T& back() const { rcAssert(m_size); return m_data[m_size - 1]; }
|
||||
T& back() { rcAssert(m_size); return m_data[m_size - 1]; }
|
||||
const T& front() const { rdAssert(m_size); return m_data[0]; }
|
||||
T& front() { rdAssert(m_size); return m_data[0]; }
|
||||
const T& back() const { rdAssert(m_size); return m_data[m_size - 1]; }
|
||||
T& back() { rdAssert(m_size); return m_data[m_size - 1]; }
|
||||
const T* data() const { return m_data; }
|
||||
T* data() { return m_data; }
|
||||
|
||||
@ -161,14 +158,14 @@ class rcVectorBase {
|
||||
const T* begin() const { return m_data; }
|
||||
const T* end() const { return m_data + m_size; }
|
||||
|
||||
void swap(rcVectorBase<T, H>& other);
|
||||
void swap(rdVectorBase<T, H>& other);
|
||||
|
||||
// Explicitly deleted.
|
||||
rcVectorBase& operator=(const rcVectorBase<T, H>& other);
|
||||
rdVectorBase& operator=(const rdVectorBase<T, H>& other);
|
||||
};
|
||||
|
||||
template<typename T, rcAllocHint H>
|
||||
bool rcVectorBase<T, H>::reserve(rcSizeType count) {
|
||||
template<typename T, rdAllocHint H>
|
||||
bool rdVectorBase<T, H>::reserve(rdSizeType count) {
|
||||
if (count <= m_cap) {
|
||||
return true;
|
||||
}
|
||||
@ -177,37 +174,37 @@ bool rcVectorBase<T, H>::reserve(rcSizeType count) {
|
||||
return false;
|
||||
}
|
||||
destroy_range(0, m_size);
|
||||
rcFree(m_data);
|
||||
rdFree(m_data);
|
||||
m_data = new_data;
|
||||
m_cap = count;
|
||||
return true;
|
||||
}
|
||||
template <typename T, rcAllocHint H>
|
||||
T* rcVectorBase<T, H>::allocate_and_copy(rcSizeType size) {
|
||||
rcAssert(RC_SIZE_MAX / static_cast<rcSizeType>(sizeof(T)) >= size);
|
||||
T* new_data = static_cast<T*>(rcAlloc(sizeof(T) * size, H));
|
||||
template <typename T, rdAllocHint H>
|
||||
T* rdVectorBase<T, H>::allocate_and_copy(rdSizeType size) {
|
||||
rdAssert(RD_SIZE_MAX / static_cast<rdSizeType>(sizeof(T)) >= size);
|
||||
T* new_data = static_cast<T*>(rdAlloc(sizeof(T) * size, H));
|
||||
if (new_data) {
|
||||
copy_range(new_data, m_data, m_data + m_size);
|
||||
}
|
||||
return new_data;
|
||||
}
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::assign(const T* begin, const T* end) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::assign(const T* begin, const T* end) {
|
||||
clear();
|
||||
reserve(end - begin);
|
||||
m_size = end - begin;
|
||||
copy_range(m_data, begin, end);
|
||||
}
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::push_back(const T& value) {
|
||||
// rcLikely increases performance by ~50% on BM_rcVector_PushPreallocated,
|
||||
// and by ~2-5% on BM_rcVector_Push.
|
||||
if (rcLikely(m_size < m_cap)) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::push_back(const T& value) {
|
||||
// rdLikely increases performance by ~50% on BM_rdVector_PushPreallocated,
|
||||
// and by ~2-5% on BM_rdVector_Push.
|
||||
if (rdLikely(m_size < m_cap)) {
|
||||
construct(m_data + m_size++, value);
|
||||
return;
|
||||
}
|
||||
|
||||
const rcSizeType new_cap = get_new_capacity(m_cap + 1);
|
||||
const rdSizeType new_cap = get_new_capacity(m_cap + 1);
|
||||
T* data = allocate_and_copy(new_cap);
|
||||
// construct between allocate and destroy+free in case value is
|
||||
// in this vector.
|
||||
@ -215,20 +212,20 @@ void rcVectorBase<T, H>::push_back(const T& value) {
|
||||
destroy_range(0, m_size);
|
||||
m_size++;
|
||||
m_cap = new_cap;
|
||||
rcFree(m_data);
|
||||
rdFree(m_data);
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
template <typename T, rcAllocHint H>
|
||||
rcSizeType rcVectorBase<T, H>::get_new_capacity(rcSizeType min_capacity) {
|
||||
rcAssert(min_capacity <= RC_SIZE_MAX);
|
||||
if (rcUnlikely(m_cap >= RC_SIZE_MAX / 2))
|
||||
return RC_SIZE_MAX;
|
||||
template <typename T, rdAllocHint H>
|
||||
rdSizeType rdVectorBase<T, H>::get_new_capacity(rdSizeType min_capacity) {
|
||||
rdAssert(min_capacity <= RD_SIZE_MAX);
|
||||
if (rdUnlikely(m_cap >= RD_SIZE_MAX / 2))
|
||||
return RD_SIZE_MAX;
|
||||
return 2 * m_cap > min_capacity ? 2 * m_cap : min_capacity;
|
||||
}
|
||||
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::resize_impl(rcSizeType size, const T* value) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::resize_impl(rdSizeType size, const T* value) {
|
||||
if (size < m_size) {
|
||||
destroy_range(size, m_size);
|
||||
m_size = size;
|
||||
@ -241,7 +238,7 @@ void rcVectorBase<T, H>::resize_impl(rcSizeType size, const T* value) {
|
||||
}
|
||||
m_size = size;
|
||||
} else {
|
||||
const rcSizeType new_cap = get_new_capacity(size);
|
||||
const rdSizeType new_cap = get_new_capacity(size);
|
||||
T* new_data = allocate_and_copy(new_cap);
|
||||
// We defer deconstructing/freeing old data until after constructing
|
||||
// new elements in case "value" is there.
|
||||
@ -251,18 +248,18 @@ void rcVectorBase<T, H>::resize_impl(rcSizeType size, const T* value) {
|
||||
construct_range(new_data + m_size, new_data + size);
|
||||
}
|
||||
destroy_range(0, m_size);
|
||||
rcFree(m_data);
|
||||
rdFree(m_data);
|
||||
m_data = new_data;
|
||||
m_cap = new_cap;
|
||||
m_size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::swap(rcVectorBase<T, H>& other) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::swap(rdVectorBase<T, H>& other) {
|
||||
// TODO: Reorganize headers so we can use rcSwap here.
|
||||
rcSizeType tmp_cap = other.m_cap;
|
||||
rcSizeType tmp_size = other.m_size;
|
||||
rdSizeType tmp_cap = other.m_cap;
|
||||
rdSizeType tmp_size = other.m_size;
|
||||
T* tmp_data = other.m_data;
|
||||
|
||||
other.m_cap = m_cap;
|
||||
@ -274,62 +271,62 @@ void rcVectorBase<T, H>::swap(rcVectorBase<T, H>& other) {
|
||||
m_data = tmp_data;
|
||||
}
|
||||
// static
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::construct_range(T* begin, T* end) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::construct_range(T* begin, T* end) {
|
||||
for (T* p = begin; p < end; p++) {
|
||||
construct(p);
|
||||
}
|
||||
}
|
||||
// static
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::construct_range(T* begin, T* end, const T& value) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::construct_range(T* begin, T* end, const T& value) {
|
||||
for (T* p = begin; p < end; p++) {
|
||||
construct(p, value);
|
||||
}
|
||||
}
|
||||
// static
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::copy_range(T* dst, const T* begin, const T* end) {
|
||||
for (rcSizeType i = 0 ; i < end - begin; i++) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::copy_range(T* dst, const T* begin, const T* end) {
|
||||
for (rdSizeType i = 0 ; i < end - begin; i++) {
|
||||
construct(dst + i, begin[i]);
|
||||
}
|
||||
}
|
||||
template <typename T, rcAllocHint H>
|
||||
void rcVectorBase<T, H>::destroy_range(rcSizeType begin, rcSizeType end) {
|
||||
for (rcSizeType i = begin; i < end; i++) {
|
||||
template <typename T, rdAllocHint H>
|
||||
void rdVectorBase<T, H>::destroy_range(rdSizeType begin, rdSizeType end) {
|
||||
for (rdSizeType i = begin; i < end; i++) {
|
||||
m_data[i].~T();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class rcTempVector : public rcVectorBase<T, RC_ALLOC_TEMP> {
|
||||
typedef rcVectorBase<T, RC_ALLOC_TEMP> Base;
|
||||
class rdTempVector : public rdVectorBase<T, RD_ALLOC_TEMP> {
|
||||
typedef rdVectorBase<T, RD_ALLOC_TEMP> Base;
|
||||
public:
|
||||
rcTempVector() : Base() {}
|
||||
explicit rcTempVector(rcSizeType size) : Base(size) {}
|
||||
rcTempVector(rcSizeType size, const T& value) : Base(size, value) {}
|
||||
rcTempVector(const rcTempVector<T>& other) : Base(other) {}
|
||||
rcTempVector(const T* begin, const T* end) : Base(begin, end) {}
|
||||
rdTempVector() : Base() {}
|
||||
explicit rdTempVector(rdSizeType size) : Base(size) {}
|
||||
rdTempVector(rdSizeType size, const T& value) : Base(size, value) {}
|
||||
rdTempVector(const rdTempVector<T>& other) : Base(other) {}
|
||||
rdTempVector(const T* begin, const T* end) : Base(begin, end) {}
|
||||
};
|
||||
template <typename T>
|
||||
class rcPermVector : public rcVectorBase<T, RC_ALLOC_PERM> {
|
||||
typedef rcVectorBase<T, RC_ALLOC_PERM> Base;
|
||||
class rdPermVector : public rdVectorBase<T, RD_ALLOC_PERM> {
|
||||
typedef rdVectorBase<T, RD_ALLOC_PERM> Base;
|
||||
public:
|
||||
rcPermVector() : Base() {}
|
||||
explicit rcPermVector(rcSizeType size) : Base(size) {}
|
||||
rcPermVector(rcSizeType size, const T& value) : Base(size, value) {}
|
||||
rcPermVector(const rcPermVector<T>& other) : Base(other) {}
|
||||
rcPermVector(const T* begin, const T* end) : Base(begin, end) {}
|
||||
rdPermVector() : Base() {}
|
||||
explicit rdPermVector(rdSizeType size) : Base(size) {}
|
||||
rdPermVector(rdSizeType size, const T& value) : Base(size, value) {}
|
||||
rdPermVector(const rdPermVector<T>& other) : Base(other) {}
|
||||
rdPermVector(const T* begin, const T* end) : Base(begin, end) {}
|
||||
};
|
||||
|
||||
|
||||
/// Legacy class. Prefer rcVector<int>.
|
||||
class rcIntArray
|
||||
/// Legacy class. Prefer rdVector<int>.
|
||||
class rdIntArray
|
||||
{
|
||||
rcTempVector<int> m_impl;
|
||||
rdTempVector<int> m_impl;
|
||||
public:
|
||||
rcIntArray() {}
|
||||
rcIntArray(int n) : m_impl(n, 0) {}
|
||||
rdIntArray() {}
|
||||
rdIntArray(int n) : m_impl(n, 0) {}
|
||||
void push(int item) { m_impl.push_back(item); }
|
||||
void resize(int size) { m_impl.resize(size); }
|
||||
void clear() { m_impl.clear(); }
|
||||
@ -348,18 +345,18 @@ public:
|
||||
|
||||
/// A simple helper class used to delete an array when it goes out of scope.
|
||||
/// @note This class is rarely if ever used by the end user.
|
||||
template<class T> class rcScopedDelete
|
||||
template<class T> class rdScopedDelete
|
||||
{
|
||||
T* ptr;
|
||||
public:
|
||||
|
||||
/// Constructs an instance with a null pointer.
|
||||
inline rcScopedDelete() : ptr(0) {}
|
||||
inline rdScopedDelete() : ptr(0) {}
|
||||
|
||||
/// Constructs an instance with the specified pointer.
|
||||
/// @param[in] p An pointer to an allocated array.
|
||||
inline rcScopedDelete(T* p) : ptr(p) {}
|
||||
inline ~rcScopedDelete() { rcFree(ptr); }
|
||||
inline rdScopedDelete(T* p) : ptr(p) {}
|
||||
inline ~rdScopedDelete() { rdFree(ptr); }
|
||||
|
||||
/// The root array pointer.
|
||||
/// @return The root array pointer.
|
||||
@ -367,8 +364,8 @@ public:
|
||||
|
||||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
rcScopedDelete(const rcScopedDelete&);
|
||||
rcScopedDelete& operator=(const rcScopedDelete&);
|
||||
rdScopedDelete(const rdScopedDelete&);
|
||||
rdScopedDelete& operator=(const rdScopedDelete&);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // RECASTDETOURALLOC_H
|
@ -16,8 +16,8 @@
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
|
||||
#ifndef DETOURASSERT_H
|
||||
#define DETOURASSERT_H
|
||||
#ifndef RECASTDETOURASSERT_H
|
||||
#define RECASTDETOURASSERT_H
|
||||
|
||||
// Note: This header file's only purpose is to include define assert.
|
||||
// Feel free to change the file and include your own implementation instead.
|
||||
@ -25,7 +25,7 @@
|
||||
#ifdef NDEBUG
|
||||
|
||||
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
|
||||
# define dtAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
|
||||
# define rdAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
|
||||
|
||||
#else
|
||||
|
||||
@ -33,24 +33,24 @@
|
||||
// @param[in] expression asserted expression.
|
||||
// @param[in] file Filename of the failed assertion.
|
||||
// @param[in] line Line number of the failed assertion.
|
||||
/// @see dtAssertFailSetCustom
|
||||
typedef void (dtAssertFailFunc)(const char* expression, const char* file, int line);
|
||||
/// @see rdAssertFailSetCustom
|
||||
typedef void (rdAssertFailFunc)(const char* expression, const char* file, int line);
|
||||
|
||||
/// Sets the base custom assertion failure function to be used by Detour.
|
||||
/// @param[in] assertFailFunc The function to be invoked in case of failure of #dtAssert
|
||||
void dtAssertFailSetCustom(dtAssertFailFunc *assertFailFunc);
|
||||
/// @param[in] assertFailFunc The function to be invoked in case of failure of #rdAssert
|
||||
void rdAssertFailSetCustom(rdAssertFailFunc *assertFailFunc);
|
||||
|
||||
/// Gets the base custom assertion failure function to be used by Detour.
|
||||
dtAssertFailFunc* dtAssertFailGetCustom();
|
||||
rdAssertFailFunc* rdAssertFailGetCustom();
|
||||
|
||||
# include <assert.h>
|
||||
# define dtAssert(expression) \
|
||||
# define rdAssert(expression) \
|
||||
{ \
|
||||
dtAssertFailFunc* failFunc = dtAssertFailGetCustom(); \
|
||||
rdAssertFailFunc* failFunc = rdAssertFailGetCustom(); \
|
||||
if(failFunc == NULL) { assert(expression); } \
|
||||
else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // DETOURASSERT_H
|
||||
#endif // RECASTDETOURASSERT_H
|
Loading…
x
Reference in New Issue
Block a user