Skip to content
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

GLTF: Add import_pre_generate and export_post_convert extension steps #96465

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

aaronfranke
Copy link
Member

This PR adds 2 missing hooks to GLTFDocumentExtension:

  • import_pre_generate: Runs at the start of scene generation, before generate_scene_node
  • export_post_convert: Runs at the end of node conversion, after convert_scene_node

Each of these can be worked around in most practical situations by using import_post_parse instead of import_pre_generate, and export_preserialize instead of export_post_convert. However, depending on the specifics of the use case, this could result in several problems. It could result in the data being potentially inconsistent and incorrect between calls to append_from_file and generate_scene, or between append_from_scene and write_to_filesystem, respectively. import_pre_generate is placed after the skins/skeletons, so if the code depends on those, it couldn't go in import_post_parse. Additionally, the lack of these methods may cause missing steps on re-runs of code, or pointless re-running of code.

All that said, I am making this PR with a use case in mind. I need export_post_convert to properly support a new system for glTF joints. I need to run some calculations at the end of node conversion, but I also need to know the indices of all nodes, so convert_scene_node is too early, and to ensure the data is correct at all stages, export_preserialize is too late. I have tested this PR on the aforementioned joints project (plus a test of import_pre_generate) and it works correctly.

@fire
Copy link
Member

fire commented Sep 3, 2024

There's some conflicting lines.

@aaronfranke aaronfranke force-pushed the gltf-pre-gen-post-conv branch from c5c8105 to 2988f75 Compare September 3, 2024 20:15
@aaronfranke aaronfranke force-pushed the gltf-pre-gen-post-conv branch from 2988f75 to 5972907 Compare September 17, 2024 11:13
@akien-mga akien-mga changed the title GLTF: Add import_pre_generate and export_post_convert extension steps GLTF: Add import_pre_generate and export_post_convert extension steps Sep 17, 2024
@akien-mga akien-mga merged commit a181d00 into godotengine:master Sep 17, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@aaronfranke aaronfranke deleted the gltf-pre-gen-post-conv branch September 17, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants