From c9795eae45c278460e27ae7f5937ca9bd1300531 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Tue, 18 Aug 2009 19:58:27 +0000 Subject: Fixed the texture preview to work with multi-output node-based textures. --- source/blender/makesrna/intern/rna_texture.c | 32 +++++++++++++++++++++++----- source/blender/makesrna/intern/rna_ui_api.c | 1 + 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 76cb9986306..a5737536b7d 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -110,6 +110,30 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) strcpy(str, ""); } +static int rna_TextureSlot_output_node_get(PointerRNA *ptr) +{ + MTex *mtex= ptr->data; + Tex *tex= mtex->tex; + int cur= mtex->which_output; + + if(tex) { + bNodeTree *ntree= tex->nodetree; + bNode *node; + if(ntree) { + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == TEX_NODE_OUTPUT) { + if(cur == node->custom1) + return cur; + } + } + } + } + + mtex->which_output= 0; + return 0; +} + + static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerRNA *ptr, int *free) { MTex *mtex= ptr->data; @@ -117,11 +141,9 @@ static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerR EnumPropertyItem *item= NULL; int totitem= 0; - if(tex) - { + if(tex) { bNodeTree *ntree= tex->nodetree; - if(ntree) - { + if(ntree) { EnumPropertyItem tmp= {0, "", 0, "", ""}; bNode *node; @@ -433,7 +455,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop= RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "which_output"); RNA_def_property_enum_items(prop, output_node_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_TextureSlot_output_node_itemf"); + RNA_def_property_enum_funcs(prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf"); RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures."); RNA_def_property_update(prop, NC_TEXTURE, NULL); } diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index f9287bddc10..82694098e69 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -244,6 +244,7 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "parent", "ID", "", "ID datablock."); + parm= RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot."); func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer."); -- cgit v1.2.3