You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
ability to click on spatial subscene to select it
(cherry-picked from d2d62122e2)
This commit is contained in:
committed by
Rémi Verschelde
parent
82b7fca937
commit
a04bb88e46
@@ -260,6 +260,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
|
|||||||
r_includes_current = false;
|
r_includes_current = false;
|
||||||
|
|
||||||
List<_RayResult> results;
|
List<_RayResult> results;
|
||||||
|
Vector<Spatial *> subscenes = Vector<Spatial *>();
|
||||||
|
|
||||||
for (int i = 0; i < instances.size(); i++) {
|
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();
|
Ref<SpatialEditorGizmo> seg = spat->get_gizmo();
|
||||||
|
|
||||||
if (!seg.is_valid())
|
if (!seg.is_valid() || found_gizmos.has(seg)){
|
||||||
continue;
|
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;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
found_gizmos.insert(seg);
|
found_gizmos.insert(seg);
|
||||||
Vector3 point;
|
Vector3 point;
|
||||||
@@ -305,6 +313,24 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
|
|||||||
res.handle = handle;
|
res.handle = handle;
|
||||||
results.push_back(res);
|
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())
|
if (results.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user