Mwni / blender-animation-retargeting

Add-on for Blender that allows the transfer of animations and poses from one armature to another
482 stars 47 forks source link

Bake issue on Blender 3.1.0 #19

Closed Theo-Cheynel closed 2 years ago

Theo-Cheynel commented 2 years ago

When I try on the 3.1.0, I get the following error :

Error: Python: Traceback (most recent call last):
  File "/home/theo/.config/blender/3.1/scripts/addons/blender-animation-retargeting/baking.py", line 75, in execute
    transfer_anim(context)
  File "/home/theo/.config/blender/3.1/scripts/addons/blender-animation-retargeting/baking.py", line 52, in transfer_anim
    bpy.ops.nla.bake(
  File "/snap/blender/1925/3.1/scripts/modules/bpy/ops.py", line 132, in __call__
    ret = _op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties:  NLA_OT_bake.frame_start expected an int type, not float

However, on 3.0.0 it works fine...

Mwni commented 2 years ago

Perhaps a simple type cast would suffice:

https://github.com/Mwni/blender-animation-retargeting/blob/f057ab26d78de1ae6363abfe71c9f3dad9445f68/baking.py#L52

bpy.ops.nla.bake(
    frame_start=int(min(keyframes)),
    frame_end=int(max(keyframes)),
    step=s.bake_step,
    visual_keying=True,
    use_current_action=True,
    bake_types={'POSE'},
    only_selected=False
)
Andrej730 commented 2 years ago

Met the same issue at 3.1 - keyframe id is float and we need to cast it to int to make it work. Not sure if it's actually float like "1.1" or just "1.0" and if it's important.

Mwni commented 2 years ago

I did not have time to dig into this, but it appears there was some code change from blender 3.0 to 3.1 that made this bake method stricter. I pushed a small fix to this repo: https://github.com/Mwni/blender-animation-retargeting/commit/042d6332de8a1d1fc10e36cc2fe5c654375cbe3c

GlitchyPSIX commented 2 years ago

You missed one!