MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / expandRegions

Function expandRegions

Source/ThirdParty/recastnavigation/RecastRegion.cpp:361–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359 unsigned short distance2;
360};
361static void expandRegions(int maxIter, unsigned short level,
362 rcCompactHeightfield& chf,
363 unsigned short* srcReg, unsigned short* srcDist,
364 rcTempVector<LevelStackEntry>& stack,
365 bool fillStack)
366{
367 const int w = chf.width;
368 const int h = chf.height;
369
370 if (fillStack)
371 {
372 // Find cells revealed by the raised level.
373 stack.clear();
374 for (int y = 0; y < h; ++y)
375 {
376 for (int x = 0; x < w; ++x)
377 {
378 const rcCompactCell& c = chf.cells[x+y*w];
379 for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
380 {
381 if (chf.dist[i] >= level && srcReg[i] == 0 && chf.areas[i] != RC_NULL_AREA)
382 {
383 stack.push_back(LevelStackEntry(x, y, i));
384 }
385 }
386 }
387 }
388 }
389 else // use cells in the input stack
390 {
391 // mark all cells which already have a region
392 for (int j=0; j<stack.size(); j++)
393 {
394 int i = stack[j].index;
395 if (srcReg[i] != 0)
396 stack[j].index = -1;
397 }
398 }
399
400 rcTempVector<DirtyEntry> dirtyEntries;
401 int iter = 0;
402 while (stack.size() > 0)
403 {
404 int failed = 0;
405 dirtyEntries.clear();
406
407 for (int j = 0; j < stack.size(); j++)
408 {
409 int x = stack[j].x;
410 int y = stack[j].y;
411 int i = stack[j].index;
412 if (i < 0)
413 {
414 failed++;
415 continue;
416 }
417
418 unsigned short r = srcReg[i];

Callers 1

rcBuildRegionsFunction · 0.85

Calls 8

LevelStackEntryClass · 0.85
rcGetConFunction · 0.85
rcGetDirOffsetXFunction · 0.85
rcGetDirOffsetYFunction · 0.85
DirtyEntryClass · 0.85
clearMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected