[Bf-blender-cvs] [0ccbf506943] master: Cleanup: Convert geometry nodes socket list to use new API

Johnny Matthews noreply at git.blender.org
Thu Sep 2 05:54:31 CEST 2021


Commit: 0ccbf5069431aaa323ca9c7f09cb62a0ea35ae86
Author: Johnny Matthews
Date:   Wed Sep 1 22:53:52 2021 -0500
Branches: master
https://developer.blender.org/rB0ccbf5069431aaa323ca9c7f09cb62a0ea35ae86

Cleanup: Convert geometry nodes socket list to use new API

The new API introduced in rB1e69a25043120c provides a shorted, more
flexibly way to declare node socket inputs and outputs. This commit
updates all geometry nodes to use the `NodeSocketBuilder` API, except
the four nodes that need `SOCK_HIDE_VALUE` or `SOCK_MULTI_INPUT`.

Differential Revisions: D12377, D12376, D12374, D12373, D12372

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc
M	source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
M	source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
M	source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_length.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_select_by_handle_type.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
M	source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc
M	source/blender/nodes/geometry/nodes/node_geo_material_assign.cc
M	source/blender/nodes/geometry/nodes/node_geo_material_replace.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_scale.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
M	source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
M	source/blender/nodes/geometry/nodes/node_geo_raycast.cc
M	source/blender/nodes/geometry/nodes/node_geo_select_by_material.cc
M	source/blender/nodes/geometry/nodes/node_geo_separate_components.cc
M	source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
M	source/blender/nodes/geometry/nodes/node_geo_switch.cc
M	source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
M	source/blender/nodes/geometry/nodes/node_geo_viewer.cc
M	source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc

===================================================================

diff --git a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
index 9b6824fdb5c..b76556b6c6c 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
@@ -22,19 +22,23 @@
 
 #include "node_geometry_util.hh"
 
