From 40e036b63e2779304ea4c06acbdd35d77eee2a08 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 29 May 2024 15:39:24 +0200 Subject: [PATCH] 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 --- source/blender/io/ply/exporter/ply_export_load_plydata.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/io/ply/exporter/ply_export_load_plydata.cc b/source/blender/io/ply/exporter/ply_export_load_plydata.cc index e68ae191243..650839d62d4 100644 --- a/source/blender/io/ply/exporter/ply_export_load_plydata.cc +++ b/source/blender/io/ply/exporter/ply_export_load_plydata.cc @@ -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); } }