-collision debug is shown above all else, fixes #2985

This commit is contained in:
Juan Linietsky 2015-12-12 08:11:36 -03:00
parent 990690f9f5
commit 9251298f46
3 changed files with 29 additions and 6 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);