KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.48k stars 316 forks source link

Hook `gather_actions_hook` is not invoked when "export_pointer_animation" is enabled #2293

Open marwie opened 1 month ago

marwie commented 1 month ago

Describe the bug I'm trying to export KHR_animation_pointer programmatically and noticed that the gather_actions_hook isnt invoked anymore when enabling the following settings:

args["export_animation_mode"] = "SCENE"
args["export_pointer_animation"] = True

Is this expected?

It currently breaks cases where I listen to animations being done exporting so that I can resolve json pointers to the correct animation index in the resulting glTF. (Maybe it's possible to resolve the pointers later in the process but I need access to both the the blender_action<>gltf_animation objects which is what the hook above provides)

To Reproduce Steps to reproduce the behavior:

  1. Create exporter extension that implements def gather_actions_hook(self, blender_object, params, export_settings):
  2. Add breakpoint in hook
  3. Invoke export operator programmatically with export_animations: True
  4. Note breakpoint at gather_actions_hook is hit
  5. Invoke export operator programmatically with export_animations: True and set export_animation_mode: SCENE + export_pointer_animation: TRUE
  6. Note that breakpoint at gather_actions_hook is not hit anymore

Expected behavior gather_actions_hook is always invoked

.blend file/ .gltf (mandatory)

anim.zip

Version

julienduroure commented 1 month ago

Is this expected?

Yes, it is "expected". gather_actions_hook is called when using "actions" animation mode, as the name of the hook indicates. Using SCENE mode does not check any action or NLA or any data model related to animation. It only bake the scene animation as it can be seen on viewport.

But ... we can probably add a hook to help you achieve what you want. Once again, there is no actions here. What can be done during the "SCENE" animation mode export: