1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Merge pull request #100708 from smix8/navobstacle2d_debug

Improve NavigationObstacle2D debug visuals and performance
This commit is contained in:
Thaddeus Crews
2024-12-23 11:15:06 -06:00
5 changed files with 95 additions and 60 deletions

View File

@@ -102,20 +102,12 @@ void NavigationObstacle3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
lines_mesh_vertices_ptrw[vertex_index++] = safe_global_basis.xform(Vector3(point.x, height, point.z));
}
Vector<Vector2> polygon_2d_vertices;
polygon_2d_vertices.resize(vertex_count);
for (int i = 0; i < vertex_count; i++) {
const Vector3 &vert = vertices[i];
polygon_2d_vertices.write[i] = Vector2(vert.x, vert.z);
}
Vector<int> triangulated_polygon_2d_indices = Geometry2D::triangulate_polygon(polygon_2d_vertices);
NavigationServer3D *ns3d = NavigationServer3D::get_singleton();
if (triangulated_polygon_2d_indices.is_empty()) {
p_gizmo->add_lines(lines_mesh_vertices, ns3d->get_debug_navigation_avoidance_static_obstacle_pushin_edge_material());
} else {
if (obstacle->are_vertices_valid()) {
p_gizmo->add_lines(lines_mesh_vertices, ns3d->get_debug_navigation_avoidance_static_obstacle_pushout_edge_material());
} else {
p_gizmo->add_lines(lines_mesh_vertices, ns3d->get_debug_navigation_avoidance_static_obstacle_pushin_edge_material());
}
p_gizmo->add_collision_segments(lines_mesh_vertices);