From 08d13c024f60b03e7f525082db9fb12fbc576502 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 13 Jul 2022 12:10:03 +0200 Subject: glTF exporter: Fixed bezier control points to cubic spline tangents conversion Fix when animation are not baked --- ...2_blender_gather_animation_sampler_keyframes.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py') 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 e1ed19ea..ba331b74 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 @@ -398,11 +398,17 @@ def gather_keyframes(blender_obj_uuid: str, key.set_first_tangent() else: # otherwise construct an in tangent coordinate from the keyframes control points. We intermediately - # use a point at t-1 to define the tangent. This allows the tangent control point to be transformed - # normally + # use a point at t+1 to define the tangent. This allows the tangent control point to be transformed + # normally, but only works for locally linear transformation. The more non-linear a transform, the + # more imprecise this method is. + # We could use any other (v1, t1) for which (v1 - v0) / (t1 - t0) equals the tangent. By using t+1 + # for both in and out tangents, we guarantee that (even if there are errors or numerical imprecisions) + # symmetrical control points translate to symmetrical tangents. + # Note: I am not sure that linearity is never broken with quaternions and their normalization. + # Especially at sign swap it might occure that the value gets negated but the control point not. + # I have however not once encountered an issue with this. key.in_tangent = [ - c.keyframe_points[i].co[1] + ((c.keyframe_points[i].co[1] - c.keyframe_points[i].handle_left[1] - ) / (frame - frames[i - 1])) + c.keyframe_points[i].co[1] + (c.keyframe_points[i].handle_left[1] - c.keyframe_points[i].co[1]) / (c.keyframe_points[i].handle_left[0] - c.keyframe_points[i].co[0]) for c in channels if c is not None ] # Construct the out tangent @@ -410,12 +416,10 @@ def gather_keyframes(blender_obj_uuid: str, # end out-tangent should become all zero key.set_last_tangent() else: - # otherwise construct an in tangent coordinate from the keyframes control points. We intermediately - # use a point at t+1 to define the tangent. This allows the tangent control point to be transformed - # normally + # otherwise construct an in tangent coordinate from the keyframes control points. + # This happens the same way how in tangents are handled above. key.out_tangent = [ - c.keyframe_points[i].co[1] + ((c.keyframe_points[i].handle_right[1] - c.keyframe_points[i].co[1] - ) / (frames[i + 1] - frame)) + c.keyframe_points[i].co[1] + (c.keyframe_points[i].handle_right[1] - c.keyframe_points[i].co[1]) / (c.keyframe_points[i].handle_right[0] - c.keyframe_points[i].co[0]) for c in channels if c is not None ] -- cgit v1.2.3 From 99576a8478e1ea90bb112e1fd2ff6aa851c05bdc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 9 Aug 2022 19:23:13 +0200 Subject: Cleanup: fix typos in blender addons Contributed by luzpaz. Differential Revision: https://developer.blender.org/D15646 --- .../blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_sampler_keyframes.py') 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 ba331b74..53d78945 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 @@ -405,7 +405,7 @@ def gather_keyframes(blender_obj_uuid: str, # for both in and out tangents, we guarantee that (even if there are errors or numerical imprecisions) # symmetrical control points translate to symmetrical tangents. # Note: I am not sure that linearity is never broken with quaternions and their normalization. - # Especially at sign swap it might occure that the value gets negated but the control point not. + # Especially at sign swap it might occur that the value gets negated but the control point not. # I have however not once encountered an issue with this. key.in_tangent = [ c.keyframe_points[i].co[1] + (c.keyframe_points[i].handle_left[1] - c.keyframe_points[i].co[1]) / (c.keyframe_points[i].handle_left[0] - c.keyframe_points[i].co[0]) -- cgit v1.2.3