diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-05-20 17:34:04 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-05-20 17:34:04 +0400 |
commit | a47c673b5525fde6484d4392160fbb5101f2c108 (patch) | |
tree | cb05981d656de969d91e12d8f74a34bfaf2ed810 | |
parent | 56b726917d35ac51c86c3fd10580ac740124494d (diff) |
2.5 Material:
* Added material "type" property, with Surface/Volume/Halo
options, compatible with sim_physics, as requested for
material buttons layout. Obviously the Volume setting
does nothing currently.
* Deprecated MA_HALO flag in favor of this.
-rw-r--r-- | release/ui/buttons_material.py | 138 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/preview/previewrender.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 13 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 51 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 8 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 2 |
11 files changed, 113 insertions, 117 deletions
diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py index 551a62cfc84..af24bba57c7 100644 --- a/release/ui/buttons_material.py +++ b/release/ui/buttons_material.py @@ -5,40 +5,41 @@ class MaterialButtonsPanel(bpy.types.Panel): __space_type__ = "BUTTONS_WINDOW" __region_type__ = "WINDOW" __context__ = "material" + + def poll(self, context): + ob = context.active_object + return (ob and ob.active_material) class MATERIAL_PT_material(MaterialButtonsPanel): __idname__= "MATERIAL_PT_material" __label__ = "Material" - + def draw(self, context): layout = self.layout - try: - mat = context.active_object.active_material - except: - mat = None - - if not mat: - return + mat = context.active_object.active_material row = layout.row() + row.itemR(mat, "type", expand=True) + + row = layout.row() row.column().itemR(mat, "diffuse_color") row.column().itemR(mat, "specular_color") row.column().itemR(mat, "mirror_color") row = layout.row() - row.itemR(mat, "color_model") row.itemR(mat, "alpha") class MATERIAL_PT_sss(MaterialButtonsPanel): __idname__= "MATERIAL_PT_sss" __label__ = "Subsurface Scattering" + + def poll(self, context): + ob = context.active_object + return (ob and ob.active_material and ob.active_material.type == "SURFACE") def draw(self, context): layout = self.layout - try: - sss = context.active_object.active_material.subsurface_scattering - except: - sss = None + sss = context.active_object.active_material.subsurface_scattering if not sss: return @@ -66,7 +67,7 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel): def poll(self, context): ob = context.active_object - return (ob and ob.active_material) + return (ob and ob.active_material and ob.active_material.type == "SURFACE") def draw_header(self, context): raym = context.active_object.active_material.raytrace_mirror @@ -99,16 +100,14 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel): class MATERIAL_PT_raytransp(MaterialButtonsPanel): __idname__= "MATERIAL_PT_raytransp" __label__= "Ray Transparency" + + def poll(self, context): + ob = context.active_object + return (ob and ob.active_material and ob.active_material.type == "SURFACE") def draw(self, context): layout = self.layout - try: - rayt = context.active_object.active_material.raytrace_transparency - except: - rayt = None - - if not rayt: - return + rayt = context.active_object.active_material.raytrace_transparency layout.itemR(rayt, "enabled", text="Enable") @@ -135,61 +134,56 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): __idname__= "MATERIAL_PT_halo" __label__= "Halo" + def poll(self, context): + ob = context.active_object + return (ob and ob.active_material and ob.active_material.type == "HALO") + def draw(self, context): layout = self.layout - try: - halo = context.active_object.active_material.halo - except: - halo = None + mat = context.active_object.active_material + halo = mat.halo - if not halo: - return - - layout.itemR(halo, "enabled", text="Enable Halo") - - if halo.enabled: - - split = layout.split() - - sub = split.column() - sub.itemL(text="General Settings:") - sub.itemR(halo, "size") - sub.itemR(halo, "hardness") - sub.itemR(halo, "add") - - sub = split.column() - sub.itemL(text="Elements:") - sub.itemR(halo, "ring") - sub.itemR(halo, "lines") - sub.itemR(halo, "star") - sub.itemR(halo, "flare_mode") + split = layout.split() + + sub = split.column() + sub.itemL(text="General Settings:") + sub.itemR(halo, "size") + sub.itemR(halo, "hardness") + sub.itemR(halo, "add") + + sub = split.column() + sub.itemL(text="Elements:") + sub.itemR(halo, "ring") + sub.itemR(halo, "lines") + sub.itemR(halo, "star") + sub.itemR(halo, "flare_mode") - row = layout.row() - - sub = row.column() - sub.itemL(text="Options:") - sub.itemR(halo, "use_texture", text="Texture") - sub.itemR(halo, "use_vertex_normal", text="Vertex Normal") - sub.itemR(halo, "xalpha") - sub.itemR(halo, "shaded") - sub.itemR(halo, "soft") - - sub = row.column() - if (halo.ring): - sub.itemR(halo, "rings") - if (halo.lines): - sub.itemR(halo, "line_number") - if (halo.ring or halo.lines): - sub.itemR(halo, "seed") - if (halo.star): - sub.itemR(halo, "star_tips") - if (halo.flare_mode): - sub.itemL(text="Flare:") - sub.itemR(halo, "flare_size", text="Size") - sub.itemR(halo, "flare_subsize", text="Subsize") - sub.itemR(halo, "flare_boost", text="Boost") - sub.itemR(halo, "flare_seed", text="Seed") - sub.itemR(halo, "flares_sub", text="Sub") + row = layout.row() + + sub = row.column() + sub.itemL(text="Options:") + sub.itemR(halo, "use_texture", text="Texture") + sub.itemR(halo, "use_vertex_normal", text="Vertex Normal") + sub.itemR(halo, "xalpha") + sub.itemR(halo, "shaded") + sub.itemR(halo, "soft") + + sub = row.column() + if (halo.ring): + sub.itemR(halo, "rings") + if (halo.lines): + sub.itemR(halo, "line_number") + if (halo.ring or halo.lines): + sub.itemR(halo, "seed") + if (halo.star): + sub.itemR(halo, "star_tips") + if (halo.flare_mode): + sub.itemL(text="Flare:") + sub.itemR(halo, "flare_size", text="Size") + sub.itemR(halo, "flare_subsize", text="Subsize") + sub.itemR(halo, "flare_boost", text="Boost") + sub.itemR(halo, "flare_seed", text="Seed") + sub.itemR(halo, "flares_sub", text="Sub") bpy.types.register(MATERIAL_PT_material) bpy.types.register(MATERIAL_PT_raymir) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 43791e32b38..6a01311f6fc 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -160,7 +160,7 @@ static AdrBit2Path ma_mode_bits[]= { // ... {MA_RAYTRANSP, "raytrace_transparency.enabled", 0}, {MA_RAYMIRROR, "raytrace_mirror.enabled", 0}, - {MA_HALO, "halo.enabled", 0} +// {MA_HALO, "type", MA_TYPE_HALO} }; /* ----------------- */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c680c6b3b54..9c5735a3020 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8912,6 +8912,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) bump the version (or sub-version.) */ { Object *ob; + Material *ma; int i; for(ob = main->object.first; ob; ob = ob->id.next) { @@ -8977,6 +8978,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ob->data = olddata; } } + + for(ma = main->mat.first; ma; ma = ma->id.next) { + if(ma->mode & MA_HALO) { + ma->material_type= MA_TYPE_HALO; + ma->mode &= ~MA_HALO; + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 0c97c1fd008..1b23967a32d 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -813,7 +813,7 @@ static void icon_set_image(ID *id, DrawInfo *di, PreviewImage* prv_img, int mipl } else if (GS(id->name) == ID_MA) { Material* mat = (Material*)id; - if (mat->mode & MA_HALO) { + if (mat->material_type == MA_TYPE_HALO) { set_alpha( (char*) ri.rect, ri.pr_rectx, ri.pr_recty, 255); } } diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index 407674163a6..1d5d809a9ee 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -349,7 +349,7 @@ static Scene *preview_prepare_scene(Scene *scene, int id_type, ShaderPreview *sp if(sp->pr_method==PR_ICON_RENDER) { - if (mat->mode & MA_HALO) { + if (mat->material_type == MA_TYPE_HALO) { sce->lay= 1<<MA_FLAT; } else { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f2528f0241f..054cd4e966e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2281,7 +2281,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base Object *ob= base->object; Mesh *me = ob->data; Material *ma= give_current_material(ob, 1); - int hasHaloMat = (ma && (ma->mode&MA_HALO)); + int hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO)); int draw_wire = 0; int totvert, totedge, totface; DispList *dl; diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 4ffd2060568..cd0b73c8f70 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -52,7 +52,7 @@ typedef struct Material { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ - short colormodel, flag; + short material_type, flag; /* note, keep this below synced with render_types.h */ float r, g, b; float specr, specg, specb; @@ -147,11 +147,10 @@ typedef struct Material { */ #define MAXMAT 16 -/* colormodel */ -#define MA_RGB 0 -#define MA_CMYK 1 -#define MA_YUV 2 -#define MA_HSV 3 +/* material_type */ +#define MA_TYPE_SURFACE 0 +#define MA_TYPE_HALO 1 +#define MA_TYPE_VOLUME 2 /* flag */ /* for render */ @@ -166,7 +165,7 @@ typedef struct Material { #define MA_WIRE 8 #define MA_VERTEXCOL 16 #define MA_HALO_SOFT 16 -#define MA_HALO 32 +#define MA_HALO 32 /* deprecated */ #define MA_ZTRA 64 #define MA_VERTEXCOLP 128 #define MA_ZINV 256 diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b5f4ee98dfe..101cd2a801f 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -62,14 +62,14 @@ static PointerRNA rna_Material_strand_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data); } -static void rna_Material_mode_halo_set(PointerRNA *ptr, int value) +static void rna_Material_type_set(PointerRNA *ptr, int value) { Material *ma= (Material*)ptr->data; - - if(value) - ma->mode |= MA_HALO; - else - ma->mode &= ~(MA_HALO|MA_STAR|MA_HALO_XALPHA|MA_ZINV|MA_ENV); + + if(ma->material_type == MA_TYPE_HALO && value != MA_TYPE_HALO) + ma->mode &= ~(MA_STAR|MA_HALO_XALPHA|MA_ZINV|MA_ENV); + + ma->material_type= value; } static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -178,7 +178,7 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_mapping_items); RNA_def_property_ui_text(prop, "Mapping", ""); - /* XXX: MTex.colormodel, pmapto, pmaptoneg */ + /* XXX: pmapto, pmaptoneg */ prop= RNA_def_property(srna, "normal_map_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "normapspace"); @@ -204,18 +204,6 @@ static void rna_def_material_colors(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem prop_type_items[] = { - {MA_RGB, "RGB", "RGB", ""}, - // {MA_CMYK, "CMYK", "CMYK", ""}, - // {MA_YUV, "YUV", "YUV", ""}, - {MA_HSV, "HSV", "HSV", ""}, - {0, NULL, NULL, NULL}}; - - prop= RNA_def_property(srna, "color_model", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "colormodel"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Color Model", "Color model to display color values with in the user interface."); - prop= RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); @@ -466,12 +454,6 @@ static void rna_def_material_halo(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Material"); RNA_def_struct_ui_text(srna, "Material Halo", "Halo particle effect settings for a Material datablock."); - prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO); /* use bitflags */ - RNA_def_property_ui_text(prop, "Enabled", "Enables halo rendering of material."); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_mode_halo_set"); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); - prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "hasize"); RNA_def_property_range(prop, 0.0f, 100.0f); @@ -737,12 +719,25 @@ void rna_def_material_strand(BlenderRNA *brna) void RNA_def_material(BlenderRNA *brna) { - StructRNA *srna= NULL; - PropertyRNA *prop= NULL; + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_type_items[] = { + {MA_TYPE_SURFACE, "SURFACE", "Surface", "Render object as a surface."}, + {MA_TYPE_VOLUME, "VOLUME", "Volume", "Render object as a volume."}, + {MA_TYPE_HALO, "HALO", "Halo", "Render object as halo particles."}, + {0, NULL, NULL, NULL}}; srna= RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material datablock to defined the appearance of geometric objects for rendering."); - + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "material_type"); + RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered."); + RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set"); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "amb"); RNA_def_property_range(prop, 0, 1); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 78f0b156eb2..3ba73aef52d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -256,7 +256,7 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "planes"); RNA_def_property_enum_items(prop, color_mode_items); - RNA_def_property_ui_text(prop, "Colour Mode", "What Colour Mode images are saved in (BW, RGB, RGBA)"); + RNA_def_property_ui_text(prop, "Color Mode", "What Color Mode images are saved in (BW, RGB, RGBA)"); prop= RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xsch"); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index ce324239492..4ca7244e976 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1387,7 +1387,7 @@ static void render_new_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mat if(ma->mode&MA_WIRE) static_particle_wire(obr, ma, loc, loc1, sd->first, sd->line); - else if(ma->mode & MA_HALO){ + else if(ma->material_type == MA_TYPE_HALO) { har= RE_inithalo_particle(re, obr, dm, ma, loc, loc1, sd->orco, sd->uvco, sd->size, 1.0, seed); if(har) har->lay= obr->ob->lay; } @@ -1593,7 +1593,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem path_nbr=(int)pow(2.0,(double) part->ren_step); if(path_nbr) { - if((ma->mode & (MA_HALO|MA_WIRE))==0) { + if((ma->material_type != MA_TYPE_HALO) && (ma->mode & MA_WIRE)==0) { sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); set_object_orco(re, psys, sd.orco); } @@ -3035,7 +3035,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) ma= give_render_material(re, ob, 1); - if(ma->mode & MA_HALO) { + if(ma->material_type == MA_TYPE_HALO) { make_render_halos(re, obr, me, totvert, mvert, ma, orco); } else { @@ -4401,7 +4401,7 @@ static int allow_render_dupli_instance(Render *re, DupliObject *dob, Object *obd if(totmaterial) { for(a= 0; a<*totmaterial; a++) { ma= give_current_material(obd, a); - if(ma && (ma->mode & MA_HALO)) + if(ma && (ma->material_type == MA_TYPE_HALO)) return 0; } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index deb6f0db743..27dd43a4ef9 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -703,7 +703,7 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl) for(sample=0; sample<totsample; sample++) { float *zrect= RE_RenderLayerGetPass(rlpp[sample], SCE_PASS_Z) + od; float *rgbrect = rlpp[sample]->rectf + 4*od; - float rgb[3]; + float rgb[3] = {0}; int done= 0; for(go=R.lights.first; go; go= go->next) { |