diff options
author | Jakub Grzesik <kubecz3k@gmail.com> | 2017-08-09 18:40:02 +0200 |
---|---|---|
committer | Jakub Grzesik <kubecz3k@gmail.com> | 2017-08-09 18:40:02 +0200 |
commit | d2d62122e26afa66ff69d17a2c3b87ec6ed7e885 (patch) | |
tree | f4aa3bb20437e57c3f2890dee5922701aa5bf644 /editor | |
parent | 1536cc438128fe4036fa7da5ec305513a781d3c8 (diff) |
ability to click on spatial subscene to select it
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 0dba1f12a2..a549f09cb1 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -266,6 +266,8 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, float closest_dist = 1e20; int selected_handle = -1; + Vector<Spatial *> subscenes = Vector<Spatial *>(); + for (int i = 0; i < instances.size(); i++) { Object *obj = ObjectDB::get_instance(instances[i]); @@ -279,11 +281,19 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, Ref<SpatialEditorGizmo> seg = spat->get_gizmo(); - if (!seg.is_valid()) - continue; + if ((!seg.is_valid()) || found_gizmos.has(seg)) { + + Node *subscene_candidate = spat; + + while (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() != "")) + subscenes.push_back(spat); - if (found_gizmos.has(seg)) continue; + } found_gizmos.insert(seg); Vector3 point; @@ -311,6 +321,22 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, // r_includes_current=true; } + 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(); + + if ((dist < 0) || (dist > 1.2)) + continue; + + if (dist < closest_dist) { + closest = subscene->get_instance_id(); + closest_dist = dist; + item = subscene; + selected_handle = -1; + } + } + if (!item) return 0; |