FBX IO: Export normals matching the mesh's normals_domain #104976

Merged
Thomas Barlow merged 4 commits from Mysteryem/blender-addons:fbx_update_for_auto_smooth into main 2023-11-03 16:42:29 +01:00
Showing only changes of commit a811d2fce8 - Show all commits

View File

@ -1183,7 +1183,7 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
normal_source.foreach_get("vector", t_normal)
t_normal = nors_transformed(t_normal, geom_mat_no, normal_fbx_dtype)
if 0:
lnidx_fbx_dtype = np.int32
normal_idx_fbx_dtype = np.int32
lay_nor = elem_data_single_int32(geom, b"LayerElementNormal", 0)
elem_data_single_int32(lay_nor, b"Version", FBX_GEOMETRY_NORMAL_VERSION)
elem_data_single_string(lay_nor, b"Name", b"")
@ -1193,20 +1193,20 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
# Tuple of unique sorted normals and then the index in the unique sorted normals of each normal in t_normal.
# Since we don't care about how the normals are sorted, only that they're unique, we can use the fast unique
# helper function.
t_normal, t_lnidx = fast_first_axis_unique(t_normal.reshape(-1, 3), return_inverse=True)
t_normal, t_normal_idx = fast_first_axis_unique(t_normal.reshape(-1, 3), return_inverse=True)

Shouldn't t_lnidx variable also be renamed, maybe to t_normal_idx then?

Shouldn't `t_lnidx` variable also be renamed, maybe to `t_normal_idx` then?
# Convert to the type for fbx
t_lnidx = astype_view_signedness(t_lnidx, lnidx_fbx_dtype)
t_normal_idx = astype_view_signedness(t_normal_idx, normal_idx_fbx_dtype)
elem_data_single_float64_array(lay_nor, b"Normals", t_normal)
# Normal weights, no idea what it is.
# t_lnw = np.zeros(len(t_normal), dtype=np.float64)
# elem_data_single_float64_array(lay_nor, b"NormalsW", t_lnw)
# t_normal_w = np.zeros(len(t_normal), dtype=np.float64)
# elem_data_single_float64_array(lay_nor, b"NormalsW", t_normal_w)
elem_data_single_int32_array(lay_nor, b"NormalsIndex", t_lnidx)
elem_data_single_int32_array(lay_nor, b"NormalsIndex", t_normal_idx)
del t_lnidx
# del t_lnw
del t_normal_idx
# del t_normal_w
else:
lay_nor = elem_data_single_int32(geom, b"LayerElementNormal", 0)
elem_data_single_int32(lay_nor, b"Version", FBX_GEOMETRY_NORMAL_VERSION)