Skip to content

Commit

Permalink
fix: ignore negative numbers and add property range
Browse files Browse the repository at this point in the history
  • Loading branch information
Veradictus committed Oct 3, 2024
1 parent 2c98f92 commit 141c101
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/math/a_star_grid_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point, bool p_allow_
}

// If we have a limit on traversals, increment and stop once we reach the threshold.
if (max_traversals != 0 && traversal_count >= max_traversals) {
if (max_traversals > 0 && traversal_count >= max_traversals) {
break;
}

Expand Down Expand Up @@ -799,7 +799,7 @@ void AStarGrid2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_shape", PROPERTY_HINT_ENUM, "Square,IsometricRight,IsometricDown"), "set_cell_shape", "get_cell_shape");

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "jumping_enabled"), "set_jumping_enabled", "is_jumping_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_traversals"), "set_max_traversals", "get_max_traversals");
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_traversals", PROPERTY_HINT_RANGE, "0,65536,0"), "set_max_traversals", "get_max_traversals");
ADD_PROPERTY(PropertyInfo(Variant::INT, "default_compute_heuristic", PROPERTY_HINT_ENUM, "Euclidean,Manhattan,Octile,Chebyshev"), "set_default_compute_heuristic", "get_default_compute_heuristic");
ADD_PROPERTY(PropertyInfo(Variant::INT, "default_estimate_heuristic", PROPERTY_HINT_ENUM, "Euclidean,Manhattan,Octile,Chebyshev"), "set_default_estimate_heuristic", "get_default_estimate_heuristic");
ADD_PROPERTY(PropertyInfo(Variant::INT, "diagonal_mode", PROPERTY_HINT_ENUM, "Never,Always,At Least One Walkable,Only If No Obstacles"), "set_diagonal_mode", "get_diagonal_mode");
Expand Down

0 comments on commit 141c101

Please sign in to comment.