[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2177] trunk/py/scripts/addons/ io_export_directx_x.py: fix for direct-x exporting vertex groups which had indicies out of the objects defgroup range
Campbell Barton
ideasman42 at gmail.com
Mon Jul 25 06:02:20 CEST 2011
Revision: 2177
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2177
Author: campbellbarton
Date: 2011-07-25 04:02:19 +0000 (Mon, 25 Jul 2011)
Log Message:
-----------
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]
Modified Paths:
--------------
trunk/py/scripts/addons/io_export_directx_x.py
Modified: trunk/py/scripts/addons/io_export_directx_x.py
===================================================================
--- trunk/py/scripts/addons/io_export_directx_x.py 2011-07-25 03:12:07 UTC (rev 2176)
+++ trunk/py/scripts/addons/io_export_directx_x.py 2011-07-25 04:02:19 UTC (rev 2177)
@@ -568,10 +568,14 @@
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 @@
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:
More information about the Bf-extensions-cvs
mailing list