[Bf-blender-cvs] [268e5fd2108] builtin-simulation-nodes: add first function node ui
Jacques Lucke
noreply at git.blender.org
Thu Mar 5 16:16:13 CET 2020
Commit: 268e5fd2108ffa279436caeb1babd5e795a72180
Author: Jacques Lucke
Date: Thu Mar 5 16:04:17 2020 +0100
Branches: builtin-simulation-nodes
https://developer.blender.org/rB268e5fd2108ffa279436caeb1babd5e795a72180
add first function node ui
===================================================================
M release/scripts/startup/nodeitems_builtins.py
M source/blender/blenkernel/BKE_node.h
M source/blender/blenkernel/intern/node.c
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/CMakeLists.txt
A source/blender/nodes/NOD_function.h
M source/blender/nodes/NOD_static_types.h
A source/blender/nodes/function/node_fn_util.cc
A source/blender/nodes/function/node_fn_util.h
A source/blender/nodes/function/nodes/node_fn_combine_vector.cc
M source/blender/nodes/simulation/node_sim_util.cc
M source/blender/nodes/simulation/node_sim_util.h
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index af0d52eb3c5..840dea1ff04 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -63,6 +63,12 @@ class SimulationNodeCategory(SortedNodeCategory):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'SimulationNodeTree')
+class FunctionNodeCategory(SortedNodeCategory):
+ @classmethod
+ def poll(cls, context):
+ return (context.space_data.type == 'NODE_EDITOR' and
+ context.space_data.tree_type == 'SimulationNodeTree')
+
# menu entry for node group tools
def group_tools_draw(self, layout, context):
@@ -490,6 +496,9 @@ simulation_node_categories = [
NodeItem("SimulationNodeExecuteCondition"),
NodeItem("SimulationNodeMultiExecute"),
]),
+ FunctionNodeCategory("VECTOR", "Vector", items=[
+ NodeItem("FunctionNodeCombineVector"),
+ ]),
]
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 887d56d27a6..dea9535a5dc 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1014,6 +1014,8 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
#define SIM_NODE_EXECUTE_CONDITION 1005
#define SIM_NODE_MULTI_EXECUTE 1006
+#define FN_NODE_COMBINE_VECTOR 1100
+
/* custom defines options for Material node */
// #define SH_NODE_MAT_DIFF 1
// #define SH_NODE_MAT_SPEC 2
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 7c06ade3220..4f15f51ffd3 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -68,6 +68,7 @@
#include "NOD_shader.h"
#include "NOD_texture.h"
#include "NOD_simulation.h"
+#include "NOD_function.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -4144,6 +4145,11 @@ static void registerSimulationNodes(void)
register_node_type_sim_multi_execute();
}
+static void registerFunctionNodes(void)
+{
+ register_node_type_fn_combine_vector();
+}
+
void init_nodesystem(void)
{
nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
@@ -4168,6 +4174,7 @@ void init_nodesystem(void)
registerShaderNodes();
registerTextureNodes();
registerSimulationNodes();
+ registerFunctionNodes();
}
void free_nodesystem(void)
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index a29f19793f5..22ec0ae67e6 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -260,6 +260,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/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index dddd90aa429..ad5d912f202 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -690,6 +690,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;
@@ -1828,6 +1842,28 @@ static StructRNA *rna_SimulationNode_register(Main *bmain,
return nt->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->ext.srna;
+}
+
static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create)
{
bNode *node = ptr->data;
@@ -8019,6 +8055,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)
@@ -9743,6 +9789,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);
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 8ad8a31a479..22259e5216c 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -21,6 +21,7 @@
set(INC
.
composite
+ function
intern
shader
simulation
@@ -128,6 +129,9 @@ set(SRC
composite/node_composite_tree.c
composite/node_composite_util.c
+ function/nodes/node_fn_combine_vector.cc
+ function/node_fn_util.cc
+
shader/nodes/node_shader_add_shader.c
shader/nodes/node_shader_ambient_occlusion.c
shader/nodes/node_shader_attribute.c
@@ -264,6 +268,7 @@ set(SRC
intern/node_util.c
composite/node_composite_util.h
+ function/node_fn_util.h
shader/node_shader_util.h
texture/node_texture_util.h
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
new file mode 100644
index 00000000000..56e7d86180b
--- /dev/null
+++ b/source/blender/nodes/NOD_function.h
@@ -0,0 +1,14 @@
+#ifndef __NOD_FUNCTION_H__
+#define __NOD_FUNCTION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void register_node_type_fn_combine_vector(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NOD_FUNCTION_H__ */
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index dab7c26fceb..407f60d71de 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -266,6 +266,8 @@ DefNode(SimulationNode, SIM_NODE_PARTICLE_TIME_STEP_EVENT, def_sim_particle_time
DefNode(SimulationNode, SIM_NODE_EXECUTE_CONDITION, 0, "EXECUTE_CONDITION", ExecuteCondition, "Execute Condition", "")
DefNode(SimulationNode, SIM_NODE_MULTI_EXECUTE, 0, "MULTI_EXECUTE", MultiExecute, "Multi Execute", "")
+DefNode(FunctionNode, FN_NODE_COMBINE_VECTOR, 0, "COMBINE_VECTOR", CombineVector, "Combine Vector", "")
+
/* undefine macros */
#undef DefNode
diff --git a/source/blender/nodes/function/node_fn_util.cc b/source/blender/nodes/function/node_fn_util.cc
new file mode 100644
index 00000000000..08ea41c2612
--- /dev/null
+++ b/source/blender/nodes/function/node_fn_util.cc
@@ -0,0 +1,14 @@
+#include "node_fn_util.h"
+#include "node_util.h"
+
+bool fn_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
+{
+ /* Function nodes are only supported in simulation node trees so far. */
+ return STREQ(ntree->idname, "SimulationNodeTree");
+}
+
+void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
+{
+ node_type_base(ntype, type, name, nclass, flag);
+ ntype->poll = fn_node_poll_default;
+}
diff --git a/source/blender/nodes/simulation/node_sim_util.h b/source/blender/nodes/function/node_fn_util.h
similarity index 54%
copy from source/blender/nodes/simulation/node_sim_util.h
copy to source/blender/nodes/function/node_fn_util.h
index 0dee312f508..8835273316c 100644
--- a/source/blender/nodes/simulation/node_sim_util.h
+++ b/source/blender/nodes/function/node_fn_util.h
@@ -1,5 +1,5 @@
-#ifndef __NODE_SHADER_UTIL_H__
-#define __NODE_SHADER_UTIL_H__
+#ifndef __NODE_FN_UTIL_H__
+#define __NODE_FN_UTIL_H__
#include <string.h>
@@ -13,12 +13,12 @@
#include "BLT_translation.h"
-#include "NOD_simulation.h"
+#include "NOD_function.h"
#include "node_util.h"
-void sim_node_type_base(
+void fn_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
-bool sim_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
+bool fn_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
-#endif /* __NODE_SHADER_UTIL_H__ */
+#endif /* __NODE_FN_UTIL_H__ */
diff --git a/source/blender/nodes/function/nodes/node_fn_combine_vector.cc b/source/blender/nodes/function/nodes/node_fn_combine_vector.cc
new file mode 100644
index 00000000000..06f839f5803
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_combine_vector.cc
@@ -0,0 +1,22 @@
+#include "node_fn_util.h"
+
+static bNodeSocketTemplate fn_node_combine_vector_in[] = {
+ {SOCK_FLOAT, 1, N_("X"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+ {SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+ {SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
+ {-1, 0, ""},
+};
+
+static bNodeSocketTemplate fn_node_combine_vector_out[] = {
+ {SOCK_VECTOR, 0, N_("
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list