diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-08-16 17:13:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-16 17:13:27 +0200 |
commit | 63453471903c09a18d3d771b24594ed082146354 (patch) | |
tree | 2eef5df871ed6d32875e8239dfd172e07f5410b6 /editor/plugins | |
parent | c1a43a09bef574eed4d3f5a9d392e4ca7677b3de (diff) | |
parent | 78e72c8e79a2b7d373190fc6bbe5d8c8c037c6df (diff) |
Merge pull request #10326 from kubecz3k/spatial-click-improve
spatial selection if subscene geometry is far from origin
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 97f85d9971..6a8ba0b675 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -267,6 +267,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, int selected_handle = -1; Vector<Spatial *> subscenes = Vector<Spatial *>(); + Vector<Vector3> subscenes_positions = Vector<Vector3>(); for (int i = 0; i < instances.size(); i++) { @@ -284,13 +285,16 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, if ((!seg.is_valid()) || found_gizmos.has(seg)) { Node *subscene_candidate = spat; + Vector3 source_click_spatial_pos = spat->get_global_transform().origin; while ((subscene_candidate->get_owner() != NULL) && (subscene_candidate->get_owner() != editor->get_edited_scene())) subscene_candidate = subscene_candidate->get_owner(); spat = subscene_candidate->cast_to<Spatial>(); - if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL)) + if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL)) { subscenes.push_back(spat); + subscenes_positions.push_back(source_click_spatial_pos); + } continue; } @@ -324,7 +328,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, for (int idx_subscene = 0; idx_subscene < subscenes.size(); idx_subscene++) { Spatial *subscene = subscenes.get(idx_subscene); - float dist = ray.cross(subscene->get_global_transform().origin - pos).length(); + float dist = ray.cross(subscenes_positions.get(idx_subscene) - pos).length(); if ((dist < 0) || (dist > 1.2)) continue; |