diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-29 10:08:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 10:08:41 +0200 |
commit | b6c170165c09c24f0b3ae224e204ae62ac75c325 (patch) | |
tree | c21dea9678eb9d947a5ed9cf79e93893997ec6df | |
parent | d2abbfb1c5c5dea4fcbd09f075e110b33c8c4e67 (diff) | |
parent | b58bb95c865095a1a4185e74e5fc7cce013ffbfe (diff) |
Merge pull request #21485 from JFonS/fix_selection
Saner selection code for instanced scenes in 3D, should close #21447
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 202d47dfb3..cfc322d2c1 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -307,7 +307,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, Node *edited_scene = get_tree()->get_edited_scene_root(); ObjectID closest = 0; - Spatial *item = NULL; + Node *item = NULL; float closest_dist = 1e20; int selected_handle = -1; @@ -341,19 +341,16 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, if (dist < closest_dist) { //make sure that whathever is selected is editable - while (spat && spat != edited_scene && spat->get_owner() != edited_scene && !edited_scene->is_editable_instance(spat->get_owner())) { - - spat = Object::cast_to<Spatial>(spat->get_owner()); - } - - if (spat) { - item = spat; - closest = spat->get_instance_id(); - closest_dist = dist; - selected_handle = handle; + Node *owner = spat->get_owner(); + if (owner != edited_scene && !edited_scene->is_editable_instance(owner)) { + item = owner; } else { - ERR_PRINT("Bug?"); + item = Object::cast_to<Node>(spat); } + + closest = item->get_instance_id(); + closest_dist = dist; + selected_handle = handle; } } |