Closed AqlaSolutions closed 9 years ago
I tried to use the old API with the current version: http://pastebin.com/fetE7Vgj http://pastebin.com/ze7v21Wi
It throws the same exception but in another place.
The ObjLoader in the SharpNav.Examples/Editor project are just meant as an example, other features like flipping/swapping axes will come later as we build up the editor.
The new API is effectively a shortcut for the old one (both are still accessible). Thanks for providing the OBJ as well.
Would you mind posting the full stack trace in case I can't reproduce the bug on my machine immediately? I'll start looking at it now.
So it looks like you're hitting one of the few remaining bugs in PolyMeshDetail - having a mesh that actually crashes instead of producing a slightly-mangled navmesh should prove really useful in debugging!
Here is the stack trace for the old API:
PolyMeshDetail.GetHeightData(CompactHeightfield compactField, Polygon poly, Int32 polyCount, PolyVertex[] verts, Int32 borderSize, HeightPatch hp) в PolyMeshDetail.cs:368
PolyMeshDetail.PolyMeshDetail..ctor
It's trying to get compactField.Cells[0 * 59 + (-1)].
For the new API it's trying to set HeightPatch[43, 37] having only 1634 elements in the data field array. Stack trace:
в SharpNav.HeightPatch.set_Item(Int32 x, Int32 y, Int32 value) в SharpNav\\HeightPatch.cs:строка 123
в SharpNav.PolyMeshDetail.GetHeightData(CompactHeightfield compactField, Polygon poly, Int32 polyCount, PolyVertex[] verts, Int32 borderSize, HeightPatch hp) в SharpNav\\PolyMeshDetail.cs:359
в SharpNav.PolyMeshDetail..ctor(PolyMesh mesh, CompactHeightfield compactField, Single sampleDist, Single sampleMaxError) в SharpNav\\PolyMeshDetail.cs:157
в SharpNav.PolyMeshDetail..ctor(PolyMesh mesh, CompactHeightfield compactField, NavMeshGenerationSettings settings) в SharpNav\\PolyMeshDetail.cs:61
в SharpNav.NavMesh.Generate(IEnumerable`1 triangles, NavMeshGenerationSettings settings) в SharpNav\NavMesh.cs:55
Both usage cases you can try yourself with my pastebin snippets above.
I think at some point I changed the names of the indices and never updated that one index - hp[hx, hy]
is now hp[x, y]
.
Unfortunately, the same old bugs in PolyMeshDetail are still there - but this issue specifically is resolved.
Thanks for the find!
I checked it and it works with model that I posted above but now I have the same exception with another model at
в SharpNav.PolyMeshDetail.GetHeightData(CompactHeightfield compactField, Polygon poly, Int32 polyCount, PolyVertex[] verts, Int32 borderSize, HeightPatch hp) в SharpNav\\PolyMeshDetail.cs:369
в SharpNav.PolyMeshDetail..ctor(PolyMesh mesh, CompactHeightfield compactField, Single sampleDist, Single sampleMaxError) в SharpNav\\PolyMeshDetail.cs:158
в SharpNav.PolyMeshDetail..ctor(PolyMesh mesh, CompactHeightfield compactField, NavMeshGenerationSettings settings) в SharpNav\\PolyMeshDetail.cs:61
в SharpNav.NavMesh.Generate(IEnumerable`1 triangles, NavMeshGenerationSettings settings) в SharpNav\\NavMesh.cs:55
I'll post that obj tomorrow.
Alright, sounds good. I'm going through PolyMeshDetail again and trying to debug the rest of it - I may end up solving this by then, but I'll reopen the issue since it's the same issue with another mesh.
Yep, now it's fixed, thanks!
Your ObjLoader misses some important features like combining models and import-flipping so we use own model loader http://pastebin.com/pd5xjc6L
This throws IndexOufOfRangeException:
Obj: https://www.dropbox.com/s/jymf3n0oqwfhidr/Fighting_scene_navmesh.obj?dl=0
It worked with old SharpNav API: http://pastebin.com/yYWL3Xxp