Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-03-22 17:33:50 +0300
committerHans Goudey <h.goudey@me.com>2022-03-22 17:33:50 +0300
commit64cd927519748bbd50b856c25f7e4eac17d8c780 (patch)
treeca23f3b5d63c5d6a01afcb8aa0177a84ee01851f /source/blender/editors/sculpt_paint
parent86d87fcbdbd5f4a18d2fdcc4f827d9bee6b5ed32 (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/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c4
3 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index b85d2d0aec8..db74d86d0f4 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -962,6 +962,7 @@ static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
trim_mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BM_mesh_elem_hflag_enable_all(bm, BM_FACE, BM_ELEM_TAG, false);
BMO_op_callf(bm,
@@ -1214,12 +1215,14 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
trim_mesh,
&((struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BM_mesh_bm_from_me(bm,
sculpt_mesh,
&((struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 0e26eb9b4b6..58da5adc5e3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -147,6 +147,7 @@ void SCULPT_dynamic_topology_enable_ex(Main *bmain, Depsgraph *depsgraph, Scene
me,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
.use_shapekey = true,
.active_shapekey = ob->shapenr,
}));
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index 5f6b8bf9b19..23bc9fbb54d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -379,6 +379,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BMIter iter;
@@ -574,6 +575,7 @@ static void sculpt_face_sets_init_flood_fill(Object *ob,
mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BLI_bitmap *visited_faces = BLI_BITMAP_NEW(mesh->totpoly, "visited faces");
@@ -652,6 +654,7 @@ static void sculpt_face_sets_init_loop(Object *ob, const int mode)
mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BMIter iter;
BMFace *f;
@@ -1184,6 +1187,7 @@ static void sculpt_face_set_delete_geometry(Object *ob,
mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BM_mesh_elem_table_init(bm, BM_FACE);