-static bNodeSocketTemplate geo_node_align_rotation_to_vector_in[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_STRING, N_("Factor")},
-    {SOCK_FLOAT, N_("Factor"), 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, PROP_FACTOR},
-    {SOCK_STRING, N_("Vector")},
-    {SOCK_VECTOR, N_("Vector"), 0.0, 0.0, 1.0, 0.0, -FLT_MAX, FLT_MAX, PROP_ANGLE},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_align_rotation_to_vector_out[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {-1, ""},
-};
+namespace blender::nodes {
+
+static void geo_node_align_rotation_to_vector_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Geometry>("Geometry");
+  b.add_input<decl::String>("Factor");
+  b.add_input<decl::Float>("Factor", "Factor_001")
+      .default_value(1.0f)
+      .min(0.0f)
+      .max(1.0f)
+      .subtype(PROP_FACTOR);
+  b.add_input<decl::String>("Vector");
+  b.add_input<decl::Vector>("Vector", "Vector_001")
+      .default_value({0.0, 0.0, 1.0})
+      .subtype(PROP_ANGLE);
+  b.add_output<decl::Geometry>("Geometry");
+}
 
 static void geo_node_align_rotation_to_vector_layout(uiLayout *layout,
                                                      bContext *UNUSED(C),
@@ -49,8 +53,6 @@ static void geo_node_align_rotation_to_vector_layout(uiLayout *layout,
   uiItemR(col, ptr, "input_type_vector", 0, IFACE_("Vector"), ICON_NONE);
 }
 
-namespace blender::nodes {
-
 static void geo_node_align_rotation_to_vector_init(bNodeTree *UNUSED(ntree), bNode *node)
 {
   NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *)
@@ -228,15 +230,14 @@ void register_node_type_geo_align_rotation_to_vector()
                      "Align Rotation to Vector",
                      NODE_CLASS_GEOMETRY,
                      0);
-  node_type_socket_templates(
-      &ntype, geo_node_align_rotation_to_vector_in, geo_node_align_rotation_to_vector_out);
   node_type_init(&ntype, blender::nodes::geo_node_align_rotation_to_vector_init);
   node_type_update(&ntype, blender::nodes::geo_node_align_rotation_to_vector_update);
   node_type_storage(&ntype,
                     "NodeGeometryAlignRotationToVector",
                     node_free_standard_storage,
                     node_copy_standard_storage);
+  ntype.declare = blender::nodes::geo_node_align_rotation_to_vector_declare;
   ntype.geometry_node_execute = blender::nodes::geo_node_align_rotation_to_vector_exec;
-  ntype.draw_buttons = geo_node_align_rotation_to_vector_layout;
+  ntype.draw_buttons = blender::nodes::geo_node_align_rotation_to_vector_layout;
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
index 71643df1cb6..3211cdbc5a7 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
@@ -20,25 +20,23 @@
 
 #include "node_geometry_util.hh"
 
-static bNodeSocketTemplate geo_node_attribute_clamp_in[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_STRING, N_("Attribute")},
-    {SOCK_STRING, N_("Result")},
-    {SOCK_VECTOR, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_VECTOR, N_("Max"), 1.0f, 1.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_FLOAT, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_FLOAT, N_("Max"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
-    {SOCK_INT, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -100000, 100000},
-    {SOCK_INT, N_("Max"), 100.0f, 0.0f, 0.0f, 0.0f, -100000, 100000},
-    {SOCK_RGBA, N_("Min"), 0.5, 0.5, 0.5, 1.0},
-    {SOCK_RGBA, N_("Max"), 0.5, 0.5, 0.5, 1.0},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_attribute_clamp_out[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {-1, ""},
-};
+namespace blender::nodes {
+
+static void geo_node_attribute_clamp_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Geometry>("Geometry");
+  b.add_input<decl::String>("Attribute");
+  b.add_input<decl::String>("Result");
+  b.add_input<decl::Vector>("Min");
+  b.add_input<decl::Vector>("Max").default_value({1.0f, 1.0f, 1.0f});
+  b.add_input<decl::Float>("Min", "Min_001");
+  b.add_input<decl::Float>("Max", "Max_001").default_value(1.0f);
+  b.add_input<decl::Int>("Min", "Min_002").min(-100000).max(100000);
+  b.add_input<decl::Int>("Max", "Max_002").default_value(100).min(-100000).max(100000);
+  b.add_input<decl::Color>("Min", "Min_003").default_value({0.5f, 0.5f, 0.5f, 1.0f});
+  b.add_input<decl::Color>("Max", "Max_003").default_value({0.5f, 0.5f, 0.5f, 1.0f});
+  b.add_output<decl::Geometry>("Geometry");
+}
 
 static void geo_node_attribute_clamp_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
@@ -78,8 +76,6 @@ static void geo_node_attribute_clamp_update(bNodeTree *UNUSED(ntree), bNode *nod
   nodeSetSocketAvailability(sock_max_color, data_type == CD_PROP_COLOR);
 }
 
-namespace blender::nodes {
-
 template<typename T> T clamp_value(const T val, const T min, const T max);
 
 template<> inline float clamp_value(const float val, const float min, const float max)
@@ -273,11 +269,11 @@ void register_node_type_geo_attribute_clamp()
   static bNodeType ntype;
 
   geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_CLAMP, "Attribute Clamp", NODE_CLASS_ATTRIBUTE, 0);
-  node_type_socket_templates(&ntype, geo_node_attribute_clamp_in, geo_node_attribute_clamp_out);
-  node_type_init(&ntype, geo_node_attribute_clamp_init);
-  node_type_update(&ntype, geo_node_attribute_clamp_update);
+  node_type_init(&ntype, blender::nodes::geo_node_attribute_clamp_init);
+  node_type_update(&ntype, blender::nodes::geo_node_attribute_clamp_update);
+  ntype.declare = blender::nodes::geo_node_attribute_clamp_declare;
   ntype.geometry_node_execute = blender::nodes::geo_node_attribute_clamp_exec;
-  ntype.draw_buttons = geo_node_attribute_clamp_layout;
+  ntype.draw_buttons = blender::nodes::geo_node_attribute_clamp_layout;
   node_type_storage(
       &ntype, "NodeAttributeClamp", node_free_standard_storage, node_copy_standard_storage);
   nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
index c5740395dfb..aae906f2e5e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
@@ -23,17 +23,15 @@
 
 #include "node_geometry_util.hh"
 
-static bNodeSocketTemplate geo_node_attribute_color_ramp_in[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_STRING, N_("Attribute")},
-    {SOCK_STRING, N_("Result")},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_attribute_color_ramp_out[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {-1, ""},
-};
+namespace blender::nodes {
+
+static void geo_node_attribute_color_ramp_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Geometry>("Geometry");
+  b.add_input<decl::String>("Attribute");
+  b.add_input<decl::String>("Result");
+  b.add_output<decl::Geometry>("Geometry");
+}
 
 static void geo_node_attribute_color_ramp_layout(uiLayout *layout,
                                                  bContext *UNUSED(C),
@@ -42,8 +40,6 @@ static void geo_node_attribute_color_ramp_layout(uiLayout *layout,
   uiTemplateColorRamp(layout, ptr, "color_ramp", false);
 }
 
-namespace blender::nodes {
-
 static void geo_node_attribute_color_ramp_init(bNodeTree *UNUSED(ntree), bNode *node)
 {
   NodeAttributeColorRamp *node_storage = (NodeAttributeColorRamp *)MEM_callocN(
@@ -131,13 +127,12 @@ void register_node_type_geo_attribute_color_ramp()
 
   geo_node_type_base(
       &ntype, GEO_NODE_ATTRIBUTE_COLOR_RAMP, "Attribute Color Ramp", NODE_CLASS_ATTRIBUTE, 0);
-  node_type_socket_templates(
-      &ntype, geo_node_attribute_color_ramp_in, geo_node_attribute_color_ramp_out);
   node_type_storage(
       &ntype, "NodeAttributeColorRamp", node_free_standard_storage, node_copy_standard_storage);
   node_type_init(&ntype, blender::nodes::geo_node_attribute_color_ramp_init);
   node_type_size_preset(&ntype, NODE_SIZE_LARGE);
+  ntype.declare = blender::nodes::geo_node_attribute_color_ramp_declare;
   ntype.geometry_node_execute = blender::nodes::geo_node_attribute_color_ramp_exec;
-  ntype.draw_buttons = geo_node_attribute_color_ramp_layout;
+  ntype.draw_buttons = blender::nodes::geo_node_attribute_color_ramp_layout;
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
index d8c52d16f41..1638793525a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
@@ -19,22 +19,20 @@
 
 #include "node_geometry_util.hh"
 
-static bNodeSocketTemplate geo_node_attribute_combine_xyz_in[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_STRING, N_("X")},
-    {SOCK_FLOAT, N_("X"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
-    {SOCK_STRING, N_("Y")},
-    {SOCK_FLOAT, N_("Y"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
-    {SOCK_STRING, N_("Z")},
-    {SOCK_FLOAT, N_("Z"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
-    {SOCK_STRING, N_("Result")},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate geo_node_attribute_combine_xyz_out[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {-1, ""},
-};
+namespace blender::nodes {
+
+static void geo_node_attribute_combine_xyz_declare(NodeDeclarationBuilder &b)
+{
+  b.add_input<decl::Geometry>("Geometry");
+  b.add_input<decl::String>("X");
+  b.add_input<decl::Float>("X", "X_001");
+  b.add_input<decl::String>("Y");
+  b.add_input<decl::Float>("Y", "Y_001");
+  b.add_input<dec

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list