Skip to content

Commit

Permalink
use simpler approach for getting loop normals while still using tessf…
Browse files Browse the repository at this point in the history
…aces
  • Loading branch information
lsalzman committed Aug 4, 2015
1 parent 1880cad commit f91c459
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions blender-2.74/iqm_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,31 +814,31 @@ def collectMeshes(context, bones, scale, matfun, useskel = True, usecol = False,
for obj in objs:
if obj.type == 'MESH':
data = obj.to_mesh(context.scene, False, 'PREVIEW')
if not data.polygons:
if not data.tessfaces:
continue
data.calc_normals_split();
data.calc_normals_split()
coordmatrix = obj.matrix_world
normalmatrix = coordmatrix.inverted().transposed()
if scale != 1.0:
coordmatrix = mathutils.Matrix.Scale(scale, 4) * coordmatrix
materials = {}
groups = obj.vertex_groups
uvfaces = data.uv_textures.active and data.uv_textures.active.data
uvfaces = data.tessface_uv_textures.active and data.tessface_uv_textures.active.data
colors = None
alpha = None
if usecol:
if data.vertex_colors.active:
if data.vertex_colors.active.name.startswith('alpha'):
alpha = data.vertex_colors.active.data
if data.tessface_vertex_colors.active:
if data.tessface_vertex_colors.active.name.startswith('alpha'):
alpha = data.tessface_vertex_colors.active.data
else:
colors = data.vertex_colors.active.data
for layer in data.vertex_colors:
colors = data.tessface_vertex_colors.active.data
for layer in data.tessface_vertex_colors:
if layer.name.startswith('alpha'):
if not alpha:
alpha = layer.data
elif not colors:
colors = layer.data
for face in data.polygons:
for face in data.tessfaces:
if len(face.vertices) < 3:
continue

Expand All @@ -861,14 +861,14 @@ def collectMeshes(context, bones, scale, matfun, useskel = True, usecol = False,
verts = mesh.verts
vertmap = mesh.vertmap
faceverts = []
for i, loop in enumerate([ data.loops[l] for l in face.loop_indices ]):
v = data.vertices[loop.vertex_index]
for i, vindex in enumerate(face.vertices):
v = data.vertices[vindex]
vertco = coordmatrix * v.co

if not face.use_smooth:
vertno = mathutils.Vector(face.normal)
else:
vertno = mathutils.Vector(loop.normal)
vertno = mathutils.Vector(data.loops[vindex].normal)
vertno = normalmatrix * vertno
vertno.normalize()

Expand Down

0 comments on commit f91c459

Please sign in to comment.