From d0425df1ef2f868bffbe09b551c2af5213b5c67c Mon Sep 17 00:00:00 2001
From: Bastien Montagne <montagne29@wanadoo.fr>
Date: Wed, 30 Jul 2014 15:07:04 +0200
Subject: [PATCH] FBX Import: Fix cornercase where some files only have one
 weight in case it's the same for all vertices...

Issue found by jrestemeier (Jens Restemeier), thanks!
---
 io_scene_fbx/import_fbx.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 6caffbf94..71641c1f4 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1153,7 +1153,12 @@ def blen_read_shape(fbx_tmpl, fbx_sdata, fbx_bcdata, meshes, scene, global_matri
     weight = elem_prop_first(elem_find_first(fbx_bcdata, b'DeformPercent'), default=100.0) / 100.0
     vgweights = tuple(vgw / 100.0 for vgw in elem_prop_first(elem_find_first(fbx_bcdata, b'FullWeights'), default=()))
 
-    assert(len(vgweights) == len(indices) == len(dvcos))
+    # Special case, in case all weights are the same, FullWeight can have only one element - *sigh!*
+    nbr_indices = len(indices)
+    if len(vgweights) == 1 and nbr_indices > 1:
+        vgweights = (vgweights[0],) * nbr_indices
+
+    assert(len(vgweights) == nbr_indices == len(dvcos))
     create_vg = bool(set(vgweights) - {1.0})
 
     keyblocks = []
-- 
GitLab