Skip to content
Snippets Groups Projects
Commit e676e8b2 authored by Bastien Montagne's avatar Bastien Montagne
Browse files

FBX Export: Make empty shape keys exportable

Currently all empty shape keys are not exported when exporting as FBX. The reason for this is that empty shape keys cause issues like crashing Unity. This can cause confusion because it is done without explanation.
This patch fixes this by making the shape keys technically empty while still keeping them intact and working as shape keys.

Reviewers: campbellbarton, mont29

Reviewed By: mont29

Tags: #bf_blender_2.8, #addons

Differential Revision: https://developer.blender.org/D4496
parent 40cf5c25
No related branches found
No related tags found
No related merge requests found
...@@ -2245,7 +2245,6 @@ def fbx_data_from_scene(scene, depsgraph, settings): ...@@ -2245,7 +2245,6 @@ def fbx_data_from_scene(scene, depsgraph, settings):
for shape in me.shape_keys.key_blocks[1:]: for shape in me.shape_keys.key_blocks[1:]:
# Only write vertices really different from org coordinates! # Only write vertices really different from org coordinates!
# XXX FBX does not like empty shapes (makes Unity crash e.g.), so we have to do this here... :/
shape_verts_co = [] shape_verts_co = []
shape_verts_idx = [] shape_verts_idx = []
...@@ -2258,8 +2257,13 @@ def fbx_data_from_scene(scene, depsgraph, settings): ...@@ -2258,8 +2257,13 @@ def fbx_data_from_scene(scene, depsgraph, settings):
continue continue
shape_verts_co.extend(Vector(sv_co) - Vector(ref_co)) shape_verts_co.extend(Vector(sv_co) - Vector(ref_co))
shape_verts_idx.append(idx) shape_verts_idx.append(idx)
# FBX does not like empty shapes (makes Unity crash e.g.).
# To prevent this, we add a vertex that does nothing, but it keeps the shape key intact
if not shape_verts_co: if not shape_verts_co:
continue shape_verts_co.extend((0, 0, 0))
shape_verts_idx.append(0)
channel_key, geom_key = get_blender_mesh_shape_channel_key(me, shape) channel_key, geom_key = get_blender_mesh_shape_channel_key(me, shape)
data = (channel_key, geom_key, shape_verts_co, shape_verts_idx) data = (channel_key, geom_key, shape_verts_co, shape_verts_idx)
data_deformers_shape.setdefault(me, (me_key, shapes_key, {}))[2][shape] = data data_deformers_shape.setdefault(me, (me_key, shapes_key, {}))[2][shape] = data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment