|
34 | 34 | #include "core/variant/typed_array.h" |
35 | 35 |
|
36 | 36 | static real_t heuristic_euclidean(const Vector2i &p_from, const Vector2i &p_to) { |
37 | | - real_t dx = (real_t)ABS(p_to.x - p_from.x); |
38 | | - real_t dy = (real_t)ABS(p_to.y - p_from.y); |
| 37 | + real_t dx = (real_t)Math::abs(p_to.x - p_from.x); |
| 38 | + real_t dy = (real_t)Math::abs(p_to.y - p_from.y); |
39 | 39 | return (real_t)Math::sqrt(dx * dx + dy * dy); |
40 | 40 | } |
41 | 41 |
|
42 | 42 | static real_t heuristic_manhattan(const Vector2i &p_from, const Vector2i &p_to) { |
43 | | - real_t dx = (real_t)ABS(p_to.x - p_from.x); |
44 | | - real_t dy = (real_t)ABS(p_to.y - p_from.y); |
| 43 | + real_t dx = (real_t)Math::abs(p_to.x - p_from.x); |
| 44 | + real_t dy = (real_t)Math::abs(p_to.y - p_from.y); |
45 | 45 | return dx + dy; |
46 | 46 | } |
47 | 47 |
|
48 | 48 | static real_t heuristic_octile(const Vector2i &p_from, const Vector2i &p_to) { |
49 | | - real_t dx = (real_t)ABS(p_to.x - p_from.x); |
50 | | - real_t dy = (real_t)ABS(p_to.y - p_from.y); |
| 49 | + real_t dx = (real_t)Math::abs(p_to.x - p_from.x); |
| 50 | + real_t dy = (real_t)Math::abs(p_to.y - p_from.y); |
51 | 51 | real_t F = Math_SQRT2 - 1; |
52 | 52 | return (dx < dy) ? F * dx + dy : F * dy + dx; |
53 | 53 | } |
54 | 54 |
|
55 | 55 | static real_t heuristic_chebyshev(const Vector2i &p_from, const Vector2i &p_to) { |
56 | | - real_t dx = (real_t)ABS(p_to.x - p_from.x); |
57 | | - real_t dy = (real_t)ABS(p_to.y - p_from.y); |
| 56 | + real_t dx = (real_t)Math::abs(p_to.x - p_from.x); |
| 57 | + real_t dy = (real_t)Math::abs(p_to.y - p_from.y); |
58 | 58 | return MAX(dx, dy); |
59 | 59 | } |
60 | 60 |
|
|
0 commit comments