Skip to content

Commit

Permalink
Fixed issue niftools#496 by allowing for multiple triangles with the …
Browse files Browse the repository at this point in the history
…same vertices used.
  • Loading branch information
Candoran2 committed Jan 5, 2022
1 parent 814fd8c commit a68aee7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions io_scene_niftools/modules/nif_import/geometry/vertex/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ def import_skin(ni_block, b_obj):
v_group.add([vert], w, 'REPLACE')

# import body parts as face maps
# get faces (triangles) as map of tuples to index
tri_map = {frozenset(polygon.vertices): polygon.index for polygon in b_obj.data.polygons}
# get faces (triangles) as map of unordered vertices to list of indices
tri_map = {}
for polygon in b_obj.data.polygons:
vertices = frozenset(polygon.vertices)
if vertices in tri_map:
tri_map[vertices].append(polygon.index)
else:
tri_map[vertices] = [polygon.index]
if isinstance(skininst, NifFormat.BSDismemberSkinInstance):
skinpart = ni_block.get_skin_partition()
for bodypart, skinpartblock in zip(skininst.partitions, skinpart.skin_partition_blocks):
Expand All @@ -178,4 +184,5 @@ def import_skin(ni_block, b_obj):
f_group = b_obj.face_maps.new(name=group_name)

# add the triangles to the face map
f_group.add([tri_map[frozenset(vertices)] for vertices in skinpartblock.get_mapped_triangles()])
for vertices in skinpartblock.get_mapped_triangles():
f_group.add(tri_map[frozenset(vertices)])

0 comments on commit a68aee7

Please sign in to comment.