@par The value of spacial parameters are in world units. @see rcCompactHeightfield, rcMedianFilterWalkableArea
| 313 | /// |
| 314 | /// @see rcCompactHeightfield, rcMedianFilterWalkableArea |
| 315 | void rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigned char areaId, |
| 316 | rcCompactHeightfield& chf) |
| 317 | { |
| 318 | rcAssert(ctx); |
| 319 | |
| 320 | rcScopedTimer timer(ctx, RC_TIMER_MARK_BOX_AREA); |
| 321 | |
| 322 | int minx = (int)((bmin[0]-chf.bmin[0])/chf.cs); |
| 323 | int miny = (int)((bmin[1]-chf.bmin[1])/chf.ch); |
| 324 | int minz = (int)((bmin[2]-chf.bmin[2])/chf.cs); |
| 325 | int maxx = (int)((bmax[0]-chf.bmin[0])/chf.cs); |
| 326 | int maxy = (int)((bmax[1]-chf.bmin[1])/chf.ch); |
| 327 | int maxz = (int)((bmax[2]-chf.bmin[2])/chf.cs); |
| 328 | |
| 329 | if (maxx < 0) return; |
| 330 | if (minx >= chf.width) return; |
| 331 | if (maxz < 0) return; |
| 332 | if (minz >= chf.height) return; |
| 333 | |
| 334 | if (minx < 0) minx = 0; |
| 335 | if (maxx >= chf.width) maxx = chf.width-1; |
| 336 | if (minz < 0) minz = 0; |
| 337 | if (maxz >= chf.height) maxz = chf.height-1; |
| 338 | |
| 339 | for (int z = minz; z <= maxz; ++z) |
| 340 | { |
| 341 | for (int x = minx; x <= maxx; ++x) |
| 342 | { |
| 343 | const rcCompactCell& c = chf.cells[x+z*chf.width]; |
| 344 | for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i) |
| 345 | { |
| 346 | rcCompactSpan& s = chf.spans[i]; |
| 347 | if ((int)s.y >= miny && (int)s.y <= maxy) |
| 348 | { |
| 349 | if (chf.areas[i] != RC_NULL_AREA) |
| 350 | chf.areas[i] = areaId; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | |
| 358 | static int pointInPoly(int nvert, const float* verts, const float* p) |