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
This commit is contained in:
@@ -1120,7 +1120,11 @@ static void normals_calc_verts_simple(const GroupedSpan<int> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user