From 45135ce6e451c3ef90ff66e035fb80eaa55c9291 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Wed, 20 Jul 2011 01:07:41 +0000 Subject: [PATCH] fix [#27964] 2.58 FBX Export can result in missing data and lost animation(s) --- io_scene_fbx/export_fbx.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py index 83c0fab28..553d9a7be 100644 --- a/io_scene_fbx/export_fbx.py +++ b/io_scene_fbx/export_fbx.py @@ -132,19 +132,6 @@ def mat4x4str(mat): return '%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f,%.15f' % tuple([f for v in mat for f in v]) -# XXX not used -# duplicated in OBJ exporter -def getVertsFromGroup(me, group_index): - ret = [] - - for i, v in enumerate(me.vertices): - for g in v.groups: - if g.group == group_index: - ret.append((i, g.weight)) - - return ret - - # ob must be OB_MESH def BPyMesh_meshWeight2List(ob, me): ''' Takes a mesh and return its group names and a list of lists, one list per vertex. @@ -164,16 +151,16 @@ def BPyMesh_meshWeight2List(ob, me): for i, v in enumerate(me.vertices): for g in v.groups: - vWeightList[i][g.group] = g.weight + # possible weights are out of range + index = g.group + if index < len_groupNames: + vWeightList[i][index] = g.weight return groupNames, vWeightList def meshNormalizedWeights(ob, me): - try: # account for old bad BPyMesh - groupNames, vWeightList = BPyMesh_meshWeight2List(ob, me) - except: - return [], [] + groupNames, vWeightList = BPyMesh_meshWeight2List(ob, me) if not groupNames: return [], [] @@ -1220,8 +1207,7 @@ def save_single(operator, scene, filepath="", else: # Normal weight painted mesh if my_bone.blenName in weights[0]: - # Before we used normalized wright list - #vgroup_data = me.getVertsFromGroup(bone.name, 1) + # Before we used normalized weight list group_index = weights[0].index(my_bone.blenName) vgroup_data = [(j, weight[group_index]) for j, weight in enumerate(weights[1]) if weight[group_index]] else: -- GitLab