diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-21 11:23:02 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-21 11:23:02 +0200 |
commit | 9e9fb165bc6de5ab6879a2c60c68b7ec9b53cd2e (patch) | |
tree | 60ac2220258e26904af53c023b6047e44be4bfd6 /editor/plugins/tiles/tile_data_editors.cpp | |
parent | d7a5f9d67ced062ac466a61e30929b1e9cfa67c9 (diff) | |
parent | e70ca3bf5a1e0a06d646024503732034671dde9c (diff) | |
download | redot-engine-9e9fb165bc6de5ab6879a2c60c68b7ec9b53cd2e.tar.gz |
Merge pull request #92171 from KoBeWi/gridder_grid
Fix tile polygon grid not covering whole tile
Diffstat (limited to 'editor/plugins/tiles/tile_data_editors.cpp')
-rw-r--r-- | editor/plugins/tiles/tile_data_editors.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 2d0e5214db..94cbb371af 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -144,7 +144,8 @@ void GenericTilePolygonEditor::_base_control_draw() { } // Draw tile-related things. - Size2 tile_size = tile_set->get_tile_size(); + const Size2 base_tile_size = tile_set->get_tile_size(); + const Size2 tile_size = background_region.size; Transform2D xform; xform.set_origin(base_control->get_size() / 2 + panning); @@ -170,12 +171,16 @@ void GenericTilePolygonEditor::_base_control_draw() { // Draw grid. if (current_snap_option == SNAP_GRID) { - Vector2 spacing = tile_size / snap_subdivision->get_value(); + Vector2 spacing = base_tile_size / snap_subdivision->get_value(); Vector2 offset = -tile_size / 2; + int w = snap_subdivision->get_value() * (tile_size / base_tile_size).x; + int h = snap_subdivision->get_value() * (tile_size / base_tile_size).y; - for (int i = 1; i < snap_subdivision->get_value(); i++) { - base_control->draw_line(Vector2(spacing.x * i, 0) + offset, Vector2(spacing.x * i, tile_size.y) + offset, Color(1, 1, 1, 0.33)); - base_control->draw_line(Vector2(0, spacing.y * i) + offset, Vector2(tile_size.x, spacing.y * i) + offset, Color(1, 1, 1, 0.33)); + for (int y = 1; y < h; y++) { + for (int x = 1; x < w; x++) { + base_control->draw_line(Vector2(spacing.x * x, 0) + offset, Vector2(spacing.x * x, tile_size.y) + offset, Color(1, 1, 1, 0.33)); + base_control->draw_line(Vector2(0, spacing.y * y) + offset, Vector2(tile_size.x, spacing.y * y) + offset, Color(1, 1, 1, 0.33)); + } } } |