Fix #104707: FBX edge creases fail to be imported/exported #104709
@ -1109,19 +1109,25 @@ 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
|
||||||
t_ec_raw = np.empty(len(me.edges), dtype=ec_bl_dtype)
|
edge_creases = me.edge_creases
|
||||||
me.edges.foreach_get('crease', t_ec_raw)
|
if edge_creases:
|
||||||
|
t_ec_raw = np.empty(len(me.edges), dtype=ec_bl_dtype)
|
||||||
|
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]
|
||||||
|
|
||||||
# Blender squares those values before sending them to OpenSubdiv, when other software don't,
|
# Blender squares those values before sending them to OpenSubdiv, when other software don't,
|
||||||
# so we need to compensate that to get similar results through FBX...
|
# so we need to compensate that to get similar results through FBX...
|
||||||
# Use the precision of the fbx dtype for the calculation since it's usually higher precision.
|
# Use the precision of the fbx dtype for the calculation since it's usually higher precision.
|
||||||
t_ec_ek_raw = t_ec_ek_raw.astype(ec_fbx_dtype, copy=False)
|
t_ec_ek_raw = t_ec_ek_raw.astype(ec_fbx_dtype, copy=False)
|
||||||
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)
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user