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>2021-09-15 17:09:00 +0300
committerJacques Lucke <jacques@blender.org>2021-09-15 17:09:00 +0300
commit46fff97604ae167473ecd4c0cd9108dc20ba22e3 (patch)
treefe814c66a0525f76d403719ace3fe56c2a39ed73 /source/blender/nodes/geometry/nodes/node_geo_boolean.cc
parent5c6cc931b2203d97aa9d570ff3b353c2a3dfebed (diff)
Nodes: refactor socket declarations
This commits adds a few common flags to `SocketDeclaration` so that they are available for all socket types (hide label, hide value, is multi input). This allows porting over the remaining geometry nodes to the new declaration system. Furthermore, this commit separates the concepts of the socket declaration and corresponding builders. The builders are used by nodes to declare which sockets they have (e.g. `FloatBuilder`). The ready build socket declarations can then be consumed by other systems such as the versioning code. Both use cases need different APIs and those will change for independent reasons, so it makes sense to separate the classes.
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_boolean.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_boolean.cc41
1 files changed, 14 insertions, 27 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc
index d8029ea1eeb..a990f1daac8 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc
@@ -23,27 +23,16 @@
#include "node_geometry_util.hh"
-static bNodeSocketTemplate geo_node_boolean_in[] = {
- {SOCK_GEOMETRY, N_("Geometry 1")},
- {SOCK_GEOMETRY,
- N_("Geometry 2"),
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- PROP_NONE,
- SOCK_MULTI_INPUT},
- {SOCK_BOOLEAN, N_("Self Intersection")},
- {SOCK_BOOLEAN, N_("Hole Tolerant")},
- {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_boolean_out[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
- {-1, ""},
-};
+namespace blender::nodes {
+
+static void geo_node_boolean_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Geometry>("Geometry 1");
+ b.add_input<decl::Geometry>("Geometry 2").multi_input(true);
+ b.add_input<decl::Bool>("Self Intersection");
+ b.add_input<decl::Bool>("Hole Tolerant");
+ b.add_output<decl::Geometry>("Geometry");
+}
static void geo_node_boolean_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
@@ -77,8 +66,6 @@ static void geo_node_boolean_init(bNodeTree *UNUSED(tree), bNode *node)
node->custom1 = GEO_NODE_BOOLEAN_DIFFERENCE;
}
-namespace blender::nodes {
-
static void geo_node_boolean_exec(GeoNodeExecParams params)
{
GeometryNodeBooleanOperation operation = (GeometryNodeBooleanOperation)params.node().custom1;
@@ -138,10 +125,10 @@ void register_node_type_geo_boolean()
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_BOOLEAN, "Boolean", NODE_CLASS_GEOMETRY, 0);
- node_type_socket_templates(&ntype, geo_node_boolean_in, geo_node_boolean_out);
- ntype.draw_buttons = geo_node_boolean_layout;
- ntype.updatefunc = geo_node_boolean_update;
- node_type_init(&ntype, geo_node_boolean_init);
+ ntype.declare = blender::nodes::geo_node_boolean_declare;
+ ntype.draw_buttons = blender::nodes::geo_node_boolean_layout;
+ ntype.updatefunc = blender::nodes::geo_node_boolean_update;
+ node_type_init(&ntype, blender::nodes::geo_node_boolean_init);
ntype.geometry_node_execute = blender::nodes::geo_node_boolean_exec;
nodeRegisterType(&ntype);
}