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 | |
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)
-rw-r--r-- | release/scripts/ui/properties_data_modifier.py | 8 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 17 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_solidify.c | 20 |
5 files changed, 52 insertions, 13 deletions
diff --git a/release/scripts/ui/properties_data_modifier.py b/release/scripts/ui/properties_data_modifier.py index 1aa28a76d1a..d038fb5ab2f 100644 --- a/release/scripts/ui/properties_data_modifier.py +++ b/release/scripts/ui/properties_data_modifier.py @@ -573,6 +573,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): col.prop(md, "edge_crease_inner", text="Inner") col.prop(md, "edge_crease_outer", text="Outer") col.prop(md, "edge_crease_rim", text="Rim") + col.label(text="Material Index Offset:") col = split.column() @@ -586,8 +587,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): col.prop(md, "use_rim") colsub = col.column() + + colsub.label() + rowsub = colsub.split(align=True, percentage=0.4) + rowsub.prop(md, "material_offset", text="") + colsub = rowsub.row() colsub.active = md.use_rim - colsub.prop(md, "use_rim_material") + colsub.prop(md, "material_offset_rim", text="Rim") def SUBSURF(self, layout, ob, md): layout.row().prop(md, "subdivision_type", expand=True) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4e00b888c90..8d1a77d1a2b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11484,6 +11484,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) { bScreen *sc; Brush *brush; + Object *ob; /* redraws flag in SpaceTime has been moved to Screen level */ for (sc = main->screen.first; sc; sc= sc->id.next) { @@ -11498,6 +11499,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(brush->height == 0) brush->height= 0.4; } + + /* replace 'rim material' option for in offset*/ + for(ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for(md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Solidify) { + SolidifyModifierData *smd = (SolidifyModifierData *)md; + if(smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) { + smd->mat_ofs_rim= 1; + smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL; + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 28840d55efc..5496c460b6f 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -705,13 +705,16 @@ typedef struct SolidifyModifierData { float crease_outer; float crease_rim; int flag; + short mat_ofs; + short mat_ofs_rim; + int pad; } SolidifyModifierData; #define MOD_SOLIDIFY_RIM (1<<0) #define MOD_SOLIDIFY_EVEN (1<<1) #define MOD_SOLIDIFY_NORMAL_CALC (1<<2) #define MOD_SOLIDIFY_VGROUP_INV (1<<3) -#define MOD_SOLIDIFY_RIM_MATERIAL (1<<4) +#define MOD_SOLIDIFY_RIM_MATERIAL (1<<4) /* deprecated, used in do_versions */ typedef struct ScrewModifierData { ModifierData modifier; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 375d9214e08..140a4b435be 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2162,6 +2162,18 @@ static void rna_def_modifier_solidify(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Rim Crease", "Assign a crease to the edges making up the rim"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop= RNA_def_property(srna, "material_offset", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "mat_ofs"); + RNA_def_property_range(prop, SHRT_MIN, SHRT_MAX); + RNA_def_property_ui_text(prop, "Material Offset", "Offset material index of generated faces"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "material_offset_rim", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "mat_ofs_rim"); + RNA_def_property_range(prop, SHRT_MIN, SHRT_MAX); + RNA_def_property_ui_text(prop, "Rim Material Offset", "Offset material index of generated rim faces"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name"); @@ -2172,11 +2184,6 @@ static void rna_def_modifier_solidify(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_RIM); RNA_def_property_ui_text(prop, "Fill Rim", "Create edge loops between the inner and outer surfaces on face edges (slow, disable when not needed)"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop= RNA_def_property(srna, "use_rim_material", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_RIM_MATERIAL); - RNA_def_property_ui_text(prop, "Rim Material", "Use in the next material for rim faces"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_even_offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_EVEN); 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; |