diff options
author | Hans Goudey <h.goudey@me.com> | 2022-03-22 17:33:50 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-22 17:33:50 +0300 |
commit | 64cd927519748bbd50b856c25f7e4eac17d8c780 (patch) | |
tree | ca23f3b5d63c5d6a01afcb8aa0177a84ee01851f /source/blender/blenkernel/intern | |
parent | 86d87fcbdbd5f4a18d2fdcc4f827d9bee6b5ed32 (diff) |
Fix T96308: Mesh to BMesh conversion doesn't calculate vertex normals
Currently there is a "calc_face_normal" argument to mesh to bmesh
conversion, but vertex normals had always implicitly inherited whatever
dirty state the mesh input's vertex normals were in. Probably they were
most often assumed to not be dirty, but this was never really correct in
the general case.
Ever since the refactor to move vertex normals out of mesh vertices,
cfa53e0fbeed7178c7, the copying logic has been explicit: copy the
normals when they are not dirty. But it turns out that more control is
needed, and sometimes normals should be calculated for the resulting
BMesh.
This commit adds an option to the conversion to calculate vertex
normals, true by default. In almost all places except the decimate
and edge split modifiers, I just copied the value of the
"calc_face_normals" argument.
Differential Revision: https://developer.blender.org/D14406
Diffstat (limited to 'source/blender/blenkernel/intern')
4 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 824c1ab1b90..97cc15e95cf 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1166,6 +1166,7 @@ BMesh *BKE_mesh_to_bmesh(Mesh *me, { BMeshFromMeshParams bmesh_from_mesh_params{}; bmesh_from_mesh_params.calc_face_normal = false; + bmesh_from_mesh_params.calc_vert_normal = false; bmesh_from_mesh_params.add_key_index = add_key_index; bmesh_from_mesh_params.use_shapekey = true; bmesh_from_mesh_params.active_shapekey = ob->shapenr; diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index da23aea43f3..9202690b3c9 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++ b/source/blender/blenkernel/intern/mesh_mirror.c @@ -46,6 +46,7 @@ Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mm &(struct BMeshCreateParams){0}, &(struct BMeshFromMeshParams){ .calc_face_normal = true, + .calc_vert_normal = true, .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX}, @@ -92,6 +93,7 @@ void BKE_mesh_mirror_apply_mirror_on_axis(struct Main *bmain, }, &(struct BMeshFromMeshParams){ .calc_face_normal = true, + .calc_vert_normal = true, .cd_mask_extra = { .vmask = CD_MASK_SHAPEKEY, diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index b34a241bca8..3c7992ec3d7 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -401,6 +401,7 @@ struct Mesh *BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh) BMeshFromMeshParams bmesh_from_mesh_params{}; bmesh_from_mesh_params.calc_face_normal = true; + bmesh_from_mesh_params.calc_vert_normal = true; BM_mesh_bm_from_me(bm, mesh, &bmesh_from_mesh_params); BMVert *v; diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c index 80926bfc1e2..cad680ecedd 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.c +++ b/source/blender/blenkernel/intern/multires_unsubdivide.c @@ -869,6 +869,7 @@ static BMesh *get_bmesh_from_mesh(Mesh *mesh) mesh, (&(struct BMeshFromMeshParams){ .calc_face_normal = true, + .calc_vert_normal = true, })); return bm; |