mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Fix NavigationServer3D.get_closest_point_to_segment() with use_collision
This commit is contained in:
parent
e96ad5af98
commit
9b191f669c
@ -617,7 +617,7 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector
|
||||
const Face3 f(p.points[0].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
|
||||
Vector3 inters;
|
||||
if (f.intersects_segment(p_from, p_to, &inters)) {
|
||||
const real_t d = closest_point_d = p_from.distance_to(inters);
|
||||
const real_t d = p_from.distance_to(inters);
|
||||
if (use_collision == false) {
|
||||
closest_point = inters;
|
||||
use_collision = true;
|
||||
|
@ -697,12 +697,16 @@ TEST_SUITE("[Navigation]") {
|
||||
CHECK_NE(navigation_server->map_get_closest_point(map, Vector3(0, 0, 0)), Vector3(0, 0, 0));
|
||||
CHECK_NE(navigation_server->map_get_closest_point_normal(map, Vector3(0, 0, 0)), Vector3());
|
||||
CHECK(navigation_server->map_get_closest_point_owner(map, Vector3(0, 0, 0)).is_valid());
|
||||
// TODO: Test map_get_closest_point_to_segment() with p_use_collision=true as well.
|
||||
CHECK_NE(navigation_server->map_get_closest_point_to_segment(map, Vector3(0, 0, 0), Vector3(1, 1, 1), false), Vector3());
|
||||
CHECK_NE(navigation_server->map_get_closest_point_to_segment(map, Vector3(0, 0, 0), Vector3(1, 1, 1), true), Vector3());
|
||||
CHECK_NE(navigation_server->map_get_path(map, Vector3(0, 0, 0), Vector3(10, 0, 10), true).size(), 0);
|
||||
CHECK_NE(navigation_server->map_get_path(map, Vector3(0, 0, 0), Vector3(10, 0, 10), false).size(), 0);
|
||||
}
|
||||
|
||||
SUBCASE("'map_get_closest_point_to_segment' with 'use_collision' should return default if segment doesn't intersect map") {
|
||||
CHECK_EQ(navigation_server->map_get_closest_point_to_segment(map, Vector3(1, 2, 1), Vector3(1, 1, 1), true), Vector3());
|
||||
}
|
||||
|
||||
SUBCASE("Elaborate query with 'CORRIDORFUNNEL' post-processing should yield non-empty result") {
|
||||
Ref<NavigationPathQueryParameters3D> query_parameters = memnew(NavigationPathQueryParameters3D);
|
||||
query_parameters->set_map(map);
|
||||
|
Loading…
Reference in New Issue
Block a user