Failure to create any contours

125 views
Skip to first unread message

Josh Klint

unread,
Sep 23, 2011, 5:01:25 PM9/23/11
to recastnavigation
My code always results in an nconts value of zero after
rcBuildContours() is called. I tried reversing my triangle order, and
it makes no difference. I am using the nav_test.obj object.

How can I diagnose this problem?

// Create contours.
cset = rcAllocContourSet();
if (!cset) return false;
if (!rcBuildContours(ctx, *chf, cfg.maxSimplificationError,
cfg.maxEdgeLen, *cset))
{
Print("Error: Failed to build contours.");
return false;
}
if (cset->nconts == 0)
{
Print("Error: No contours created.");//Fails here
return false;
}

Mikko Mononen

unread,
Sep 24, 2011, 1:39:49 AM9/24/11
to recastna...@googlegroups.com
Hi,
No it's time to implement the debug draw interface :) Seriously, it is
the most easiest way to debug these things. There are debug draw
functions to display the data at every step along the pipeline.

--mikko

Josh Klint

unread,
Sep 25, 2011, 1:11:23 AM9/25/11
to recastnavigation
I created a struc called "NavMeshDebugger" that is derived from the
duDebugDraw struc.

After all triangles are rasterized, I use this code:
NavMeshDebugger* navmeshdebugger = new NavMeshDebugger;
duDebugDrawHeightfieldSolid(navmeshdebugger,*solid);

The NavMeshDebugger::begin() function is being called, with
DU_DRAW_QUADS for the prim value. No calls to
NavMeshDebugger::vertex() are made before the NavMeshDebugger::end()
function is called.

So it looks like the triangle rasterization isn't resulting in any
voxels at all?

Mikko Mononen

unread,
Sep 25, 2011, 1:48:01 AM9/25/11
to recastna...@googlegroups.com
That would explain things. You could try to draw the bbox of the tile
building procedure, to see that it matches the geometry you feed to
Recast.


--mikko

Message has been deleted

Mikko Mononen

unread,
Sep 25, 2011, 2:16:04 AM9/25/11
to recastna...@googlegroups.com
Hi,

What's chf.spanCount when the crash happens? Can you post screenshot
of duDebugDrawCompactHeightfieldRegions()?


--mikko


On Sun, Sep 25, 2011 at 9:06 AM, Josh Klint <jkl...@leadwerks.com> wrote:
> The problem was the tilesize parameter was too low (though the
> bounding box was fine).
>
> Now I get an exception on line 697 in RecastContour.cpp:
> if (flags[i] == 0 || flags[i] == 0xf)
>
> According to the Visual Studio debugger:
> i = 3997806
> chf.spanCount = 3040357
>
> So it looks like it's trying to access beyond the length of the
> flags[] array.

Josh Klint

unread,
Sep 25, 2011, 7:29:09 PM9/25/11
to recastnavigation
I deleted my post about the crash due to an error on my part.

I have navmesh data generating now, and the detail mesh looks
correct. I had to change the tileSize parameter from 200 to 2000 for
it to generate all voxels. Can you explain what this parameter does?
I don't understand it.

Thanks.

Mikko Mononen

unread,
Sep 26, 2011, 1:29:43 AM9/26/11
to recastna...@googlegroups.com
The tile size defines the size of a tile in the navmesh in voxels. I
don't know better to explain it :)

Maybe you're missing that you need to call the Recast stuff all your
tiles? See buildAllTiles() in the tile sample:
http://code.google.com/p/recastnavigation/source/browse/trunk/RecastDemo/Source/Sample_TileMesh.cpp#817

First it calculates the voxel dimensions for the whole level bounding
box, from that it calculates how many tiles there are (tw,th) and then
in then in the loop it calculates all the tiles.

That is the reason the tile builder should take tile location as
input, so that you can use the same build process when a tile changes.
Build all can be preprocess which happens at level export time.


--mikko

Josh Klint

unread,
Sep 26, 2011, 12:12:20 PM9/26/11
to recastnavigation
tileSize = the number of voxels on an edge? i.e. a tilesize of 10
would have 10x10 (=100) voxels?

So tileSize should be calculated as the dimensions of a tile, divided
by the voxel size:

tileSize = ceil( ( bmax[0] - bmin[0] ) / cellSize );
Message has been deleted

Mikko Mononen

unread,
Sep 26, 2011, 12:38:39 PM9/26/11
to recastna...@googlegroups.com
Hi,

If you want to use tiles, then you decide the tile size yourself. If
you wish to update the tiles at runtime, I'd test tileSizes between
16x16 to 128x128. Depending on how large objects you have and how much
perf and memory you can put to update the tiles. You adjust the
tileSize in the RecastDemo to see how it affects the navmesh.

If you want to use only one tile (that is, solo mesh), then you can
use the provided function to calculate the tile size rom bounding box.


--mikko

Reply all
Reply to author
Forward
0 new messages