Index: export_obj.py =================================================================== --- export_obj.py (revision 3491) +++ export_obj.py (working copy) @@ -245,7 +245,7 @@ def veckey2d(v): return round(v[0], 6), round(v[1], 6) - def findVertexGroupName(face, vWeightMap): + def findVertexGroupsForFace(face, vWeightMap): """ Searches the vertexDict to see what groups is assigned to a given face. We use a frequency system in order to sort out the name because a given vetex can @@ -254,17 +254,15 @@ frequency in descend order. The top element is the one shared by the highest number of vertices is the face's group """ - weightDict = {} + vert_groups = {} # dict of vert_index: set(of group names) for vert_index in face.vertices: vWeights = vWeightMap[vert_index] + vert_groups[vert_index] = set() for vGroupName, weight in vWeights: - weightDict[vGroupName] = weightDict.get(vGroupName, 0.0) + weight + if weight > 0: + vert_groups[vert_index].add(vGroupName) + return sorted(list(set.intersection(*[ vert_groups[v] for v in vert_groups ]))) - if weightDict: - return max((weight, vGroupName) for vGroupName, weight in weightDict.items())[1] - else: - return '(null)' - print('OBJ Export path: %r' % filepath) time1 = time.time() @@ -454,7 +452,7 @@ # Retrieve the list of vertex groups vertGroupNames = ob.vertex_groups.keys() - currentVGroup = '' + currentVGroup = [] # Create a dictionary keyed by face id and listing, for each vertex, the vertex groups it belongs to vgroupsMap = [[] for _i in range(len(me_verts))] for v_idx, v_ls in enumerate(vgroupsMap): @@ -477,11 +475,11 @@ # Write the vertex group if EXPORT_POLYGROUPS: if ob.vertex_groups: - # find what vertext group the face belongs to - vgroup_of_face = findVertexGroupName(f, vgroupsMap) + # find what vertext groups the face belongs to + vgroup_of_face = findVertexGroupsForFace(f, vgroupsMap) if vgroup_of_face != currentVGroup: currentVGroup = vgroup_of_face - fw('g %s\n' % vgroup_of_face) + fw('g %s\n' % " ".join(vgroup_of_face)) # CHECK FOR CONTEXT SWITCH if key == contextMat: