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)
This commit is contained in:
Campbell Barton
2011-03-03 05:09:07 +00:00
parent 385c5f0755
commit a18e1043e8
5 changed files with 52 additions and 13 deletions

View File

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

View File

@@ -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! */

View File

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

View File

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

View File

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