Fix #104714: Missing shape keys in FBX export when original mesh data cannot be used #104890
@ -2548,19 +2548,22 @@ def fbx_data_from_scene(scene, depsgraph, settings):
|
||||
# There are 4 different cases for what we need to do with the original data of each Object:
|
||||
# 1) The original data can be used without changes.
|
||||
# 2) A copy of the original data needs to be made.
|
||||
# - If a mesh needs to be modified upon export, e.g. it needs triangulating.
|
||||
# - If a mesh has Object-linked materials. This is to do with how materials are currently mapped to FBX.
|
||||
# 3) A non-mesh needs to be converted to a mesh.
|
||||
# - If an export option modifies the data, e.g. Triangulate Faces is enabled.
|
||||
# - If the Object has Object-linked materials. This is because our current mapping of materials to FBX requires
|
||||
# that multiple Objects sharing a single mesh must have the same materials.
|
||||
# 3) The Object needs to be converted to a mesh.
|
||||
# - All mesh-like Objects that are not meshes need to be converted to a mesh in order to be exported.
|
||||
# 4) The Object needs to be evaluated and then converted to a mesh.
|
||||
# - Whenever use_mesh_modifiers is enabled and either there are modifiers to apply or the Object is not a mesh.
|
||||
# - Whenever use_mesh_modifiers is enabled and either there are modifiers to apply or the Object needs to be
|
||||
# converted to a mesh.
|
||||
# If multiple cases apply to an Object, then only the last applicable case is relevant.
|
||||
do_copy = any(ms.link == 'OBJECT' for ms in ob.material_slots) or (ob.type == 'MESH' and settings.use_triangles)
|
||||
do_copy = any(ms.link == 'OBJECT' for ms in ob.material_slots) or settings.use_triangles
|
||||
do_convert = ob.type in BLENDER_OTHER_OBJECT_TYPES
|
||||
do_evaluate = do_convert and settings.use_mesh_modifiers
|
||||
|
||||
# If the Object is a mesh, and we're applying modifiers, check if there are actually any modifiers to apply.
|
||||
# If there are then the mesh will need to be evaluated, and we may need to make some temporary changes before
|
||||
# evaluating the mesh.
|
||||
# If there are then the mesh will need to be evaluated, and we may need to make some temporary changes to the
|
||||
# modifiers or scene before the mesh is evaluated.
|
||||
backup_pose_positions = []
|
||||
tmp_mods = []
|
||||
if ob.type == 'MESH' and settings.use_mesh_modifiers:
|
||||
@ -2608,8 +2611,8 @@ def fbx_data_from_scene(scene, depsgraph, settings):
|
||||
tmp_me = bpy.data.meshes.new_from_object(
|
||||
ob_to_convert, preserve_all_data_layers=True, depsgraph=depsgraph)
|
||||
|
||||
# Usually the materials of the evaluated object will be the same, but modifiers, such as Geometry
|
||||
# Nodes, can change the materials.
|
||||
# Usually the materials of the evaluated object will be the same, but modifiers, such as Geometry Nodes,
|
||||
# can change the materials.
|
||||
orig_mats = tuple(slot.material for slot in ob.material_slots)
|
||||
eval_mats = tuple(slot.material.original if slot.material else None
|
||||
for slot in ob_to_convert.material_slots)
|
||||
@ -2619,8 +2622,7 @@ def fbx_data_from_scene(scene, depsgraph, settings):
|
||||
elif do_convert:
|
||||
tmp_me = bpy.data.meshes.new_from_object(ob, preserve_all_data_layers=True, depsgraph=depsgraph)
|
||||
elif do_copy:
|
||||
# bpy.data.meshes.new_from_object always removes shape keys (see #104714), so create a direct copy of the
|
||||
# mesh instead.
|
||||
# bpy.data.meshes.new_from_object removes shape keys (see #104714), so create a copy of the mesh instead.
|
||||
tmp_me = ob.data.copy()
|
||||
else:
|
||||
tmp_me = None
|
||||
|
Loading…
Reference in New Issue
Block a user