New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NULL dereference crash in rcBuildContours() #38
Comments
This should not happen (tm) :) Can you make this happen in RecastDemo and can you provide a test level? If not, can you add this after the qsort: if (!region.outline)
{
printf(“Region without outline!\n”);
for (int i = 0; i < region.nholes; i++)
{
printf(“ - Hole %d\n”, i);
rcContour* hole = region.holes[i].contour;
for (int j = 0; j < hole->nverts; i++)
printf(“%d, %d, %d,\n”, hole->verts[j*4+0],hole->verts[j*4+1],hole->verts[j*4+2]);
}
return;
} The correct fix is probably this, but I'd like to verify with the data: // Positively would contours are outlines, negative holes.
if (winding[i] >= 0) Change |
Even with Reproducing it with RecastDemo will probably take a while, meanwhile here are more details I found debugging it in rcBuildContours():
Update: |
The code around 1091 allocating distributing space for the holes, and the code around 1099 is then assigning values to the holes. The outline you printed looks ok, let's print some more values. Can you put this the line before bool failure = false;
for (int i = 0; i < nregions; i++)
if (!regions[i].outline)
failure = true;
if (failure)
{
// Dump all countours
for (int i = 0; i < cset.nconts; ++i)
{
rcContour& cont = cset.conts[i];
int area = calcAreaOfPolygon2D(cont.verts, cont.nverts);
printf(“Contour %d: reg=%d area=%d\n”, i, cont.reg, area);
for (int j = 0; j < cont.nverts; i++)
printf(“%d, %d, %d,\n”, contverts[j*4+0],cont.verts[j*4+1],cont.verts[j*4+2]);
}
} |
Contour 8 Region 14 is the one with a hole
|
The areas look ok, but that one. Can you post your build settings? Also If you can post a screenshot of the the location where the navmesh is from with compact heighfield region debug draw, that would help me a lot. |
Add test case mesh for recastnavigation#38
I added the settings to RecastDemo and was able to reproduce it, you can find the branch with a test case at https://github.com/jackpoz/recastnavigation/tree/issue38 The only custom changes are some x64 fixes. Load the Tile Mesh sample and then the map5712525.obj mesh, tick the TrinityCore Configs custom check and then Build all tiles. The bounding box is actually a section of the whole mesh and that's how it's supposed to be. |
Thanks for setting up a test case, I'll take a look at it. Quick note about settings: m_agentHeight = 6 * m_cellSize;
m_agentMaxClimb = 8 * m_cellSize; Agent climb must be less than agent height or you'll get invalid navmesh in some cases. |
I had to set those settings to allow to "jump" over high fences by walking over them, most of the meshes are in open space anyway. Thank you tho for taking a look at those configs. |
- do circumCircle calculations relative to first vertex for adde precision - improved the results of triangulateHull(), produces less degen triangles - fixed case with contour merging when outline is null
The crash is fixed now, but you'll get a warning when building your level. The problem comes from contour simplification. You are using error of 1.8, which can sometimes be too eager to cut corners and that creates overlapping contour. I suggest to make the error lower, like 1.5. |
Looks like 1.787f is low enough to avoid the crash, that high simplification value made some complex meshes work much better. I'll lower it down and see how it works, thank you for the feedback. |
what are the effects tho of skipped region ? I can't see any particular visible difference in recast demo |
The change I made basically just does not try to merge the contours if there is no outline. The triangulator then will try to triangulate the contour, and may succeed to do that for a region (there will also be error spit out when this happens). So all in all, the process tries to create as many triangles as it can. You can see this effect at the backside of the dome in your test case. There is small sliver navmesh piece on the rims of the dome (hard to exaplain), half of it wil be missing. |
Yes, that's the one. |
Update recast to recastnavigation/recastnavigation@42b96b7 Previous MMAPs might still work but it's recommended to re-extract them.
I got a NULL dereference crash in mergeRegionHoles() called by rcBuildContours() using revision eacaa87
region.outline is NULL as shown by Visual Studio
callstack:
I didn't change any call to Recast to use the new features of a89bb84 .
I can reproduce the bug and I'm available to test any crashfix.
The text was updated successfully, but these errors were encountered: