GLTF: Add import_pre_generate
and export_post_convert
extension steps
#96465
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.
This PR adds 2 missing hooks to GLTFDocumentExtension:
import_pre_generate
: Runs at the start of scene generation, beforegenerate_scene_node
export_post_convert
: Runs at the end of node conversion, afterconvert_scene_node
Each of these can be worked around in most practical situations by using
import_post_parse
instead ofimport_pre_generate
, andexport_preserialize
instead ofexport_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 toappend_from_file
andgenerate_scene
, or betweenappend_from_scene
andwrite_to_filesystem
, respectively.import_pre_generate
is placed after the skins/skeletons, so if the code depends on those, it couldn't go inimport_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, soconvert_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 ofimport_pre_generate
) and it works correctly.