diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-03 08:09:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-03 08:09:07 +0300 |
commit | a18e1043e87cffb63ef2e6818315431efea17496 (patch) | |
tree | eaa7d5be9421f2329e3d9502cb16b37e10cd0d6b /source/blender/modifiers/intern | |
parent | 385c5f07553b2b5c0dc18d5e6d0862078c6769f8 (diff) |
solidify material offsets for 2nd surface and rim faces.
run do_versions() on use_rim_material option so Sintel's jacket loads ok.
(request from Bassam)
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r-- | source/blender/modifiers/intern/MOD_solidify.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 14a07b62a91..8e44cd1ec37 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -214,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; @@ -360,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); + } } } @@ -520,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; @@ -582,9 +589,10 @@ 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(mat_ofs_rim) { + mf->mat_nr += mat_ofs_rim; + CLAMP(mf->mat_nr, 0, mat_nr_max); + } if(crease_outer) ed->crease= crease_outer; |