Fix #122344: PLY exports non-normalized custom normals on scaled objects

On export, PLY creates a matrix (in `set_world_axes_transform`) -- the
inverse transpose of the regular matrix [seems like the usual way of
transforming normals]] --  by which the normals are multiplied. This can end
up in non-normalized custom normals on scaled objects though. Corrected
in this PR by just normalizing after said multiplication.

On import, `BKE_mesh_set_custom_normals_from_verts` is used with the raw
data -- which ends up in `mesh_normals_corner_custom_set` which in turn
"is expected to have normalized normals" (from the comment).
We _could_ also make sure to normalize on import, however, setting these
properly on export seems the primary choice.
Other importers also dont go the extra route of making sure to normalize
the incoming data, so this seems to be in line of what other Im-/Exports
do.

Pull Request: https://projects.blender.org/blender/blender/pulls/122432
This commit is contained in:
Philipp Oeser
2024-05-29 15:39:24 +02:00
committed by Philipp Oeser
parent 98eecfcff0
commit 40e036b63e

View File

@@ -432,6 +432,7 @@ void load_plydata(PlyData &plyData, Depsgraph *depsgraph, const PLYExportParams
for (int vertex_index : ply_to_vertex) {
float3 normal = vert_normals[vertex_index];
mul_m3_v3(world_and_axes_normal_transform, normal);
normalize_v3(normal);
plyData.vertex_normals.append(normal);
}
}