Skip to content

Commit 5699180

Browse files
committed
Merge pull request #108249 from Nikitf777/polygon-2d-editor-fix-selecting-wrong-point
Fix selecting wrong vertices in the Polygon2D editor when adding a polygon
2 parents db1b6b9 + abfa249 commit 5699180

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

editor/scene/2d/polygon_2d_editor_plugin.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,12 @@ void Polygon2DEditor::_canvas_input(const Ref<InputEvent> &p_input) {
640640

641641
if (current_action == ACTION_ADD_POLYGON) {
642642
int closest = -1;
643-
real_t closest_dist = 1e20;
644643

645-
for (int i = 0; i < editing_points.size(); i++) {
644+
for (int i = editing_points.size() - 1; i >= 0; i--) {
646645
Vector2 tuv = mtx.xform(editing_points[i]);
647-
real_t dist = tuv.distance_to(mb->get_position());
648-
if (dist < 8 && dist < closest_dist) {
646+
if (tuv.distance_to(mb->get_position()) < 8) {
649647
closest = i;
650-
closest_dist = dist;
648+
break;
651649
}
652650
}
653651

0 commit comments

Comments
 (0)