Add debug visual for NavigationRegion2D bake rect
Adds debug visual for NavigationRegion2D bake rect.
This commit is contained in:
parent
f15ced3f18
commit
1cf407e7c9
2 changed files with 14 additions and 0 deletions
|
@ -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()) {
|
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_mesh();
|
||||||
_update_debug_edge_connections_mesh();
|
_update_debug_edge_connections_mesh();
|
||||||
|
_update_debug_baking_rect();
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
} break;
|
} break;
|
||||||
|
@ -659,3 +660,15 @@ void NavigationRegion2D::_update_debug_edge_connections_mesh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#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
|
||||||
|
|
|
@ -58,6 +58,7 @@ class NavigationRegion2D : public Node2D {
|
||||||
private:
|
private:
|
||||||
void _update_debug_mesh();
|
void _update_debug_mesh();
|
||||||
void _update_debug_edge_connections_mesh();
|
void _update_debug_edge_connections_mesh();
|
||||||
|
void _update_debug_baking_rect();
|
||||||
void _navigation_map_changed(RID p_map);
|
void _navigation_map_changed(RID p_map);
|
||||||
void _navigation_debug_changed();
|
void _navigation_debug_changed();
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
Loading…
Reference in a new issue