2.5 Preview Render:
authorThomas Dinges <blender@dingto.org>
Sun, 4 Apr 2010 12:09:59 +0000 (12:09 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 4 Apr 2010 12:09:59 +0000 (12:09 +0000)
* Converted Type Buttons (Flat, Cube, Monkey etc.) in Material Preview to RNA.
* "Alpha" option in texture Preview Render is back!

source/blender/editors/interface/interface_templates.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_texture.c

index 2bbabf66ffe940a94c233f3b1a155a3a55117897..200ef1fa501f2a69d52ba358355b4c68965e0033 100644 (file)
@@ -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);
+                       }
                }
        }
 }
index b6a6f072c6ba33b592aecbd19a3fe831633cd204..4d47737038a657905dc60a0ed4552d247393266c 100644 (file)
@@ -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);
index 69d1884e75628e29a58ea428aa9082a900c2b0e6..ba91cdf690aad011f3f3e8b6031e40d1ca3cf210 100644 (file)
@@ -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);