Skip to content

Commit

Permalink
Better vertex map calculation when calculating skin partitions (impro…
Browse files Browse the repository at this point in the history
…ves in-game fps).
  • Loading branch information
amorilia committed Sep 18, 2010
1 parent 1d87806 commit 972e967
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Release 2.1.6 (in development)
based box collisions to primitive box collisions, which are much
faster in-game (contributed by PacificMorrowind).

* Optimizer spell now stitches strips when calculating skin partitions
(improves in-game fps).

* Better vertex map calculation when calculating skin partitions
(improves in-game fps).

Release 2.1.5 (18 July 2010)
============================

Expand Down
41 changes: 24 additions & 17 deletions pyffi/formats/nif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6553,26 +6553,33 @@ def update_skin_partition(self,
# get sorted list of bones
bones = sorted(list(part[0]))
triangles = part[1]
# get sorted list of vertices
vertices = set()
for tri in triangles:
vertices |= set(tri)
vertices = sorted(list(vertices))
# remap the vertices
parttriangles = []
for tri in triangles:
parttriangles.append([vertices.index(t) for t in tri])
# stripify if needed and get sorted list of vertices
vertices = []
if stripify:
# stripify the triangles
# also update triangle list
logger.info("Stripifying partition %i" % parts.index(part))
strips = pyffi.utils.tristrip.stripify(
parttriangles, stitchstrips=stitchstrips)
triangles, stitchstrips=stitchstrips)
numtriangles = 0
# calculate number of triangles and get sorted
# list of vertices
# for optimal performance, vertices must be sorted
# by strip
for strip in strips:
numtriangles += len(strip) - 2
for t in strip:
if t not in vertices:
vertices.append(t)
else:
numtriangles = len(parttriangles)

numtriangles = len(triangles)
# get sorted list of vertices
# for optimal performance, vertices must be sorted
# by triangle
for tri in triangles:
for t in tri:
if t not in vertices:
vertices.append(t)
# set all the data
skinpartblock.num_vertices = len(vertices)
skinpartblock.num_triangles = numtriangles
Expand Down Expand Up @@ -6619,18 +6626,18 @@ def update_skin_partition(self,
skinpartblock.strips.update_size()
for i, strip in enumerate(strips):
for j, v in enumerate(strip):
skinpartblock.strips[i][j] = v
skinpartblock.strips[i][j] = vertices.index(v)
else:
skinpartblock.has_faces = True
# clear strip lengths array
skinpartblock.strip_lengths.update_size()
# clear strips array
skinpartblock.strips.update_size()
skinpartblock.triangles.update_size()
for i, (v_1,v_2,v_3) in enumerate(parttriangles):
skinpartblock.triangles[i].v_1 = v_1
skinpartblock.triangles[i].v_2 = v_2
skinpartblock.triangles[i].v_3 = v_3
for i, (v_1,v_2,v_3) in enumerate(triangles):
skinpartblock.triangles[i].v_1 = vertices.index(v_1)
skinpartblock.triangles[i].v_2 = vertices.index(v_2)
skinpartblock.triangles[i].v_3 = vertices.index(v_3)
skinpartblock.has_bone_indices = True
skinpartblock.bone_indices.update_size()
for i, v in enumerate(vertices):
Expand Down

0 comments on commit 972e967

Please sign in to comment.