| 359 | unsigned short distance2; |
| 360 | }; |
| 361 | static 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]; |
no test coverage detected