diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 127 |
1 files changed, 115 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index eb2cb9e9312..4df954b062b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -30,7 +30,6 @@ #include "BLI_listbase.h" #include "BLI_math.h" -#include "BLI_string.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -39,7 +38,6 @@ #include "DNA_mesh_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" @@ -48,7 +46,6 @@ #include "BKE_node.h" #include "BKE_image.h" #include "BKE_texture.h" -#include "BKE_idprop.h" #include "RNA_access.h" #include "RNA_define.h" @@ -1549,7 +1546,7 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value) nodeUniqueName(ntree, node); /* fix all the animation data which may link to this */ - BKE_all_animdata_fix_paths_rename(NULL, "nodes", oldname, node->name); + BKE_animdata_fix_paths_rename_all(NULL, "nodes", oldname, node->name); } static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, ReportList *reports, const char *type, const char *name, const char *identifier) @@ -1578,7 +1575,7 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, ReportList *report sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name); if (sock == NULL) { - BKE_reportf(reports, RPT_ERROR, "Unable to create socket"); + BKE_report(reports, RPT_ERROR, "Unable to create socket"); } else { ntreeUpdateTree(G.main, ntree); @@ -2258,8 +2255,13 @@ static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA * nodeFindNode(ntree, sock, &node, NULL); } - if (node) + if (node) { nodeSynchronizeID(node, true); + + /* extra update for sockets that get synced to material */ + if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) + WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, node->id); + } } @@ -2616,6 +2618,70 @@ static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *UNUSED(C), Pointer return item; } +static int rna_Node_image_has_layers_get(PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + Image *ima = (Image *)node->id; + + if (!ima || !(ima->rr)) return 0; + + return RE_layers_have_name(ima->rr); +} + +static int rna_Node_image_has_views_get(PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + Image *ima = (Image *)node->id; + + if (!ima || !(ima->rr)) return 0; + + return BLI_listbase_count_ex(&ima->rr->views, 2) > 1; +} + +static EnumPropertyItem *renderresult_views_add_enum(RenderView *rv) +{ + EnumPropertyItem *item = NULL; + EnumPropertyItem tmp = {0, "ALL", 0, "All", ""}; + int i = 1, totitem = 0; + + /* option to use all views */ + RNA_enum_item_add(&item, &totitem, &tmp); + + while (rv) { + tmp.identifier = rv->name; + /* little trick: using space char instead empty string makes the item selectable in the dropdown */ + if (rv->name[0] == '\0') + tmp.name = " "; + else + tmp.name = rv->name; + tmp.value = i++; + RNA_enum_item_add(&item, &totitem, &tmp); + rv = rv->next; + } + + RNA_enum_item_end(&item, &totitem); + + return item; +} + +static EnumPropertyItem *rna_Node_image_view_itemf(bContext *UNUSED(C), PointerRNA *ptr, + PropertyRNA *UNUSED(prop), bool *free) +{ + bNode *node = (bNode *)ptr->data; + Image *ima = (Image *)node->id; + EnumPropertyItem *item = NULL; + RenderView *rv; + + if (!ima || !(ima->rr)) return NULL; + + rv = ima->rr->views.first; + item = renderresult_views_add_enum(rv); + + *free = true; + + return item; +} + static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { @@ -2701,7 +2767,7 @@ static void rna_Image_Node_update_id(Main *UNUSED(bmain), Scene *UNUSED(scene), static void rna_Mapping_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr) { bNode *node = ptr->data; - init_tex_mapping(node->storage); + BKE_texture_mapping_init(node->storage); rna_Node_update(bmain, scene, ptr); } @@ -2907,6 +2973,11 @@ static EnumPropertyItem prop_image_layer_items[] = { {0, NULL, 0, NULL, NULL} }; +static EnumPropertyItem prop_image_view_items[] = { + { 0, "ALL", 0, "All", ""}, + {0, NULL, 0, NULL, NULL} +}; + static EnumPropertyItem prop_scene_layer_items[] = { { 0, "PLACEHOLDER", 0, "Placeholder", ""}, {0, NULL, 0, NULL, NULL} @@ -3234,6 +3305,8 @@ static void def_sh_mapping(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; + static float default_1[3] = {1.f, 1.f, 1.f}; + PropertyRNA *prop; RNA_def_struct_sdna_from(srna, "TexMapping", "storage"); @@ -3257,6 +3330,7 @@ static void def_sh_mapping(StructRNA *srna) prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); + RNA_def_property_float_array_default(prop, default_1); RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_ui_text(prop, "Scale", ""); RNA_def_property_update(prop, 0, "rna_Mapping_Node_update"); @@ -3268,6 +3342,7 @@ static void def_sh_mapping(StructRNA *srna) prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "max"); + RNA_def_property_float_array_default(prop, default_1); RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping"); RNA_def_property_update(prop, 0, "rna_Mapping_Node_update"); @@ -3410,6 +3485,7 @@ static void def_sh_tex_environment(StructRNA *srna) prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_color_space_items); + RNA_def_property_enum_default(prop, SHD_COLORSPACE_COLOR); RNA_def_property_ui_text(prop, "Color Space", "Image file color space"); RNA_def_property_update(prop, 0, "rna_Node_update"); @@ -3475,6 +3551,7 @@ static void def_sh_tex_image(StructRNA *srna) prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_color_space_items); + RNA_def_property_enum_default(prop, SHD_COLORSPACE_COLOR); RNA_def_property_ui_text(prop, "Color Space", "Image file color space"); RNA_def_property_update(prop, 0, "rna_Node_update"); @@ -4263,6 +4340,24 @@ static void def_node_image_user(StructRNA *srna) RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); RNA_def_property_ui_text(prop, "Layer", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_image_layer_update"); + + prop = RNA_def_property(srna, "has_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Node_image_has_layers_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has Layers", "True if this image has any named layer"); + + prop = RNA_def_property(srna, "view", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "view"); + RNA_def_property_enum_items(prop, prop_image_view_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_image_view_itemf"); + RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); + RNA_def_property_ui_text(prop, "View", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "has_views", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Node_image_has_views_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has View", "True if this image has multiple views"); } static void def_cmp_image(StructRNA *srna) @@ -5811,6 +5906,16 @@ static void def_cmp_switch(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_cmp_switch_view(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "check", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0); + RNA_def_property_ui_text(prop, "Switch", "Off: first socket, On: second socket"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + static void def_cmp_colorcorrection(StructRNA *srna) { PropertyRNA *prop; @@ -6294,14 +6399,12 @@ static void def_tex_image(StructRNA *srna) RNA_def_property_ui_text(prop, "Image", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - /* is this supposed to be exposed? not sure.. */ -#if 0 - prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "storage"); RNA_def_property_struct_type(prop, "ImageUser"); - RNA_def_property_ui_text(prop, "Settings", ""); + RNA_def_property_ui_text(prop, "Image User", + "Parameters defining the image duration, offset and related settings"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -#endif } static void def_tex_bricks(StructRNA *srna) |