Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2321 #2324

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/io_scene_gltf2/blender/com/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


# Custom properties, which are in most cases present and should not be imported/exported.
BLACK_LIST = ['cycles', 'cycles_visibility', 'cycles_curves', 'glTF2ExportSettings']
BLACK_LIST = ['cycles', 'cycles_visibility', 'cycles_curves', 'glTF2ExportSettings', 'gltf2_mesh_applied']


def generate_extras(blender_element):
Expand Down
4 changes: 2 additions & 2 deletions addons/io_scene_gltf2/blender/exp/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __gather_extras(blender_mesh: bpy.types.Mesh,
extras = generate_extras(blender_mesh) or {}

# Not for GN Instances
if export_settings['gltf_morph'] and blender_mesh.shape_keys and blender_mesh.users != 0:
if export_settings['gltf_morph'] and blender_mesh.shape_keys and ((blender_mesh.is_evaluated is True and blender_mesh.get('gltf2_mesh_applied') is not None) or blender_mesh.is_evaluated is False):
morph_max = len(blender_mesh.shape_keys.key_blocks) - 1
if morph_max > 0:
extras['targetNames'] = [k.name for k in get_sk_exported(blender_mesh.shape_keys.key_blocks)]
Expand Down Expand Up @@ -159,7 +159,7 @@ def __gather_weights(blender_mesh: bpy.types.Mesh,
return None

# Not for GN Instances
if blender_mesh.users == 0:
if blender_mesh.is_evaluated is True and blender_mesh.get('gltf2_mesh_applied') is None:
return None

morph_max = len(blender_mesh.shape_keys.key_blocks) - 1
Expand Down
2 changes: 2 additions & 0 deletions addons/io_scene_gltf2/blender/exp/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def __gather_mesh(vnode, blender_object, export_settings):
# But we need to remove some properties that are not needed
for prop in [p for p in blender_object.data.keys() if p in BLACK_LIST]:
del blender_mesh[prop]
# Store that this evaluated mesh has been created by the exporter, and is not a GN instance mesh
blender_mesh['gltf2_mesh_applied'] = True

if export_settings['gltf_skins']:
# restore Armature modifiers
Expand Down
3 changes: 1 addition & 2 deletions addons/io_scene_gltf2/blender/exp/primitive_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def prepare_data(self):
# We need to check if we are in a GN Instance, because for GN instances, it seems that shape keys are preserved,
# even if we apply modifiers
# (For classic objects, shape keys are not preserved if we apply modifiers)
# We can check it by checking if the mesh is used by a user
if self.blender_mesh.shape_keys and self.export_settings['gltf_morph'] and self.blender_mesh.users != 0:
if self.blender_mesh.shape_keys and self.export_settings['gltf_morph'] and ((self.blender_mesh.is_evaluated is True and self.blender_mesh.get('gltf2_mesh_applied') is not None) or self.blender_mesh.is_evaluated is False):
self.key_blocks = get_sk_exported(self.blender_mesh.shape_keys.key_blocks)

# Fetch vert positions and bone data (joint,weights)
Expand Down
Loading