diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 92 |
1 files changed, 67 insertions, 25 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index ccd16e16760..55ae7fdb6af 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -66,6 +66,8 @@ #include "NOD_composite.h" +#include "DEG_depsgraph.h" + const EnumPropertyItem rna_enum_node_socket_in_out_items[] = { { SOCK_IN, "IN", 0, "Input", "" }, { SOCK_OUT, "OUT", 0, "Output", "" }, @@ -187,6 +189,8 @@ static const EnumPropertyItem node_sampler_type_items[] = { #include "ED_node.h" #include "ED_render.h" +#include "GPU_material.h" + #include "NOD_common.h" #include "NOD_socket.h" @@ -2299,13 +2303,31 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo *softmax = dval->max; } +static void rna_NodeSocket_value_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNodeSocket *sock = ptr->data; + + if (ntree->type == NTREE_SHADER) { + DEG_id_tag_update_ex(bmain, &ntree->id, DEG_TAG_SHADING_UPDATE); + WM_main_add_notifier(NC_MATERIAL | ND_SHADING, NULL); + + if (sock->type == SOCK_STRING) { + rna_NodeSocket_update(bmain, scene, ptr); + } + } + else { + rna_NodeSocket_update(bmain, scene, ptr); + } +} + /* using a context update function here, to avoid searching the node if possible */ static void rna_NodeSocketStandard_value_update(struct bContext *C, PointerRNA *ptr) { bNode *node; /* default update */ - rna_NodeSocket_update(CTX_data_main(C), CTX_data_scene(C), ptr); + rna_NodeSocket_value_update(CTX_data_main(C), CTX_data_scene(C), ptr); /* try to use node from context, faster */ node = CTX_data_pointer_get(C, "node").data; @@ -2751,7 +2773,7 @@ static const EnumPropertyItem *rna_Node_image_view_itemf(bContext *UNUSED(C), Po return item; } -static const EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, +static const EnumPropertyItem *rna_Node_view_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { bNode *node = (bNode *)ptr->data; @@ -2764,7 +2786,7 @@ static const EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), P return DummyRNA_NULL_items; } - rl = sce->r.layers.first; + rl = sce->view_layers.first; item = renderresult_layers_add_enum(rl); *r_free = true; @@ -2772,7 +2794,7 @@ static const EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), P return item; } -static void rna_Node_scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Node_view_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) { rna_Node_update(bmain, scene, ptr); if (scene->nodetree != NULL) { @@ -3012,7 +3034,7 @@ static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *p { bNodeTree *ntree = (bNodeTree *)ptr->id.data; bNode *node = (bNode *)ptr->data; - RenderEngineType *engine_type = RE_engines_find(scene->r.engine); + RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id); if (engine_type && engine_type->update_script_node) { /* auto update node */ @@ -3112,15 +3134,22 @@ static int point_density_vertex_color_source_from_shader(NodeShaderTexPointDensi } void rna_ShaderNodePointDensity_density_cache(bNode *self, - Scene *scene, + Depsgraph *depsgraph, int settings) { NodeShaderTexPointDensity *shader_point_density = self->storage; PointDensity *pd = &shader_point_density->pd; - if (scene == NULL) { + + if (depsgraph == NULL) { return; } + EvaluationContext eval_ctx; + DEG_evaluation_context_init_from_depsgraph(&eval_ctx, + depsgraph, + settings == 1 ? DAG_EVAL_RENDER : + DAG_EVAL_VIEWPORT); + /* Make sure there's no cached data. */ BKE_texture_pointdensity_free_data(pd); RE_point_density_free(pd); @@ -3149,13 +3178,12 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self, shader_point_density->cached_resolution = shader_point_density->resolution; /* Single-threaded sampling of the voxel domain. */ - RE_point_density_cache(scene, - pd, - settings == 1); + RE_point_density_cache(&eval_ctx, + pd); } void rna_ShaderNodePointDensity_density_calc(bNode *self, - Scene *scene, + Depsgraph *depsgraph, int settings, int *length, float **values) @@ -3164,11 +3192,17 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, PointDensity *pd = &shader_point_density->pd; const int resolution = shader_point_density->cached_resolution; - if (scene == NULL) { + if (depsgraph == NULL) { *length = 0; return; } + EvaluationContext eval_ctx; + DEG_evaluation_context_init_from_depsgraph(&eval_ctx, + depsgraph, + settings == 1 ? DAG_EVAL_RENDER : + DAG_EVAL_VIEWPORT); + /* TODO(sergey): Will likely overflow, but how to pass size_t via RNA? */ *length = 4 * resolution * resolution * resolution; @@ -3177,9 +3211,9 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, } /* Single-threaded sampling of the voxel domain. */ - RE_point_density_sample(scene, pd, + RE_point_density_sample(&eval_ctx, + pd, resolution, - settings == 1, *values); /* We're done, time to clean up. */ @@ -3189,19 +3223,27 @@ void rna_ShaderNodePointDensity_density_calc(bNode *self, } void rna_ShaderNodePointDensity_density_minmax(bNode *self, - Scene *scene, + Depsgraph *depsgraph, 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) { + + if (depsgraph == NULL) { zero_v3(r_min); zero_v3(r_max); return; } - RE_point_density_minmax(scene, pd, settings == 1, r_min, r_max); + + EvaluationContext eval_ctx; + DEG_evaluation_context_init_from_depsgraph(&eval_ctx, + depsgraph, + settings == 1 ? DAG_EVAL_RENDER : + DAG_EVAL_VIEWPORT); + + RE_point_density_minmax(&eval_ctx, pd, r_min, r_max); } #else @@ -3216,7 +3258,7 @@ static const EnumPropertyItem prop_image_view_items[] = { {0, NULL, 0, NULL, NULL} }; -static const EnumPropertyItem prop_scene_layer_items[] = { +static const EnumPropertyItem prop_view_layer_items[] = { { 0, "PLACEHOLDER", 0, "Placeholder", ""}, {0, NULL, 0, NULL, NULL} }; @@ -4191,12 +4233,12 @@ static void def_sh_tex_pointdensity(StructRNA *srna) 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_pointer(func, "depsgraph", "Depsgraph", "", ""); 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_pointer(func, "depsgraph", "Depsgraph", "", ""); 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. */ parm = RNA_def_float_array(func, "rgba_values", 1, NULL, 0, 0, "", "RGBA Values", 0, 0); @@ -4205,7 +4247,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna) 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_pointer(func, "depsgraph", "Depsgraph", "", ""); RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS); RNA_def_property_array(parm, 3); @@ -4888,15 +4930,15 @@ static void def_cmp_render_layers(StructRNA *srna) RNA_def_property_struct_type(prop, "Scene"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Scene", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_scene_layer_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_view_layer_update"); prop = RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, prop_scene_layer_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_scene_layer_itemf"); + RNA_def_property_enum_items(prop, prop_view_layer_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_view_layer_itemf"); 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_scene_layer_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_view_layer_update"); } static void rna_def_cmp_output_file_slot_file(BlenderRNA *brna) |