diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 371 |
1 files changed, 266 insertions, 105 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 8ebc3f03608..ccbabb2b238 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -64,7 +64,7 @@ #include "RE_render_ext.h" -EnumPropertyItem node_socket_in_out_items[] = { +EnumPropertyItem rna_enum_node_socket_in_out_items[] = { { SOCK_IN, "IN", 0, "Input", "" }, { SOCK_OUT, "OUT", 0, "Output", "" }, { 0, NULL, 0, NULL, NULL } @@ -104,14 +104,14 @@ static EnumPropertyItem node_chunksize_items[] = { #define DEF_ICON_BLANK_SKIP #define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""}, #define DEF_VICO(name) -EnumPropertyItem node_icon_items[] = { +EnumPropertyItem rna_enum_node_icon_items[] = { #include "UI_icons.h" {0, NULL, 0, NULL, NULL}}; #undef DEF_ICON_BLANK_SKIP #undef DEF_ICON #undef DEF_VICO -EnumPropertyItem node_math_items[] = { +EnumPropertyItem rna_enum_node_math_items[] = { {NODE_MATH_ADD, "ADD", 0, "Add", ""}, {NODE_MATH_SUB, "SUBTRACT", 0, "Subtract", ""}, {NODE_MATH_MUL, "MULTIPLY", 0, "Multiply", ""}, @@ -134,7 +134,7 @@ EnumPropertyItem node_math_items[] = { {0, NULL, 0, NULL, NULL} }; -EnumPropertyItem node_vec_math_items[] = { +EnumPropertyItem rna_enum_node_vec_math_items[] = { {0, "ADD", 0, "Add", ""}, {1, "SUBTRACT", 0, "Subtract", ""}, {2, "AVERAGE", 0, "Average", ""}, @@ -144,7 +144,7 @@ EnumPropertyItem node_vec_math_items[] = { {0, NULL, 0, NULL, NULL} }; -EnumPropertyItem node_filter_items[] = { +EnumPropertyItem rna_enum_node_filter_items[] = { {0, "SOFTEN", 0, "Soften", ""}, {1, "SHARPEN", 0, "Sharpen", ""}, {2, "LAPLACE", 0, "Laplace", ""}, @@ -657,11 +657,12 @@ static bool rna_NodeTree_check(bNodeTree *ntree, ReportList *reports) static void rna_NodeTree_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNode *node = (bNode *)ptr->data; WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); WM_main_add_notifier(NC_SCENE | ND_NODES, &ntree->id); - ED_node_tag_update_nodetree(bmain, ntree); + ED_node_tag_update_nodetree(bmain, ntree, node); } static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *reports, const char *type) @@ -1048,7 +1049,7 @@ static void rna_NodeTree_interface_update(bNodeTree *ntree, bContext *C) ntree->update |= NTREE_UPDATE_GROUP; ntreeUpdateTree(G.main, ntree); - ED_node_tag_update_nodetree(CTX_data_main(C), ntree); + ED_node_tag_update_nodetree(CTX_data_main(C), ntree, NULL); } @@ -1182,6 +1183,24 @@ static void rna_Node_update_reg(bNodeTree *ntree, bNode *node) RNA_parameter_list_free(&list); } +static void rna_Node_insert_link(bNodeTree *ntree, bNode *node, bNodeLink *link) +{ + extern FunctionRNA rna_Node_insert_link_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create((ID *)ntree, node->typeinfo->ext.srna, node, &ptr); + func = &rna_Node_insert_link_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "link", &link); + node->typeinfo->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + static void rna_Node_init(const bContext *C, PointerRNA *ptr) { extern FunctionRNA rna_Node_init_func; @@ -1331,7 +1350,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc PointerRNA dummyptr; FunctionRNA *func; PropertyRNA *parm; - int have_function[9]; + int have_function[10]; /* setup dummy node & node type to store static properties in */ memset(&dummynt, 0, sizeof(bNodeType)); @@ -1384,12 +1403,13 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc nt->poll = (have_function[0]) ? rna_Node_poll : NULL; nt->poll_instance = (have_function[1]) ? rna_Node_poll_instance : rna_Node_poll_instance_default; nt->updatefunc = (have_function[2]) ? rna_Node_update_reg : NULL; - nt->initfunc_api = (have_function[3]) ? rna_Node_init : NULL; - nt->copyfunc_api = (have_function[4]) ? rna_Node_copy : NULL; - nt->freefunc_api = (have_function[5]) ? rna_Node_free : NULL; - nt->draw_buttons = (have_function[6]) ? rna_Node_draw_buttons : NULL; - nt->draw_buttons_ex = (have_function[7]) ? rna_Node_draw_buttons_ext : NULL; - nt->labelfunc = (have_function[8]) ? rna_Node_draw_label : NULL; + nt->insert_link = (have_function[3]) ? rna_Node_insert_link : NULL; + nt->initfunc_api = (have_function[4]) ? rna_Node_init : NULL; + nt->copyfunc_api = (have_function[5]) ? rna_Node_copy : NULL; + nt->freefunc_api = (have_function[6]) ? rna_Node_free : NULL; + nt->draw_buttons = (have_function[7]) ? rna_Node_draw_buttons : NULL; + nt->draw_buttons_ex = (have_function[8]) ? rna_Node_draw_buttons_ext : NULL; + nt->labelfunc = (have_function[9]) ? rna_Node_draw_label : NULL; /* sanitize size values in case not all have been registered */ if (nt->maxwidth < nt->minwidth) @@ -1526,12 +1546,13 @@ static int rna_Node_parent_poll(PointerRNA *ptr, PointerRNA value) static void rna_Node_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; - ED_node_tag_update_nodetree(bmain, ntree); + bNode *node = (bNode *)ptr->data; + ED_node_tag_update_nodetree(bmain, ntree, node); } -static void rna_Node_socket_value_update(ID *id, bNode *UNUSED(node), bContext *C) +static void rna_Node_socket_value_update(ID *id, bNode *node, bContext *C) { - ED_node_tag_update_nodetree(CTX_data_main(C), (bNodeTree *)id); + ED_node_tag_update_nodetree(CTX_data_main(C), (bNodeTree *)id, node); } static void rna_Node_select_set(PointerRNA *ptr, int value) @@ -1897,7 +1918,11 @@ static PointerRNA rna_NodeSocket_node_get(PointerRNA *ptr) static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; - ED_node_tag_update_nodetree(bmain, ntree); + bNodeSocket *sock = (bNodeSocket *)ptr->data; + bNode *node; + if (nodeFindNode(ntree, sock, &node, NULL)) { + ED_node_tag_update_nodetree(bmain, ntree, node); + } } static int rna_NodeSocket_is_output_get(PointerRNA *ptr) @@ -2163,7 +2188,7 @@ static void rna_NodeSocketInterface_update(Main *bmain, Scene *UNUSED(scene), Po ntree->update |= NTREE_UPDATE_GROUP; ntreeUpdateTree(G.main, ntree); - ED_node_tag_update_nodetree(bmain, ntree); + ED_node_tag_update_nodetree(bmain, ntree, NULL); } @@ -2419,8 +2444,9 @@ static void rna_CompositorNode_tag_need_exec(bNode *node) static void rna_Node_tex_image_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNode *node = (bNode *)ptr->data; - ED_node_tag_update_nodetree(bmain, ntree); + ED_node_tag_update_nodetree(bmain, ntree, node); WM_main_add_notifier(NC_IMAGE, NULL); } @@ -2432,7 +2458,7 @@ static void rna_Node_material_update(Main *bmain, Scene *UNUSED(scene), PointerR if (node->id) nodeSetActive(ntree, node); - ED_node_tag_update_nodetree(bmain, ntree); + ED_node_tag_update_nodetree(bmain, ntree, node); } static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -2443,7 +2469,7 @@ static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * if (node->id) ntreeUpdateTree(bmain, (bNodeTree *)node->id); - ED_node_tag_update_nodetree(bmain, ntree); + ED_node_tag_update_nodetree(bmain, ntree, node); } static void rna_NodeGroup_node_tree_set(PointerRNA *ptr, const PointerRNA value) @@ -2887,7 +2913,7 @@ static void rna_ShaderNodeScript_mode_set(PointerRNA *ptr, int value) nss->filepath[0] = '\0'; nss->flag &= ~NODE_SCRIPT_AUTO_UPDATE; - /* replace text datablock by filepath */ + /* replace text data-block by filepath */ if (node->id) { Text *text = (Text *)node->id; @@ -2953,7 +2979,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p RE_engine_free(engine); } - ED_node_tag_update_nodetree(bmain, ntree); + ED_node_tag_update_nodetree(bmain, ntree, node); } static void rna_ShaderNodeSubsurface_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -3004,57 +3030,123 @@ static void rna_ShaderNodePointDensity_psys_set(PointerRNA *ptr, PointerRNA valu } } -static int point_density_color_source_from_shader(NodeShaderTexPointDensity *shader_point_density) +static int point_density_particle_color_source_from_shader(NodeShaderTexPointDensity *shader_point_density) { switch (shader_point_density->color_source) { - case SHD_POINTDENSITY_COLOR_PARTAGE: return TEX_PD_COLOR_PARTAGE; - case SHD_POINTDENSITY_COLOR_PARTSPEED: return TEX_PD_COLOR_PARTSPEED; - case SHD_POINTDENSITY_COLOR_PARTVEL: return TEX_PD_COLOR_PARTVEL; + case SHD_POINTDENSITY_COLOR_PARTAGE: + return TEX_PD_COLOR_PARTAGE; + case SHD_POINTDENSITY_COLOR_PARTSPEED: + return TEX_PD_COLOR_PARTSPEED; + case SHD_POINTDENSITY_COLOR_PARTVEL: + return TEX_PD_COLOR_PARTVEL; default: BLI_assert(!"Unknown color source"); return TEX_PD_COLOR_CONSTANT; } } -/* TODO(sergey): This function assumes allocated array was passed, - * works fine with Cycles via C++ RNA, but fails with call from python. - */ -void rna_ShaderNodePointDensity_density_calc(bNode *self, Scene *scene, int *length, float **values) +static int point_density_vertex_color_source_from_shader(NodeShaderTexPointDensity *shader_point_density) { - NodeShaderTexPointDensity *shader_point_density = self->storage; - PointDensity pd; - - *length = 4 * shader_point_density->resolution * - shader_point_density->resolution * - shader_point_density->resolution; + switch (shader_point_density->ob_color_source) { + case SHD_POINTDENSITY_COLOR_VERTCOL: + return TEX_PD_COLOR_VERTCOL; + case SHD_POINTDENSITY_COLOR_VERTWEIGHT: + return TEX_PD_COLOR_VERTWEIGHT; + case SHD_POINTDENSITY_COLOR_VERTNOR: + return TEX_PD_COLOR_VERTNOR; + default: + BLI_assert(!"Unknown color source"); + return TEX_PD_COLOR_CONSTANT; + } +} - if (*values == NULL) { - *values = MEM_mallocN(sizeof(float) * (*length), "point density dynamic array"); +void rna_ShaderNodePointDensity_density_cache(bNode *self, + Scene *scene, + int settings) +{ + NodeShaderTexPointDensity *shader_point_density = self->storage; + PointDensity *pd = &shader_point_density->pd; + if (scene == NULL) { + return; } + /* Make sure there's no cached data. */ + BKE_texture_pointdensity_free_data(pd); + RE_point_density_free(pd); + /* Create PointDensity structure from node for sampling. */ - BKE_texture_pointdensity_init_data(&pd); - pd.object = (Object *)self->id; - pd.radius = shader_point_density->radius; + BKE_texture_pointdensity_init_data(pd); + pd->object = (Object *)self->id; + pd->radius = shader_point_density->radius; if (shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_PSYS) { - pd.source = TEX_PD_PSYS; - pd.psys = shader_point_density->particle_system; - pd.psys_cache_space = TEX_PD_OBJECTSPACE; + pd->source = TEX_PD_PSYS; + pd->psys = shader_point_density->particle_system; + pd->psys_cache_space = TEX_PD_OBJECTSPACE; + pd->color_source = point_density_particle_color_source_from_shader(shader_point_density); } else { BLI_assert(shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_OBJECT); - pd.source = TEX_PD_OBJECT; - pd.ob_cache_space = TEX_PD_OBJECTSPACE; + pd->source = TEX_PD_OBJECT; + pd->ob_cache_space = TEX_PD_OBJECTSPACE; + pd->ob_color_source = point_density_vertex_color_source_from_shader(shader_point_density); + BLI_strncpy(pd->vertex_attribute_name, + shader_point_density->vertex_attribute_name, + sizeof(pd->vertex_attribute_name)); } - pd.color_source = point_density_color_source_from_shader(shader_point_density); /* Single-threaded sampling of the voxel domain. */ - RE_sample_point_density(scene, &pd, + RE_point_density_cache(scene, + pd, + settings == 1); +} + +void rna_ShaderNodePointDensity_density_calc(bNode *self, + Scene *scene, + int settings, + int *length, + float **values) +{ + NodeShaderTexPointDensity *shader_point_density = self->storage; + PointDensity *pd = &shader_point_density->pd; + + if (scene == NULL) { + *length = 0; + return; + } + + *length = 4 * shader_point_density->resolution * + shader_point_density->resolution * + shader_point_density->resolution; + + if (*values == NULL) { + *values = MEM_mallocN(sizeof(float) * (*length), "point density dynamic array"); + } + + /* Single-threaded sampling of the voxel domain. */ + RE_point_density_sample(scene, pd, shader_point_density->resolution, + settings == 1, *values); /* We're done, time to clean up. */ - BKE_texture_pointdensity_free_data(&pd); + BKE_texture_pointdensity_free_data(pd); + memset(pd, 0, sizeof(*pd)); +} + +void rna_ShaderNodePointDensity_density_minmax(bNode *self, + Scene *scene, + int settings, + float r_min[3], + float r_max[3]) +{ + NodeShaderTexPointDensity *shader_point_density = self->storage; + PointDensity *pd = &shader_point_density->pd; + if (scene == NULL) { + zero_v3(r_min); + zero_v3(r_max); + return; + } + RE_point_density_minmax(scene, pd, settings == 1, r_min, r_max); } #else @@ -3130,7 +3222,7 @@ static EnumPropertyItem node_hair_items[] = { }; static EnumPropertyItem node_script_mode_items[] = { - {NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text datablock"}, + {NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text data-block"}, {NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or .oso file"}, {0, NULL, 0, NULL, NULL} }; @@ -3227,7 +3319,7 @@ static void def_math(StructRNA *srna) prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, node_math_items); + RNA_def_property_enum_items(prop, rna_enum_node_math_items); RNA_def_property_ui_text(prop, "Operation", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -3243,7 +3335,7 @@ static void def_vector_math(StructRNA *srna) prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, node_vec_math_items); + RNA_def_property_enum_items(prop, rna_enum_node_vec_math_items); RNA_def_property_ui_text(prop, "Operation", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3308,7 +3400,7 @@ static void def_mix_rgb(StructRNA *srna) prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, ramp_blend_items); + RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items); RNA_def_property_ui_text(prop, "Blend Type", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -3543,17 +3635,29 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static const EnumPropertyItem sh_tex_prop_color_space_items[] = { + {SHD_COLORSPACE_COLOR, "COLOR", 0, "Color", + "Image contains color data, and will be converted to linear color for rendering"}, + {SHD_COLORSPACE_NONE, "NONE", 0, "Non-Color Data", + "Image contains non-color data, for example a displacement or normal map, " + "and will not be converted"}, + {0, NULL, 0, NULL, NULL} +}; + +static const EnumPropertyItem sh_tex_prop_interpolation_items[] = { + {SHD_INTERP_LINEAR, "Linear", 0, "Linear", + "Linear interpolation"}, + {SHD_INTERP_CLOSEST, "Closest", 0, "Closest", + "No interpolation (sample closest texel)"}, + {SHD_INTERP_CUBIC, "Cubic", 0, "Cubic", + "Cubic interpolation (CPU only)"}, + {SHD_INTERP_SMART, "Smart", 0, "Smart", + "Bicubic when magnifying, else bilinear (OSL only)"}, + {0, NULL, 0, NULL, NULL} +}; + static void def_sh_tex_environment(StructRNA *srna) { - static const EnumPropertyItem prop_color_space_items[] = { - {SHD_COLORSPACE_COLOR, "COLOR", 0, "Color", - "Image contains color data, and will be converted to linear color for rendering"}, - {SHD_COLORSPACE_NONE, "NONE", 0, "Non-Color Data", - "Image contains non-color data, for example a displacement or normal map, " - "and will not be converted"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem prop_projection_items[] = { {SHD_PROJ_EQUIRECTANGULAR, "EQUIRECTANGULAR", 0, "Equirectangular", "Equirectangular or latitude-longitude projection"}, @@ -3575,7 +3679,7 @@ static void def_sh_tex_environment(StructRNA *srna) def_sh_tex(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_items(prop, sh_tex_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"); @@ -3585,6 +3689,11 @@ static void def_sh_tex_environment(StructRNA *srna) RNA_def_property_ui_text(prop, "Projection", "Projection of the input image"); RNA_def_property_update(prop, 0, "rna_Node_update"); + prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, sh_tex_prop_interpolation_items); + RNA_def_property_ui_text(prop, "Interpolation", "Texture interpolation"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "iuser"); @@ -3595,15 +3704,6 @@ static void def_sh_tex_environment(StructRNA *srna) static void def_sh_tex_image(StructRNA *srna) { - static const EnumPropertyItem prop_color_space_items[] = { - {SHD_COLORSPACE_COLOR, "COLOR", 0, "Color", - "Image contains color data, and will be converted to linear color for rendering"}, - {SHD_COLORSPACE_NONE, "NONE", 0, "Non-Color Data", - "Image contains non-color data, for example a displacement or normal map, " - "and will not be converted"}, - {0, NULL, 0, NULL, NULL} - }; - static const EnumPropertyItem prop_projection_items[] = { {SHD_PROJ_FLAT, "FLAT", 0, "Flat", "Image is projected flat using the X and Y coordinates of the texture vector"}, @@ -3616,18 +3716,6 @@ static void def_sh_tex_image(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; - static const EnumPropertyItem prop_interpolation_items[] = { - {SHD_INTERP_LINEAR, "Linear", 0, "Linear", - "Linear interpolation"}, - {SHD_INTERP_CLOSEST, "Closest", 0, "Closest", - "No interpolation (sample closest texel)"}, - {SHD_INTERP_CUBIC, "Cubic", 0, "Cubic", - "Cubic interpolation (CPU only)"}, - {SHD_INTERP_SMART, "Smart", 0, "Smart", - "Bicubic when magnifying, else bilinear (OSL only)"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem prop_image_extension[] = { {SHD_IMAGE_EXTENSION_REPEAT, "REPEAT", 0, "Repeat", "Cause the image to repeat horizontally and vertically"}, {SHD_IMAGE_EXTENSION_EXTEND, "EXTEND", 0, "Extend", "Extend by repeating edge pixels of the image"}, @@ -3648,7 +3736,7 @@ static void def_sh_tex_image(StructRNA *srna) def_sh_tex(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_items(prop, sh_tex_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"); @@ -3659,7 +3747,7 @@ static void def_sh_tex_image(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Node_update"); prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_interpolation_items); + RNA_def_property_enum_items(prop, sh_tex_prop_interpolation_items); RNA_def_property_ui_text(prop, "Interpolation", "Texture interpolation"); RNA_def_property_update(prop, 0, "rna_Node_update"); @@ -3819,6 +3907,12 @@ static void def_sh_tex_wave(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem prop_wave_profile_items[] = { + {SHD_WAVE_PROFILE_SIN, "SIN", 0, "Sine", "Use a standard sine profile"}, + {SHD_WAVE_PROFILE_SAW, "SAW", 0, "Saw", "Use a sawtooth profile"}, + {0, NULL, 0, NULL, NULL} + }; + PropertyRNA *prop; RNA_def_struct_sdna_from(srna, "NodeTexWave", "storage"); @@ -3829,6 +3923,12 @@ static void def_sh_tex_wave(StructRNA *srna) RNA_def_property_enum_items(prop, prop_wave_type_items); RNA_def_property_ui_text(prop, "Wave Type", ""); RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "wave_profile", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "wave_profile"); + RNA_def_property_enum_items(prop, prop_wave_profile_items); + RNA_def_property_ui_text(prop, "Wave Profile", ""); + RNA_def_property_update(prop, 0, "rna_Node_update"); } static void def_sh_tex_coord(StructRNA *srna) @@ -3924,7 +4024,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem color_source_items[] = { + static EnumPropertyItem particle_color_source_items[] = { {SHD_POINTDENSITY_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age", "Lifetime mapped as 0.0 - 1.0 intensity"}, {SHD_POINTDENSITY_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed", @@ -3934,6 +4034,21 @@ static void def_sh_tex_pointdensity(StructRNA *srna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem vertex_color_source_items[] = { + {SHD_POINTDENSITY_COLOR_VERTCOL, "VERTEX_COLOR", 0, "Vertex Color", "Vertex color layer"}, + {SHD_POINTDENSITY_COLOR_VERTWEIGHT, "VERTEX_WEIGHT", 0, "Vertex Weight", "Vertex group weight"}, + {SHD_POINTDENSITY_COLOR_VERTNOR, "VERTEX_NORMAL", 0, "Vertex Normal", + "XYZ normal vector mapped to RGB colors"}, + {0, NULL, 0, NULL, NULL} + }; + + /* TODO(sergey): Use some mnemonic names for the hardcoded values here. */ + static EnumPropertyItem calc_mode_items[] = { + {0, "VIEWPORT", 0, "Viewport", "Canculate density using viewport settings"}, + {1, "RENDER", 0, "Render", "Canculate duplis using render settings"}, + {0, NULL, 0, NULL, NULL} + }; + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Object"); @@ -3977,19 +4092,48 @@ static void def_sh_tex_pointdensity(StructRNA *srna) RNA_def_property_ui_text(prop, "Interpolation", "Texture interpolation"); RNA_def_property_update(prop, 0, "rna_Node_update"); - prop = RNA_def_property(srna, "color_source", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "particle_color_source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "color_source"); - RNA_def_property_enum_items(prop, color_source_items); + RNA_def_property_enum_items(prop, particle_color_source_items); RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from"); RNA_def_property_update(prop, 0, "rna_Node_update"); + prop = RNA_def_property(srna, "vertex_color_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "ob_color_source"); + RNA_def_property_enum_items(prop, vertex_color_source_items); + RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "vertex_attribute_name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Vertex Attribute Name", "Vertex attribute to use for color"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + func = RNA_def_function(srna, "cache_point_density", "rna_ShaderNodePointDensity_density_cache"); + RNA_def_function_ui_description(func, "Cache point density data for later calculation"); + RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); + func = RNA_def_function(srna, "calc_point_density", "rna_ShaderNodePointDensity_density_calc"); RNA_def_function_ui_description(func, "Calculate point density"); RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); /* TODO, See how array size of 0 works, this shouldnt be used. */ prop = RNA_def_float_array(func, "rgba_values", 1, NULL, 0, 0, "", "RGBA Values", 0, 0); RNA_def_property_flag(prop, PROP_DYNAMIC); RNA_def_function_output(func, prop); + + func = RNA_def_function(srna, "calc_point_density_minmax", "rna_ShaderNodePointDensity_density_minmax"); + RNA_def_function_ui_description(func, "Calculate point density"); + RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); + prop = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS); + RNA_def_property_array(prop, 3); + RNA_def_property_flag(prop, PROP_THICK_WRAP); + RNA_def_function_output(func, prop); + prop = RNA_def_property(func, "max", PROP_FLOAT, PROP_COORDS); + RNA_def_property_array(prop, 3); + RNA_def_property_flag(prop, PROP_THICK_WRAP); + RNA_def_function_output(func, prop); } static void def_glossy(StructRNA *srna) @@ -4154,6 +4298,7 @@ static void def_sh_subsurface(StructRNA *srna) static EnumPropertyItem prop_subsurface_falloff_items[] = { {SHD_SUBSURFACE_CUBIC, "CUBIC", 0, "Cubic", "Simple cubic falloff function"}, {SHD_SUBSURFACE_GAUSSIAN, "GAUSSIAN", 0, "Gaussian", "Normal distribution, multiple can be combined to fit more complex profiles"}, + {SHD_SUBSURFACE_BURLEY, "BURLEY", 0, "Christensen-Burley", "Approximation to physically based volume scattering"}, {0, NULL, 0, NULL, NULL} }; @@ -4312,6 +4457,11 @@ static void def_cmp_blur(StructRNA *srna) RNA_def_property_ui_text(prop, "Variable Size", "Support variable blur per-pixel when using an image for size input"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "use_extended_bounds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_BLUR_EXTEND_BOUNDS); + RNA_def_property_ui_text(prop, "Extend Bounds", "Extend bounds of the input image to fully fit blurred image"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage"); prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE); @@ -4378,7 +4528,7 @@ static void def_cmp_filter(StructRNA *srna) prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, node_filter_items); + RNA_def_property_enum_items(prop, rna_enum_node_filter_items); RNA_def_property_ui_text(prop, "Filter Type", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -4772,7 +4922,7 @@ static void def_cmp_dilate_erode(StructRNA *srna) /* CMP_NODE_DILATEERODE_DISTANCE_FEATHER only */ prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "falloff"); - RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items); + RNA_def_property_enum_items(prop, rna_enum_proportional_falloff_curve_only_items); RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather"); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -5160,15 +5310,9 @@ static void def_cmp_splitviewer(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem axis_items[] = { - {0, "X", 0, "X", ""}, - {1, "Y", 0, "Y", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom2"); - RNA_def_property_enum_items(prop, axis_items); + RNA_def_property_enum_items(prop, rna_enum_axis_xy_items); RNA_def_property_ui_text(prop, "Axis", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -5817,6 +5961,11 @@ static void def_cmp_stabilize2d(StructRNA *srna) RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", CMP_NODEFLAG_STABILIZE_INVERSE); + RNA_def_property_ui_text(prop, "Invert", "Invert stabilization to re-introduce motion to the frame"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_cmp_moviedistortion(StructRNA *srna) @@ -6035,6 +6184,11 @@ static void def_cmp_bokehblur(StructRNA *srna) "Support variable blur per-pixel when using an image for size input"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "use_extended_bounds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_BLUR_EXTEND_BOUNDS); + RNA_def_property_ui_text(prop, "Extend Bounds", "Extend bounds of the input image to fully fit blurred image"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + #if 0 prop = RNA_def_property(srna, "f_stop", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "custom3"); @@ -6429,7 +6583,7 @@ static void def_cmp_keying(StructRNA *srna) prop = RNA_def_property(srna, "feather_falloff", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "feather_falloff"); - RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items); + RNA_def_property_enum_items(prop, rna_enum_proportional_falloff_curve_only_items); RNA_def_property_ui_text(prop, "Feather Falloff", "Falloff type the feather"); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -7610,7 +7764,7 @@ static void rna_def_node(BlenderRNA *brna) prop = RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typeinfo->ui_icon"); - RNA_def_property_enum_items(prop, node_icon_items); + RNA_def_property_enum_items(prop, rna_enum_node_icon_items); RNA_def_property_enum_default(prop, ICON_NODE); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_ui_text(prop, "Icon", "The node icon"); @@ -7668,6 +7822,13 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_function_ui_description(func, "Update on editor changes"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + /* insert_link */ + func = RNA_def_function(srna, "insert_link", NULL); + RNA_def_function_ui_description(func, "Handle creation of a link to or from the node"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + parm = RNA_def_pointer(func, "link", "NodeLink", "Link", "Node link that will be inserted"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + /* init */ func = RNA_def_function(srna, "init", NULL); RNA_def_function_ui_description(func, "Initialize a new instance of this node"); @@ -7934,7 +8095,7 @@ static void rna_def_nodetree(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "gpd"); RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); - RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); + RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil data-block"); RNA_def_property_update(prop, NC_NODE, NULL); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -7989,7 +8150,7 @@ static void rna_def_nodetree(BlenderRNA *brna) prop = RNA_def_property(srna, "bl_icon", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typeinfo->ui_icon"); - RNA_def_property_enum_items(prop, node_icon_items); + RNA_def_property_enum_items(prop, rna_enum_node_icon_items); RNA_def_property_enum_default(prop, ICON_NODETREE); RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_property_ui_text(prop, "Icon", "The node tree icon"); @@ -8072,7 +8233,7 @@ static void rna_def_shader_nodetree(BlenderRNA *brna) srna = RNA_def_struct(brna, "ShaderNodeTree", "NodeTree"); RNA_def_struct_ui_text(srna, "Shader Node Tree", - "Node tree consisting of linked nodes used for materials (and other shading datablocks)"); + "Node tree consisting of linked nodes used for materials (and other shading data-blocks)"); RNA_def_struct_sdna(srna, "bNodeTree"); RNA_def_struct_ui_icon(srna, ICON_MATERIAL); } |