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>2019-11-14 01:08:40 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-11-14 01:08:40 +0300
commit97b11857d320cda94564d3b151f871164b64a3d8 (patch)
tree34de4a03a547f206b0f00faf585831eb387eda50 /io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
parent9189c4595844752b8a534d132eed153a8ea991e4 (diff)
glTF exporter: avoid exporting rotation twice when both euler and quaternion are animated
Keeping only the current rotation mode of the object or bone
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py')
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py14
1 files changed, 13 insertions, 1 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 611cd74a..8f2f036e 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
@@ -15,7 +15,7 @@
import bpy
import typing
-from ..com.gltf2_blender_data_path import get_target_object_path, get_target_property_name
+from ..com.gltf2_blender_data_path import get_target_object_path, get_target_property_name, get_rotation_modes
from io_scene_gltf2.io.com import gltf2_io
from io_scene_gltf2.io.com import gltf2_io_debug
from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached
@@ -200,6 +200,7 @@ def __gather_target(channels: typing.Tuple[bpy.types.FCurve],
def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.types.Object, export_settings):
targets = {}
+ multiple_rotation_mode_detected = False
for fcurve in blender_action.fcurves:
# In some invalid files, channel hasn't any keyframes ... this channel need to be ignored
if len(fcurve.keyframe_points) == 0:
@@ -239,6 +240,13 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t
gltf2_io_debug.print_console("WARNING", "Animation target {} not found".format(object_path))
continue
+ # Detect that object or bone are not multiple keyed for euler and quaternion
+ # Keep only the current rotation mode used by object / bone
+ rotation, rotation_modes = get_rotation_modes(target_property)
+ if rotation and target.rotation_mode not in rotation_modes:
+ multiple_rotation_mode_detected = True
+ continue
+
# group channels by target object and affected property of the target
target_properties = targets.get(target, {})
channels = target_properties.get(target_property, [])
@@ -250,5 +258,9 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t
for p in targets.values():
groups += list(p.values())
+ if multiple_rotation_mode_detected is True:
+ gltf2_io_debug.print_console("WARNING", "Multiple rotation mode detected for {}".format(blender_object.name))
+
+
return map(tuple, groups)