Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_nodetree.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2,761 Lines • ▼ Show 20 Lines | static const EnumPropertyItem *rna_Node_image_view_itemf(bContext *UNUSED(C), PointerRNA *ptr, | ||||
| rv = ima->rr->views.first; | rv = ima->rr->views.first; | ||||
| item = renderresult_views_add_enum(rv); | item = renderresult_views_add_enum(rv); | ||||
| *r_free = true; | *r_free = true; | ||||
| return item; | 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) | PropertyRNA *UNUSED(prop), bool *r_free) | ||||
| { | { | ||||
| bNode *node = (bNode *)ptr->data; | bNode *node = (bNode *)ptr->data; | ||||
| Scene *sce = (Scene *)node->id; | Scene *sce = (Scene *)node->id; | ||||
| const EnumPropertyItem *item = NULL; | const EnumPropertyItem *item = NULL; | ||||
| RenderLayer *rl; | RenderLayer *rl; | ||||
| if (sce == NULL) { | if (sce == NULL) { | ||||
| *r_free = false; | *r_free = false; | ||||
| return DummyRNA_NULL_items; | return DummyRNA_NULL_items; | ||||
| } | } | ||||
| rl = sce->render_layers.first; | rl = sce->view_layers.first; | ||||
| item = renderresult_layers_add_enum(rl); | item = renderresult_layers_add_enum(rl); | ||||
| *r_free = true; | *r_free = true; | ||||
| return item; | 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); | rna_Node_update(bmain, scene, ptr); | ||||
| if (scene->nodetree != NULL) { | if (scene->nodetree != NULL) { | ||||
| ntreeCompositUpdateRLayers(scene->nodetree); | ntreeCompositUpdateRLayers(scene->nodetree); | ||||
| } | } | ||||
| } | } | ||||
| static const EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA *ptr, | static const EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA *ptr, | ||||
| ▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | switch (shader_point_density->ob_color_source) { | ||||
| default: | default: | ||||
| BLI_assert(!"Unknown color source"); | BLI_assert(!"Unknown color source"); | ||||
| return TEX_PD_COLOR_CONSTANT; | return TEX_PD_COLOR_CONSTANT; | ||||
| } | } | ||||
| } | } | ||||
| void rna_ShaderNodePointDensity_density_cache(bNode *self, | void rna_ShaderNodePointDensity_density_cache(bNode *self, | ||||
| Scene *scene, | Scene *scene, | ||||
| SceneLayer *scene_layer, | ViewLayer *view_layer, | ||||
| int settings) | int settings) | ||||
| { | { | ||||
| NodeShaderTexPointDensity *shader_point_density = self->storage; | NodeShaderTexPointDensity *shader_point_density = self->storage; | ||||
| PointDensity *pd = &shader_point_density->pd; | PointDensity *pd = &shader_point_density->pd; | ||||
| if (scene == NULL) { | if (scene == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 21 Lines | BLI_strncpy(pd->vertex_attribute_name, | ||||
| sizeof(pd->vertex_attribute_name)); | sizeof(pd->vertex_attribute_name)); | ||||
| } | } | ||||
| /* Store resolution, so it can be changed in the UI. */ | /* Store resolution, so it can be changed in the UI. */ | ||||
| shader_point_density->cached_resolution = shader_point_density->resolution; | shader_point_density->cached_resolution = shader_point_density->resolution; | ||||
| /* Single-threaded sampling of the voxel domain. */ | /* Single-threaded sampling of the voxel domain. */ | ||||
| RE_point_density_cache(scene, | RE_point_density_cache(scene, | ||||
| scene_layer, pd, | view_layer, pd, | ||||
| settings == 1); | settings == 1); | ||||
| } | } | ||||
| void rna_ShaderNodePointDensity_density_calc(bNode *self, | void rna_ShaderNodePointDensity_density_calc(bNode *self, | ||||
| Scene *scene, | Scene *scene, | ||||
| SceneLayer *scene_layer, | ViewLayer *view_layer, | ||||
| int settings, | int settings, | ||||
| int *length, | int *length, | ||||
| float **values) | float **values) | ||||
| { | { | ||||
| NodeShaderTexPointDensity *shader_point_density = self->storage; | NodeShaderTexPointDensity *shader_point_density = self->storage; | ||||
| PointDensity *pd = &shader_point_density->pd; | PointDensity *pd = &shader_point_density->pd; | ||||
| const int resolution = shader_point_density->cached_resolution; | const int resolution = shader_point_density->cached_resolution; | ||||
| if (scene == NULL) { | if (scene == NULL) { | ||||
| *length = 0; | *length = 0; | ||||
| return; | return; | ||||
| } | } | ||||
| /* TODO(sergey): Will likely overflow, but how to pass size_t via RNA? */ | /* TODO(sergey): Will likely overflow, but how to pass size_t via RNA? */ | ||||
| *length = 4 * resolution * resolution * resolution; | *length = 4 * resolution * resolution * resolution; | ||||
| if (*values == NULL) { | if (*values == NULL) { | ||||
| *values = MEM_mallocN(sizeof(float) * (*length), "point density dynamic array"); | *values = MEM_mallocN(sizeof(float) * (*length), "point density dynamic array"); | ||||
| } | } | ||||
| /* Single-threaded sampling of the voxel domain. */ | /* Single-threaded sampling of the voxel domain. */ | ||||
| RE_point_density_sample(scene, scene_layer, pd, | RE_point_density_sample(scene, view_layer, pd, | ||||
| resolution, | resolution, | ||||
| settings == 1, | settings == 1, | ||||
| *values); | *values); | ||||
| /* We're done, time to clean up. */ | /* We're done, time to clean up. */ | ||||
| BKE_texture_pointdensity_free_data(pd); | BKE_texture_pointdensity_free_data(pd); | ||||
| memset(pd, 0, sizeof(*pd)); | memset(pd, 0, sizeof(*pd)); | ||||
| shader_point_density->cached_resolution = 0.0f; | shader_point_density->cached_resolution = 0.0f; | ||||
| } | } | ||||
| void rna_ShaderNodePointDensity_density_minmax(bNode *self, | void rna_ShaderNodePointDensity_density_minmax(bNode *self, | ||||
| Scene *scene, | Scene *scene, | ||||
| SceneLayer *scene_layer, | ViewLayer *view_layer, | ||||
| int settings, | int settings, | ||||
| float r_min[3], | float r_min[3], | ||||
| float r_max[3]) | float r_max[3]) | ||||
| { | { | ||||
| NodeShaderTexPointDensity *shader_point_density = self->storage; | NodeShaderTexPointDensity *shader_point_density = self->storage; | ||||
| PointDensity *pd = &shader_point_density->pd; | PointDensity *pd = &shader_point_density->pd; | ||||
| if (scene == NULL) { | if (scene == NULL) { | ||||
| zero_v3(r_min); | zero_v3(r_min); | ||||
| zero_v3(r_max); | zero_v3(r_max); | ||||
| return; | return; | ||||
| } | } | ||||
| RE_point_density_minmax(scene, scene_layer, pd, settings == 1, r_min, r_max); | RE_point_density_minmax(scene, view_layer, pd, settings == 1, r_min, r_max); | ||||
| } | } | ||||
| #else | #else | ||||
| static const EnumPropertyItem prop_image_layer_items[] = { | static const EnumPropertyItem prop_image_layer_items[] = { | ||||
| { 0, "PLACEHOLDER", 0, "Placeholder", ""}, | { 0, "PLACEHOLDER", 0, "Placeholder", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static const EnumPropertyItem prop_image_view_items[] = { | static const EnumPropertyItem prop_image_view_items[] = { | ||||
| { 0, "ALL", 0, "All", ""}, | { 0, "ALL", 0, "All", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static const EnumPropertyItem prop_scene_layer_items[] = { | static const EnumPropertyItem prop_view_layer_items[] = { | ||||
| { 0, "PLACEHOLDER", 0, "Placeholder", ""}, | { 0, "PLACEHOLDER", 0, "Placeholder", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static const EnumPropertyItem prop_tri_channel_items[] = { | static const EnumPropertyItem prop_tri_channel_items[] = { | ||||
| { 1, "R", 0, "R", ""}, | { 1, "R", 0, "R", ""}, | ||||
| { 2, "G", 0, "G", ""}, | { 2, "G", 0, "G", ""}, | ||||
| { 3, "B", 0, "B", ""}, | { 3, "B", 0, "B", ""}, | ||||
| ▲ Show 20 Lines • Show All 952 Lines • ▼ Show 20 Lines | static void def_sh_tex_pointdensity(StructRNA *srna) | ||||
| prop = RNA_def_property(srna, "vertex_attribute_name", PROP_STRING, PROP_NONE); | 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_ui_text(prop, "Vertex Attribute Name", "Vertex attribute to use for color"); | ||||
| RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | ||||
| func = RNA_def_function(srna, "cache_point_density", "rna_ShaderNodePointDensity_density_cache"); | 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_function_ui_description(func, "Cache point density data for later calculation"); | ||||
| RNA_def_pointer(func, "scene", "Scene", "", ""); | RNA_def_pointer(func, "scene", "Scene", "", ""); | ||||
| RNA_def_pointer(func, "scene_layer", "SceneLayer", "", ""); | RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); | ||||
| RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); | 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"); | func = RNA_def_function(srna, "calc_point_density", "rna_ShaderNodePointDensity_density_calc"); | ||||
| RNA_def_function_ui_description(func, "Calculate point density"); | RNA_def_function_ui_description(func, "Calculate point density"); | ||||
| RNA_def_pointer(func, "scene", "Scene", "", ""); | RNA_def_pointer(func, "scene", "Scene", "", ""); | ||||
| RNA_def_pointer(func, "scene_layer", "SceneLayer", "", ""); | RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); | ||||
| RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); | 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. */ | /* 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); | parm = RNA_def_float_array(func, "rgba_values", 1, NULL, 0, 0, "", "RGBA Values", 0, 0); | ||||
| RNA_def_parameter_flags(parm, PROP_DYNAMIC, 0); | RNA_def_parameter_flags(parm, PROP_DYNAMIC, 0); | ||||
| RNA_def_function_output(func, parm); | RNA_def_function_output(func, parm); | ||||
| func = RNA_def_function(srna, "calc_point_density_minmax", "rna_ShaderNodePointDensity_density_minmax"); | func = RNA_def_function(srna, "calc_point_density_minmax", "rna_ShaderNodePointDensity_density_minmax"); | ||||
| RNA_def_function_ui_description(func, "Calculate point density"); | RNA_def_function_ui_description(func, "Calculate point density"); | ||||
| RNA_def_pointer(func, "scene", "Scene", "", ""); | RNA_def_pointer(func, "scene", "Scene", "", ""); | ||||
| RNA_def_pointer(func, "scene_layer", "SceneLayer", "", ""); | RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); | ||||
| RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); | RNA_def_enum(func, "settings", calc_mode_items, 1, "", "Calculate density for rendering"); | ||||
| parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS); | parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_COORDS); | ||||
| RNA_def_property_array(parm, 3); | RNA_def_property_array(parm, 3); | ||||
| RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); | RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); | ||||
| RNA_def_function_output(func, parm); | RNA_def_function_output(func, parm); | ||||
| parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_COORDS); | parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_COORDS); | ||||
| RNA_def_property_array(parm, 3); | RNA_def_property_array(parm, 3); | ||||
| RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); | RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); | ||||
| ▲ Show 20 Lines • Show All 620 Lines • ▼ Show 20 Lines | static void def_cmp_render_layers(StructRNA *srna) | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_pointer_sdna(prop, NULL, "id"); | RNA_def_property_pointer_sdna(prop, NULL, "id"); | ||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL); | RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL); | ||||
| RNA_def_property_struct_type(prop, "Scene"); | RNA_def_property_struct_type(prop, "Scene"); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); | RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); | ||||
| RNA_def_property_ui_text(prop, "Scene", ""); | 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); | prop = RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "custom1"); | RNA_def_property_enum_sdna(prop, NULL, "custom1"); | ||||
| RNA_def_property_enum_items(prop, prop_scene_layer_items); | RNA_def_property_enum_items(prop, prop_view_layer_items); | ||||
| RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_scene_layer_itemf"); | 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_flag(prop, PROP_ENUM_NO_TRANSLATE); | ||||
| RNA_def_property_ui_text(prop, "Layer", ""); | 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) | static void rna_def_cmp_output_file_slot_file(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "NodeOutputFileSlotFile", NULL); | srna = RNA_def_struct(brna, "NodeOutputFileSlotFile", NULL); | ||||
| ▲ Show 20 Lines • Show All 3,616 Lines • Show Last 20 Lines | |||||