Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-04-20 16:27:12 +0300
committerJacques Lucke <jacques@blender.org>2020-04-20 16:27:58 +0300
commit8dbbac43bb38442e69e8dcd6a02c424ffb7855df (patch)
treeaebca66b6a2b55558030a18bbdc2b50d1ce4e3cc /source/blender/makesrna
parentdcb45992bff2e4ca27a1860b9a34411f23db49a1 (diff)
Simulations: Add Boolean Math, Switch and Float Compare node UI
Reviewers: brecht Differential Revision: https://developer.blender.org/D7424
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c142
3 files changed, 145 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index a77d07dfe17..d2e27bdbcad 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -259,6 +259,7 @@ extern StructRNA RNA_FreestyleLineStyle;
extern StructRNA RNA_FreestyleModuleSettings;
extern StructRNA RNA_FreestyleSettings;
extern StructRNA RNA_Function;
+extern StructRNA RNA_FunctionNode;
extern StructRNA RNA_GPencilFrame;
extern StructRNA RNA_GPencilInterpolateSettings;
extern StructRNA RNA_GPencilLayer;
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index fef98f9da4b..b2f9c90b7f5 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -191,6 +191,8 @@ extern const EnumPropertyItem rna_enum_node_socket_in_out_items[];
extern const EnumPropertyItem rna_enum_node_math_items[];
extern const EnumPropertyItem rna_enum_mapping_type_items[];
extern const EnumPropertyItem rna_enum_node_vec_math_items[];
+extern const EnumPropertyItem rna_enum_node_boolean_math_items[];
+extern const EnumPropertyItem rna_enum_node_float_compare_items[];
extern const EnumPropertyItem rna_enum_node_filter_items[];
extern const EnumPropertyItem rna_enum_node_map_range_items[];
extern const EnumPropertyItem rna_enum_node_clamp_items[];
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0c4583983a8..9242ad7237f 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -101,6 +101,18 @@ static const EnumPropertyItem particle_attribute_socket_type_items[] = {
{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[] = {
{NTREE_QUALITY_HIGH, "HIGH", 0, "High", "High quality"},
{NTREE_QUALITY_MEDIUM, "MEDIUM", 0, "Medium", "Medium quality"},
@@ -261,6 +273,47 @@ const EnumPropertyItem rna_enum_node_vec_math_items[] = {
{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[] = {
{NODE_MAP_RANGE_LINEAR,
"LINEAR",
@@ -700,6 +753,20 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C),
# 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);
*r_free = true;
@@ -1838,6 +1905,28 @@ static StructRNA *rna_SimulationNode_register(Main *bmain,
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)
{
bNode *node = ptr->data;
@@ -3634,6 +3723,15 @@ static void rna_ShaderNode_socket_update(Main *bmain, Scene *scene, PointerRNA *
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)
{
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
@@ -4078,6 +4176,39 @@ static void def_math(StructRNA *srna)
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)
{
PropertyRNA *prop;
@@ -8084,6 +8215,16 @@ static void rna_def_simulation_node(BlenderRNA *brna)
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)
@@ -9830,6 +9971,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
rna_def_compositor_node(brna);
rna_def_texture_node(brna);
rna_def_simulation_node(brna);
+ rna_def_function_node(brna);
rna_def_nodetree(brna);