ability to click on spatial subscene to select it
(cherry-picked from d2d62122e2
)
This commit is contained in:
parent
82b7fca937
commit
a04bb88e46
1 changed files with 29 additions and 3 deletions
|
@ -260,6 +260,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
|
|||
r_includes_current = false;
|
||||
|
||||
List<_RayResult> results;
|
||||
Vector<Spatial *> subscenes = Vector<Spatial *>();
|
||||
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
|
||||
|
@ -275,11 +276,18 @@ 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;
|
||||
|
@ -305,6 +313,24 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
|
|||
res.handle = handle;
|
||||
results.push_back(res);
|
||||
}
|
||||
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 (editor_selection->is_selected(subscene))
|
||||
r_includes_current = true;
|
||||
|
||||
_RayResult res;
|
||||
res.item = subscene;
|
||||
res.depth = dist;
|
||||
res.handle = -1;
|
||||
results.push_back(res);
|
||||
}
|
||||
|
||||
|
||||
if (results.empty())
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue