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.
This commit is contained in:
Campbell Barton 2016-04-11 22:56:17 +10:00
parent 90271e7ff1
commit e5a2790ecb
Notes: blender-bot 2023-02-14 08:00:41 +01:00
Referenced by issue #48084, Solidify modifier fails on twisted quad.
1 changed files with 14 additions and 3 deletions

View File

@ -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;