MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _select_clicked

Method _select_clicked

editor/scene/3d/node_3d_editor_plugin.cpp:777–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777void Node3DEditorViewport::_select_clicked(bool p_allow_locked) {
778 Node *node = ObjectDB::get_instance<Node3D>(clicked);
779 Node3D *selected = Object::cast_to<Node3D>(node);
780 clicked = ObjectID();
781
782 if (!selected) {
783 return;
784 }
785
786 Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
787
788 // Prevent selection of nodes not owned by the edited scene.
789 while (node && node != edited_scene->get_parent()) {
790 Node *node_owner = node->get_owner();
791 if (node_owner == edited_scene || node == edited_scene || (node_owner != nullptr && edited_scene->is_editable_instance(node_owner))) {
792 break;
793 }
794 node = node->get_parent();
795 selected = Object::cast_to<Node3D>(node);
796 }
797
798 if (!p_allow_locked) {
799 // Replace the node by the group if grouped
800 while (node && node != edited_scene->get_parent()) {
801 Node3D *selected_tmp = Object::cast_to<Node3D>(node);
802 if (selected_tmp && node->has_meta("_edit_group_")) {
803 selected = selected_tmp;
804 }
805 node = node->get_parent();
806 }
807 }
808
809 if (p_allow_locked || (selected != nullptr && !_is_node_locked(selected))) {
810 if (clicked_wants_append) {
811 const List<Node *> &top_node_list = editor_selection->get_top_selected_node_list();
812 const Node *active_node = top_node_list.is_empty() ? nullptr : top_node_list.back()->get();
813 if (editor_selection->is_selected(selected)) {
814 editor_selection->remove_node(selected);
815 if (selected != active_node) {
816 editor_selection->add_node(selected);
817 }
818 } else {
819 editor_selection->add_node(selected);
820 }
821 } else {
822 if (!editor_selection->is_selected(selected)) {
823 editor_selection->clear();
824 editor_selection->add_node(selected);
825 EditorNode::get_singleton()->edit_node(selected);
826 }
827 }
828
829 const List<Node *> &top_node_list = editor_selection->get_top_selected_node_list();
830 if (top_node_list.size() == 1) {
831 EditorNode::get_singleton()->edit_node(top_node_list.front()->get());
832 }
833 }
834}

Callers

nothing calls this directly

Calls 15

is_editable_instanceMethod · 0.80
sizeMethod · 0.65
ObjectIDClass · 0.50
get_edited_sceneMethod · 0.45
get_parentMethod · 0.45
get_ownerMethod · 0.45
has_metaMethod · 0.45
is_emptyMethod · 0.45
getMethod · 0.45
backMethod · 0.45
is_selectedMethod · 0.45
remove_nodeMethod · 0.45

Tested by

no test coverage detected