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

Function rcMarkBoxArea

Source/ThirdParty/recastnavigation/RecastArea.cpp:315–355  ·  view source on GitHub ↗

@par The value of spacial parameters are in world units. @see rcCompactHeightfield, rcMedianFilterWalkableArea

Source from the content-addressed store, hash-verified

313///
314/// @see rcCompactHeightfield, rcMedianFilterWalkableArea
315void 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
358static int pointInPoly(int nvert, const float* verts, const float* p)

Callers 1

GenerateTileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected