Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tile polygon grid not covering whole tile #92171

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions editor/plugins/tiles/tile_data_editors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
}
}

Expand Down
Loading