Skip to content

Commit

Permalink
try detecting instance placeholders during packed scene instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOrioli committed Apr 4, 2024
1 parent f47f4a0 commit fe34765
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scene/resources/packed_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
ERR_FAIL_INDEX_V(nprops[j].value, prop_count, nullptr);

if (nprops[j].name & FLAG_PATH_PROPERTY_IS_NODE) {
if (node->get_scene_instance_load_placeholder()) {
// nodes might not exist yet, so we skip deffering nodepath resolution to placeholder instantiation
// this does not solve arrays problems, and creates issues with external node referneces

uint32_t name_idx = nprops[j].name & (FLAG_PATH_PROPERTY_IS_NODE - 1);
ERR_FAIL_UNSIGNED_INDEX_V(name_idx, (uint32_t)sname_count, nullptr);

node->set(snames[name_idx], props[nprops[j].value], &valid);
continue;
}

uint32_t name_idx = nprops[j].name & (FLAG_PATH_PROPERTY_IS_NODE - 1);
ERR_FAIL_UNSIGNED_INDEX_V(name_idx, (uint32_t)sname_count, nullptr);

Expand Down Expand Up @@ -358,7 +369,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
value = setup_resources_in_array(set_array, n, resources_local_to_sub_scene, node, snames[nprops[j].name], resources_local_to_scene, i, ret_nodes, p_edit_state);

bool is_get_valid = false;
Variant get_value = node->get(snames[nprops[j].name], &is_get_valid);
Variant get_value = node->get(snames[nprops[j].name], &is_get_valid); // this will always be false for InstancePlaceholders because set has not been called, resulting in un-typed arrays

if (is_get_valid && get_value.get_type() == Variant::ARRAY) {
Array get_array = get_value;
Expand Down

0 comments on commit fe34765

Please sign in to comment.