Zylann / godot_voxel

Voxel module for Godot Engine
Other
2.47k stars 231 forks source link

Are there any simple path finding for voxel terrains? #321

Open slapin opened 2 years ago

slapin commented 2 years ago

Hi, I need to implement simple path finding for voxel terrain to be able to go anywhere (even not generated parts). The navmesh solution is too complex for my poor brain (even though I see people use recastnavigation-based solutions for these) and I'd prefer something generated at run time from voxel sdf, but calculated on demand. Is there some libraries/plugins I could use? (I know I can generate AStar nodes for sdf in [ -0.5 .. - 1.0] range but I need to exclude nodes in structures and connect structure enterances too, but I guess that will take lots of RAM and can't be generated on demand instead of storing :( which makes me sad; I do generate my cities and roads from Voronoi diagram and have to store it). I also could generate grid from Voronoi diagram and have grid both for structure placement and pathfinding but I somehow fail to understand the best way to structure data with that... The worse things are narrow corridoors which could go ok with navmesh but are hard with grid-based systems...

Zylann commented 2 years ago

Hi, I need to implement simple path finding for voxel terrain to be able to go anywhere

Pathfinding should be worked on at some point. I was thinking, like physics, to have a system generating navmeshes so Godot's standard stuff could be used (if it proves performant enough to withstand that), and another doing AStar on the voxel grid. The former might be useful on smooth terrain, the latter on blocky. The maximum distances will be limited depending on the setup though, as storing a full-resolution navmesh for the entire world doesnt sound practical when the world is huge.

even not generated parts

I'm afraid it's not possible to do that. This also hints extremely long-range pathfinding, which sounds very expensive as well (and a bit extreme compared to common use cases). Either you need ridiculous amounts of RAM to store the entire world just in case it needs to be queried, or ridiculous amounts of CPU to generate every point on the fly or even load chunks temporarily. If you control generation, you will need to make your own system, maybe even through a different data set than voxels.

Is there some libraries/plugins I could use?

I dont know. For such needs you may have to do your own research, it seems to be outside the scope of this module. My only guess is to pathfind on a larger-scale data set which is better fit for this kind of job. For example if you want to use roads and special structures, use these, not voxels. You may want to use AStar and adapt it maybe.

probedrone commented 2 years ago

On using Astar for path finding; Godot already has Astar algorithms built in. They could potentially be jerry rigged to work with the blocky voxels?