You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix get_simple_path behavior in 2D & 3D
This commit is contained in:
@@ -351,11 +351,15 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
|
|||||||
|
|
||||||
// Add mid points
|
// Add mid points
|
||||||
int np_id = least_cost_id;
|
int np_id = least_cost_id;
|
||||||
while (np_id != -1) {
|
while (np_id != -1 && navigation_polys[np_id].back_navigation_poly_id != -1) {
|
||||||
path.push_back(navigation_polys[np_id].entry);
|
int prev = navigation_polys[np_id].back_navigation_edge;
|
||||||
|
int prev_n = (navigation_polys[np_id].back_navigation_edge + 1) % navigation_polys[np_id].poly->points.size();
|
||||||
|
Vector3 point = (navigation_polys[np_id].poly->points[prev].pos + navigation_polys[np_id].poly->points[prev_n].pos) * 0.5;
|
||||||
|
path.push_back(point);
|
||||||
np_id = navigation_polys[np_id].back_navigation_poly_id;
|
np_id = navigation_polys[np_id].back_navigation_poly_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path.push_back(begin_point);
|
||||||
path.reverse();
|
path.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user