The navigation mesh
Reference to the polygon to start the search from
Center position of the search circle
Maximum radius of the search circle
Query filter to apply to polygons
Function that returns random values [0,1]
The result object with success flag, random point, and polygon reference
Finds a random point around a center position on the navigation mesh. The location is not exactly constrained by the circle, but it limits the visited polygons.
Uses Dijkstra-like search to explore reachable polygons within the circle, then selects a random polygon weighted by area, and finally generates a random point within that polygon. This function is using reservoir sampling and can fail in rare occurences even if there is an actual solution.