Fix T47457: FBX export: Force full keying in case Simplify factor is set to 0.0
Note that it will export all sampled values - even for actually non-animated channels, not really possible to avoid that without a hell lot more of code, and this rea is convoluted enough right now.
This commit is contained in:
parent
da3be8b8f3
commit
219e882b31
Notes:
blender-bot
2023-02-14 08:12:29 +01:00
Referenced by issue blender/blender#47457, FBX EXPORT: no keyframes are appearing in the exported fbx when objects stays put, even though i have manually inserted keyframes
|
@ -1856,6 +1856,7 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
|
|||
Generate animation data (a single AnimStack) from objects, for a given frame range.
|
||||
"""
|
||||
bake_step = scene_data.settings.bake_anim_step
|
||||
simplify_fac = scene_data.settings.bake_anim_simplify_factor
|
||||
scene = scene_data.scene
|
||||
force_keying = scene_data.settings.bake_anim_use_all_bones
|
||||
force_sek = scene_data.settings.bake_anim_force_startend_keying
|
||||
|
@ -1883,18 +1884,21 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
|
|||
ACNW = AnimationCurveNodeWrapper
|
||||
loc, rot, scale, _m, _mr = ob_obj.fbx_object_tx(scene_data)
|
||||
rot_deg = tuple(convert_rad_to_deg_iter(rot))
|
||||
animdata_ob[ob_obj] = (ACNW(ob_obj.key, 'LCL_TRANSLATION', ob_obj.is_bone and force_keying, force_sek, loc),
|
||||
ACNW(ob_obj.key, 'LCL_ROTATION', ob_obj.is_bone and force_keying, force_sek, rot_deg),
|
||||
ACNW(ob_obj.key, 'LCL_SCALING', ob_obj.is_bone and force_keying, force_sek, scale))
|
||||
force_key = (simplify_fac == 0.0) or (ob_obj.is_bone and force_keying)
|
||||
print(force_key, simplify_fac)
|
||||
animdata_ob[ob_obj] = (ACNW(ob_obj.key, 'LCL_TRANSLATION', force_key, force_sek, loc),
|
||||
ACNW(ob_obj.key, 'LCL_ROTATION', force_key, force_sek, rot_deg),
|
||||
ACNW(ob_obj.key, 'LCL_SCALING', force_key, force_sek, scale))
|
||||
p_rots[ob_obj] = rot
|
||||
|
||||
animdata_shapes = OrderedDict()
|
||||
force_key = (simplify_fac == 0.0)
|
||||
for me, (me_key, _shapes_key, shapes) in scene_data.data_deformers_shape.items():
|
||||
# Ignore absolute shape keys for now!
|
||||
if not me.shape_keys.use_relative:
|
||||
continue
|
||||
for shape, (channel_key, geom_key, _shape_verts_co, _shape_verts_idx) in shapes.items():
|
||||
acnode = AnimationCurveNodeWrapper(channel_key, 'SHAPE_KEY', False, force_sek, (0.0,))
|
||||
acnode = AnimationCurveNodeWrapper(channel_key, 'SHAPE_KEY', force_key, force_sek, (0.0,))
|
||||
# Sooooo happy to have to twist again like a mad snake... Yes, we need to write those curves twice. :/
|
||||
acnode.add_group(me_key, shape.name, shape.name, (shape.name,))
|
||||
animdata_shapes[channel_key] = (acnode, me, shape)
|
||||
|
@ -1923,7 +1927,6 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
|
|||
scene.frame_set(back_currframe, 0.0)
|
||||
|
||||
animations = OrderedDict()
|
||||
simplify_fac = scene_data.settings.bake_anim_simplify_factor
|
||||
|
||||
# And now, produce final data (usable by FBX export code)
|
||||
# Objects-like loc/rot/scale...
|
||||
|
|
|
@ -775,6 +775,9 @@ class AnimationCurveNodeWrapper:
|
|||
if not self._keys:
|
||||
return
|
||||
|
||||
if fac == 0.0:
|
||||
return
|
||||
|
||||
# So that, with default factor and step values (1), we get:
|
||||
min_reldiff_fac = fac * 1.0e-3 # min relative value evolution: 0.1% of current 'order of magnitude'.
|
||||
min_absdiff_fac = 0.1 # A tenth of reldiff...
|
||||
|
|
Loading…
Reference in New Issue