[Bf-blender-cvs] [bf52d20e627] blender2.8: Modifiers: add back dirty normal flag

Campbell Barton noreply at git.blender.org
Fri May 4 10:06:23 CEST 2018


Commit: bf52d20e62798579b490581adcfa8ea4d4082993
Author: Campbell Barton
Date:   Fri May 4 10:05:57 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBbf52d20e62798579b490581adcfa8ea4d4082993

Modifiers: add back dirty normal flag

===================================================================

M	source/blender/modifiers/intern/MOD_array.c
M	source/blender/modifiers/intern/MOD_bevel.c
M	source/blender/modifiers/intern/MOD_build.c
M	source/blender/modifiers/intern/MOD_mirror.c

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 6dcb29abd63..01414a3dfad 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -372,7 +372,7 @@ static Mesh *arrayModifier_doArray(
 	int tot_doubles;
 
 	const bool use_merge = (amd->flags & MOD_ARR_MERGE) != 0;
-	const bool use_recalc_normals = /* (dm->dirty & DM_DIRTY_NORMALS) || */ use_merge;
+	const bool use_recalc_normals = (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || use_merge;
 	const bool use_offset_ob = ((amd->offset_type & MOD_ARR_OFF_OBJ) && amd->offset_ob);
 
 	int start_cap_nverts = 0, start_cap_nedges = 0, start_cap_npolys = 0, start_cap_nloops = 0;
@@ -733,8 +733,11 @@ static Mesh *arrayModifier_doArray(
 		MEM_freeN(full_doubles_map);
 	}
 
+	/* In case org dm has dirty normals, or we made some merging, mark normals as dirty in new mesh!
+	 * TODO: we may need to set other dirty flags as well?
+	 */
 	if (use_recalc_normals) {
-		BKE_mesh_calc_normals(result);
+		result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
 	}
 
 	if (vgroup_start_cap_remap) {
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index aa07aea3e11..9e5913af6c9 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -184,6 +184,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
 	           bm->ftoolflagpool == NULL);  /* make sure we never alloc'd these */
 	BM_mesh_free(bm);
 
+	result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+
 	return result;
 }
 
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index aebf63c3100..048e9ce33c0 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -297,6 +297,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
 	MEM_freeN(edgeMap);
 	MEM_freeN(faceMap);
 
+	if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
+		result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+	}
+
 	/* TODO(sybren): also copy flags & tags? */
 	return result;
 }
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 5c5b8e4f11d..78a2f43c8e2 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -337,8 +337,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
 	MirrorModifierData *mmd = (MirrorModifierData *) md;
 
 	result = mirrorModifier__doMirror(mmd, ctx->object, mesh);
-	BKE_mesh_calc_normals(result);
 
+	if (result != mesh) {
+		result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+	}
 	return result;
 }



More information about the Bf-blender-cvs mailing list