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-24 16:38:24 +0300
commitfb2cb0324a391041db3fdc6c66ce992adf9598aa (patch)
treea472d1cce7a82923d8e4a1d8cc48730a4792edbd /source/blender/editors
parentb89437c27e4ce286d8f3525ade8d8d28c35d582f (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')
-rw-r--r--source/blender/editors/mesh/editmesh_mask_extract.c1
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c1
-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
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c1
6 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c
index a1a7dfac282..0fdf44ffc25 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -124,6 +124,7 @@ static int geometry_extract_apply(bContext *C,
new_mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
BMEditMesh *em = BKE_editmesh_create(bm);
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 3452edd51dd..7fb4221a1f4 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -685,6 +685,7 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em)
(&(struct BMeshFromMeshParams){
/* Handled with tessellation. */
.calc_face_normal = false,
+ .calc_vert_normal = false,
.active_shapekey = um->shapenr,
}));
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index e65d6ce2d48..ae419c08746 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -978,6 +978,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,
@@ -1230,12 +1231,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 ae6dcbdbff4..616c8afe051 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -163,6 +163,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 dc8cda964ea..bb2965126b5 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -395,6 +395,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;
@@ -590,6 +591,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");
@@ -668,6 +670,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;
@@ -1200,6 +1203,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);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 362e020f306..63331bba6b2 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -2985,6 +2985,7 @@ void ED_uvedit_add_simple_uvs(Main *bmain, const Scene *scene, Object *ob)
me,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
+ .calc_vert_normal = true,
}));
/* select all uv loops first - pack parameters needs this to make sure charts are registered */
ED_uvedit_select_all(bm);