Ensure selected node is a descendant of the edited scene
This commit is contained in:
parent
a7a124a57d
commit
b1a45d9487
@ -1064,21 +1064,23 @@ void Node3DEditorViewport::_select_region() {
|
|||||||
if (found_nodes.has(sp)) {
|
if (found_nodes.has(sp)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
found_nodes.insert(sp);
|
found_nodes.insert(sp);
|
||||||
|
|
||||||
Node *node = Object::cast_to<Node>(sp);
|
Node *node = Object::cast_to<Node>(sp);
|
||||||
if (node != edited_scene) {
|
|
||||||
node = edited_scene->get_deepest_editable_node(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent selection of nodes not owned by the edited scene.
|
// Selection requires that the node is the edited scene or its descendant, and has an owner.
|
||||||
while (node && node != edited_scene->get_parent()) {
|
if (node != edited_scene) {
|
||||||
Node *node_owner = node->get_owner();
|
if (!node->get_owner() || !edited_scene->is_ancestor_of(node)) {
|
||||||
if (node_owner == edited_scene || node == edited_scene || (node_owner != nullptr && edited_scene->is_editable_instance(node_owner))) {
|
continue;
|
||||||
break;
|
}
|
||||||
|
node = edited_scene->get_deepest_editable_node(node);
|
||||||
|
while (node != edited_scene) {
|
||||||
|
Node *node_owner = node->get_owner();
|
||||||
|
if (node_owner == edited_scene || (node_owner != nullptr && edited_scene->is_editable_instance(node_owner))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
node = node->get_parent();
|
||||||
}
|
}
|
||||||
node = node->get_parent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the node by the group if grouped
|
// Replace the node by the group if grouped
|
||||||
|
Loading…
Reference in New Issue
Block a user