diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-07-25 08:02:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-07-25 08:02:19 +0400 |
commit | 7690c2a38db02317d7ad289a16b8c55b5ec0ed3a (patch) | |
tree | 9cc5733091a9abba29a356c4c23d5556198f5381 /io_export_directx_x.py | |
parent | 1e6477aef52efa5e803df4e3e694ff874b5fbaac (diff) |
fix for direct-x exporting vertex groups which had indicies out of the objects defgroup range
Tested using the file 'FBX_Export_Glitched.blend' from report: [#27964]
Diffstat (limited to 'io_export_directx_x.py')
-rw-r--r-- | io_export_directx_x.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/io_export_directx_x.py b/io_export_directx_x.py index eaa4cbe2..056111b2 100644 --- a/io_export_directx_x.py +++ b/io_export_directx_x.py @@ -568,10 +568,14 @@ def WriteMeshSkinWeights(Config, Object, Mesh): UsedBones = set() #Maps bones to a list of vertices they affect VertexGroups = {} - + ObjectVertexGroups = {i: Group.name for (i, Group) in enumerate(Object.vertex_groups)} for Vertex in Mesh.vertices: #BoneInfluences contains the bones of the armature that affect the current vertex - BoneInfluences = [PoseBones[Object.vertex_groups[Group.group].name] for Group in Vertex.groups if Object.vertex_groups[Group.group].name in PoseBones] + BoneInfluences = [PoseBone for Group in Vertex.groups + for PoseBone in (PoseBones.get(ObjectVertexGroups.get(Group.group, "")), ) + if PoseBone is not None + ] + if len(BoneInfluences) > MaxInfluences: MaxInfluences = len(BoneInfluences) for Bone in BoneInfluences: @@ -611,10 +615,12 @@ def WriteMeshSkinWeights(Config, Object, Mesh): if Vertex in VertexIndexes: Config.File.write("{}{}".format(" " * Config.Whitespace, Index)) - GroupIndexes = {Object.vertex_groups[Group.group].name: Index for Index, Group in enumerate(Mesh.vertices[Vertex].groups) if Object.vertex_groups[Group.group].name in PoseBones} + GroupIndexes = {ObjectVertexGroups.get(Group.group): Index + for Index, Group in enumerate(Mesh.vertices[Vertex].groups) + if ObjectVertexGroups.get(Group.group, "") in PoseBones} WeightTotal = 0.0 - for Weight in [Group.weight for Group in Mesh.vertices[Vertex].groups if Object.vertex_groups[Group.group].name in PoseBones]: + for Weight in (Group.weight for Group in Mesh.vertices[Vertex].groups if ObjectVertexGroups.get(Group.group, "") in PoseBones): WeightTotal += Weight if WeightTotal: |