X Tutup
Skip to content

Fix snap Polygon2D editor#110989

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
xuhuisheng:dev/snap
Oct 21, 2025
Merged

Fix snap Polygon2D editor#110989
Repiteo merged 1 commit intogodotengine:masterfrom
xuhuisheng:dev/snap

Conversation

@xuhuisheng
Copy link
Contributor

@xuhuisheng xuhuisheng commented Sep 28, 2025

Issue Description

When we drag a vertex of a Polygon from polygon editor.

  • Pressed mouse left key, record mouse position as drag_from
  • Drag to somewhere and release mouse, get mouse position as drag_to, depending on grid snap configuration, we will calculate with snap_point() to let mouse position snap to the grid
  • The problem is we used drag_to - drag_from as distance to update points of polygon, that caused very hard to drag a vertex to snap the grid correctly. It should use snapped mouse position directly.

e.g.

  • vertex position (1, 1)
  • grid (10, 10)
  • original mouse position (5, 5), we pressed mouse on (5,5)
  • target mouse position (10, 10), we released mouse on (10, 10). Maybe real position is (9,9) or (11,11), it will be snapped to (10, 10) as grid configuration.
  • The the distance is (10, 10) - (5, 5) = (5,5)
  • Finally, vertex will move to (1, 1) + (5,5) = (6,6), which is not snapped on grid.
  • We should let vertext move to (10, 10) directly.

@Ayanakoji77
Copy link

@AThousandShips hey i am beginner in this . So sorry if mistakes made , but my question is that how to know if i should review this pr , as in many pr you have added the pr to a milestone , so should i review them and provide results , and i though of pr review before contributing it seems easier .

@AThousandShips
Copy link
Member

Any review you want to contribute would be welcome but please focus on functionality and not style etc.

@Repiteo Repiteo merged commit a58968d into godotengine:master Oct 21, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 21, 2025

Thanks!

@xuhuisheng xuhuisheng deleted the dev/snap branch October 22, 2025 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Polygon 2D grid snap does not function consistently

5 participants

X Tutup