From bf52d20e62798579b490581adcfa8ea4d4082993 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2018 10:05:57 +0200 Subject: Modifiers: add back dirty normal flag --- source/blender/modifiers/intern/MOD_array.c | 7 +++++-- source/blender/modifiers/intern/MOD_bevel.c | 2 ++ source/blender/modifiers/intern/MOD_build.c | 4 ++++ source/blender/modifiers/intern/MOD_mirror.c | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) 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; } -- cgit v1.2.3