From c956e5d2d92f8a687e6f884602a12adade7b6c09 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 26 Feb 2012 18:12:01 +0000 Subject: modified fix for "Fix [#30351] Solidify Modifier High Quality Normals fails." from r44464. rather then recalc polygon normals - solidify is simple enough to just flip the normals of the copied faces, the rim faces normals are already re-calculated so copy them. --- source/blender/modifiers/intern/MOD_explode.c | 2 +- source/blender/modifiers/intern/MOD_screw.c | 17 ----------------- source/blender/modifiers/intern/MOD_solidify.c | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index afcfcc396ee..89e47094108 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -183,7 +183,7 @@ static void createFacepa(ExplodeModifierData *emd, BLI_kdtree_free(tree); } -static int edgecut_get(EdgeHash *edgehash, int v1, int v2) +static int edgecut_get(EdgeHash *edgehash, unsigned int v1, unsigned int v2) { return GET_INT_FROM_POINTER(BLI_edgehash_lookup(edgehash, v1, v2)); } diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 8ff4080b99b..92e50d36b1b 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -132,23 +132,6 @@ static void copyData(ModifierData *md, ModifierData *target) tltmd->iter= sltmd->iter; } -#if 0 -static int findEd(MEdge *medge_new, int toted, int v1, int v2) -{ - int i; - - for (i = 0; i < toted; i++) { - if ( (medge_new[i].v1 == v1 && medge_new[i].v2 == v2) || - (medge_new[i].v1 == v2 && medge_new[i].v2 == v1) ) - { - return i; - } - } - - return -1; -} -#endif - static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, int useRenderParams, diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index defc2b9de5e..78178387ee9 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -235,6 +235,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, float (*vert_nors)[3]= NULL; + float (*face_nors_result)[3] = NULL; + const float ofs_orig= - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); const float ofs_new= smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); const float offset_fac_vg= smd->offset_fac_vg; @@ -354,7 +356,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DM_copy_poly_data(dm, result, 0, 0, numFaces); DM_copy_poly_data(dm, result, 0, numFaces, numFaces); - + + /* if the original has it, get the result so we can update it */ + face_nors_result = CustomData_get_layer(&result->polyData, CD_NORMAL); + /*flip normals*/ mp = mpoly + numFaces; for (i=0; inumPolyData; i++, mp++) { @@ -384,6 +389,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, ml2[j].e += numEdges; ml2[j].v += numVerts; } + + if (face_nors_result) { + negate_v3_v3(face_nors_result[numFaces + i], face_nors_result[i]); + } } for(i=0, ed=medge+numEdges; iv1], nor); add_v3_v3(edge_vert_nos[ed->v2], nor); + + if (face_nors_result) { + copy_v3_v3(face_nors_result[(numFaces * 2) + i], nor); + } #endif } @@ -702,8 +715,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MEM_freeN(old_vert_arr); /* must recalculate normals with vgroups since they can displace unevenly [#26888] */ - /* Also needed in case of HQ normals [#30351] (don't really undestand why, though... --mont29). */ - if (dvert || smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { + if (dvert) { CDDM_calc_normals(result); } -- cgit v1.2.3