[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47039] trunk/blender/source/blender/ modifiers/intern/MOD_solidify.c: patch [#31579] Solidify modifier: Add new option "Flip Normals"

Campbell Barton ideasman42 at gmail.com
Sat May 26 11:39:04 CEST 2012


Revision: 47039
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47039
Author:   campbellbarton
Date:     2012-05-26 09:39:04 +0000 (Sat, 26 May 2012)
Log Message:
-----------
patch [#31579] Solidify modifier: Add new option "Flip Normals"

- previous commit was so similar to the patch Shinsuke wrote, better to add him as contributor, this commit will add to generated credits.
- this commit has no functional changes.

Modified Paths:
--------------
    trunk/blender/source/blender/modifiers/intern/MOD_solidify.c

Modified: trunk/blender/source/blender/modifiers/intern/MOD_solidify.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_solidify.c	2012-05-26 09:33:15 UTC (rev 47038)
+++ trunk/blender/source/blender/modifiers/intern/MOD_solidify.c	2012-05-26 09:39:04 UTC (rev 47039)
@@ -18,11 +18,8 @@
  * The Original Code is Copyright (C) 2005 by the Blender Foundation.
  * All rights reserved.
  *
- * Contributor(s): Daniel Dunbar
- *                 Ton Roosendaal,
- *                 Ben Batt,
- *                 Brecht Van Lommel,
- *                 Campbell Barton
+ * Contributor(s): Campbell Barton
+ *                 Shinsuke Irie
  *
  * ***** END GPL LICENSE BLOCK *****
  *
@@ -75,7 +72,7 @@
 	mpoly = dm->getPolyArray(dm);
 	mvert = dm->getVertArray(dm);
 	mloop = dm->getLoopArray(dm);
-	
+
 	/* we don't want to overwrite any referenced layers */
 
 	/* Doesn't work here! */
@@ -107,7 +104,7 @@
 			unsigned int ml_v1;
 			unsigned int ml_v2;
 			int j;
-			
+
 			f_no = face_nors[i];
 			if (calc_face_nors)
 				mesh_calc_poly_normal(mp, mloop + mp->loopstart, mvert, f_no);
@@ -210,9 +207,9 @@
 	r[2] += (float)a[2] * f;
 }
 
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, 
-                                  DerivedMesh *dm,
-                                  ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
+		DerivedMesh *dm,
+		ModifierApplyFlag UNUSED(flag))
 {
 	int i;
 	DerivedMesh *result;
@@ -227,7 +224,7 @@
 	const int numFaces = dm->getNumPolys(dm);
 	int numLoops = 0, newLoops = 0, newFaces = 0, newEdges = 0;
 	int j;
-	
+
 	/* only use material offsets if we have 2 or more materials  */
 	const short mat_nr_max = ob->totcol > 1 ? ob->totcol - 1 : 0;
 	const short mat_ofs = mat_nr_max ? smd->mat_ofs : 0;
@@ -251,7 +248,7 @@
 	const float ofs_new  = smd->offset + ofs_orig;
 	const float offset_fac_vg = smd->offset_fac_vg;
 	const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg;
-	const int   do_flip = (smd->flag & MOD_SOLIDIFY_FLIP) != 0;
+	const int do_flip = (smd->flag & MOD_SOLIDIFY_FLIP) != 0;
 
 	/* weights */
 	MDeformVert *dvert, *dv = NULL;
@@ -262,7 +259,7 @@
 
 	numLoops = dm->numLoopData;
 	newLoops = 0;
-	
+
 	orig_mvert = dm->getVertArray(dm);
 	orig_medge = dm->getEdgeArray(dm);
 	orig_mloop = dm->getLoopArray(dm);
@@ -396,9 +393,9 @@
 			ml2[j].e = ml2[j + 1].e;
 		}
 		ml2[mp->totloop - 1].e = e;
-		
+
 		mp->loopstart += dm->numLoopData;
-		
+
 		for (j = 0; j < mp->totloop; j++) {
 			ml2[j].e += numEdges;
 			ml2[j].v += numVerts;
@@ -450,7 +447,6 @@
 				madd_v3v3short_fl(mv->co, mv->no, scalar_short_vgroup);
 			}
 		}
-
 	}
 	else {
 		/* make a face normal layer if not present */
@@ -572,16 +568,16 @@
 	}
 
 	if (smd->flag & MOD_SOLIDIFY_RIM) {
-		
+
 		/* bugger, need to re-calculate the normals for the new edge faces.
 		 * This could be done in many ways, but probably the quickest way
 		 * is to calculate the average normals for side faces only.
 		 * Then blend them with the normals of the edge verts.
-		 * 
+		 *
 		 * at the moment its easiest to allocate an entire array for every vertex,
 		 * even though we only need edge verts - campbell
 		 */
-		
+
 #define SOLIDIFY_SIDE_NORMALS
 
 #ifdef SOLIDIFY_SIDE_NORMALS
@@ -652,13 +648,13 @@
 			if (flip == FALSE) {
 				ml[j].v = ed->v1;
 				ml[j++].e = eidx;
-				
+
 				ml[j].v = ed->v2;
 				ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2];
-				
+
 				ml[j].v = ed->v2 + numVerts;
 				ml[j++].e = eidx + numEdges;
-				
+
 				ml[j].v = ed->v1 + numVerts;
 				ml[j++].e = numEdges * 2 + old_vert_arr[ed->v1];
 			}
@@ -675,7 +671,7 @@
 				ml[j].v = ed->v2 + numVerts;
 				ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2];
 			}
-			
+
 			origindex_edge[ml[j - 3].e] = ORIGINDEX_NONE;
 			origindex_edge[ml[j - 1].e] = ORIGINDEX_NONE;
 
@@ -697,7 +693,7 @@
 				int tcr = *cr + crease_inner;
 				*cr = tcr > 255 ? 255 : tcr;
 			}
-			
+
 #ifdef SOLIDIFY_SIDE_NORMALS
 			normal_quad_v3(nor,
 			               mvert[ml[j - 4].v].co,
@@ -713,17 +709,17 @@
 			}
 #endif
 		}
-		
+
 #ifdef SOLIDIFY_SIDE_NORMALS
 		ed = medge + (numEdges * 2);
 		for (i = 0; i < newEdges; i++, ed++) {
 			float nor_cpy[3];
 			short *nor_short;
 			int j;
-			
+
 			/* note, only the first vertex (lower half of the index) is calculated */
 			normalize_v3_v3(nor_cpy, edge_vert_nos[ed->v1]);
-			
+
 			for (j = 0; j < 2; j++) { /* loop over both verts of the edge */
 				nor_short = mvert[*(&ed->v1 + j)].no;
 				normal_short_to_float_v3(nor, nor_short);
@@ -744,7 +740,7 @@
 
 	if (old_vert_arr)
 		MEM_freeN(old_vert_arr);
-	
+
 	/* must recalculate normals with vgroups since they can displace unevenly [#26888] */
 	if (dvert) {
 		CDDM_calc_normals(result);




More information about the Bf-blender-cvs mailing list