Skip to content
Snippets Groups Projects
Commit 422c47c5 authored by Julien Duroure's avatar Julien Duroure
Browse files

glTF exporter: use split normals when exporting morph targets

Thanks scurest!
parent bd8e1f3e
Branches
Tags
No related merge requests found
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
bl_info = { bl_info = {
'name': 'glTF 2.0 format', 'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 3, 36), "version": (1, 3, 37),
'blender': (2, 90, 0), 'blender': (2, 90, 0),
'location': 'File > Import-Export', 'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0', 'description': 'Import-Export as glTF 2.0',
......
...@@ -34,10 +34,9 @@ class Prim: ...@@ -34,10 +34,9 @@ class Prim:
self.indices = [] self.indices = []
class ShapeKey: class ShapeKey:
def __init__(self, shape_key, vertex_normals, polygon_normals): def __init__(self, shape_key, split_normals):
self.shape_key = shape_key self.shape_key = shape_key
self.vertex_normals = vertex_normals self.split_normals = split_normals
self.polygon_normals = polygon_normals
# #
...@@ -210,16 +209,14 @@ def extract_primitives(glTF, blender_mesh, library, blender_object, blender_vert ...@@ -210,16 +209,14 @@ def extract_primitives(glTF, blender_mesh, library, blender_object, blender_vert
for blender_shape_key in blender_mesh.shape_keys.key_blocks: for blender_shape_key in blender_mesh.shape_keys.key_blocks:
if blender_shape_key == blender_shape_key.relative_key or blender_shape_key.mute: if blender_shape_key == blender_shape_key.relative_key or blender_shape_key.mute:
continue continue
split_normals = None
if use_morph_normals: if use_morph_normals:
vertex_normals = blender_shape_key.normals_vertex_get() split_normals = blender_shape_key.normals_split_get()
polygon_normals = blender_shape_key.normals_polygon_get()
else:
vertex_normals = None
polygon_normals = None
shape_keys.append(ShapeKey( shape_keys.append(ShapeKey(
blender_shape_key, blender_shape_key,
vertex_normals, split_normals,
polygon_normals,
)) ))
...@@ -330,20 +327,8 @@ def extract_primitives(glTF, blender_mesh, library, blender_object, blender_vert ...@@ -330,20 +327,8 @@ def extract_primitives(glTF, blender_mesh, library, blender_object, blender_vert
vert += ((v_morph[0], v_morph[1], v_morph[2]),) vert += ((v_morph[0], v_morph[1], v_morph[2]),)
if use_morph_normals: if use_morph_normals:
if blender_polygon.use_smooth: normals = shape_key.split_normals
normals = shape_key.vertex_normals n_morph = Vector(normals[loop_index * 3 : loop_index * 3 + 3])
n_morph = Vector((
normals[vertex_index * 3 + 0],
normals[vertex_index * 3 + 1],
normals[vertex_index * 3 + 2],
))
else:
normals = shape_key.polygon_normals
n_morph = Vector((
normals[blender_polygon.index * 3 + 0],
normals[blender_polygon.index * 3 + 1],
normals[blender_polygon.index * 3 + 2],
))
n_morph = n_morph - n # store delta n_morph = n_morph - n # store delta
vert += ((n_morph[0], n_morph[1], n_morph[2]),) vert += ((n_morph[0], n_morph[1], n_morph[2]),)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment