-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typed array export #67454
Closed
GuilhermeGSousa
wants to merge
1
commit into
godotengine:master
from
GuilhermeGSousa:fix-array-export
Closed
Fix typed array export #67454
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,16 +238,37 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { | |
|
||
if (nprops[j].name & FLAG_PATH_PROPERTY_IS_NODE) { | ||
uint32_t name_idx = nprops[j].name & (FLAG_PATH_PROPERTY_IS_NODE - 1); | ||
NodeData::Property nprop = nprops[j]; | ||
Variant prop_variant = props[nprop.value]; | ||
StringName prop_name = snames[name_idx]; | ||
ERR_FAIL_UNSIGNED_INDEX_V(name_idx, (uint32_t)sname_count, nullptr); | ||
if (Engine::get_singleton()->is_editor_hint()) { | ||
// If editor, just set the metadata and be it | ||
node->set(META_POINTER_PROPERTY_BASE + String(snames[name_idx]), props[nprops[j].value]); | ||
|
||
if (prop_variant.get_type() == Variant::ARRAY) { | ||
if (Engine::get_singleton()->is_editor_hint()) { | ||
// If editor, just set the metadata and be it | ||
node->set(prop_name, prop_variant); | ||
continue; | ||
} | ||
Array array = prop_variant; | ||
for (int k = 0; k < array.size(); k++) { | ||
DeferredNodePathProperties dnp; | ||
dnp.path = array[k]; | ||
dnp.base = node; | ||
dnp.property = StringName(String(prop_name) + "/indices/" + itos(k)); | ||
deferred_node_paths.push_back(dnp); | ||
} | ||
|
||
} else { | ||
if (Engine::get_singleton()->is_editor_hint()) { | ||
// If editor, just set the metadata and be it | ||
node->set(META_POINTER_PROPERTY_BASE + String(prop_name), prop_variant); | ||
continue; | ||
} | ||
// Do an actual deferred sed of the property path. | ||
DeferredNodePathProperties dnp; | ||
dnp.path = props[nprops[j].value]; | ||
dnp.path = prop_variant; | ||
dnp.base = node; | ||
dnp.property = snames[name_idx]; | ||
dnp.property = prop_name; | ||
deferred_node_paths.push_back(dnp); | ||
} | ||
continue; | ||
|
@@ -404,7 +425,20 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { | |
|
||
for (const DeferredNodePathProperties &dnp : deferred_node_paths) { | ||
Node *other = dnp.base->get_node_or_null(dnp.path); | ||
dnp.base->set(dnp.property, other); | ||
if (String(dnp.property).contains("/indices/")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid converting String string_property = dnp.property; |
||
Vector<String> properties = String(dnp.property).split("/"); | ||
Array array = dnp.base->get(properties[0]); | ||
|
||
if (array.size() >= properties[2].to_int()) { | ||
array.push_back(other); | ||
} else { | ||
array.set(properties[2].to_int(), other); | ||
} | ||
|
||
dnp.base->set(properties[0], array); | ||
} else { | ||
dnp.base->set(dnp.property, other); | ||
} | ||
} | ||
|
||
for (KeyValue<Ref<Resource>, Ref<Resource>> &E : resources_local_to_scene) { | ||
|
@@ -599,6 +633,20 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has | |
if (ures.is_null()) { | ||
value = missing_resource_properties[E.name]; | ||
} | ||
} else if (E.type == Variant::ARRAY && E.hint == PROPERTY_HINT_TYPE_STRING) { | ||
int hint_subtype_separator = E.hint_string.find(":"); | ||
if (hint_subtype_separator >= 0) { | ||
String subtype_string = E.hint_string.substr(0, hint_subtype_separator); | ||
int slash_pos = subtype_string.find("/"); | ||
PropertyHint subtype_hint = PropertyHint::PROPERTY_HINT_NONE; | ||
if (slash_pos >= 0) { | ||
subtype_hint = PropertyHint(subtype_string.get_slice("/", 1).to_int()); | ||
subtype_string = subtype_string.substr(0, slash_pos); | ||
} | ||
Variant::Type subtype = Variant::Type(subtype_string.to_int()); | ||
|
||
use_deferred_node_path_bit = subtype == Variant::OBJECT && subtype_hint == PROPERTY_HINT_NODE_TYPE; | ||
} | ||
} | ||
|
||
if (!pinned_props.has(name)) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(technically applies to other variables too)