From 714e42ffcf2d7d2b90219b91184c1331121c1f0d Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Sun, 26 Nov 2023 18:14:04 +0000 Subject: [PATCH] FBX IO: Fix import of shape key animations without any keyframes Attempting to import a shape key animation without any animation curves or with only empty animation curves would result in attempting to get the min/max of an empty list or array. The animation curve values array is now checked for being non-empty before attempting to get its minimum and maximum values. The list of animated shape key deform values is now only created when there are values to add to it, thus ensuring it is never empty. --- io_scene_fbx/__init__.py | 2 +- io_scene_fbx/import_fbx.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 1349ea38b..471c9c229 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -5,7 +5,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem", - "version": (5, 8, 12), + "version": (5, 8, 13), "blender": (4, 0, 0), "location": "File > Import-Export", "description": "FBX IO meshes, UVs, vertex colors, materials, textures, cameras, lamps and actions", diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index cbf48d020..a181c5c83 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -950,7 +950,6 @@ def blen_read_animations_action_item(action, item, cnodes, fps, anim_offset, glo blen_store_keyframes(fbx_key_times, blen_curve, values, anim_offset, fps) elif isinstance(item, ShapeKey): - deform_values = shape_key_deforms.setdefault(item, []) for fbxprop, channel_to_curve in fbx_curves.items(): assert(fbxprop == b'DeformPercent') for channel, curve in channel_to_curve.items(): @@ -964,8 +963,10 @@ def blen_read_animations_action_item(action, item, cnodes, fps, anim_offset, glo # Store the minimum and maximum shape key values, so that the shape key's slider range can be expanded # if necessary after reading all animations. - deform_values.append(values.min()) - deform_values.append(values.max()) + if values.size: + deform_values = shape_key_deforms.setdefault(item, []) + deform_values.append(values.min()) + deform_values.append(values.max()) elif isinstance(item, Camera): for fbxprop, channel_to_curve in fbx_curves.items(): -- 2.30.2