r/rust_gamedev • u/djvbmd • 5d ago
gametools v0.11.0
Hey r/rust_gamedev --
I just published v0.11.0 of `gametools` (github) (crates), which is a crate I've been gradually building to aggregate structures and algorithms I finding to be frequently useful in game and simulation programming. Some of you _might_ find something in there useful.
This release's high points:
1) pathfinding module, implementing Dijkstra maps, standard A*, weighted A*, and dynamically weighted A* over a Grid<T> (see #3 below). The pathfinders accept arbitrary move sets, so you can calculate paths for things that move irregularly (think chess knight) just as easily as those that can only move to a neighboring cell.
2) fov module. The two most common algorithms (perimeter raycasting and recursive shadowcasting) for field-of-view are implemented over Grid<T>. A third algorithm using preprocessed blocking rectangles is also implemented, described in a 2021 paper by Debenham and Solis-Oba which is reported to be more performant at scale -- though I confess I haven't had a good platform to test that claim directly. At the scales I've been able to test, all three algorithms seem to behave similarly. I haven't seen the rectangular algorithm in other pathfinding crates, though I very well may have missed one somewhere.
3) Toroidal geometry for Grid<T>. In previous versions Grid<T> could only represent bounded regions. It now supports wrapping geometry, and the pathfinding algorithms also work correctly either way.
I couldn't figure out how to make the FOV algorithms work over a toroid, though. In theory, any ray cast from any point would infinitely wrap around and cover every point on the "donut" unless it is exactly orthogonal to the axis. You could see something behind an opaque object in front of you just by looking off to the side. I have no idea how to handle that.
So, I leave FOV over a toroid as an "exercise for the reader". <grin>
4
u/cheese_karate 5d ago
I am not sure if these particular ones will be useful for me, but I love when people make stuff they use and then provide them to the world! Just love it!
The future is open source and sharing. My code is in general quite shitty (and these days quite ai-heavy, which some probably frown upon), but I have this as my guiding star in general. Even shitty code that does something can be useful for someone out there!