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-02-18 22:21:36 +0300
committerHans Goudey <h.goudey@me.com>2022-02-18 22:21:36 +0300
commit969c4a45ce09100edc961fd0dc6f37d4689373c7 (patch)
tree73930cda7e3eab5c538df678abeaca7f823888c7
parenteaa4aa864427e8aaa0bb1d4f0ce930b562aabc05 (diff)
Cleanup: Use functions for accessing mesh normal dirty state
It's better not to expose the details of where the dirty flags are stored to every place that wants to know if the normals are dirty. Some of these places are relics from before vertex normals were computed lazily anyway, so this is more of an incrememtal cleanup. This will make part of the fix for T95839 simpler.
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.cc5
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/mesh.cc8
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc8
-rw-r--r--source/blender/modifiers/intern/MOD_array.c2
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c3
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_extrude.c6
7 files changed, 14 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index 6056b69b5c8..411e5f81262 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -1981,9 +1981,8 @@ Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph,
mesh_eval = BKE_object_get_evaluated_mesh(ob);
}
- if (mesh_eval != nullptr) {
- BLI_assert(!(mesh_eval->runtime.cd_dirty_vert & CD_MASK_NORMAL));
- }
+ BKE_mesh_assert_normals_dirty_or_calculated(mesh_eval);
+
return mesh_eval;
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index a4f3e84a2bf..474478922f8 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -265,7 +265,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
dm->deformedOnly = 1;
dm->cd_flag = mesh->cd_flag;
- if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
+ if (BKE_mesh_vertex_normals_are_dirty(mesh)) {
dm->dirty |= DM_DIRTY_NORMALS;
}
/* TODO: DM_DIRTY_TESS_CDLAYERS ? Maybe not though,
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 76a15fd0a1c..351535a6f78 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -1116,11 +1116,9 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
/* Ensure that when no normal layers exist, they are marked dirty, because
* normals might not have been included in the mask of copied layers. */
- if (!CustomData_has_layer(&me_dst->vdata, CD_NORMAL)) {
- me_dst->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
- }
- if (!CustomData_has_layer(&me_dst->pdata, CD_NORMAL)) {
- me_dst->runtime.cd_dirty_poly |= CD_MASK_NORMAL;
+ if (!CustomData_has_layer(&me_dst->vdata, CD_NORMAL) ||
+ !CustomData_has_layer(&me_dst->pdata, CD_NORMAL)) {
+ BKE_mesh_normals_tag_dirty(me_dst);
}
/* The destination mesh should at least have valid primary CD layers,
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index 22e4c3bf13c..3562f6c6b17 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -1500,11 +1500,9 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
/* Ensure that when no normal layers exist, they are marked dirty, because
* normals might not have been included in the mask of copied layers. */
- if (!CustomData_has_layer(&tmp.vdata, CD_NORMAL)) {
- tmp.runtime.cd_dirty_vert |= CD_MASK_NORMAL;
- }
- if (!CustomData_has_layer(&tmp.pdata, CD_NORMAL)) {
- tmp.runtime.cd_dirty_poly |= CD_MASK_NORMAL;
+ if (!CustomData_has_layer(&tmp.vdata, CD_NORMAL) ||
+ !CustomData_has_layer(&tmp.pdata, CD_NORMAL)) {
+ BKE_mesh_normals_tag_dirty(&tmp);
}
if (CustomData_has_layer(&mesh_src->vdata, CD_SHAPEKEY)) {
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 56db68b163c..de129888060 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -387,7 +387,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
int tot_doubles;
const bool use_merge = (amd->flags & MOD_ARR_MERGE) != 0;
- const bool use_recalc_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || use_merge;
+ const bool use_recalc_normals = BKE_mesh_vertex_normals_are_dirty(mesh) || use_merge;
const bool use_offset_ob = ((amd->offset_type & MOD_ARR_OFF_OBJ) && amd->offset_ob != NULL);
int start_cap_nverts = 0, start_cap_nedges = 0, start_cap_npolys = 0, start_cap_nloops = 0;
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index c81e6cafa39..cdb7035570e 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -329,8 +329,7 @@ static void displaceModifier_do(DisplaceModifierData *dmd,
if (CustomData_has_layer(ldata, CD_CUSTOMLOOPNORMAL)) {
float(*clnors)[3] = NULL;
- if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) ||
- !CustomData_has_layer(ldata, CD_NORMAL)) {
+ if (!CustomData_has_layer(ldata, CD_NORMAL)) {
BKE_mesh_calc_normals_split(mesh);
}
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index fa8d08bf839..a9aec2f1c15 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -967,7 +967,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
}
/* must recalculate normals with vgroups since they can displace unevenly T26888. */
- if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || do_rim || dvert) {
+ if (BKE_mesh_vertex_normals_are_dirty(mesh) || do_rim || dvert) {
BKE_mesh_normals_tag_dirty(result);
}
else if (do_shell) {
@@ -1023,9 +1023,9 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
#define SOLIDIFY_SIDE_NORMALS
#ifdef SOLIDIFY_SIDE_NORMALS
- /* NOTE(@sybren): due to the code setting cd_dirty_vert a few lines above,
+ /* NOTE(@sybren): due to the code setting normals dirty a few lines above,
* do_side_normals is always false. */
- const bool do_side_normals = !(result->runtime.cd_dirty_vert & CD_MASK_NORMAL);
+ const bool do_side_normals = !BKE_mesh_vertex_normals_are_dirty(result);
/* annoying to allocate these since we only need the edge verts, */
float(*edge_vert_nos)[3] = do_side_normals ?
MEM_calloc_arrayN(numVerts, sizeof(float[3]), __func__) :