diff options
Diffstat (limited to 'scene/resources/packed_scene.cpp')
-rw-r--r-- | scene/resources/packed_scene.cpp | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 633771506e..199f0e3989 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -42,12 +42,10 @@ #define PACKED_SCENE_VERSION 2 bool SceneState::can_instance() const { - return nodes.size() > 0; } Node *SceneState::instance(GenEditState p_edit_state) const { - // nodes where instancing failed (because something is missing) List<Node *> stray_instances; @@ -85,18 +83,15 @@ Node *SceneState::instance(GenEditState p_edit_state) const { Map<Ref<Resource>, Ref<Resource>> resources_local_to_scene; for (int i = 0; i < nc; i++) { - const NodeData &n = nd[i]; Node *parent = nullptr; if (i > 0) { - ERR_FAIL_COND_V_MSG(n.parent == -1, nullptr, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name])); NODE_FROM_ID(nparent, n.parent); #ifdef DEBUG_ENABLED if (!nparent && (n.parent & FLAG_ID_IS_PATH)) { - WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data()); } #endif @@ -118,10 +113,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const { } else if (n.instance >= 0) { //instance a scene into this node if (n.instance & FLAG_INSTANCE_IS_PLACEHOLDER) { - String path = props[n.instance & FLAG_MASK]; if (disable_placeholders) { - Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene"); ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); @@ -187,11 +180,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //properties int nprop_count = n.properties.size(); if (nprop_count) { - const NodeData::Property *nprops = &n.properties[0]; for (int j = 0; j < nprop_count; j++) { - bool valid; ERR_FAIL_INDEX_V(nprops[j].name, sname_count, nullptr); ERR_FAIL_INDEX_V(nprops[j].value, prop_count, nullptr); @@ -213,7 +204,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const { node->set(E->get().first, E->get().second); } } else { - Variant value = props[nprops[j].value]; if (value.get_type() == Variant::OBJECT) { @@ -221,13 +211,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const { Ref<Resource> res = value; if (res.is_valid()) { if (res->is_local_to_scene()) { - Map<Ref<Resource>, Ref<Resource>>::Element *E = resources_local_to_scene.find(res); if (E) { value = E->get(); } else { - Node *base = i == 0 ? node : ret_nodes[0]; if (p_edit_state == GEN_EDIT_STATE_MAIN) { @@ -259,7 +247,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //groups for (int j = 0; j < n.groups.size(); j++) { - ERR_FAIL_INDEX_V(n.groups[j], sname_count, nullptr); node->add_to_group(snames[n.groups[j]], true); } @@ -287,7 +274,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const { } if (n.owner >= 0) { - NODE_FROM_ID(owner, n.owner); if (owner) node->_set_owner_nocheck(owner); @@ -303,7 +289,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const { } for (Map<Ref<Resource>, Ref<Resource>>::Element *E = resources_local_to_scene.front(); E; E = E->next()) { - E->get()->setup_local_to_scene(); } @@ -313,7 +298,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const { const ConnectionData *cdata = connections.ptr(); for (int i = 0; i < cc; i++) { - const ConnectionData &c = cdata[i]; //ERR_FAIL_INDEX_V( c.from, nc, nullptr ); //ERR_FAIL_INDEX_V( c.to, nc, nullptr ); @@ -353,7 +337,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const { } static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map) { - if (name_map.has(p_string)) return name_map[p_string]; @@ -363,7 +346,6 @@ static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map } static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map) { - if (variant_map.has(p_variant)) return variant_map[p_variant]; @@ -373,7 +355,6 @@ static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, Varia } Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) { - // this function handles all the work related to properly packing scenes, be it // instanced or inherited. // given the complexity of this process, an attempt will be made to properly @@ -418,9 +399,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map Node *n = p_node; while (n) { - if (n == p_owner) { - Ref<SceneState> state = n->get_scene_inherited_state(); if (state.is_valid()) { int node = state->find_node_by_path(n->get_path_to(p_node)); @@ -435,7 +414,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } if (p_node->get_filename() != String() && p_node->get_owner() == p_owner && instanced_by_owner) { - if (p_node->get_scene_instance_load_placeholder()) { //it's a placeholder, use the placeholder path nd.instance = _vm_get_variant(p_node->get_filename(), variant_map); @@ -479,7 +457,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map StringName type = p_node->get_class(); for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -530,7 +507,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } if (exists) { - //check if already exists and did not change if (value.get_type() == Variant::FLOAT && original.get_type() == Variant::FLOAT) { //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error @@ -540,7 +516,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map if (Math::is_equal_approx(a, b)) continue; } else if (bool(Variant::evaluate(Variant::OP_EQUAL, value, original))) { - continue; } } @@ -552,7 +527,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } } else { - if (isdefault) { //it's the default value, no point in saving it continue; @@ -608,7 +582,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map //part of saved scene nd.owner = 0; } else { - nd.owner = -1; } @@ -637,14 +610,12 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map int parent_node = NO_PARENT_SAVED; if (save_node) { - //don't save the node if nothing and subscene node_map[p_node] = idx; //ok validate parent node if (p_parent_idx == NO_PARENT_SAVED) { - int sidx; if (nodepath_map.has(p_node->get_parent())) { sidx = nodepath_map[p_node->get_parent()]; @@ -663,7 +634,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } for (int i = 0; i < p_node->get_child_count(); i++) { - Node *c = p_node->get_child(i); Error err = _parse_node(p_owner, c, parent_node, name_map, variant_map, node_map, nodepath_map); if (err) @@ -674,7 +644,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) { - if (p_node != p_owner && p_node->get_owner() && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner())) return OK; @@ -686,14 +655,12 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName //NodeData &nd = nodes[node_map[p_node]]; for (List<MethodInfo>::Element *E = _signals.front(); E; E = E->next()) { - List<Node::Connection> conns; p_node->get_signal_connection_list(E->get().name, &conns); conns.sort(); for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) { - const Node::Connection &c = F->get(); if (!(c.flags & CONNECT_PERSIST)) //only persistent connections get saved @@ -721,7 +688,6 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName //go through ownership chain to see if this exists while (common_parent) { - Ref<SceneState> ps; if (common_parent == p_owner) @@ -730,7 +696,6 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName ps = common_parent->get_scene_instance_state(); if (ps.is_valid()) { - NodePath signal_from = common_parent->get_path_to(p_node); NodePath signal_to = common_parent->get_path_to(target); @@ -756,9 +721,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName bool exists2 = false; while (nl) { - if (nl == p_owner) { - Ref<SceneState> state = nl->get_scene_inherited_state(); if (state.is_valid()) { int from_node = state->find_node_by_path(nl->get_path_to(p_node)); @@ -835,7 +798,6 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName cd.signal = _nm_get_string(c.signal.get_name(), name_map); cd.flags = c.flags; for (int i = 0; i < c.binds.size(); i++) { - cd.binds.push_back(_vm_get_variant(c.binds[i], variant_map)); } connections.push_back(cd); @@ -843,7 +805,6 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName } for (int i = 0; i < p_node->get_child_count(); i++) { - Node *c = p_node->get_child(i); Error err = _parse_connections(p_owner, c, name_map, variant_map, node_map, nodepath_map); if (err) @@ -870,7 +831,6 @@ Error SceneState::pack(Node *p_scene) { String path = scene->get_scene_inherited_state()->get_path(); Ref<PackedScene> instance = ResourceLoader::load(path); if (instance.is_valid()) { - base_scene_idx = _vm_get_variant(instance, variant_map); } } @@ -891,21 +851,18 @@ Error SceneState::pack(Node *p_scene) { names.resize(name_map.size()); for (Map<StringName, int>::Element *E = name_map.front(); E; E = E->next()) { - names.write[E->get()] = E->key(); } variants.resize(variant_map.size()); const Variant *K = nullptr; while ((K = variant_map.next(K))) { - int idx = variant_map[*K]; variants.write[idx] = *K; } node_paths.resize(nodepath_map.size()); for (Map<Node *, int>::Element *E = nodepath_map.front(); E; E = E->next()) { - node_paths.write[E->get()] = scene->get_path_to(E->key()); } @@ -913,17 +870,14 @@ Error SceneState::pack(Node *p_scene) { } void SceneState::set_path(const String &p_path) { - path = p_path; } String SceneState::get_path() const { - return path; } void SceneState::clear() { - names.clear(); variants.clear(); nodes.clear(); @@ -935,9 +889,7 @@ void SceneState::clear() { } Ref<SceneState> SceneState::_get_base_scene_state() const { - if (base_scene_idx >= 0) { - Ref<PackedScene> ps = variants[base_scene_idx]; if (ps.is_valid()) { return ps->get_state(); @@ -948,7 +900,6 @@ Ref<SceneState> SceneState::_get_base_scene_state() const { } int SceneState::find_node_by_path(const NodePath &p_node) const { - if (!node_path_cache.has(p_node)) { if (_get_base_scene_state().is_valid()) { int idx = _get_base_scene_state()->find_node_by_path(p_node); @@ -980,7 +931,6 @@ int SceneState::find_node_by_path(const NodePath &p_node) const { } int SceneState::_find_base_scene_node_remap_key(int p_idx) const { - for (Map<int, int>::Element *E = base_scene_node_remap.front(); E; E = E->next()) { if (E->value() == p_idx) { return E->key(); @@ -990,7 +940,6 @@ int SceneState::_find_base_scene_node_remap_key(int p_idx) const { } Variant SceneState::get_property_value(int p_node, const StringName &p_property, bool &found) const { - found = false; ERR_FAIL_COND_V(p_node < 0, Variant()); @@ -1019,7 +968,6 @@ Variant SceneState::get_property_value(int p_node, const StringName &p_property, } bool SceneState::is_node_in_group(int p_node, const StringName &p_group) const { - ERR_FAIL_COND_V(p_node < 0, false); if (p_node < nodes.size()) { @@ -1040,17 +988,14 @@ bool SceneState::is_node_in_group(int p_node, const StringName &p_group) const { bool SceneState::disable_placeholders = false; void SceneState::set_disable_placeholders(bool p_disable) { - disable_placeholders = p_disable; } bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_node, const StringName &p_to_method) const { - ERR_FAIL_COND_V(p_node < 0, false); ERR_FAIL_COND_V(p_to_node < 0, false); if (p_node < nodes.size() && p_to_node < nodes.size()) { - int signal_idx = -1; int method_idx = -1; for (int i = 0; i < names.size(); i++) { @@ -1065,9 +1010,7 @@ bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_ //signal and method strings are stored.. for (int i = 0; i < connections.size(); i++) { - if (connections[i].from == p_node && connections[i].to == p_to_node && connections[i].signal == signal_idx && connections[i].method == method_idx) { - return true; } } @@ -1082,7 +1025,6 @@ bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_ } void SceneState::set_bundled_scene(const Dictionary &p_dictionary) { - ERR_FAIL_COND(!p_dictionary.has("names")); ERR_FAIL_COND(!p_dictionary.has("variants")); ERR_FAIL_COND(!p_dictionary.has("node_count")); @@ -1107,7 +1049,6 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) { Vector<String> snames = p_dictionary["names"]; if (snames.size()) { - int namecount = snames.size(); names.resize(namecount); const String *r = snames.ptr(); @@ -1121,7 +1062,6 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) { int varcount = svariants.size(); variants.resize(varcount); for (int i = 0; i < varcount; i++) { - variants.write[i] = svariants[i]; } @@ -1145,13 +1085,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) { nd.instance = r[idx++]; nd.properties.resize(r[idx++]); for (int j = 0; j < nd.properties.size(); j++) { - nd.properties.write[j].name = r[idx++]; nd.properties.write[j].value = r[idx++]; } nd.groups.resize(r[idx++]); for (int j = 0; j < nd.groups.size(); j++) { - nd.groups.write[j] = r[idx++]; } } @@ -1171,7 +1109,6 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) { cd.binds.resize(r[idx++]); for (int j = 0; j < cd.binds.size(); j++) { - cd.binds.write[j] = r[idx++]; } } @@ -1204,12 +1141,10 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) { } Dictionary SceneState::get_bundled_scene() const { - Vector<String> rnames; rnames.resize(names.size()); if (names.size()) { - String *r = rnames.ptrw(); for (int i = 0; i < names.size(); i++) @@ -1224,7 +1159,6 @@ Dictionary SceneState::get_bundled_scene() const { d["node_count"] = nodes.size(); for (int i = 0; i < nodes.size(); i++) { - const NodeData &nd = nodes[i]; rnodes.push_back(nd.parent); rnodes.push_back(nd.owner); @@ -1237,13 +1171,11 @@ Dictionary SceneState::get_bundled_scene() const { rnodes.push_back(nd.instance); rnodes.push_back(nd.properties.size()); for (int j = 0; j < nd.properties.size(); j++) { - rnodes.push_back(nd.properties[j].name); rnodes.push_back(nd.properties[j].value); } rnodes.push_back(nd.groups.size()); for (int j = 0; j < nd.groups.size(); j++) { - rnodes.push_back(nd.groups[j]); } } @@ -1254,7 +1186,6 @@ Dictionary SceneState::get_bundled_scene() const { d["conn_count"] = connections.size(); for (int i = 0; i < connections.size(); i++) { - const ConnectionData &cd = connections[i]; rconns.push_back(cd.from); rconns.push_back(cd.to); @@ -1291,12 +1222,10 @@ Dictionary SceneState::get_bundled_scene() const { } int SceneState::get_node_count() const { - return nodes.size(); } StringName SceneState::get_node_type(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName()); if (nodes[p_idx].type == TYPE_INSTANCED) return StringName(); @@ -1304,7 +1233,6 @@ StringName SceneState::get_node_type(int p_idx) const { } StringName SceneState::get_node_name(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName()); return names[nodes[p_idx].name]; } @@ -1315,7 +1243,6 @@ int SceneState::get_node_index(int p_idx) const { } bool SceneState::is_node_instance_placeholder(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), false); return nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER); @@ -1330,7 +1257,6 @@ Ref<PackedScene> SceneState::get_node_instance(int p_idx) const { else return variants[nodes[p_idx].instance & FLAG_MASK]; } else if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) { - if (base_scene_idx >= 0) { return variants[base_scene_idx]; } @@ -1340,7 +1266,6 @@ Ref<PackedScene> SceneState::get_node_instance(int p_idx) const { } String SceneState::get_node_instance_placeholder(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), String()); if (nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)) { @@ -1360,7 +1285,6 @@ Vector<StringName> SceneState::get_node_groups(int p_idx) const { } NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath()); if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) { @@ -1376,7 +1300,6 @@ NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const { int nidx = p_idx; while (true) { if (nodes[nidx].parent == NO_PARENT_SAVED || nodes[nidx].parent < 0) { - sub_path.insert(0, "."); break; } @@ -1405,7 +1328,6 @@ NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const { } int SceneState::get_node_property_count(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), -1); return nodes[p_idx].properties.size(); } @@ -1422,7 +1344,6 @@ Variant SceneState::get_node_property_value(int p_idx, int p_prop) const { } NodePath SceneState::get_node_owner_path(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath()); if (nodes[p_idx].owner < 0 || nodes[p_idx].owner == NO_PARENT_SAVED) return NodePath(); //root likely @@ -1434,11 +1355,9 @@ NodePath SceneState::get_node_owner_path(int p_idx) const { } int SceneState::get_connection_count() const { - return connections.size(); } NodePath SceneState::get_connection_source(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, connections.size(), NodePath()); if (connections[p_idx].from & FLAG_ID_IS_PATH) { return node_paths[connections[p_idx].from & FLAG_MASK]; @@ -1448,12 +1367,10 @@ NodePath SceneState::get_connection_source(int p_idx) const { } StringName SceneState::get_connection_signal(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, connections.size(), StringName()); return names[connections[p_idx].signal]; } NodePath SceneState::get_connection_target(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, connections.size(), NodePath()); if (connections[p_idx].to & FLAG_ID_IS_PATH) { return node_paths[connections[p_idx].to & FLAG_MASK]; @@ -1462,19 +1379,16 @@ NodePath SceneState::get_connection_target(int p_idx) const { } } StringName SceneState::get_connection_method(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, connections.size(), StringName()); return names[connections[p_idx].method]; } int SceneState::get_connection_flags(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, connections.size(), -1); return connections[p_idx].flags; } Array SceneState::get_connection_binds(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, connections.size(), Array()); Array binds; for (int i = 0; i < connections[p_idx].binds.size(); i++) { @@ -1484,7 +1398,6 @@ Array SceneState::get_connection_binds(int p_idx) const { } bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) { - // this method cannot be const because of this Ref<SceneState> ss = this; @@ -1528,13 +1441,11 @@ Vector<NodePath> SceneState::get_editable_instances() const { //add int SceneState::add_name(const StringName &p_name) { - names.push_back(p_name); return names.size() - 1; } int SceneState::find_name(const StringName &p_name) const { - for (int i = 0; i < names.size(); i++) { if (names[i] == p_name) return i; @@ -1544,18 +1455,15 @@ int SceneState::find_name(const StringName &p_name) const { } int SceneState::add_value(const Variant &p_value) { - variants.push_back(p_value); return variants.size() - 1; } int SceneState::add_node_path(const NodePath &p_path) { - node_paths.push_back(p_path); return (node_paths.size() - 1) | FLAG_ID_IS_PATH; } int SceneState::add_node(int p_parent, int p_owner, int p_type, int p_name, int p_instance, int p_index) { - NodeData nd; nd.parent = p_parent; nd.owner = p_owner; @@ -1569,7 +1477,6 @@ int SceneState::add_node(int p_parent, int p_owner, int p_type, int p_name, int return nodes.size() - 1; } void SceneState::add_node_property(int p_node, int p_name, int p_value) { - ERR_FAIL_INDEX(p_node, nodes.size()); ERR_FAIL_INDEX(p_name, names.size()); ERR_FAIL_INDEX(p_value, variants.size()); @@ -1580,18 +1487,15 @@ void SceneState::add_node_property(int p_node, int p_name, int p_value) { nodes.write[p_node].properties.push_back(prop); } void SceneState::add_node_group(int p_node, int p_group) { - ERR_FAIL_INDEX(p_node, nodes.size()); ERR_FAIL_INDEX(p_group, names.size()); nodes.write[p_node].groups.push_back(p_group); } void SceneState::set_base_scene(int p_idx) { - ERR_FAIL_INDEX(p_idx, variants.size()); base_scene_idx = p_idx; } void SceneState::add_connection(int p_from, int p_to, int p_signal, int p_method, int p_flags, const Vector<int> &p_binds) { - ERR_FAIL_INDEX(p_signal, names.size()); ERR_FAIL_INDEX(p_method, names.size()); @@ -1608,12 +1512,10 @@ void SceneState::add_connection(int p_from, int p_to, int p_signal, int p_method connections.push_back(c); } void SceneState::add_editable_instance(const NodePath &p_path) { - editable_instances.push_back(p_path); } Vector<String> SceneState::_get_node_groups(int p_idx) const { - Vector<StringName> groups = get_node_groups(p_idx); Vector<String> ret; @@ -1624,7 +1526,6 @@ Vector<String> SceneState::_get_node_groups(int p_idx) const { } void SceneState::_bind_methods() { - //unbuild API ClassDB::bind_method(D_METHOD("get_node_count"), &SceneState::get_node_count); @@ -1654,7 +1555,6 @@ void SceneState::_bind_methods() { } SceneState::SceneState() { - base_scene_idx = -1; last_modified_time = 0; } @@ -1662,32 +1562,26 @@ SceneState::SceneState() { //////////////// void PackedScene::_set_bundled_scene(const Dictionary &p_scene) { - state->set_bundled_scene(p_scene); } Dictionary PackedScene::_get_bundled_scene() const { - return state->get_bundled_scene(); } Error PackedScene::pack(Node *p_scene) { - return state->pack(p_scene); } void PackedScene::clear() { - state->clear(); } bool PackedScene::can_instance() const { - return state->can_instance(); } Node *PackedScene::instance(GenEditState p_edit_state) const { - #ifndef TOOLS_ENABLED ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, nullptr, "Edit state is only for editors, does not work without tools compiled."); #endif @@ -1709,7 +1603,6 @@ Node *PackedScene::instance(GenEditState p_edit_state) const { } void PackedScene::replace_state(Ref<SceneState> p_by) { - state = p_by; state->set_path(get_path()); #ifdef TOOLS_ENABLED @@ -1718,7 +1611,6 @@ void PackedScene::replace_state(Ref<SceneState> p_by) { } void PackedScene::recreate_state() { - state = Ref<SceneState>(memnew(SceneState)); state->set_path(get_path()); #ifdef TOOLS_ENABLED @@ -1727,18 +1619,15 @@ void PackedScene::recreate_state() { } Ref<SceneState> PackedScene::get_state() { - return state; } void PackedScene::set_path(const String &p_path, bool p_take_over) { - state->set_path(p_path); Resource::set_path(p_path, p_take_over); } void PackedScene::_bind_methods() { - ClassDB::bind_method(D_METHOD("pack", "path"), &PackedScene::pack); ClassDB::bind_method(D_METHOD("instance", "edit_state"), &PackedScene::instance, DEFVAL(GEN_EDIT_STATE_DISABLED)); ClassDB::bind_method(D_METHOD("can_instance"), &PackedScene::can_instance); @@ -1754,6 +1643,5 @@ void PackedScene::_bind_methods() { } PackedScene::PackedScene() { - state = Ref<SceneState>(memnew(SceneState)); } |