From e9295fad6524f85149df2407e47fd91daab25d1d Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Thu, 11 Sep 2025 01:20:10 +0200 Subject: [PATCH] Sculpt: Avoid setting vertex normal to the zero vector It is possible for the simple vertex normal calculated during Paint BVH normal updates to have a length of 0 if the connected faces cancel each other out. This is a generally unlikely scenario, but will almost always lead to further corruption of the mesh with the new normal. If we detect this case, set the vertex normal to (0, 0, 1) Pull Request: https://projects.blender.org/blender/blender/pulls/146004 --- source/blender/blenkernel/intern/pbvh.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index ecce5a95441..f7c93beab35 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -1120,7 +1120,11 @@ static void normals_calc_verts_simple(const GroupedSpan vert_to_face_map, for (const int face : vert_to_face_map[vert]) { normal += face_normals[face]; } - vert_normals[vert] = math::normalize(normal); + float length; + vert_normals[vert] = math::normalize_and_get_length(normal, length); + if (length == 0.0f) { + vert_normals[vert] = float3(0, 0, 1); + } } }