Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AStarGrid2D class with jump-point pathfinding #62717

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Jul 4, 2022

After some discussion with Juan I decided to try to implement the class which containing a pathfinding grid. Compared to AStar classes it should be more effecient solution for the many users, since that class would support Jump-point search pathfinding algorithm (see https://en.wikipedia.org/wiki/Jump_point_search).

Compared to AStar(right) the performance of this algorithm should be slighty faster in many situations (Elapsed Time is system ticks before call get_point_path function):

image

It also provides three different Diagonal modes which are:

Always

image

Never

image

At Least One Walkable

image

Only If No Obstacles

image

I based my implementation on modified version of https://github.com/juhgiyo/EpPathFinding.cs C# library (MIT licensed) which itself based on https://github.com/qiao/PathFinding.js (also MIT licensed).

Also I've included four heuristics modes which are: Manhattan, Euclidean, Octile and Chebyshev which are originally included in the original JS repository (https://github.com/qiao/PathFinding.js/blob/master/src/core/Heuristic.js). If its not desired I could cut it off and leave only Euclidean (which are closest to the existed AStar heuristic).

If you want to test my PR you can download a demo project with it:
TestAStarGrid.zip (UPDATED: 14/08/2022)

I would leave it as a draft for some time, to be successfully checked by @Calinou, @akien-mga, Juan or other engine members.

@Chaosus Chaosus requested a review from a team as a code owner July 4, 2022 19:19
@Chaosus Chaosus added this to the 4.0 milestone Jul 4, 2022
@Chaosus Chaosus force-pushed the jps_pathfinding branch 2 times, most recently from eb26848 to 9061a67 Compare July 4, 2022 19:30
@Chaosus Chaosus marked this pull request as draft July 4, 2022 19:33
@Chaosus Chaosus force-pushed the jps_pathfinding branch 4 times, most recently from 75080f4 to 3df925a Compare July 5, 2022 05:49
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
core/math/a_star_grid_2d.h Outdated Show resolved Hide resolved
@Chaosus
Copy link
Member Author

Chaosus commented Aug 14, 2022

@reduz Fixed all your remarks. Check again. New demo project version -
TestAStarGrid.zip

@Chaosus Chaosus requested a review from reduz August 14, 2022 14:26
@Chaosus Chaosus marked this pull request as ready for review August 29, 2022 09:10
@Chaosus Chaosus requested a review from a team as a code owner August 29, 2022 09:10
@Chaosus
Copy link
Member Author

Chaosus commented Aug 30, 2022

Note: I've removed the point weight parameter from the field - because I'm not sure how it should interact with the jumps correctly. If this feature would be required by the users - it can be implemented later. As the first iteration I think it's good and Juan think so too.

@Chaosus Chaosus force-pushed the jps_pathfinding branch 3 times, most recently from 8ce2bcc to 84bb9c7 Compare August 30, 2022 14:25
@Chaosus Chaosus merged commit 94b3a50 into godotengine:master Aug 30, 2022
@Chaosus Chaosus deleted the jps_pathfinding branch August 30, 2022 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants