Sahnvour / PathFinder

A small, simple and generic C++ path finding library.
BSD 2-Clause "Simplified" License
83 stars 26 forks source link

A* disable crossing via diagonal corners #7

Open playingoDEERUX opened 4 years ago

playingoDEERUX commented 4 years ago

Is it possible? Title says all.

Sahnvour commented 4 years ago

Yes, see for example https://github.com/Sahnvour/PathFinder/blob/master/examples/image.cpp#L138 . In these loops, for each pixel we look at its (up to) 9 neighbours and add them as children, ie. accessible nodes. If you don't want to allow moving in diagonal, just add the up/down and left/right neighbours.