diff options
Diffstat (limited to 'io_scene_gltf2/blender')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py | 35 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py | 13 |
2 files changed, 24 insertions, 24 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 b2d69ae9..1ac3600e 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 @@ -31,24 +31,27 @@ def gather_animation_channels(blender_action: bpy.types.Action, ) -> typing.List[gltf2_io.AnimationChannel]: channels = [] + + # First calculate range of animation for baking + # This is need if user set 'Force sampling' and in case we need to bake + bake_range_start = None + bake_range_end = None + groups = __get_channel_groups(blender_action, blender_object, export_settings) + for chans in groups: + ranges = [channel.range() for channel in chans] + if bake_range_start is None: + bake_range_start = min([channel.range()[0] for channel in chans]) + else: + bake_range_start = min(bake_range_start, min([channel.range()[0] for channel in chans])) + if bake_range_end is None: + bake_range_end = max([channel.range()[1] for channel in chans]) + else: + bake_range_end = max(bake_range_end, max([channel.range()[1] for channel in chans])) + + if blender_object.type == "ARMATURE" and export_settings['gltf_force_sampling'] is True: # We have to store sampled animation data for every deformation bones - # First calculate range of animation for baking - bake_range_start = None - bake_range_end = None - groups = __get_channel_groups(blender_action, blender_object, export_settings) - for chans in groups: - ranges = [channel.range() for channel in chans] - if bake_range_start is None: - bake_range_start = min([channel.range()[0] for channel in chans]) - else: - bake_range_start = min(bake_range_start, min([channel.range()[0] for channel in chans])) - if bake_range_end is None: - bake_range_end = max([channel.range()[1] for channel in chans]) - else: - bake_range_end = max(bake_range_end, max([channel.range()[1] for channel in chans])) - # Then bake all bones for bone in blender_object.data.bones: for p in ["location", "rotation_quaternion", "scale"]: @@ -65,7 +68,7 @@ def gather_animation_channels(blender_action: bpy.types.Action, else: for channel_group in __get_channel_groups(blender_action, blender_object, export_settings): channel_group_sorted = __get_channel_group_sorted(channel_group, blender_object) - channel = __gather_animation_channel(channel_group_sorted, blender_object, export_settings, None, None, None, None, blender_action.name) + channel = __gather_animation_channel(channel_group_sorted, blender_object, export_settings, None, None, bake_range_start, bake_range_end, blender_action.name) 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 20e7dbb6..8a4f011a 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 @@ -126,15 +126,12 @@ def get_bone_matrix(blender_object_if_armature: typing.Optional[bpy.types.Object data = {} - if bake_bone is None: - # Find the start and end of the whole action group - ranges = [channel.range() for channel in channels] + # Always using bake_range, because some bones may need to be baked, + # even if user didn't request it + + start_frame = bake_range_start + end_frame = bake_range_end - start_frame = min([channel.range()[0] for channel in channels]) - end_frame = max([channel.range()[1] for channel in channels]) - else: - start_frame = bake_range_start - end_frame = bake_range_end frame = start_frame while frame <= end_frame: |