Merge pull request #58209 from Scony/fix-navi-get-simple-path

Fix `get_simple_path` behavior in 2D & 3D
This commit is contained in:
Rémi Verschelde 2022-04-01 08:46:54 +02:00 committed by GitHub
commit fce09f19dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -376,19 +376,16 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
// Add mid points
int np_id = least_cost_id;
while (np_id != -1) {
#ifdef USE_ENTRY_POINT
Vector3 point = navigation_polys[np_id].entry;
#else
while (np_id != -1 && navigation_polys[np_id].prev_navigation_poly_id != -1) {
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;
#endif
path.push_back(point);
np_id = navigation_polys[np_id].prev_navigation_poly_id;
}
path.push_back(begin_point);
path.invert();
}