MCPcopy Create free account
hub / github.com/axmolengine/axmol / dtCreateNavMeshData

Function dtCreateNavMeshData

3rdparty/recast/DetourNavMeshBuilder.cpp:280–658  ·  view source on GitHub ↗

@par The output data array is allocated using the detour allocator (dtAlloc()). The method used to free the memory will be determined by how the tile is added to the navigation mesh. @see dtNavMesh, dtNavMesh::addTile()

Source from the content-addressed store, hash-verified

278///
279/// @see dtNavMesh, dtNavMesh::addTile()
280bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData, int* outDataSize)
281{
282 if (params->nvp > DT_VERTS_PER_POLYGON)
283 return false;
284 if (params->vertCount >= 0xffff)
285 return false;
286 if (!params->vertCount || !params->verts)
287 return false;
288 if (!params->polyCount || !params->polys)
289 return false;
290
291 const int nvp = params->nvp;
292
293 // Classify off-mesh connection points. We store only the connections
294 // whose start point is inside the tile.
295 unsigned char* offMeshConClass = 0;
296 int storedOffMeshConCount = 0;
297 int offMeshConLinkCount = 0;
298
299 if (params->offMeshConCount > 0)
300 {
301 offMeshConClass = (unsigned char*)dtAlloc(sizeof(unsigned char)*params->offMeshConCount*2, DT_ALLOC_TEMP);
302 if (!offMeshConClass)
303 return false;
304
305 // Find tight heigh bounds, used for culling out off-mesh start locations.
306 float hmin = FLT_MAX;
307 float hmax = -FLT_MAX;
308
309 if (params->detailVerts && params->detailVertsCount)
310 {
311 for (int i = 0; i < params->detailVertsCount; ++i)
312 {
313 const float h = params->detailVerts[i*3+1];
314 hmin = dtMin(hmin,h);
315 hmax = dtMax(hmax,h);
316 }
317 }
318 else
319 {
320 for (int i = 0; i < params->vertCount; ++i)
321 {
322 const unsigned short* iv = &params->verts[i*3];
323 const float h = params->bmin[1] + iv[1] * params->ch;
324 hmin = dtMin(hmin,h);
325 hmax = dtMax(hmax,h);
326 }
327 }
328 hmin -= params->walkableClimb;
329 hmax += params->walkableClimb;
330 float bmin[3], bmax[3];
331 dtVcopy(bmin, params->bmin);
332 dtVcopy(bmax, params->bmax);
333 bmin[1] = hmin;
334 bmax[1] = hmax;
335
336 for (int i = 0; i < params->offMeshConCount; ++i)
337 {

Callers 1

buildNavMeshTileMethod · 0.85

Calls 10

dtAllocFunction · 0.85
dtMinFunction · 0.85
dtMaxFunction · 0.85
dtVcopyFunction · 0.85
classifyOffMeshPointFunction · 0.85
dtAlign4Function · 0.85
dtFreeFunction · 0.85
createBVTreeFunction · 0.85
setAreaMethod · 0.80
setTypeMethod · 0.45

Tested by

no test coverage detected