Fix #104707: FBX edge creases fail to be imported/exported #104709

Merged
Bastien Montagne merged 1 commits from Mysteryem/blender-addons:fbx_update_edge_crease_pr2 into main 2023-06-21 15:46:51 +02:00
2 changed files with 19 additions and 13 deletions

View File

@ -1109,8 +1109,10 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
ec_fbx_dtype = np.float64 ec_fbx_dtype = np.float64
if t_pvi_edge_indices.size: if t_pvi_edge_indices.size:
ec_bl_dtype = np.single ec_bl_dtype = np.single
edge_creases = me.edge_creases
if edge_creases:
t_ec_raw = np.empty(len(me.edges), dtype=ec_bl_dtype) t_ec_raw = np.empty(len(me.edges), dtype=ec_bl_dtype)
me.edges.foreach_get('crease', t_ec_raw) edge_creases.data.foreach_get("value", t_ec_raw)
# Convert to t_pvi edge-keys. # Convert to t_pvi edge-keys.
t_ec_ek_raw = t_ec_raw[t_pvi_edge_indices] t_ec_ek_raw = t_ec_raw[t_pvi_edge_indices]
@ -1122,6 +1124,10 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
t_ec = np.square(t_ec_ek_raw, out=t_ec_ek_raw) t_ec = np.square(t_ec_ek_raw, out=t_ec_ek_raw)
del t_ec_ek_raw del t_ec_ek_raw
del t_ec_raw del t_ec_raw
else:
# todo: Blender edge creases are optional now, we may be able to avoid writing the array to FBX when
# there are no edge creases.
t_ec = np.zeros(t_pvi_edge_indices.shape, dtype=ec_fbx_dtype)
else: else:
t_ec = np.empty(0, dtype=ec_fbx_dtype) t_ec = np.empty(0, dtype=ec_fbx_dtype)

View File

@ -1360,9 +1360,9 @@ def blen_read_geom_layer_edge_crease(fbx_obj, mesh):
print("warning skipping edge crease data, no valid edges...") print("warning skipping edge crease data, no valid edges...")
return False return False
blen_data = mesh.edges blen_data = mesh.edge_creases_ensure().data
return blen_read_geom_array_mapped_edge( return blen_read_geom_array_mapped_edge(
mesh, blen_data, "crease", np.single, mesh, blen_data, "value", np.single,
fbx_layer_data, None, fbx_layer_data, None,
fbx_layer_mapping, fbx_layer_ref, fbx_layer_mapping, fbx_layer_ref,
1, 1, layer_id, 1, 1, layer_id,