diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-12 08:11:36 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-12 08:11:36 -0300 |
commit | 9251298f46537cde669e66ed740c9987678c4617 (patch) | |
tree | d0c88201f7d128cfee10a9d2f3fa3aa7ffb15169 | |
parent | 990690f9f53ec3f042d6df174fff05f2de25ca3d (diff) |
-collision debug is shown above all else, fixes #2985
-rw-r--r-- | scene/2d/collision_polygon_2d.cpp | 6 | ||||
-rw-r--r-- | scene/2d/collision_shape_2d.cpp | 6 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 23 |
3 files changed, 29 insertions, 6 deletions
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 1479cb7881..616d3da7c9 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -113,6 +113,12 @@ void CollisionPolygon2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { unparenting=false; can_update_body=get_tree()->is_editor_hint(); + if (!get_tree()->is_editor_hint()) { + //display above all else + set_z_as_relative(false); + set_z(VS::CANVAS_ITEM_Z_MAX-1); + } + } break; case NOTIFICATION_EXIT_TREE: { can_update_body=false; diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 85751fc735..56f68ae634 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -77,6 +77,11 @@ void CollisionShape2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { unparenting=false; can_update_body=get_tree()->is_editor_hint(); + if (!get_tree()->is_editor_hint()) { + //display above all else + set_z_as_relative(false); + set_z(VS::CANVAS_ITEM_Z_MAX-1); + } } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { @@ -120,6 +125,7 @@ void CollisionShape2D::_notification(int p_what) { rect=Rect2(); + Color draw_col=get_tree()->get_debug_collisions_color(); shape->draw(get_canvas_item(),draw_col); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 167b637bdc..e23b00bf09 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -299,6 +299,7 @@ void TileMap::_update_dirty_quadrants() { q.occluder_instances.clear(); Ref<CanvasItemMaterial> prev_material; RID prev_canvas_item; + RID prev_debug_canvas_item; for(int i=0;i<q.cells.size();i++) { @@ -319,6 +320,7 @@ void TileMap::_update_dirty_quadrants() { Ref<CanvasItemMaterial> mat = tile_set->tile_get_material(c.id); RID canvas_item; + RID debug_canvas_item; if (prev_canvas_item==RID() || prev_material!=mat) { @@ -331,11 +333,24 @@ void TileMap::_update_dirty_quadrants() { vs->canvas_item_set_transform( canvas_item, xform ); q.canvas_items.push_back(canvas_item); + if (debug_shapes) { + + debug_canvas_item=vs->canvas_item_create(); + vs->canvas_item_set_parent( debug_canvas_item, canvas_item ); + vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item,false); + vs->canvas_item_set_z(debug_canvas_item,VS::CANVAS_ITEM_Z_MAX-1); + q.canvas_items.push_back(debug_canvas_item); + prev_debug_canvas_item=debug_canvas_item; + } + prev_canvas_item=canvas_item; prev_material=mat; } else { canvas_item=prev_canvas_item; + if (debug_shapes) { + debug_canvas_item=prev_debug_canvas_item; + } } @@ -407,9 +422,8 @@ void TileMap::_update_dirty_quadrants() { _fix_cell_transform(xform,c,shape_ofs+center_ofs,s); - if (debug_shapes) { - vs->canvas_item_add_set_transform(canvas_item,xform); - shape->draw(canvas_item,debug_collision_color); + if (debug_canvas_item) { + shape->draw(debug_canvas_item,debug_collision_color); } ps->body_add_shape(q.body,shape->get_rid(),xform); @@ -417,9 +431,6 @@ void TileMap::_update_dirty_quadrants() { } } - if (debug_shapes) { - vs->canvas_item_add_set_transform(canvas_item,Matrix32()); - } if (navigation) { Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id); |