[Bf-blender-cvs] [e5a2790] master: Fix T48084: Solidify uses alternate quad-direction

Campbell Barton noreply at git.blender.org
Mon Apr 11 15:02:17 CEST 2016


Commit: e5a2790ecbdc748cc5d67af60ad5251eee0a7b6f
Author: Campbell Barton
Date:   Mon Apr 11 22:56:17 2016 +1000
Branches: master
https://developer.blender.org/rBe5a2790ecbdc748cc5d67af60ad5251eee0a7b6f

Fix T48084: Solidify uses alternate quad-direction

This prevents twisted quads from self-intersecting.

This change makes the duplicate surface match the first vertex in the face,
so the diagonal indices match in the face copy.

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

M	source/blender/modifiers/intern/MOD_solidify.c

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

diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 0a4d647..5275768 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -455,6 +455,7 @@ static DerivedMesh *applyModifier(
 
 		mp = mpoly + numFaces;
 		for (i = 0; i < dm->numPolyData; i++, mp++) {
+			const int loop_end = mp->totloop - 1;
 			MLoop *ml2;
 			unsigned int e;
 			int j;
@@ -462,10 +463,20 @@ static DerivedMesh *applyModifier(
 			/* reverses the loop direction (MLoop.v as well as custom-data)
 			 * MLoop.e also needs to be corrected too, done in a separate loop below. */
 			ml2 = mloop + mp->loopstart + dm->numLoopData;
+#if 0
 			for (j = 0; j < mp->totloop; j++) {
 				CustomData_copy_data(&dm->loopData, &result->loopData, mp->loopstart + j,
-				                     mp->loopstart + (mp->totloop - j - 1) + dm->numLoopData, 1);
+				                     mp->loopstart + (loop_end - j) + dm->numLoopData, 1);
 			}
+#else
+			/* slightly more involved, keep the first vertex the same for the copy,
+			 * ensures the diagonals in the new face match the original. */
+			j = 0;
+			for (int j_prev = loop_end; j < mp->totloop; j_prev = j++) {
+				CustomData_copy_data(&dm->loopData, &result->loopData, mp->loopstart + j,
+				                     mp->loopstart + (loop_end - j_prev) + dm->numLoopData, 1);
+			}
+#endif
 
 			if (mat_ofs) {
 				mp->mat_nr += mat_ofs;
@@ -473,10 +484,10 @@ static DerivedMesh *applyModifier(
 			}
 
 			e = ml2[0].e;
-			for (j = 0; j < mp->totloop - 1; j++) {
+			for (j = 0; j < loop_end; j++) {
 				ml2[j].e = ml2[j + 1].e;
 			}
-			ml2[mp->totloop - 1].e = e;
+			ml2[loop_end].e = e;
 
 			mp->loopstart += dm->numLoopData;




More information about the Bf-blender-cvs mailing list