Robmaister / SharpNav

Advanced Pathfinding for C#
sharpnav.com
Other
534 stars 165 forks source link

FindRandomPointAroundCircle IndexOutOfRangeException #61

Closed AqlaSolutions closed 8 years ago

AqlaSolutions commented 8 years ago

Sometimes it throws

FindRandomPointAroundCircle problem: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SharpNav.Pathfinding.PathfindingCommon.RandomPointInConvexPoly(Vector3[] pts, Int32 npts, Single[] areas, Single s, Single t, Vector3& pt) in D:\Dropbox\DotNet Resources\SharpNav\Source\SharpNav\Pathfinding\PathfindingCommon.cs:line 45
at SharpNav.NavMeshQuery.FindRandomPointOnPoly(MeshTile tile, Poly poly, PolyId polyRef, Vector3& randomPt) in D:\Dropbox\DotNet Resources\SharpNav\Source\SharpNav\NavMeshQuery.cs:line 121
at SharpNav.NavMeshQuery.FindRandomPointAroundCircle(NavPoint center, Single radius, NavPoint& randomPoint) in D:\Dropbox\DotNet Resources\SharpNav\Source\SharpNav\NavMeshQuery.cs:line 410

I don't have a specific point logged, only range (99999) and it's very rare but still could you check the code?

Robmaister commented 8 years ago

The logic for this exception is fairly straightforward, how it would reach that state worries me a bit.

Regardless, I ensured the exception can never be triggered and cleaned up the APIs for RandomPointInConvexPoly and FindRandomPointOnPoly. The fixes will be included in the next release.

AqlaSolutions commented 8 years ago

Looks like it's fixed now.