Beta 3.3.8 Errors

Just wanted to take it for a quick spin to see how the recast tiling is coming along might apply or not to our project. If I set the size of a C# recast to something around 1,000 X and Y it finishes a manual scan OK. If I set those to 5,000 each, then I see the following error when it completes the scan:

IndexOutOfRangeException: Array index is out of range. Pathfinding.RecastGraph.GetVertex (Int32 index) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:299) Pathfinding.TriangleMeshNode.GetVertex (Int32 i) (at Assets/AstarPathfindingProject/Generators/NodeClasses/TriangleMeshNode.cs:79) Pathfinding.RecastGraph.ConnectTiles (Pathfinding.NavmeshTile tile1, Pathfinding.NavmeshTile tile2) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:1623) Pathfinding.RecastGraph.ScanAllTiles (.OnScanStatus statusCallback) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:1209) Pathfinding.RecastGraph.ScanTiledNavmesh (.OnScanStatus statusCallback) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:1126) Pathfinding.RecastGraph.Scan (.OnScanStatus statusCallback) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:986) AstarPath.ScanLoop (.OnScanStatus statusCallback) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1823) AstarPath.MenuScan () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1715) UnityEditor.DockArea:OnGUI()

Setting those higher, e.g., 80,000 each, seems to hang the scan, i.e., it does progress past scanning tile 0 even after 10–15 minutes.

I’ve cell size and height at 1, tile size at 1,000, and am using the C# recast.

C++ errors immediately on scan click with:
NullReferenceException: Object reference not set to an instance of an object Pathfinding.RecastGraph+<OnDrawGizmos>c__AnonStorey27.<>m__1B (Pathfinding.GraphNode _node) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:2459) Pathfinding.RecastGraph.GetNodes (Pathfinding.GraphNodeDelegateCancelable del) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:407) Pathfinding.RecastGraph.OnDrawGizmos (Boolean drawNodes) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:2479) AstarPath.OnDrawGizmos () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:531) UnityEditor.DockArea:OnGUI()

Let me know if I can provide any other info.

There have been some index changes (Mostly Class names) sadly due to conflicts… Hopefully Arron will get some documentation on setting up the beta soon ~

Actually that is a bug, not a naming conflict.

The scripts are using bitpacking to keep the memory usage down, but when there are too many vertices per tile, or too many tiles in total, those numbers can overflow and cause all kinds of havoc (like what you are seeing). You can change the limits by adding or removing the line
right at the top of the RecastGenerator.cs script (the line might not exist in your version).

It was bad of me not to log errors with more detailed information when these things happen. I have added better error messages now. They will be included in the next beta.

Thanks much Aron. ASTAR_RECAST_LARGER_TILES was not defined, so I tried it defined and with it the above error after a C# recast scan is not raised, however this message is logged:

This should not happen UnityEngine.Debug:LogError(Object) Pathfinding.Voxels.Voxelize:Triangulate(Int32, Int32[], Int32[]&, Int32[]&) (at Assets/AstarPathfindingProject/Generators/Utilities/Voxels/VoxelMesh.cs:380) Pathfinding.Voxels.Voxelize:BuildPolyMesh(VoxelContourSet, Int32, VoxelMesh&) (at Assets/AstarPathfindingProject/Generators/Utilities/Voxels/VoxelMesh.cs:248) Pathfinding.RecastGraph:BuildTileMesh(Voxelize, Int32, Int32) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:1325) Pathfinding.RecastGraph:ScanAllTiles(OnScanStatus) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:1190) Pathfinding.RecastGraph:ScanTiledNavmesh(OnScanStatus) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:1128) Pathfinding.RecastGraph:Scan(OnScanStatus) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:988) AstarPath:ScanLoop(OnScanStatus) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1823) AstarPath:MenuScan() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1715) AstarPathEditor:OnInspectorGUI() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:428) UnityEditor.DockArea:OnGUI()

Just to be clear, the null reference issue is still observed on a C++ scan (just FYI, as I wasn’t expecting this to change C++ behavior.)

Again, just have to say if there’s any other information you’d like to see or specifics you’d like me to test through.

Ah, the “This Should Not Happen” bug…
I have been trying to fix that for a long time. Basically the voxel rasterization process can sometimes give degenerate results (this was from the recast source). It isn’t very easy to fix. However usually you can fix it temporarily by changing the node size or height by some small amount (like change from 1 to 1.01).
My try at rewriting the process (which can be enabled by adding ASTAR_RECAST_BFS, see Optimizations tab in the A* Inspector) did make scan faster, but unfortunately it triggers that error even more. I am sketching on some improvements which can reduce the risk of that error to effectively zero, but it takes time to implement.

While the C++ shouldn’t really throw exceptions, it is being phased out because of incompatibilities with the rest of the system. In fact, in my current dev version, I have removed support for it completely, so you can skip that.