Robmaister / SharpNav

Advanced Pathfinding for C#
sharpnav.com
Other
537 stars 129 forks source link

A bug about MeshTile.detailVerts . #10

Open sysujack opened 10 years ago

sysujack commented 10 years ago

Recently, I use SharpNav as navigation module in a Unity web project. When I try to display poly detail mesh in scene, I use data in PolyMeshDetail Object in the middle generating process, there is no problem. But when I switch to use data in TiledNavMesh, an IndexOutOfRangeException is throw out. I research the code, I find out that process in NavMeshBuilder constructor have some problem. You adjust var navDVerts , navDVerts is not the same with parameters.detailVerts ; But you don't adjust navDTris, navDTris is the same with parameters.detailTris. Should those vars adjust consistence?

Robmaister commented 10 years ago

Could you be a bit more clear about what the bug is? navDVerts, navDMeshes, and navDTris are all stored in the header in NavMeshBuilder with calculated values:

header.detailMeshCount = parameters.polyCount;
header.detailVertCount = uniqueDetailVertCount;
header.detailTriCount = detailTriCount;

And stored in TiledNavMesh:

tile.detailMeshes = data.NavDMeshes;
tile.detailVerts = data.NavDVerts;
tile.detailTris = data.NavDTris;

And navDTris is copied from parameters.detailTris on line 312-313 of NavMeshBuilder.cs:

for (int j = 0; j < parameters.detailTriCount; j++)
    navDTris[j] = parameters.detailTris[j];

Also, this could just be an issue with how PolyMeshDetail still has several bugs in it, which I've been working through for a while.

Robmaister commented 9 years ago

Are you still experiencing this issue @sysujack? Most of this API should disappear with a few more refactoring runs, and I'll close this issue when it does.

All remaining blocking issues with PolyMeshDetail should also be fixed by then.

Robmaister commented 9 years ago

Experienced this myself but only under MeshTile.Data.NavDVerts while drawing a NavMesh loaded from file.