summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorJFonS <joan.fonssanchez@gmail.com>2018-08-27 16:02:49 +0200
committerJFonS <joan.fonssanchez@gmail.com>2018-08-27 16:02:49 +0200
commitb58bb95c865095a1a4185e74e5fc7cce013ffbfe (patch)
tree34507eb2f32e9f97f8618681387cde73575ad4e7 /editor/plugins
parent49cf675ef460eb8baac7b5e598cd018f53bcec39 (diff)
Saner selection code for instanced scenes in 3D, should close #21447
Selecting instanced scenes still doesn't work properly because gizmos are not being added to instanced nodes. I will probably work on fixing all the shenanigans around selection, but that will take some time. This part of the code should work better for the moment.
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 906c51b9f6..ad4a2bdb22 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;
}
}