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
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')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc29
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_vector_rotate.cc48
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_boolean.cc41
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc27
4 files changed, 51 insertions, 94 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc
index e4f3230ebb9..ca205362a61 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc
@@ -16,28 +16,15 @@
#include "node_geometry_util.hh"
-static bNodeSocketTemplate geo_node_attribute_remove_in[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
- {SOCK_STRING,
- N_("Attribute"),
- 0.0f,
- 0.0f,
- 0.0f,
- 1.0f,
- -1.0f,
- 1.0f,
- PROP_NONE,
- SOCK_MULTI_INPUT},
- {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_attribute_remove_out[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
- {-1, ""},
-};
-
namespace blender::nodes {
+static void geo_node_attribute_remove_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Geometry>("Geometry");
+ b.add_input<decl::String>("Attribute").multi_input(true);
+ b.add_output<decl::Geometry>("Geometry");
+}
+
static void remove_attribute(GeometryComponent &component,
GeoNodeExecParams &params,
Span<std::string> attribute_names)
@@ -85,7 +72,7 @@ void register_node_type_geo_attribute_remove()
geo_node_type_base(
&ntype, GEO_NODE_ATTRIBUTE_REMOVE, "Attribute Remove", NODE_CLASS_ATTRIBUTE, 0);
- node_type_socket_templates(&ntype, geo_node_attribute_remove_in, geo_node_attribute_remove_out);
ntype.geometry_node_execute = blender::nodes::geo_node_attribute_remove_exec;
+ ntype.declare = blender::nodes::geo_node_attribute_remove_declare;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_rotate.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_rotate.cc
index da753dfc11b..ddeef267240 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_rotate.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_rotate.cc
@@ -21,27 +21,26 @@
#include "UI_interface.h"
#include "UI_resources.h"
-static bNodeSocketTemplate geo_node_attribute_vector_rotate_in[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
- {SOCK_STRING, N_("Vector")},
- {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- {SOCK_STRING, N_("Center")},
- {SOCK_VECTOR, N_("Center"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_XYZ},
- {SOCK_STRING, N_("Axis")},
- {SOCK_VECTOR, N_("Axis"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_XYZ, PROP_NONE},
- {SOCK_STRING, N_("Angle")},
- {SOCK_FLOAT, N_("Angle"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_ANGLE, PROP_NONE},
- {SOCK_STRING, N_("Rotation")},
- {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
- {SOCK_BOOLEAN, N_("Invert")},
- {SOCK_STRING, N_("Result")},
- {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_attribute_vector_rotate_out[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
- {-1, ""},
-};
+namespace blender::nodes {
+
+static void geo_node_attribute_vector_rotate_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Geometry>("Geometry");
+ b.add_input<decl::String>("Vector");
+ b.add_input<decl::Vector>("Vector", "Vector_001").min(0.0f).max(1.0f).hide_value(true);
+ b.add_input<decl::String>("Center");
+ b.add_input<decl::Vector>("Center", "Center_001").subtype(PROP_XYZ);
+ b.add_input<decl::String>("Axis");
+ b.add_input<decl::Vector>("Axis", "Axis_001").min(-1.0f).max(1.0f).subtype(PROP_XYZ);
+ b.add_input<decl::String>("Angle");
+ b.add_input<decl::Float>("Angle", "Angle_001").subtype(PROP_ANGLE);
+ b.add_input<decl::String>("Rotation");
+ b.add_input<decl::Vector>("Rotation", "Rotation_001").subtype(PROP_EULER);
+ b.add_input<decl::Bool>("Invert");
+ b.add_input<decl::String>("Result");
+
+ b.add_output<decl::Geometry>("Geometry");
+}
static void geo_node_attribute_vector_rotate_layout(uiLayout *layout,
bContext *UNUSED(C),
@@ -71,8 +70,6 @@ static void geo_node_attribute_vector_rotate_layout(uiLayout *layout,
}
}
-namespace blender::nodes {
-
static void geo_node_attribute_vector_rotate_update(bNodeTree *UNUSED(ntree), bNode *node)
{
const NodeAttributeVectorRotate *node_storage = (NodeAttributeVectorRotate *)node->storage;
@@ -339,14 +336,13 @@ void register_node_type_geo_attribute_vector_rotate()
"Attribute Vector Rotate",
NODE_CLASS_ATTRIBUTE,
0);
- node_type_socket_templates(
- &ntype, geo_node_attribute_vector_rotate_in, geo_node_attribute_vector_rotate_out);
node_type_update(&ntype, blender::nodes::geo_node_attribute_vector_rotate_update);
node_type_init(&ntype, blender::nodes::geo_node_attribute_vector_rotate_init);
node_type_size(&ntype, 165, 100, 600);
node_type_storage(
&ntype, "NodeAttributeVectorRotate", node_free_standard_storage, node_copy_standard_storage);
ntype.geometry_node_execute = blender::nodes::geo_node_attribute_vector_rotate_exec;
- ntype.draw_buttons = geo_node_attribute_vector_rotate_layout;
+ ntype.draw_buttons = blender::nodes::geo_node_attribute_vector_rotate_layout;
+ ntype.declare = blender::nodes::geo_node_attribute_vector_rotate_declare;
nodeRegisterType(&ntype);
}
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);
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
index 5792ee1485a..3de5c89b77b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
@@ -29,27 +29,14 @@
using blender::fn::GVArray_For_GSpan;
-static bNodeSocketTemplate geo_node_join_geometry_in[] = {
- {SOCK_GEOMETRY,
- N_("Geometry"),
- 0.0f,
- 0.0f,
- 0.0f,
- 1.0f,
- -1.0f,
- 1.0f,
- PROP_NONE,
- SOCK_MULTI_INPUT},
- {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_join_geometry_out[] = {
- {SOCK_GEOMETRY, N_("Geometry")},
- {-1, ""},
-};
-
namespace blender::nodes {
+static void geo_node_join_geometry_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Geometry>("Geometry").multi_input(true);
+ b.add_output<decl::Geometry>("Geometry");
+}
+
static Mesh *join_mesh_topology_and_builtin_attributes(Span<const MeshComponent *> src_components)
{
int totverts = 0;
@@ -508,7 +495,7 @@ void register_node_type_geo_join_geometry()
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_JOIN_GEOMETRY, "Join Geometry", NODE_CLASS_GEOMETRY, 0);
- node_type_socket_templates(&ntype, geo_node_join_geometry_in, geo_node_join_geometry_out);
ntype.geometry_node_execute = blender::nodes::geo_node_join_geometry_exec;
+ ntype.declare = blender::nodes::geo_node_join_geometry_declare;
nodeRegisterType(&ntype);
}