Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2018-12-06 00:09:48 +0300
committerJulien Duroure <julien.duroure@gmail.com>2018-12-06 00:09:48 +0300
commitc850bf4fc1e167cecff3ca5711f7ef45241747f5 (patch)
tree5339cd73419a910edac834430d49cf912e073976 /io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
parent10e85f21856c9d7a4b6976277a7c135770155b4e (diff)
glTF importer: Fix custom normals import
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_mesh.py')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_mesh.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index aafb9498..f0d0af2a 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -55,8 +55,13 @@ class BlenderMesh():
"""Set all data after mesh creation."""
# Normals
offset = 0
+ custom_normals = [[0.0, 0.0, 0.0]] * len(mesh.vertices)
+
+ if gltf.import_settings['import_shading'] == "NORMALS":
+ mesh.create_normals_split()
+
for prim in pymesh.primitives:
- offset = BlenderPrimitive.set_normals(gltf, prim, mesh, offset)
+ offset = BlenderPrimitive.set_normals(gltf, prim, mesh, offset, custom_normals)
mesh.update()
@@ -67,6 +72,11 @@ class BlenderMesh():
mesh.update()
+ # Normals, now that every update is done
+ if gltf.import_settings['import_shading'] == "NORMALS":
+ mesh.normals_split_custom_set_from_vertices(custom_normals)
+ mesh.use_auto_smooth = True
+
# Object and UV are now created, we can set UVMap into material
for prim in pymesh.primitives:
BlenderPrimitive.set_UV_in_mat(gltf, prim, obj)