Merge pull request #88701 from smix8/bake_rect_debug

Add debug visual for NavigationRegion2D bake rect
This commit is contained in:
Rémi Verschelde 2024-02-23 13:14:05 +01:00
commit 87d40ba743
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 14 additions and 0 deletions

View File

@ -177,6 +177,7 @@ void NavigationRegion2D::_notification(int p_what) {
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || NavigationServer2D::get_singleton()->get_debug_enabled()) && navigation_polygon.is_valid()) {
_update_debug_mesh();
_update_debug_edge_connections_mesh();
_update_debug_baking_rect();
}
#endif // DEBUG_ENABLED
} break;
@ -659,3 +660,15 @@ void NavigationRegion2D::_update_debug_edge_connections_mesh() {
}
}
#endif // DEBUG_ENABLED
#ifdef DEBUG_ENABLED
void NavigationRegion2D::_update_debug_baking_rect() {
Rect2 baking_rect = get_navigation_polygon()->get_baking_rect();
if (baking_rect.has_area()) {
Vector2 baking_rect_offset = get_navigation_polygon()->get_baking_rect_offset();
Rect2 debug_baking_rect = Rect2(baking_rect.position.x + baking_rect_offset.x, baking_rect.position.y + baking_rect_offset.y, baking_rect.size.x, baking_rect.size.y);
Color debug_baking_rect_color = Color(0.8, 0.5, 0.7, 0.1);
draw_rect(debug_baking_rect, debug_baking_rect_color);
}
}
#endif // DEBUG_ENABLED

View File

@ -58,6 +58,7 @@ class NavigationRegion2D : public Node2D {
private:
void _update_debug_mesh();
void _update_debug_edge_connections_mesh();
void _update_debug_baking_rect();
void _navigation_map_changed(RID p_map);
void _navigation_debug_changed();
#endif // DEBUG_ENABLED