diff options
author | Thomas Dinges <blender@dingto.org> | 2010-04-04 16:09:59 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2010-04-04 16:09:59 +0400 |
commit | d574e8b82617c389de85a09fcf9b0f14172466a8 (patch) | |
tree | 14ae0ae8d3939d471e9b4c8ef406dcd7336b1027 /source | |
parent | 426aaaa0a29ea2ddaf008142752fc1efb91033f0 (diff) |
2.5 Preview Render:
* Converted Type Buttons (Flat, Cube, Monkey etc.) in Material Preview to RNA.
* "Alpha" option in texture Preview Render is back!
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 28 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 6 |
3 files changed, 42 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2bbabf66ffe..200ef1fa501 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1286,6 +1286,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) #include "DNA_lamp_types.h" #include "DNA_material_types.h" +#include "DNA_texture_types.h" #include "DNA_world_types.h" #define B_MATPRV 1 @@ -1304,8 +1305,11 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) uiLayout *row, *col; uiBlock *block; Material *ma= NULL; + Tex *tex = (Tex*)id; ID *pid, *pparent; short *pr_texture= NULL; + PointerRNA material_ptr; + PointerRNA texture_ptr; if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { printf("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n"); @@ -1348,20 +1352,20 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) if(GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { if(GS(pid->name) == ID_MA) ma= (Material*)pid; else ma= (Material*)pparent; + + /* Create RNA Pointer */ + RNA_pointer_create(id, &RNA_Material, ma, &material_ptr); - uiLayoutColumn(row, 1); - - uiDefIconButC(block, ROW, B_MATPRV, ICON_MATPLANE, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_FLAT, 0, 0, "Preview type: Flat XY plane"); - uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE, 0, 0, "Preview type: Sphere"); - uiDefIconButC(block, ROW, B_MATPRV, ICON_MATCUBE, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_CUBE, 0, 0, "Preview type: Cube"); - uiDefIconButC(block, ROW, B_MATPRV, ICON_MONKEY, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_MONKEY, 0, 0, "Preview type: Monkey"); - uiDefIconButC(block, ROW, B_MATPRV, ICON_HAIR, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_HAIR, 0, 0, "Preview type: Hair strands"); - uiDefIconButC(block, ROW, B_MATPRV, ICON_MAT_SPHERE_SKY, 0, 0,UI_UNIT_X*1.5,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE_A, 0, 0, "Preview type: Large sphere with sky"); + col = uiLayoutColumn(row, 1); + uiLayoutSetScaleX(col, 1.5); + uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", 0); } if(pr_texture) { + /* Create RNA Pointer */ + RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); + uiLayoutRow(layout, 1); - uiDefButS(block, ROW, B_MATPRV, "Texture", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); if(GS(parent->name) == ID_MA) uiDefButS(block, ROW, B_MATPRV, "Material", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); @@ -1370,6 +1374,12 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot) else if(GS(parent->name) == ID_WO) uiDefButS(block, ROW, B_MATPRV, "World", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); uiDefButS(block, ROW, B_MATPRV, "Both", 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_BOTH, 0, 0, ""); + + /* Alpha buton for texture preview */ + if(*pr_texture!=TEX_PR_OTHER) { + row = uiLayoutRow(layout, 0); + uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, 0); + } } } } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b6a6f072c6b..4d47737038a 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1486,6 +1486,16 @@ void RNA_def_material(BlenderRNA *brna) {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces"}, {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering"}, {0, NULL, 0, NULL, NULL}}; + + /* Render Preview Types */ + static EnumPropertyItem preview_type_items[] = { + {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Preview type: Flat XY plane"}, + {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Preview type: Sphere"}, + {MA_CUBE, "CUBE", ICON_MATCUBE, "Flat", "Preview type: Cube"}, + {MA_MONKEY, "MONKEY", ICON_MONKEY, "Flat", "Preview type: Monkey"}, + {MA_HAIR, "HAIR", ICON_HAIR, "Flat", "Preview type: Hair strands"}, + {MA_SPHERE_A, "SPHERE_A", ICON_MAT_SPHERE_SKY, "Flat", "Preview type: Large sphere with sky"}, + {0, NULL, 0, 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"); @@ -1509,6 +1519,13 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency"); RNA_def_property_update(prop, 0, "rna_Material_update"); + /* For Preview Render */ + prop= RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "pr_type"); + RNA_def_property_enum_items(prop, preview_type_items); + RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render"); + RNA_def_property_update(prop, 0, "rna_Material_update"); + prop= RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "amb"); RNA_def_property_range(prop, 0, 1); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 69d1884e756..ba91cdf690a 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1725,6 +1725,12 @@ static void rna_def_texture(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Factor Blue", ""); RNA_def_property_update(prop, 0, "rna_Texture_update"); + /* Alpha for preview render */ + prop= RNA_def_property(srna, "use_preview_alpha", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PRV_ALPHA); + RNA_def_property_ui_text(prop, "Show Alpha", "Show Alpha in Preview Render"); + RNA_def_property_update(prop, 0, "rna_Texture_update"); + /* nodetree */ prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); |