Skip to content

Commit

Permalink
Merge pull request #2420 from KhronosGroup/fix_2919
Browse files Browse the repository at this point in the history
Fix #2419 - Fix crash when animation on not used material
  • Loading branch information
julienduroure authored Nov 28, 2024
2 parents 637d1eb + aaa457e commit 6c9833c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addons/io_scene_gltf2/blender/imp/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def anim(gltf, anim_idx):
BlenderPointerAnim.anim(gltf, anim_idx, light, light_idx, 'LIGHT')

for mat_idx, mat in enumerate(gltf.data.materials if gltf.data.materials else []):
if len(mat.blender_material) == 0:
# The animated material is not used in Blender, so do not animate it
continue
if len(mat.animations) != 0:
BlenderPointerAnim.anim(gltf, anim_idx, mat, mat_idx, 'MATERIAL')
if mat.normal_texture is not None and len(mat.normal_texture.animations) != 0:
Expand Down Expand Up @@ -167,5 +170,8 @@ def restore_animation(gltf, animation_name):
restore_animation_on_object(light['blender_object_data'], animation_name)

for mat in gltf.data.materials if gltf.data.materials else []:
if len(mat.blender_material) == 0:
# The animated material is not used in Blender, so do not animate it
continue
restore_animation_on_object(mat.blender_nodetree, animation_name)
restore_animation_on_object(mat.blender_mat, animation_name)

0 comments on commit 6c9833c

Please sign in to comment.