Merge pull request #116789 from aaronfranke/gltf-duplicate-doc-ext
GLTF: Duplicate extensions at the start of the import and export process
This commit is contained in:
commit
4bee1639b2
2 changed files with 13 additions and 5 deletions
|
|
@ -6,7 +6,7 @@
|
|||
<description>
|
||||
Extends the functionality of the [GLTFDocument] class by allowing you to run arbitrary code at various stages of glTF import or export.
|
||||
To use, make a new class extending GLTFDocumentExtension, override any methods you need, make an instance of your class, and register it using [method GLTFDocument.register_gltf_document_extension].
|
||||
[b]Note:[/b] Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the [code]set_additional_data[/code] and [code]get_additional_data[/code] methods in [GLTFState] or [GLTFNode].
|
||||
[b]Note:[/b] All GLTFDocumentExtension classes are duplicated when beginning the import or export process. Except for configuration values, these classes must be stateless in order to function properly. If you need to store data, use the [code]set_additional_data[/code] and [code]get_additional_data[/code] methods in [GLTFState] or [GLTFNode].
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="Runtime file loading and saving">$DOCS_URL/tutorials/io/runtime_file_loading_and_saving.html</link>
|
||||
|
|
|
|||
|
|
@ -6550,9 +6550,13 @@ Error GLTFDocument::_parse(Ref<GLTFState> p_state, const String &p_path, Ref<Fil
|
|||
document_extensions.clear();
|
||||
for (Ref<GLTFDocumentExtension> ext : all_document_extensions) {
|
||||
ERR_CONTINUE(ext.is_null());
|
||||
err = ext->import_preflight(p_state, p_state->json["extensionsUsed"]);
|
||||
Ref<GLTFDocumentExtension> ext_dup = ext;
|
||||
if (ClassDB::is_class_exposed(ext->get_class_name())) {
|
||||
ext_dup = ext->duplicate();
|
||||
}
|
||||
err = ext_dup->import_preflight(p_state, p_state->json["extensionsUsed"]);
|
||||
if (err == OK) {
|
||||
document_extensions.push_back(ext);
|
||||
document_extensions.push_back(ext_dup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7116,9 +7120,13 @@ Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> p_state, uint
|
|||
document_extensions.clear();
|
||||
for (Ref<GLTFDocumentExtension> ext : all_document_extensions) {
|
||||
ERR_CONTINUE(ext.is_null());
|
||||
Error err = ext->export_preflight(state, p_node);
|
||||
Ref<GLTFDocumentExtension> ext_dup = ext;
|
||||
if (ClassDB::is_class_exposed(ext->get_class_name())) {
|
||||
ext_dup = ext->duplicate();
|
||||
}
|
||||
Error err = ext_dup->export_preflight(state, p_node);
|
||||
if (err == OK) {
|
||||
document_extensions.push_back(ext);
|
||||
document_extensions.push_back(ext_dup);
|
||||
}
|
||||
}
|
||||
// Add the root node(s) and their descendants to the state.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue