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

Method SceneDebuggerTree

scene/debugger/scene_debugger.cpp:914–963  ·  view source on GitHub ↗

SceneDebuggerTree

Source from the content-addressed store, hash-verified

912
913/// SceneDebuggerTree
914SceneDebuggerTree::SceneDebuggerTree(Node *p_root) {
915 // Flatten tree into list, depth first, use stack to avoid recursion.
916 List<Node *> stack;
917 stack.push_back(p_root);
918 bool is_root = true;
919 const StringName &is_visible_sn = SNAME("is_visible");
920 const StringName &is_visible_in_tree_sn = SNAME("is_visible_in_tree");
921 while (stack.size()) {
922 Node *n = stack.front()->get();
923 stack.pop_front();
924
925 int count = n->get_child_count();
926 for (int i = 0; i < count; i++) {
927 stack.push_front(n->get_child(count - i - 1));
928 }
929
930 int view_flags = 0;
931 if (is_root) {
932 // Prevent root window visibility from being changed.
933 is_root = false;
934 } else if (n->has_method(is_visible_sn)) {
935 const Variant visible = n->call(is_visible_sn);
936 if (visible.get_type() == Variant::BOOL) {
937 view_flags = RemoteNode::VIEW_HAS_VISIBLE_METHOD;
938 view_flags |= uint8_t(visible) * RemoteNode::VIEW_VISIBLE;
939 }
940 if (n->has_method(is_visible_in_tree_sn)) {
941 const Variant visible_in_tree = n->call(is_visible_in_tree_sn);
942 if (visible_in_tree.get_type() == Variant::BOOL) {
943 view_flags |= uint8_t(visible_in_tree) * RemoteNode::VIEW_VISIBLE_IN_TREE;
944 }
945 }
946 }
947
948 String class_name;
949 ScriptInstance *script_instance = n->get_script_instance();
950 if (script_instance) {
951 Ref<Script> script = script_instance->get_script();
952 if (script.is_valid()) {
953 class_name = script->get_global_name();
954
955 if (class_name.is_empty()) {
956 // If there is no class_name in this script we just take the script path.
957 class_name = script->get_path();
958 }
959 }
960 }
961 nodes.push_back(RemoteNode(count, n->get_name(), class_name.is_empty() ? n->get_class() : class_name, n->get_instance_id(), n->get_scene_file_path(), view_flags));
962 }
963}
964
965void SceneDebuggerTree::serialize(Array &p_arr) {
966 for (const RemoteNode &n : nodes) {

Callers

nothing calls this directly

Calls 15

RemoteNodeClass · 0.85
get_script_instanceMethod · 0.80
get_scene_file_pathMethod · 0.80
sizeMethod · 0.65
push_backMethod · 0.45
getMethod · 0.45
frontMethod · 0.45
pop_frontMethod · 0.45
get_child_countMethod · 0.45
push_frontMethod · 0.45
get_childMethod · 0.45
has_methodMethod · 0.45

Tested by

no test coverage detected