Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_solidify.c')
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c69
1 files changed, 47 insertions, 22 deletions
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 4faf955b953..1b7b724835c 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -30,6 +30,11 @@
*
*/
+/** \file blender/modifiers/intern/MOD_solidify.c
+ * \ingroup modifiers
+ */
+
+
#include "DNA_meshdata_types.h"
#include "BLI_math.h"
@@ -209,6 +214,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
const int numEdges = dm->getNumEdges(dm);
const int numFaces = dm->getNumFaces(dm);
+ /* 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;
+ const short mat_ofs_rim= mat_nr_max ? smd->mat_ofs_rim : 0;
+
/* use for edges */
int *new_vert_arr= NULL;
int newFaces = 0;
@@ -291,7 +301,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
ehi= BLI_edgehashIterator_new(edgehash);
for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
- int eidx= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
+ eidx= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
if(edge_users[eidx] >= 0) {
BLI_edgehashIterator_getKey(ehi, &v1, &v2);
orig_mvert[v1].flag |= ME_VERT_TMP_TAG;
@@ -355,6 +365,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
DM_swap_face_data(result, i+numFaces, corner_indices);
test_index_face(mf, &result->faceData, numFaces, is_quad ? 4:3);
}
+
+ if(mat_ofs) {
+ mf->mat_nr += mat_ofs;
+ CLAMP(mf->mat_nr, 0, mat_nr_max);
+ }
}
}
@@ -408,7 +423,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
float *vert_angles= MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */
float *vert_accum= vert_angles + numVerts;
float face_angles[4];
- int i, j, vidx;
+ int j, vidx;
face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
if(!face_nors) {
@@ -515,9 +530,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
float (*edge_vert_nos)[3]= MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos");
float nor[3];
#endif
- /* maximum value -1, so we have room to increase */
- const short mat_nr_shift= (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) ? ob->totcol-1 : -1;
-
const unsigned char crease_rim= smd->crease_rim * 255.0f;
const unsigned char crease_outer= smd->crease_outer * 255.0f;
const unsigned char crease_inner= smd->crease_inner * 255.0f;
@@ -577,14 +589,22 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
}
/* use the next material index if option enabled */
- if(mf->mat_nr < mat_nr_shift)
- mf->mat_nr++;
-
- if(crease_outer)
- ed->crease= crease_outer;
+ if(mat_ofs_rim) {
+ mf->mat_nr += mat_ofs_rim;
+ CLAMP(mf->mat_nr, 0, mat_nr_max);
+ }
+ if(crease_outer) {
+ /* crease += crease_outer; without wrapping */
+ unsigned char *cr= (unsigned char *)&(ed->crease);
+ int tcr= *cr + crease_outer;
+ *cr= tcr > 255 ? 255 : tcr;
+ }
if(crease_inner) {
- medge[numEdges + eidx].crease= crease_inner;
+ /* crease += crease_inner; without wrapping */
+ unsigned char *cr= (unsigned char *)&(medge[numEdges + eidx].crease);
+ int tcr= *cr + crease_inner;
+ *cr= tcr > 255 ? 255 : tcr;
}
#ifdef SOLIDIFY_SIDE_NORMALS
@@ -623,6 +643,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
MEM_freeN(edge_order);
}
+ /* must recalculate normals with vgroups since they can displace unevenly [#26888] */
+ if(dvert) {
+ CDDM_calc_normals(result);
+ }
+
return result;
}
@@ -650,19 +675,19 @@ ModifierTypeInfo modifierType_Solidify = {
| eModifierTypeFlag_EnableInEditmode,
/* copyData */ copyData,
- /* deformVerts */ 0,
- /* deformMatrices */ 0,
- /* deformVertsEM */ 0,
- /* deformMatricesEM */ 0,
+ /* deformVerts */ NULL,
+ /* deformMatrices */ NULL,
+ /* deformVertsEM */ NULL,
+ /* deformMatricesEM */ NULL,
/* applyModifier */ applyModifier,
/* applyModifierEM */ applyModifierEM,
/* initData */ initData,
/* requiredDataMask */ requiredDataMask,
- /* freeData */ 0,
- /* isDisabled */ 0,
- /* updateDepgraph */ 0,
- /* dependsOnTime */ 0,
- /* dependsOnNormals */ 0,
- /* foreachObjectLink */ 0,
- /* foreachIDLink */ 0,
+ /* freeData */ NULL,
+ /* isDisabled */ NULL,
+ /* updateDepgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* dependsOnNormals */ NULL,
+ /* foreachObjectLink */ NULL,
+ /* foreachIDLink */ NULL
};