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 95 Lines • ▼ Show 20 Lines | static const EnumPropertyItem particle_attribute_socket_type_items[] = { | ||||
| {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, | {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, | ||||
| {SOCK_VECTOR, "VECTOR", 0, "Vector", ""}, | {SOCK_VECTOR, "VECTOR", 0, "Vector", ""}, | ||||
| {SOCK_RGBA, "RGBA", 0, "Color", ""}, | {SOCK_RGBA, "RGBA", 0, "Color", ""}, | ||||
| {SOCK_OBJECT, "OBJECT", 0, "Object", ""}, | {SOCK_OBJECT, "OBJECT", 0, "Object", ""}, | ||||
| {SOCK_IMAGE, "IMAGE", 0, "Image", ""}, | {SOCK_IMAGE, "IMAGE", 0, "Image", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static const EnumPropertyItem node_socket_data_type_items[] = { | |||||
| {SOCK_FLOAT, "FLOAT", 0, "Float", ""}, | |||||
| {SOCK_INT, "INT", 0, "Int", ""}, | |||||
| {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, | |||||
| {SOCK_VECTOR, "VECTOR", 0, "Vector", ""}, | |||||
| {SOCK_STRING, "STRING", 0, "String", ""}, | |||||
| {SOCK_RGBA, "RGBA", 0, "Color", ""}, | |||||
| {SOCK_OBJECT, "OBJECT", 0, "Object", ""}, | |||||
| {SOCK_IMAGE, "IMAGE", 0, "Image", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| static const EnumPropertyItem node_quality_items[] = { | static const EnumPropertyItem node_quality_items[] = { | ||||
| {NTREE_QUALITY_HIGH, "HIGH", 0, "High", "High quality"}, | {NTREE_QUALITY_HIGH, "HIGH", 0, "High", "High quality"}, | ||||
| {NTREE_QUALITY_MEDIUM, "MEDIUM", 0, "Medium", "Medium quality"}, | {NTREE_QUALITY_MEDIUM, "MEDIUM", 0, "Medium", "Medium quality"}, | ||||
| {NTREE_QUALITY_LOW, "LOW", 0, "Low", "Low quality"}, | {NTREE_QUALITY_LOW, "LOW", 0, "Low", "Low quality"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static const EnumPropertyItem node_chunksize_items[] = { | static const EnumPropertyItem node_chunksize_items[] = { | ||||
| ▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | const EnumPropertyItem rna_enum_node_vec_math_items[] = { | ||||
| "Round A to the largest integer multiple of B less than or equal A"}, | "Round A to the largest integer multiple of B less than or equal A"}, | ||||
| {0, "", ICON_NONE, NULL, NULL}, | {0, "", ICON_NONE, NULL, NULL}, | ||||
| {NODE_VECTOR_MATH_SINE, "SINE", 0, "Sine", "Entry-wise sin(A)"}, | {NODE_VECTOR_MATH_SINE, "SINE", 0, "Sine", "Entry-wise sin(A)"}, | ||||
| {NODE_VECTOR_MATH_COSINE, "COSINE", 0, "Cosine", "Entry-wise cos(A)"}, | {NODE_VECTOR_MATH_COSINE, "COSINE", 0, "Cosine", "Entry-wise cos(A)"}, | ||||
| {NODE_VECTOR_MATH_TANGENT, "TANGENT", 0, "Tangent", "Entry-wise tan(A)"}, | {NODE_VECTOR_MATH_TANGENT, "TANGENT", 0, "Tangent", "Entry-wise tan(A)"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| const EnumPropertyItem rna_enum_node_boolean_math_items[] = { | |||||
| {NODE_BOOLEAN_MATH_AND, "AND", 0, "And", "Outputs true only when both inputs are true"}, | |||||
| {NODE_BOOLEAN_MATH_OR, "OR", 0, "Or", "Outputs or when at least one of the inputs is true"}, | |||||
| {NODE_BOOLEAN_MATH_NOT, "NOT", 0, "Not", "Outputs the opposite of the input"}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| const EnumPropertyItem rna_enum_node_float_compare_items[] = { | |||||
| {NODE_FLOAT_COMPARE_LESS_THAN, | |||||
| "LESS_THAN", | |||||
| 0, | |||||
| "A < B", | |||||
| "True when the first input is smaller than second input"}, | |||||
| {NODE_FLOAT_COMPARE_LESS_EQUAL, | |||||
| "LESS_EQUAL", | |||||
| 0, | |||||
| "A <= B", | |||||
| "True when the first input is smaller than the second input or equal"}, | |||||
| {NODE_FLOAT_COMPARE_GREATER_THAN, | |||||
| "GREATER_THAN", | |||||
| 0, | |||||
| "A > B", | |||||
| "True when the first input is greater than the second input"}, | |||||
| {NODE_FLOAT_COMPARE_GREATER_EQUAL, | |||||
| "GREATER_EQUAL", | |||||
| 0, | |||||
| "A >= B", | |||||
| "True when the first input is greater than the second input or equal"}, | |||||
| {NODE_FLOAT_COMPARE_EQUAL, | |||||
| "EQUAL", | |||||
| 0, | |||||
| "A = B", | |||||
| "True when both inputs are approximately equal"}, | |||||
| {NODE_FLOAT_COMPARE_NOT_EQUAL, | |||||
| "NOT_EQUAL", | |||||
| 0, | |||||
| "A != B", | |||||
| "True when both inputs are not approximately equal"}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| const EnumPropertyItem rna_enum_node_map_range_items[] = { | const EnumPropertyItem rna_enum_node_map_range_items[] = { | ||||
| {NODE_MAP_RANGE_LINEAR, | {NODE_MAP_RANGE_LINEAR, | ||||
| "LINEAR", | "LINEAR", | ||||
| 0, | 0, | ||||
| "Linear", | "Linear", | ||||
| "Linear interpolation between From Min and From Max values"}, | "Linear interpolation between From Min and From Max values"}, | ||||
| {NODE_MAP_RANGE_STEPPED, | {NODE_MAP_RANGE_STEPPED, | ||||
| "STEPPED", | "STEPPED", | ||||
| ▲ Show 20 Lines • Show All 423 Lines • ▼ Show 20 Lines | if (STREQ(#Category, "SimulationNode")) { \ | ||||
| tmp.description = UIDesc; \ | tmp.description = UIDesc; \ | ||||
| tmp.icon = ICON_NONE; \ | tmp.icon = ICON_NONE; \ | ||||
| RNA_enum_item_add(&item, &totitem, &tmp); \ | RNA_enum_item_add(&item, &totitem, &tmp); \ | ||||
| } | } | ||||
| # include "../../nodes/NOD_static_types.h" | # include "../../nodes/NOD_static_types.h" | ||||
| # undef DefNode | # undef DefNode | ||||
| } | } | ||||
| if (RNA_struct_is_a(ptr->type, &RNA_FunctionNode)) { | |||||
| # define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ | |||||
| if (STREQ(#Category, "FunctionNode")) { \ | |||||
| tmp.value = ID; \ | |||||
| tmp.identifier = EnumName; \ | |||||
| tmp.name = UIName; \ | |||||
| tmp.description = UIDesc; \ | |||||
| tmp.icon = ICON_NONE; \ | |||||
| RNA_enum_item_add(&item, &totitem, &tmp); \ | |||||
| } | |||||
| # include "../../nodes/NOD_static_types.h" | |||||
| # undef DefNode | |||||
| } | |||||
| RNA_enum_item_end(&item, &totitem); | RNA_enum_item_end(&item, &totitem); | ||||
| *r_free = true; | *r_free = true; | ||||
| return item; | return item; | ||||
| } | } | ||||
| /* ******** Node Tree ******** */ | /* ******** Node Tree ******** */ | ||||
| ▲ Show 20 Lines • Show All 1,122 Lines • ▼ Show 20 Lines | static StructRNA *rna_SimulationNode_register(Main *bmain, | ||||
| nodeRegisterType(nt); | nodeRegisterType(nt); | ||||
| /* update while blender is running */ | /* update while blender is running */ | ||||
| WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); | WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); | ||||
| return nt->rna_ext.srna; | return nt->rna_ext.srna; | ||||
| } | } | ||||
| static StructRNA *rna_FunctionNode_register(Main *bmain, | |||||
| ReportList *reports, | |||||
| void *data, | |||||
| const char *identifier, | |||||
| StructValidateFunc validate, | |||||
| StructCallbackFunc call, | |||||
| StructFreeFunc free) | |||||
| { | |||||
| bNodeType *nt = rna_Node_register_base( | |||||
| bmain, reports, &RNA_FunctionNode, data, identifier, validate, call, free); | |||||
| if (!nt) { | |||||
| return NULL; | |||||
| } | |||||
| nodeRegisterType(nt); | |||||
| /* update while blender is running */ | |||||
| WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); | |||||
| return nt->rna_ext.srna; | |||||
| } | |||||
| static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create) | static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create) | ||||
| { | { | ||||
| bNode *node = ptr->data; | bNode *node = ptr->data; | ||||
| if (create && !node->prop) { | if (create && !node->prop) { | ||||
| IDPropertyTemplate val = {0}; | IDPropertyTemplate val = {0}; | ||||
| node->prop = IDP_New(IDP_GROUP, &val, "RNA_Node ID properties"); | node->prop = IDP_New(IDP_GROUP, &val, "RNA_Node ID properties"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,780 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| bNodeTree *ntree = (bNodeTree *)ptr->owner_id; | bNodeTree *ntree = (bNodeTree *)ptr->owner_id; | ||||
| bNode *node = (bNode *)ptr->data; | bNode *node = (bNode *)ptr->data; | ||||
| nodeUpdate(ntree, node); | nodeUpdate(ntree, node); | ||||
| rna_Node_update(bmain, scene, ptr); | rna_Node_update(bmain, scene, ptr); | ||||
| } | } | ||||
| static void rna_FunctionNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr) | |||||
| { | |||||
| bNodeTree *ntree = (bNodeTree *)ptr->owner_id; | |||||
| bNode *node = (bNode *)ptr->data; | |||||
| nodeUpdate(ntree, node); | |||||
| rna_Node_update(bmain, scene, ptr); | |||||
| } | |||||
| static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA *ptr) | static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA *ptr) | ||||
| { | { | ||||
| bNodeTree *ntree = (bNodeTree *)ptr->owner_id; | bNodeTree *ntree = (bNodeTree *)ptr->owner_id; | ||||
| bNode *node = (bNode *)ptr->data; | bNode *node = (bNode *)ptr->data; | ||||
| nodeUpdate(ntree, node); | nodeUpdate(ntree, node); | ||||
| rna_Node_update(bmain, scene, ptr); | rna_Node_update(bmain, scene, ptr); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | static void def_math(StructRNA *srna) | ||||
| RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); | RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); | ||||
| prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "custom2", SHD_MATH_CLAMP); | RNA_def_property_boolean_sdna(prop, NULL, "custom2", SHD_MATH_CLAMP); | ||||
| RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range"); | RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range"); | ||||
| RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | ||||
| } | } | ||||
| static void def_boolean_math(StructRNA *srna) | |||||
| { | |||||
| PropertyRNA *prop; | |||||
| prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "custom1"); | |||||
| RNA_def_property_enum_items(prop, rna_enum_node_boolean_math_items); | |||||
| RNA_def_property_ui_text(prop, "Operation", ""); | |||||
| RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update"); | |||||
| } | |||||
| static void def_float_compare(StructRNA *srna) | |||||
| { | |||||
| PropertyRNA *prop; | |||||
| prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "custom1"); | |||||
| RNA_def_property_enum_items(prop, rna_enum_node_float_compare_items); | |||||
| RNA_def_property_ui_text(prop, "Operation", ""); | |||||
| RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update"); | |||||
| } | |||||
| static void def_fn_switch(StructRNA *srna) | |||||
| { | |||||
| PropertyRNA *prop; | |||||
| prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "custom1"); | |||||
| RNA_def_property_enum_items(prop, node_socket_data_type_items); | |||||
| RNA_def_property_ui_text(prop, "Data Type", "Data type for inputs and outputs"); | |||||
| RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update"); | |||||
| } | |||||
| static void def_vector_math(StructRNA *srna) | static void def_vector_math(StructRNA *srna) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "operation", 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, rna_enum_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_ui_text(prop, "Operation", ""); | ||||
| ▲ Show 20 Lines • Show All 3,969 Lines • ▼ Show 20 Lines | static void rna_def_simulation_node(BlenderRNA *brna) | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| srna = RNA_def_struct(brna, "SimulationNode", "NodeInternal"); | srna = RNA_def_struct(brna, "SimulationNode", "NodeInternal"); | ||||
| RNA_def_struct_ui_text(srna, "Simulation Node", ""); | RNA_def_struct_ui_text(srna, "Simulation Node", ""); | ||||
| RNA_def_struct_sdna(srna, "bNode"); | RNA_def_struct_sdna(srna, "bNode"); | ||||
| RNA_def_struct_register_funcs(srna, "rna_SimulationNode_register", "rna_Node_unregister", NULL); | RNA_def_struct_register_funcs(srna, "rna_SimulationNode_register", "rna_Node_unregister", NULL); | ||||
| } | } | ||||
| static void rna_def_function_node(BlenderRNA *brna) | |||||
| { | |||||
| StructRNA *srna; | |||||
| srna = RNA_def_struct(brna, "FunctionNode", "NodeInternal"); | |||||
| RNA_def_struct_ui_text(srna, "Function Node", ""); | |||||
| RNA_def_struct_sdna(srna, "bNode"); | |||||
| RNA_def_struct_register_funcs(srna, "rna_FunctionNode_register", "rna_Node_unregister", NULL); | |||||
| } | |||||
| /* -------------------------------------------------------------------------- */ | /* -------------------------------------------------------------------------- */ | ||||
| static void rna_def_node_socket(BlenderRNA *brna) | static void rna_def_node_socket(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| PropertyRNA *parm; | PropertyRNA *parm; | ||||
| FunctionRNA *func; | FunctionRNA *func; | ||||
| ▲ Show 20 Lines • Show All 1,730 Lines • ▼ Show 20 Lines | void RNA_def_nodetree(BlenderRNA *brna) | ||||
| rna_def_node(brna); | rna_def_node(brna); | ||||
| rna_def_node_link(brna); | rna_def_node_link(brna); | ||||
| rna_def_internal_node(brna); | rna_def_internal_node(brna); | ||||
| rna_def_shader_node(brna); | rna_def_shader_node(brna); | ||||
| rna_def_compositor_node(brna); | rna_def_compositor_node(brna); | ||||
| rna_def_texture_node(brna); | rna_def_texture_node(brna); | ||||
| rna_def_simulation_node(brna); | rna_def_simulation_node(brna); | ||||
| rna_def_function_node(brna); | |||||
| rna_def_nodetree(brna); | rna_def_nodetree(brna); | ||||
| rna_def_node_socket_standard_types(brna); | rna_def_node_socket_standard_types(brna); | ||||
| rna_def_composite_nodetree(brna); | rna_def_composite_nodetree(brna); | ||||
| rna_def_shader_nodetree(brna); | rna_def_shader_nodetree(brna); | ||||
| rna_def_texture_nodetree(brna); | rna_def_texture_nodetree(brna); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines | |||||