[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35317] trunk/blender: solidify material offsets for 2nd surface and rim faces.
Campbell Barton
ideasman42 at gmail.com
Thu Mar 3 06:09:08 CET 2011
Revision: 35317
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35317
Author: campbellbarton
Date: 2011-03-03 05:09:07 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
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)
Modified Paths:
--------------
trunk/blender/release/scripts/ui/properties_data_modifier.py
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/makesdna/DNA_modifier_types.h
trunk/blender/source/blender/makesrna/intern/rna_modifier.c
trunk/blender/source/blender/modifiers/intern/MOD_solidify.c
Modified: trunk/blender/release/scripts/ui/properties_data_modifier.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_modifier.py 2011-03-03 04:25:14 UTC (rev 35316)
+++ trunk/blender/release/scripts/ui/properties_data_modifier.py 2011-03-03 05:09:07 UTC (rev 35317)
@@ -573,6 +573,7 @@
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 @@
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)
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2011-03-03 04:25:14 UTC (rev 35316)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2011-03-03 05:09:07 UTC (rev 35317)
@@ -11484,6 +11484,7 @@
{
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 @@
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! */
Modified: trunk/blender/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_modifier_types.h 2011-03-03 04:25:14 UTC (rev 35316)
+++ trunk/blender/source/blender/makesdna/DNA_modifier_types.h 2011-03-03 05:09:07 UTC (rev 35317)
@@ -705,13 +705,16 @@
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;
Modified: trunk/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_modifier.c 2011-03-03 04:25:14 UTC (rev 35316)
+++ trunk/blender/source/blender/makesrna/intern/rna_modifier.c 2011-03-03 05:09:07 UTC (rev 35317)
@@ -2162,6 +2162,18 @@
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 @@
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);
Modified: trunk/blender/source/blender/modifiers/intern/MOD_solidify.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_solidify.c 2011-03-03 04:25:14 UTC (rev 35316)
+++ trunk/blender/source/blender/modifiers/intern/MOD_solidify.c 2011-03-03 05:09:07 UTC (rev 35317)
@@ -214,6 +214,11 @@
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 @@
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 @@
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 @@
}
/* 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;
More information about the Bf-blender-cvs
mailing list