mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #107573 from lodetrick/tilemap-hide-overlay
Fade TileMap editor overlay when zoomed out
This commit is contained in:
commit
edcbdc5706
1 changed files with 89 additions and 84 deletions
|
@ -4246,6 +4246,10 @@ void TileMapLayerEditor::_draw_overlay() {
|
||||||
Transform2D xform_inv = xform.affine_inverse();
|
Transform2D xform_inv = xform.affine_inverse();
|
||||||
Vector2i tile_shape_size = tile_set->get_tile_size();
|
Vector2i tile_shape_size = tile_set->get_tile_size();
|
||||||
|
|
||||||
|
// Fade the overlay out when size too small.
|
||||||
|
Vector2 hint_distance = xform.get_scale() * tile_shape_size;
|
||||||
|
float scale_fading = MIN(1, (MIN(hint_distance.x, hint_distance.y) - 5) / 5);
|
||||||
|
if (scale_fading > 0) {
|
||||||
// Draw tiles with invalid IDs in the grid.
|
// Draw tiles with invalid IDs in the grid.
|
||||||
TypedArray<Vector2i> used_cells = edited_layer->get_used_cells();
|
TypedArray<Vector2i> used_cells = edited_layer->get_used_cells();
|
||||||
for (int i = 0; i < used_cells.size(); i++) {
|
for (int i = 0; i < used_cells.size(); i++) {
|
||||||
|
@ -4270,7 +4274,7 @@ void TileMapLayerEditor::_draw_overlay() {
|
||||||
(float)((hash >> 24) & 0xFF) / 256.0,
|
(float)((hash >> 24) & 0xFF) / 256.0,
|
||||||
Math::lerp(0.5, 1.0, (float)((hash >> 16) & 0xFF) / 256.0),
|
Math::lerp(0.5, 1.0, (float)((hash >> 16) & 0xFF) / 256.0),
|
||||||
Math::lerp(0.5, 1.0, (float)((hash >> 8) & 0xFF) / 256.0),
|
Math::lerp(0.5, 1.0, (float)((hash >> 8) & 0xFF) / 256.0),
|
||||||
0.8);
|
0.8 * scale_fading);
|
||||||
|
|
||||||
// Display the warning pattern.
|
// Display the warning pattern.
|
||||||
Transform2D tile_xform;
|
Transform2D tile_xform;
|
||||||
|
@ -4284,7 +4288,7 @@ void TileMapLayerEditor::_draw_overlay() {
|
||||||
icon_size[min_axis] = tile_set->get_tile_size()[min_axis] / 3;
|
icon_size[min_axis] = tile_set->get_tile_size()[min_axis] / 3;
|
||||||
icon_size[(min_axis + 1) % 2] = (icon_size[min_axis] * missing_tile_texture->get_size()[(min_axis + 1) % 2] / missing_tile_texture->get_size()[min_axis]);
|
icon_size[(min_axis + 1) % 2] = (icon_size[min_axis] * missing_tile_texture->get_size()[(min_axis + 1) % 2] / missing_tile_texture->get_size()[min_axis]);
|
||||||
Rect2 rect = Rect2(xform.xform(tile_set->map_to_local(coords)) - (icon_size * xform.get_scale() / 2), icon_size * xform.get_scale());
|
Rect2 rect = Rect2(xform.xform(tile_set->map_to_local(coords)) - (icon_size * xform.get_scale() / 2), icon_size * xform.get_scale());
|
||||||
custom_overlay->draw_texture_rect(missing_tile_texture, rect);
|
custom_overlay->draw_texture_rect(missing_tile_texture, rect, false, Color(1, 1, 1, scale_fading));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4334,7 +4338,7 @@ void TileMapLayerEditor::_draw_overlay() {
|
||||||
tile_xform.set_origin(tile_set->map_to_local(Vector2(x, y)));
|
tile_xform.set_origin(tile_set->map_to_local(Vector2(x, y)));
|
||||||
tile_xform.set_scale(tile_shape_size);
|
tile_xform.set_scale(tile_shape_size);
|
||||||
Color color = grid_color;
|
Color color = grid_color;
|
||||||
color.a = color.a * opacity;
|
color.a = color.a * opacity * scale_fading;
|
||||||
tile_set->draw_tile_shape(custom_overlay, xform * tile_xform, color, false);
|
tile_set->draw_tile_shape(custom_overlay, xform * tile_xform, color, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4347,6 +4351,7 @@ void TileMapLayerEditor::_draw_overlay() {
|
||||||
custom_overlay->draw_string(font, xform.xform(tile_set->map_to_local(Vector2(x, y))) + Vector2i(-tile_shape_size.x / 2, 0), vformat("%s", Vector2(x, y)));
|
custom_overlay->draw_string(font, xform.xform(tile_set->map_to_local(Vector2(x, y))) + Vector2i(-tile_shape_size.x / 2, 0), vformat("%s", Vector2(x, y)));
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the plugins.
|
// Draw the plugins.
|
||||||
tabs_plugins[tabs_bar->get_current_tab()]->forward_canvas_draw_over_viewport(custom_overlay);
|
tabs_plugins[tabs_bar->get_current_tab()]->forward_canvas_draw_over_viewport(custom_overlay);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue