Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug visual for NavigationRegion2D bake rect #88701

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scene/2d/navigation_region_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions scene/2d/navigation_region_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading