I'm implementing a nav mesh pathfinding system and I need to be able to raycast between two points in the mesh and get a list of all edges crossed by the ray. Obviously I'll need to be able to test for individual line intersections, but I expect there to be an efficient way of picking which lines actually need to be checked rather than brute force iterating over every edge in the entire mesh. Does anyone know how I might go about that?
Asked
Active
Viewed 3,271 times
3
-
nav mesh could be in 3d, which would mean you have to be more specific in your question on how a ray can intersect a mesh. Typical approach would involve space partitioning like kd-tree, but that depends on what your mesh looks like. – Nicko Po Sep 08 '15 at 19:45
-
It could be 3D, but all the calculations (line intersection, etc.) get more complicated if I allow that, and I don't need it, so I'm constraining it to be effectively 2D. – SilentSin Sep 09 '15 at 05:38
-
I suppose what I mean is, if you navigating over say 3d terrain, your nav map will be in 3d. Either way, then look at kd-trees, for 2 dimensions, for ray trace queries. However, if you paths are short, and change often, "clever" brute force maybe the best option. – Nicko Po Sep 09 '15 at 22:41
1 Answers
0
If your mesh is rectangular grid, consider effective method of Woo and Amanatides from article "Fast Voxel Traversal Algorithm..."

MBo
- 77,366
- 5
- 53
- 86
-
2The whole reason I'm trying to implement a nav mesh is so that it isn't constrained to a grid. – SilentSin Sep 09 '15 at 05:41