diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-08-23 08:26:40 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-08-23 08:26:40 +0300 |
commit | 3c3c2243dbbd8a35d1472db445a7dbc6c561ab38 (patch) | |
tree | cf76bbd7215e4f690e0f256799b6c022d1045a27 /io_scene_gltf2 | |
parent | 4a66c4e0b80f5483c8434554c615a56fef71d627 (diff) |
glTF exporter: fix normal export when normals are modified by modifier(s)
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-x | io_scene_gltf2/__init__.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_extract.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py | 7 |
3 files changed, 8 insertions, 3 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 1ecf2c7e..b38eaf82 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (0, 9, 47), + "version": (0, 9, 48), 'blender': (2, 80, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py index 69c3f1d6..7adda5a4 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py @@ -588,7 +588,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp vertex = blender_mesh.vertices[vertex_index] v = convert_swizzle_location(vertex.co, export_settings) - if blender_polygon.use_smooth: + if blender_polygon.use_smooth or blender_mesh.use_auto_smooth: if blender_mesh.has_custom_normals: n = convert_swizzle_location(blender_mesh.loops[loop_index].normal, export_settings) else: diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py index c13af707..c0fa11ff 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py @@ -224,6 +224,11 @@ def __gather_mesh(blender_object, export_settings): if blender_object.type != "MESH": return None + modifier_normal_types = [ + "NORMAL_EDIT", + "WEIGHTED_NORMAL" + ] + # If not using vertex group, they are irrelevant for caching --> ensure that they do not trigger a cache miss vertex_groups = blender_object.vertex_groups modifiers = blender_object.modifiers @@ -239,7 +244,7 @@ def __gather_mesh(blender_object, export_settings): edge_split = blender_object.modifiers.new('Temporary_Auto_Smooth', 'EDGE_SPLIT') edge_split.split_angle = blender_object.data.auto_smooth_angle edge_split.use_edge_angle = not blender_object.data.has_custom_normals - blender_object.data.use_auto_smooth = False + blender_object.data.use_auto_smooth = any([m in modifier_normal_types for m in [mod.type for mod in blender_object.modifiers]]) bpy.context.view_layer.update() armature_modifiers = {} |