DetourTileCache issues

147 views
Skip to first unread message

Joey

unread,
Sep 5, 2012, 11:01:22 PM9/5/12
to recastnavigation
How can i set a proper capacity for dtTileCacheAlloc?
My scene has: Tiles = 16 x 16, TileSize = 80

Mikko Mononen

unread,
Sep 6, 2012, 2:42:18 AM9/6/12
to recastna...@googlegroups.com
Hi,

Tile size 80 is pretty high for tile cache, but it should work. If you
have really complicated geometry the system can run out of regions IDs
as it only uses 8 bit values for them.

There is no simple formula which could ne used to calculated the used
memory. First the pipeline allocates some predictable "big" buffers
size of 80x80 (tile size squared) and later smaller but more
unpredictable arrays for things like regions and vertices.

I think the best strategy is to log all the allocations, first add up
all the big allocs, and the multiply the small allocs by 4 and round
up. You should end up with relative small buffersize.


--mikko

Joey

unread,
Sep 6, 2012, 3:12:05 AM9/6/12
to recastnavigation
thanks, i print the allocate process, it need 40153, so i change the
capacity to 45000, it works.

Joey

unread,
Sep 6, 2012, 7:40:52 PM9/6/12
to recastna...@googlegroups.com
I mark a non walkable box in Sample_TempObstacles, and got this:
The red box is non walkable, but there still generate walkable area inside the box, is this a bug?
test code:

// 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);
}

//.....
}
Message has been deleted

Joey

unread,
Sep 6, 2012, 9:42:15 PM9/6/12
to recastna...@googlegroups.com

Mikko Mononen

unread,
Sep 7, 2012, 1:32:49 AM9/7/12
to recastna...@googlegroups.com
That is correct. There is enough space inside the box so that an agent can stand there. You should use rcMarkBoxArea() with null area type if you want to mark a solid box.

There has been discussion (and a pathc) to allow solid voxelization, but I have not had time yet to think about how to apply it.


--mikko

Joey

unread,
Sep 7, 2012, 2:14:00 AM9/7/12
to recastnavigation
Using rcMarkBoxArea it works ok

Joey

unread,
Sep 7, 2012, 5:56:23 AM9/7/12
to recastnavigation
I added a issue r214

Joey

unread,
Sep 7, 2012, 11:16:54 PM9/7/12
to recastnavigation
Now I'm using DetourCrowd to handle movement for movable units,
DetourTileCache for stationary units.
Pseudo:
CrowdManager::requestMoveTarget(index)
{
1. remove agent obstacle from dtTileCache.
2. add agent to dtCrowd.
3. dtCrowd->requestMoveTarget
}

CrowdManager::update(dt)
{
1. update dtTileCache
2. update dtCrowd
}

CrowdManager::stopMove(index)
{
1. remove agent from dtCrowd
2. add agent obstacle to dtTileCache.
}

But the dtTileCache only build one tile in update() every frame,
if the moving units in different tiles, some units will not move.

Joey

unread,
Sep 10, 2012, 6:42:07 AM9/10/12
to recastna...@googlegroups.com
I record a video to demonstrate this question:
Click the ground, the units will move to the target in squad.
Click the unit, the units will move  around the target and attack.
You can see, when units move to attack target, some units do not move,
maybe checkPathValidity failed. any suggestion?
Reply all
Reply to author
Forward
0 new messages