-
-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Fix selecting wrong vertices in the Polygon2D editor when adding a polygon #108249
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
base: master
Are you sure you want to change the base?
Fix selecting wrong vertices in the Polygon2D editor when adding a polygon #108249
Conversation
This loop could be extracted to a method, it's the same in both cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs rebase.
e93a58f
to
abfa249
Compare
Vector2 tuv = mtx.xform(editing_points[i]); | ||
real_t dist = tuv.distance_to(mb->get_position()); | ||
if (dist < 8 && dist < closest_dist) { | ||
if (tuv.distance_to(mb->get_position()) < 8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (tuv.distance_to(mb->get_position()) < 8) { | |
if (tuv.distance_squared_to(mb->get_position()) < 64.0) { |
Better to avoid the square root if we don't need the result here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the only place where it makes sense. I can change it everywhere here or create another pull request with these optimizations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been looking into that myself so might make a PR soon, just to avoid double work
Applied the same fix as in #107932, but for another action:
ACTION_ADD_POLYGON
. Sorry, I didn't know that this algorithm was used twice in the code. But this one seems to be the last. The interesting thing is that this code seems to be writter by none other than @reduz. I wounder why did he implement it like this.