The red box is non walkable, but there still generate walkable area inside the box, is this a bug?
// the test box
float _box_min[3] = {46, -4, -28};
float _box_max[3] = {50, 5, -25};
float _box_verts[24] = {
_box_min[0], _box_min[1], _box_min[2],
_box_max[0], _box_min[1], _box_min[2],
_box_max[0], _box_min[1], _box_max[2],
_box_min[0], _box_min[1], _box_max[2],
_box_min[0], _box_max[1], _box_min[2],
_box_max[0], _box_max[1], _box_min[2],
_box_max[0], _box_max[1], _box_max[2],
_box_min[0], _box_max[1], _box_max[2]
};
int _box_tri[30] = {
0, 1, 5,
5, 4, 0,
1, 2, 6,
6, 5, 2,
2, 3, 7,
7, 6, 2,
3, 0, 4,
4, 7, 3,
4, 5, 6,
6, 7, 4
};
static int rasterizeTileLayers(BuildContext* ctx, InputGeom* geom,
const int tx, const int ty,
const rcConfig& cfg,
TileCacheData* tiles,
const int maxTiles)
{
//.....
// Allocate array that can hold triangle flags.
// If you have multiple meshes you need to process, allocate
// and array which can hold the max number of triangles you need to process.
rc.triareas = new unsigned char[chunkyMesh->maxTrisPerChunk];
if (!rc.triareas)
{
ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk);
return 0;
}
float tbmin[2], tbmax[2];
tbmin[0] = tcfg.bmin[0];
tbmin[1] = tcfg.bmin[2];
tbmax[0] = tcfg.bmax[0];
tbmax[1] = tcfg.bmax[2];
int cid[512];// TODO: Make grow when returning too many items.
const int ncid = rcGetChunksOverlappingRect(chunkyMesh, tbmin, tbmax, cid, 512);
if (!ncid)
{
return 0; // empty
}
for (int i = 0; i < ncid; ++i)
{
const rcChunkyTriMeshNode& node = chunkyMesh->nodes[cid[i]];
const int* tris = &chunkyMesh->tris[node.i*3];
const int ntris = node.n;
memset(rc.triareas, 0, ntris*sizeof(unsigned char));
rcMarkWalkableTriangles(ctx, tcfg.walkableSlopeAngle,
verts, nverts, tris, ntris, rc.triareas);
rcRasterizeTriangles(ctx, verts, nverts, tris, rc.triareas, ntris, *rc.solid, tcfg.walkableClimb);
}
// test non walkable area
if (tx == 5 && ty == 1)
{
unsigned char triareas[10];
memset(triareas, 0, 10*sizeof(unsigned char));
rcRasterizeTriangles(ctx, _box_verts, 8, _box_tri, triareas, 10, *rc.solid, tcfg.walkableClimb);
}
//.....
}