Skip to content

Commit

Permalink
Fixed bug in optimize spell, when has_vertex_colors was False but ver…
Browse files Browse the repository at this point in the history
…tex color array was present (reported by Baphometal, debugged by PacificMorrowind).
  • Loading branch information
amorilia committed Jan 15, 2010
1 parent 3071aee commit 473aafb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Release 2.1.2 (in development)

* Fallout 3 skin partition flag bugfix (reported by Ghostwalker71).

* Fixed bug in optimize spell, when has_vertex_colors was False but vertex
color array was present (reported by Baphometal, debugged by
PacificMorrowind).

Release 2.1.1 (Jan 11, 2010)
============================

Expand Down
37 changes: 19 additions & 18 deletions pyffi/spells/nif/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,32 +266,33 @@ def branchentry(self, branch):
data.num_vertices = new_numvertices
if data.has_vertices:
data.vertices.update_size()
for i, v in enumerate(data.vertices):
old_i = v_map_inverse[i]
v.x = oldverts[old_i][0]
v.y = oldverts[old_i][1]
v.z = oldverts[old_i][2]
if data.has_normals:
data.normals.update_size()
for i, n in enumerate(data.normals):
old_i = v_map_inverse[i]
n.x = oldnorms[old_i][0]
n.y = oldnorms[old_i][1]
n.z = oldnorms[old_i][2]
# XXX todo: if ...has_uv_sets...:
data.uv_sets.update_size()
if data.has_vertex_colors:
data.vertex_colors.update_size()
for i, v in enumerate(data.vertices):
old_i = v_map_inverse[i]
v.x = oldverts[old_i][0]
v.y = oldverts[old_i][1]
v.z = oldverts[old_i][2]
for i, n in enumerate(data.normals):
old_i = v_map_inverse[i]
n.x = oldnorms[old_i][0]
n.y = oldnorms[old_i][1]
n.z = oldnorms[old_i][2]
for j, uvset in enumerate(data.uv_sets):
for i, uv in enumerate(uvset):
old_i = v_map_inverse[i]
uv.u = olduvs[j][old_i][0]
uv.v = olduvs[j][old_i][1]
for i, c in enumerate(data.vertex_colors):
old_i = v_map_inverse[i]
c.r = oldvcols[old_i][0]
c.g = oldvcols[old_i][1]
c.b = oldvcols[old_i][2]
c.a = oldvcols[old_i][3]
if data.has_vertex_colors:
data.vertex_colors.update_size()
for i, c in enumerate(data.vertex_colors):
old_i = v_map_inverse[i]
c.r = oldvcols[old_i][0]
c.g = oldvcols[old_i][1]
c.b = oldvcols[old_i][2]
c.a = oldvcols[old_i][3]
del oldverts
del oldnorms
del olduvs
Expand Down

0 comments on commit 473aafb

Please sign in to comment.