From 0f30fa8fbd53a5415af12020ca46d5b93657db29 Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Tue, 23 Jun 2020 15:22:08 +0800 Subject: [PATCH] Enable finer grained control when creating polygon with UV Editor Modifies polygon auto-completion based on UV editor scale, in order to enable finer grained control for the user. Enables selection of points closer than the current threshold of 8 pixels. (cherry picked from commit 69d0d8921448acfa3c01f2d88bf6311f4ffef593) --- editor/plugins/polygon_2d_editor_plugin.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 35c0142d4b6..ee42e7977b7 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -509,7 +509,8 @@ void Polygon2DEditor::_uv_input(const Ref &p_input) { Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y))); - if (points_prev.size() > 2 && tuv.distance_to(points_prev[0]) < 8) { + // Close the polygon if selected point is near start. Threshold for closing scaled by zoom level + if (points_prev.size() > 2 && tuv.distance_to(points_prev[0]) < (8 / uv_draw_zoom)) { undo_redo->create_action(TTR("Create Polygon & UV")); undo_redo->add_do_method(node, "set_uv", node->get_uv()); undo_redo->add_undo_method(node, "set_uv", uv_create_uv_prev);