Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2022-02-11 21:37:58 +0300
committerJulien Duroure <julien.duroure@gmail.com>2022-02-11 21:37:58 +0300
commit0508df3751345a454d2d82a0e10fa4b38d1dae16 (patch)
treefb39ade363962d2addb17cc138f92f9c79259494
parentdd0aa51642e8a6c35076eedf55a63c2fad62e477 (diff)
glTF exporter: various baking fixes
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py37
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py12
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py32
3 files changed, 41 insertions, 40 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
index f09a395f..0b5cab5d 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
@@ -174,23 +174,26 @@ def gather_animation_channels(obj_uuid: int,
to_be_done = ['location', 'rotation_quaternion', 'scale']
to_be_done = [c for c in to_be_done if c not in done_paths]
- for p in to_be_done:
- channel = gather_animation_channel(
- obj_uuid,
- (),
- export_settings,
- None,
- p,
- start_frame,
- end_frame,
- force_range,
- blender_action.name,
- None,
- False #If Object is not animated, don't keep animation for this channel
- )
-
- if channel is not None:
- channels.append(channel)
+ # In case of weight action, do nothing.
+ # If there is only weight --> TRS is already managed at first
+ if not (len(done_paths) == 1 and 'weights' in done_paths):
+ for p in to_be_done:
+ channel = gather_animation_channel(
+ obj_uuid,
+ (),
+ export_settings,
+ None,
+ p,
+ start_frame,
+ end_frame,
+ force_range,
+ blender_action.name,
+ None,
+ False #If Object is not animated, don't keep animation for this channel
+ )
+
+ if channel is not None:
+ channels.append(channel)
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py
index 741c7c0c..de0ec3fd 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py
@@ -148,16 +148,12 @@ def get_object_matrix(blender_obj_uuid: str,
data = {}
-
- # If we bake (because export selection), we don't know exactly the frame range,
+ # TODO : bake_range_start & bake_range_end are no more needed here
+ # Because we bake, we don't know exactly the frame range,
# So using min / max of all actions
- if export_settings['gltf_selected'] is True and export_settings['vtree'].tree_troncated is True:
- start_frame = min([v[0] for v in [a.frame_range for a in bpy.data.actions]])
- end_frame = max([v[1] for v in [a.frame_range for a in bpy.data.actions]])
- else:
- start_frame = bake_range_start
- end_frame = bake_range_end
+ start_frame = min([v[0] for v in [a.frame_range for a in bpy.data.actions]])
+ end_frame = max([v[1] for v in [a.frame_range for a in bpy.data.actions]])
frame = start_frame
while frame <= end_frame:
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
index cc6f5dd0..0d249660 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animations.py
@@ -69,21 +69,23 @@ def gather_animations( obj_uuid: int,
# Collect all 'actions' affecting this object. There is a direct mapping between blender actions and glTF animations
blender_actions = __get_blender_actions(blender_object, export_settings)
- if export_settings['gltf_selected'] is True \
- and not (blender_object.animation_data is not None and blender_object.animation_data.action is not None): #there is no animation
- channels = __gather_channels_baked(obj_uuid, export_settings)
- if channels is not None:
- animation = gltf2_io.Animation(
- channels=channels,
- extensions=None, # as other animations
- extras=None, # Because there is no animation to get extras from
- name=blender_object.name, # Use object name as animation name
- samplers=[]
- )
-
- __link_samplers(animation, export_settings)
- if animation is not None:
- animations.append(animation)
+ if len([a for a in blender_actions if a[2] == "OBJECT"]) == 0:
+ # No TRS animation are found for this object.
+ # But we need to bake, in case we export selection
+ if export_settings['gltf_selected'] is True and blender_object.type != "ARMATURE":
+ channels = __gather_channels_baked(obj_uuid, export_settings)
+ if channels is not None:
+ animation = gltf2_io.Animation(
+ channels=channels,
+ extensions=None, # as other animations
+ extras=None, # Because there is no animation to get extras from
+ name=blender_object.name, # Use object name as animation name
+ samplers=[]
+ )
+
+ __link_samplers(animation, export_settings)
+ if animation is not None:
+ animations.append(animation)
current_action = None
if blender_object.animation_data and blender_object.animation_data.action: