From 0ccbf5069431aaa323ca9c7f09cb62a0ea35ae86 Mon Sep 17 00:00:00 2001 From: Johnny Matthews Date: Wed, 1 Sep 2021 22:53:52 -0500 Subject: 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 --- .../nodes/node_geo_align_rotation_to_vector.cc | 37 ++++----- .../geometry/nodes/node_geo_attribute_clamp.cc | 46 ++++++------ .../nodes/node_geo_attribute_color_ramp.cc | 27 +++---- .../nodes/node_geo_attribute_combine_xyz.cc | 38 +++++----- .../geometry/nodes/node_geo_attribute_compare.cc | 45 +++++------ .../geometry/nodes/node_geo_attribute_convert.cc | 29 +++----- .../geometry/nodes/node_geo_attribute_curve_map.cc | 35 ++++----- .../geometry/nodes/node_geo_attribute_map_range.cc | 53 ++++++------- .../geometry/nodes/node_geo_attribute_math.cc | 38 +++++----- .../nodes/geometry/nodes/node_geo_attribute_mix.cc | 43 +++++------ .../geometry/nodes/node_geo_attribute_proximity.cc | 32 ++++---- .../geometry/nodes/node_geo_attribute_randomize.cc | 44 +++++------ .../nodes/node_geo_attribute_sample_texture.cc | 25 +++---- .../nodes/node_geo_attribute_separate_xyz.cc | 33 ++++---- .../geometry/nodes/node_geo_attribute_transfer.cc | 29 +++----- .../nodes/node_geo_attribute_vector_math.cc | 44 +++++------ .../nodes/geometry/nodes/node_geo_bounding_box.cc | 22 +++--- .../geometry/nodes/node_geo_collection_info.cc | 31 +++----- .../nodes/geometry/nodes/node_geo_convex_hull.cc | 18 ++--- .../geometry/nodes/node_geo_curve_endpoints.cc | 20 ++--- .../nodes/geometry/nodes/node_geo_curve_fill.cc | 21 +++--- .../nodes/geometry/nodes/node_geo_curve_length.cc | 18 ++--- .../node_geo_curve_primitive_bezier_segment.cc | 41 ++++------ .../nodes/node_geo_curve_primitive_circle.cc | 36 ++++----- .../nodes/node_geo_curve_primitive_line.cc | 29 +++----- .../node_geo_curve_primitive_quadratic_bezier.cc | 26 +++---- .../node_geo_curve_primitive_quadrilateral.cc | 46 +++++------- .../nodes/node_geo_curve_primitive_spiral.cc | 29 +++----- .../nodes/node_geo_curve_primitive_star.cc | 25 +++---- .../geometry/nodes/node_geo_curve_resample.cc | 28 +++---- .../nodes/geometry/nodes/node_geo_curve_reverse.cc | 20 ++--- .../nodes/node_geo_curve_select_by_handle_type.cc | 25 +++---- .../geometry/nodes/node_geo_curve_set_handles.cc | 23 +++--- .../geometry/nodes/node_geo_curve_spline_type.cc | 23 +++--- .../geometry/nodes/node_geo_curve_subdivide.cc | 28 +++---- .../nodes/geometry/nodes/node_geo_curve_to_mesh.cc | 20 ++--- .../geometry/nodes/node_geo_curve_to_points.cc | 30 ++++---- .../geometry/nodes/node_geo_delete_geometry.cc | 30 ++++---- .../geometry/nodes/node_geo_material_assign.cc | 31 +++----- .../geometry/nodes/node_geo_material_replace.cc | 22 +++--- .../geometry/nodes/node_geo_mesh_primitive_cube.cc | 25 +++---- .../nodes/node_geo_mesh_primitive_cylinder.cc | 30 +++----- .../geometry/nodes/node_geo_mesh_primitive_grid.cc | 25 +++---- .../nodes/node_geo_mesh_primitive_ico_sphere.cc | 21 ++---- .../geometry/nodes/node_geo_mesh_primitive_line.cc | 41 ++++------ .../nodes/node_geo_mesh_primitive_uv_sphere.cc | 23 +++--- .../geometry/nodes/node_geo_mesh_subdivide.cc | 20 ++--- .../nodes/geometry/nodes/node_geo_mesh_to_curve.cc | 20 ++--- .../geometry/nodes/node_geo_point_distribute.cc | 36 ++++----- .../geometry/nodes/node_geo_point_instance.cc | 37 +++------ .../nodes/geometry/nodes/node_geo_point_rotate.cc | 34 ++++----- .../nodes/geometry/nodes/node_geo_point_scale.cc | 31 ++++---- .../geometry/nodes/node_geo_point_separate.cc | 22 +++--- .../geometry/nodes/node_geo_point_translate.cc | 26 +++---- .../geometry/nodes/node_geo_points_to_volume.cc | 30 ++++---- .../nodes/geometry/nodes/node_geo_raycast.cc | 50 ++++++------- .../geometry/nodes/node_geo_select_by_material.cc | 32 +++----- .../geometry/nodes/node_geo_separate_components.cc | 24 +++--- .../geometry/nodes/node_geo_subdivision_surface.cc | 28 +++---- .../nodes/geometry/nodes/node_geo_switch.cc | 87 +++++++++++----------- .../nodes/geometry/nodes/node_geo_triangulate.cc | 23 +++--- .../nodes/geometry/nodes/node_geo_viewer.cc | 12 +-- .../geometry/nodes/node_geo_volume_to_mesh.cc | 32 ++++---- 63 files changed, 823 insertions(+), 1126 deletions(-) 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("Geometry"); + b.add_input("Factor"); + b.add_input("Factor", "Factor_001") + .default_value(1.0f) + .min(0.0f) + .max(1.0f) + .subtype(PROP_FACTOR); + b.add_input("Vector"); + b.add_input("Vector", "Vector_001") + .default_value({0.0, 0.0, 1.0}) + .subtype(PROP_ANGLE); + b.add_output("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("Geometry"); + b.add_input("Attribute"); + b.add_input("Result"); + b.add_input("Min"); + b.add_input("Max").default_value({1.0f, 1.0f, 1.0f}); + b.add_input("Min", "Min_001"); + b.add_input("Max", "Max_001").default_value(1.0f); + b.add_input("Min", "Min_002").min(-100000).max(100000); + b.add_input("Max", "Max_002").default_value(100).min(-100000).max(100000); + b.add_input("Min", "Min_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); + b.add_input("Max", "Max_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); + b.add_output("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 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("Geometry"); + b.add_input("Attribute"); + b.add_input("Result"); + b.add_output("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("Geometry"); + b.add_input("X"); + b.add_input("X", "X_001"); + b.add_input("Y"); + b.add_input("Y", "Y_001"); + b.add_input("Z"); + b.add_input("Z", "Z_001"); + b.add_input("Result"); + b.add_output("Geometry"); +} static void geo_node_attribute_combine_xyz_layout(uiLayout *layout, bContext *UNUSED(C), @@ -48,8 +46,6 @@ static void geo_node_attribute_combine_xyz_layout(uiLayout *layout, uiItemR(col, ptr, "input_type_z", 0, IFACE_("Z"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_attribute_combine_xyz_init(bNodeTree *UNUSED(tree), bNode *node) { NodeAttributeCombineXYZ *data = (NodeAttributeCombineXYZ *)MEM_callocN( @@ -142,13 +138,13 @@ void register_node_type_geo_attribute_combine_xyz() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_COMBINE_XYZ, "Attribute Combine XYZ", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_combine_xyz_in, geo_node_attribute_combine_xyz_out); node_type_init(&ntype, blender::nodes::geo_node_attribute_combine_xyz_init); node_type_update(&ntype, blender::nodes::geo_node_attribute_combine_xyz_update); node_type_storage( &ntype, "NodeAttributeCombineXYZ", node_free_standard_storage, node_copy_standard_storage); + + ntype.declare = blender::nodes::geo_node_attribute_combine_xyz_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_combine_xyz_exec; - ntype.draw_buttons = geo_node_attribute_combine_xyz_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_combine_xyz_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc index 57ac68b4cd4..75c88a6953a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc @@ -21,25 +21,23 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_compare_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("A")}, - {SOCK_FLOAT, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_RGBA, N_("A"), 0.5, 0.5, 0.5, 1.0}, - {SOCK_STRING, N_("B")}, - {SOCK_FLOAT, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_RGBA, N_("B"), 0.5, 0.5, 0.5, 1.0}, - {SOCK_FLOAT, N_("Threshold"), 0.01f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_compare_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_compare_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("A"); + b.add_input("A", "A_001"); + b.add_input("A", "A_002"); + b.add_input("A", "A_003").default_value({0.5, 0.5, 0.5, 1.0}); + b.add_input("B"); + b.add_input("B", "B_001"); + b.add_input("B", "B_002"); + b.add_input("B", "B_003").default_value({0.5, 0.5, 0.5, 1.0}); + b.add_input("Threshold").default_value(0.01f).min(0.0f); + b.add_input("Result"); + b.add_output("Geometry"); +} static void geo_node_attribute_compare_layout(uiLayout *layout, bContext *UNUSED(C), @@ -67,8 +65,6 @@ static bool operation_tests_equality(const NodeAttributeCompare &node_storage) return ELEM(node_storage.operation, NODE_FLOAT_COMPARE_EQUAL, NODE_FLOAT_COMPARE_NOT_EQUAL); } -namespace blender::nodes { - static void geo_node_attribute_compare_update(bNodeTree *UNUSED(ntree), bNode *node) { NodeAttributeCompare *node_storage = (NodeAttributeCompare *)node->storage; @@ -353,13 +349,12 @@ void register_node_type_geo_attribute_compare() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_COMPARE, "Attribute Compare", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_compare_in, geo_node_attribute_compare_out); + ntype.declare = blender::nodes::geo_node_attribute_compare_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_compare_exec; - ntype.draw_buttons = geo_node_attribute_compare_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_compare_layout; node_type_update(&ntype, blender::nodes::geo_node_attribute_compare_update); node_type_storage( &ntype, "NodeAttributeCompare", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, geo_node_attribute_compare_init); + node_type_init(&ntype, blender::nodes::geo_node_attribute_compare_init); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc index 60b5b91db19..72e1930952a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc @@ -19,17 +19,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_convert_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Attribute")}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_convert_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_convert_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Attribute"); + b.add_input("Result"); + b.add_output("Geometry"); +} static void geo_node_attribute_convert_layout(uiLayout *layout, bContext *UNUSED(C), @@ -51,8 +49,6 @@ static void geo_node_attribute_convert_init(bNodeTree *UNUSED(tree), bNode *node node->storage = data; } -namespace blender::nodes { - static AttributeMetaData get_result_domain_and_type(const GeometryComponent &component, const StringRef source_name, const StringRef result_name) @@ -187,11 +183,10 @@ void register_node_type_geo_attribute_convert() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_CONVERT, "Attribute Convert", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_convert_in, geo_node_attribute_convert_out); + ntype.declare = blender::nodes::geo_node_attribute_convert_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_convert_exec; - ntype.draw_buttons = geo_node_attribute_convert_layout; - node_type_init(&ntype, geo_node_attribute_convert_init); + ntype.draw_buttons = blender::nodes::geo_node_attribute_convert_layout; + node_type_init(&ntype, blender::nodes::geo_node_attribute_convert_init); node_type_storage( &ntype, "NodeAttributeConvert", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc index 3b951bda95e..cb86dfa90a8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_curve_map.cc @@ -24,17 +24,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_curve_map_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Attribute")}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_curve_map_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_curve_map_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Attribute"); + b.add_input("Result"); + b.add_output("Geometry"); +} static void geo_node_attribute_curve_map_layout(uiLayout *layout, bContext *UNUSED(C), @@ -101,8 +99,6 @@ static void geo_node_attribute_curve_map_update(bNodeTree *UNUSED(ntree), bNode } } -namespace blender::nodes { - static AttributeDomain get_result_domain(const GeometryComponent &component, StringRef input_name, StringRef result_name) @@ -216,16 +212,15 @@ void register_node_type_geo_attribute_curve_map() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_CURVE_MAP, "Attribute Curve Map", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_curve_map_in, geo_node_attribute_curve_map_out); - node_type_update(&ntype, geo_node_attribute_curve_map_update); - node_type_init(&ntype, geo_node_attribute_curve_map_init); + node_type_update(&ntype, blender::nodes::geo_node_attribute_curve_map_update); + node_type_init(&ntype, blender::nodes::geo_node_attribute_curve_map_init); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_storage(&ntype, "NodeAttributeCurveMap", - geo_node_attribute_curve_map_free_storage, - geo_node_attribute_curve_map_copy_storage); + blender::nodes::geo_node_attribute_curve_map_free_storage, + blender::nodes::geo_node_attribute_curve_map_copy_storage); + ntype.declare = blender::nodes::geo_node_attribute_curve_map_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_curve_map_exec; - ntype.draw_buttons = geo_node_attribute_curve_map_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_curve_map_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc index 00f38fb0c6b..4cb452a97cd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc @@ -22,28 +22,26 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_map_range_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Attribute")}, - {SOCK_STRING, N_("Result")}, - {SOCK_FLOAT, N_("From Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("From Max"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("To Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("To Max"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("Steps"), 4.0f, 4.0f, 4.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("From Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("From Max"), 1.0f, 1.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("To Min"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("To Max"), 1.0f, 1.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("Steps"), 4.0f, 4.0f, 4.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_BOOLEAN, N_("Clamp")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_map_range_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_map_range_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Attribute"); + b.add_input("Result"); + b.add_input("From Min"); + b.add_input("From Max").default_value(1.0f); + b.add_input("To Min"); + b.add_input("To Max").default_value(1.0f); + b.add_input("Steps").default_value(4.0f); + b.add_input("From Min", "From Min_001"); + b.add_input("From Max", "From Max_001").default_value({1.0f, 1.0f, 1.0f}); + b.add_input("To Min", "To Min_001"); + b.add_input("To Max", "To Max_001").default_value({1.0f, 1.0f, 1.0f}); + b.add_input("Steps", "Steps_001").default_value({4.0f, 4.0f, 4.0f}); + b.add_input("Clamp"); + b.add_output("Geometry"); +} static void fn_attribute_map_range_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -101,8 +99,6 @@ static void geo_node_attribute_map_range_update(bNodeTree *UNUSED(ntree), bNode node_storage.interpolation_type == NODE_MAP_RANGE_STEPPED); } -namespace blender::nodes { - static float map_linear(const float value, const float min_from, const float max_from, @@ -425,13 +421,12 @@ void register_node_type_geo_attribute_map_range() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_MAP_RANGE, "Attribute Map Range", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_map_range_in, geo_node_attribute_map_range_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_map_range_exec; - node_type_init(&ntype, geo_node_attribute_map_range_init); - node_type_update(&ntype, geo_node_attribute_map_range_update); + node_type_init(&ntype, blender::nodes::geo_node_attribute_map_range_init); + node_type_update(&ntype, blender::nodes::geo_node_attribute_map_range_update); node_type_storage( &ntype, "NodeAttributeMapRange", node_free_standard_storage, node_copy_standard_storage); - ntype.draw_buttons = fn_attribute_map_range_layout; + ntype.declare = blender::nodes::geo_node_attribute_map_range_declare; + ntype.draw_buttons = blender::nodes::fn_attribute_map_range_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc index 368c4025eb7..de1d5ca815d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -25,22 +25,20 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_math_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("A")}, - {SOCK_FLOAT, N_("A"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("B")}, - {SOCK_FLOAT, N_("B"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("C")}, - {SOCK_FLOAT, N_("C"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_math_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_math_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("A"); + b.add_input("A", "A_001"); + b.add_input("B"); + b.add_input("B", "B_001"); + b.add_input("C"); + b.add_input("C", "C_001"); + b.add_input("Result"); + b.add_output("Geometry"); +} static bool operation_use_input_c(const NodeMathOperation operation) { @@ -132,8 +130,6 @@ static void geo_node_attribute_math_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -namespace blender::nodes { - static void geo_node_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { NodeAttributeMath &node_storage = *(NodeAttributeMath *)node->storage; @@ -306,12 +302,12 @@ void register_node_type_geo_attribute_math() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_MATH, "Attribute Math", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates(&ntype, geo_node_attribute_math_in, geo_node_attribute_math_out); + ntype.declare = blender::nodes::geo_node_attribute_math_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_math_exec; - ntype.draw_buttons = geo_node_attribute_math_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_math_layout; node_type_label(&ntype, blender::nodes::geo_node_math_label); node_type_update(&ntype, blender::nodes::geo_node_attribute_math_update); - node_type_init(&ntype, geo_node_attribute_math_init); + node_type_init(&ntype, blender::nodes::geo_node_attribute_math_init); node_type_storage( &ntype, "NodeAttributeMath", node_free_standard_storage, node_copy_standard_storage); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc index 931b7758a57..582b1a88221 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc @@ -25,26 +25,24 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_mix_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Factor")}, - {SOCK_FLOAT, N_("Factor"), 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, PROP_FACTOR}, - {SOCK_STRING, N_("A")}, - {SOCK_FLOAT, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_RGBA, N_("A"), 0.5, 0.5, 0.5, 1.0}, - {SOCK_STRING, N_("B")}, - {SOCK_FLOAT, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_RGBA, N_("B"), 0.5, 0.5, 0.5, 1.0}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_mix_attribute_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +static void geo_node_mix_attribute_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Factor"); + b.add_input("Factor").default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_input("A"); + b.add_input("A", "A_001"); + b.add_input("A", "A_002"); + b.add_input("A", "A_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); + b.add_input("B"); + b.add_input("B", "B_001"); + b.add_input("B", "B_002"); + b.add_input("B", "B_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); + b.add_input("Result"); + b.add_output("Geometry"); +} static void geo_node_attribute_mix_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -57,8 +55,6 @@ static void geo_node_attribute_mix_layout(uiLayout *layout, bContext *UNUSED(C), uiItemR(col, ptr, "input_type_b", 0, IFACE_("B"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_attribute_mix_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeAttributeMix *data = (NodeAttributeMix *)MEM_callocN(sizeof(NodeAttributeMix), @@ -243,12 +239,11 @@ static void geo_node_attribute_mix_exec(GeoNodeExecParams params) void register_node_type_geo_attribute_mix() { static bNodeType ntype; - geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_MIX, "Attribute Mix", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates(&ntype, geo_node_attribute_mix_in, geo_node_mix_attribute_out); node_type_init(&ntype, blender::nodes::geo_node_attribute_mix_init); node_type_update(&ntype, blender::nodes::geo_node_attribute_mix_update); - ntype.draw_buttons = geo_node_attribute_mix_layout; + ntype.declare = blender::nodes::geo_node_mix_attribute_declare; + ntype.draw_buttons = blender::nodes::geo_node_attribute_mix_layout; node_type_storage( &ntype, "NodeAttributeMix", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_mix_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc index bfcde288cfb..9ca19f70be6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc @@ -26,18 +26,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_proximity_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_GEOMETRY, N_("Target")}, - {SOCK_STRING, N_("Distance")}, - {SOCK_STRING, N_("Position")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_proximity_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_proximity_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Target"); + b.add_input("Distance"); + b.add_input("Position"); + b.add_output("Geometry"); +} static void geo_node_attribute_proximity_layout(uiLayout *layout, bContext *UNUSED(C), @@ -55,8 +53,6 @@ static void geo_attribute_proximity_init(bNodeTree *UNUSED(ntree), bNode *node) node->storage = node_storage; } -namespace blender::nodes { - static void calculate_mesh_proximity(const VArray &positions, const Mesh &mesh, const GeometryNodeAttributeProximityTargetType type, @@ -242,14 +238,14 @@ void register_node_type_geo_attribute_proximity() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_PROXIMITY, "Attribute Proximity", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_proximity_in, geo_node_attribute_proximity_out); - node_type_init(&ntype, geo_attribute_proximity_init); + node_type_init(&ntype, blender::nodes::geo_attribute_proximity_init); node_type_storage(&ntype, "NodeGeometryAttributeProximity", node_free_standard_storage, node_copy_standard_storage); + + ntype.declare = blender::nodes::geo_node_attribute_proximity_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_proximity_exec; - ntype.draw_buttons = geo_node_attribute_proximity_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_proximity_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc index 15d419a003a..64035c4fc16 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc @@ -23,23 +23,21 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_randomize_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Attribute")}, - {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_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_randomize_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_randomize_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Attribute"); + b.add_input("Min"); + b.add_input("Max").default_value({1.0f, 1.0f, 1.0f}); + b.add_input("Min", "Min_001"); + b.add_input("Max", "Max_001").default_value(1.0f); + b.add_input("Min", "Min_002").min(-100000).max(100000); + b.add_input("Max", "Max_002").default_value(100).min(-100000).max(100000); + b.add_input("Seed").min(-10000).max(10000); + b.add_output("Geometry"); +} static void geo_node_attribute_random_layout(uiLayout *layout, bContext *UNUSED(C), @@ -78,8 +76,6 @@ static void geo_node_attribute_randomize_update(bNodeTree *UNUSED(ntree), bNode nodeSetSocketAvailability(sock_max_int, data_type == CD_PROP_INT32); } -namespace blender::nodes { - template T random_value_in_range(const uint32_t id, const uint32_t seed, const T min, const T max); @@ -336,12 +332,12 @@ void register_node_type_geo_attribute_randomize() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_RANDOMIZE, "Attribute Randomize", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_randomize_in, geo_node_attribute_randomize_out); - node_type_init(&ntype, geo_node_attribute_randomize_init); - node_type_update(&ntype, geo_node_attribute_randomize_update); + node_type_init(&ntype, blender::nodes::geo_node_attribute_randomize_init); + node_type_update(&ntype, blender::nodes::geo_node_attribute_randomize_update); + + ntype.declare = blender::nodes::geo_node_attribute_randomize_declare; ntype.geometry_node_execute = blender::nodes::geo_node_random_attribute_exec; - ntype.draw_buttons = geo_node_attribute_random_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_random_layout; node_type_storage( &ntype, "NodeAttributeRandomize", node_free_standard_storage, node_copy_standard_storage); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc index 5f02061da97..c78a3d956e3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc @@ -28,21 +28,17 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_sample_texture_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_TEXTURE, N_("Texture"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, PROP_NONE, SOCK_HIDE_LABEL}, - {SOCK_STRING, N_("Mapping")}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_sample_texture_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_attribute_sample_texture_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Texture").hide_label(true); + b.add_input("Mapping"); + b.add_input("Result"); + b.add_output("Geometry"); +} + static AttributeDomain get_result_domain(const GeometryComponent &component, const StringRef result_name, const StringRef map_name) @@ -135,8 +131,7 @@ void register_node_type_geo_sample_texture() NODE_CLASS_ATTRIBUTE, 0); node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_socket_templates( - &ntype, geo_node_attribute_sample_texture_in, geo_node_attribute_sample_texture_out); + ntype.declare = blender::nodes::geo_node_attribute_sample_texture_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_sample_texture_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc index 137a72bb707..b1ac608faad 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc @@ -19,20 +19,18 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_separate_xyz_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Vector")}, - {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("Result X")}, - {SOCK_STRING, N_("Result Y")}, - {SOCK_STRING, N_("Result Z")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_separate_xyz_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_separate_xyz_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Vector"); + b.add_input("Vector", "Vector_001"); + b.add_input("Result X"); + b.add_input("Result Y"); + b.add_input("Result Z"); + b.add_output("Geometry"); +} static void geo_node_attribute_separate_xyz_layout(uiLayout *layout, bContext *UNUSED(C), @@ -43,8 +41,6 @@ static void geo_node_attribute_separate_xyz_layout(uiLayout *layout, uiItemR(layout, ptr, "input_type", 0, IFACE_("Type"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_attribute_separate_xyz_init(bNodeTree *UNUSED(tree), bNode *node) { NodeAttributeSeparateXYZ *data = (NodeAttributeSeparateXYZ *)MEM_callocN( @@ -163,13 +159,12 @@ void register_node_type_geo_attribute_separate_xyz() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_SEPARATE_XYZ, "Attribute Separate XYZ", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_separate_xyz_in, geo_node_attribute_separate_xyz_out); + ntype.declare = blender::nodes::geo_node_attribute_separate_xyz_declare; node_type_init(&ntype, blender::nodes::geo_node_attribute_separate_xyz_init); node_type_update(&ntype, blender::nodes::geo_node_attribute_separate_xyz_update); node_type_storage( &ntype, "NodeAttributeSeparateXYZ", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_separate_xyz_exec; - ntype.draw_buttons = geo_node_attribute_separate_xyz_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_separate_xyz_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc index ab2136f4e8d..6cef09aca67 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_transfer.cc @@ -29,18 +29,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_transfer_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_GEOMETRY, N_("Source Geometry")}, - {SOCK_STRING, N_("Source")}, - {SOCK_STRING, N_("Destination")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_transfer_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_transfer_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Source Geometry"); + b.add_input("Source"); + b.add_input("Destination"); + b.add_output("Geometry"); +} static void geo_node_attribute_transfer_layout(uiLayout *layout, bContext *UNUSED(C), @@ -52,8 +50,6 @@ static void geo_node_attribute_transfer_layout(uiLayout *layout, uiItemR(layout, ptr, "mapping", 0, IFACE_("Mapping"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_attribute_transfer_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryAttributeTransfer *data = (NodeGeometryAttributeTransfer *)MEM_callocN( @@ -521,14 +517,13 @@ void register_node_type_geo_attribute_transfer() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_TRANSFER, "Attribute Transfer", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_transfer_in, geo_node_attribute_transfer_out); node_type_init(&ntype, blender::nodes::geo_node_attribute_transfer_init); node_type_storage(&ntype, "NodeGeometryAttributeTransfer", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_attribute_transfer_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_transfer_exec; - ntype.draw_buttons = geo_node_attribute_transfer_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_transfer_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc index be70ebdebfe..47f2cf39d51 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc @@ -26,24 +26,22 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_attribute_vector_math_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("A")}, - {SOCK_VECTOR, N_("A"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("B")}, - {SOCK_VECTOR, N_("B"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("B"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("C")}, - {SOCK_VECTOR, N_("C"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("C"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("Result")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_attribute_vector_math_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_attribute_vector_math_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("A"); + b.add_input("A", "A_001"); + b.add_input("B"); + b.add_input("B", "B_001"); + b.add_input("B", "B_002"); + b.add_input("C"); + b.add_input("C", "C_001"); + b.add_input("C", "C_002"); + b.add_input("Result"); + b.add_output("Geometry"); +} static bool operation_use_input_b(const NodeVectorMathOperation operation) { @@ -154,8 +152,6 @@ static CustomDataType operation_get_result_type(const NodeVectorMathOperation op return CD_PROP_FLOAT3; } -namespace blender::nodes { - static void geo_node_vector_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, @@ -561,14 +557,14 @@ void register_node_type_geo_attribute_vector_math() geo_node_type_base( &ntype, GEO_NODE_ATTRIBUTE_VECTOR_MATH, "Attribute Vector Math", NODE_CLASS_ATTRIBUTE, 0); - node_type_socket_templates( - &ntype, geo_node_attribute_vector_math_in, geo_node_attribute_vector_math_out); + ntype.declare = blender::nodes::geo_node_attribute_vector_math_declare; ntype.geometry_node_execute = blender::nodes::geo_node_attribute_vector_math_exec; - ntype.draw_buttons = geo_node_attribute_vector_math_layout; + ntype.draw_buttons = blender::nodes::geo_node_attribute_vector_math_layout; node_type_label(&ntype, blender::nodes::geo_node_vector_math_label); node_type_update(&ntype, blender::nodes::geo_node_attribute_vector_math_update); - node_type_init(&ntype, geo_node_attribute_vector_math_init); + node_type_init(&ntype, blender::nodes::geo_node_attribute_vector_math_init); node_type_storage( &ntype, "NodeAttributeVectorMath", node_free_standard_storage, node_copy_standard_storage); + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc index 6276849bc94..fdc6b12095c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc @@ -19,20 +19,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_bounding_box_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_bounding_box_out[] = { - {SOCK_GEOMETRY, N_("Bounding Box")}, - {SOCK_VECTOR, N_("Min")}, - {SOCK_VECTOR, N_("Max")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_bounding_box_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_output("Bounding Box"); + b.add_output("Min"); + b.add_output("Max"); +} + using bke::GeometryInstanceGroup; static void compute_min_max_from_position_and_transform(const GeometryComponent &component, @@ -171,7 +167,7 @@ void register_node_type_geo_bounding_box() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_BOUNDING_BOX, "Bounding Box", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_bounding_box_in, geo_node_bounding_box_out); + ntype.declare = blender::nodes::geo_node_bounding_box_declare; ntype.geometry_node_execute = blender::nodes::geo_node_bounding_box_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index b2dc4661e9c..e731b4c0cdc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -23,32 +23,19 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_collection_info_in[] = { - {SOCK_COLLECTION, - N_("Collection"), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - PROP_NONE, - SOCK_HIDE_LABEL}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_collection_info_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_collection_info_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Collection").hide_label(true); + b.add_output("Geometry"); +} static void geo_node_collection_info_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "transform_space", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); } -namespace blender::nodes { - static void geo_node_collection_info_node_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryCollectionInfo *data = (NodeGeometryCollectionInfo *)MEM_callocN( @@ -98,13 +85,13 @@ void register_node_type_geo_collection_info() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_COLLECTION_INFO, "Collection Info", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, geo_node_collection_info_in, geo_node_collection_info_out); + ntype.declare = blender::nodes::geo_node_collection_info_declare; node_type_init(&ntype, blender::nodes::geo_node_collection_info_node_init); node_type_storage(&ntype, "NodeGeometryCollectionInfo", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_collection_info_exec; - ntype.draw_buttons = geo_node_collection_info_layout; + ntype.draw_buttons = blender::nodes::geo_node_collection_info_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc index 91e08d7777b..f1e10e3d276 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -28,18 +28,14 @@ # include "RBI_hull_api.h" #endif -static bNodeSocketTemplate geo_node_convex_hull_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_convex_hull_out[] = { - {SOCK_GEOMETRY, N_("Convex Hull")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_convex_hull_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_output("Convex Hull"); +} + using bke::GeometryInstanceGroup; #ifdef WITH_BULLET @@ -317,7 +313,7 @@ void register_node_type_geo_convex_hull() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CONVEX_HULL, "Convex Hull", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_convex_hull_in, geo_node_convex_hull_out); + ntype.declare = blender::nodes::geo_node_convex_hull_declare; ntype.geometry_node_execute = blender::nodes::geo_node_convex_hull_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc index 1f878259f30..699fcc5e983 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoints.cc @@ -25,19 +25,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_endpoints_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_endpoints_out[] = { - {SOCK_GEOMETRY, N_("Start Points")}, - {SOCK_GEOMETRY, N_("End Points")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_endpoints_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_output("Start Points"); + b.add_output("End Points"); +} + /** * Evaluate splines in parallel to speed up the rest of the node's execution. */ @@ -216,7 +212,7 @@ void register_node_type_geo_curve_endpoints() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_ENDPOINTS, "Curve Endpoints", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_endpoints_in, geo_node_curve_endpoints_out); + ntype.declare = blender::nodes::geo_node_curve_endpoints_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_endpoints_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index a004de4aa03..d8f40b0a0df 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -31,23 +31,19 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_fill_in[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_curve_fill_out[] = { - {SOCK_GEOMETRY, N_("Mesh")}, - {-1, ""}, -}; +static void geo_node_curve_fill_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Curve"); + b.add_output("Mesh"); +} static void geo_node_curve_fill_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); } -namespace blender::nodes { - static void geo_node_curve_fill_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryCurveFill *data = (NodeGeometryCurveFill *)MEM_callocN(sizeof(NodeGeometryCurveFill), @@ -168,11 +164,12 @@ void register_node_type_geo_curve_fill() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_FILL, "Curve Fill", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_fill_in, geo_node_curve_fill_out); + node_type_init(&ntype, blender::nodes::geo_node_curve_fill_init); node_type_storage( &ntype, "NodeGeometryCurveFill", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_curve_fill_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_fill_exec; - ntype.draw_buttons = geo_node_curve_fill_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_fill_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc index 306085e3b75..8fe054633a1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc @@ -17,18 +17,14 @@ #include "BKE_spline.hh" #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_length_in[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_length_out[] = { - {SOCK_FLOAT, N_("Length")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_length_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Curve"); + b.add_output("Length"); +} + static void geo_node_curve_length_exec(GeoNodeExecParams params) { GeometrySet curve_set = params.extract_input("Curve"); @@ -52,7 +48,7 @@ void register_node_type_geo_curve_length() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_LENGTH, "Curve Length", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_length_in, geo_node_curve_length_out); + ntype.declare = blender::nodes::geo_node_curve_length_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_length_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc index 78b5b109419..313473e3442 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc @@ -21,27 +21,20 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_bezier_segment_in[] = { - {SOCK_INT, N_("Resolution"), 16.0f, 0.0f, 0.0f, 0.0f, 1, 256, PROP_UNSIGNED}, - {SOCK_VECTOR, N_("Start"), -1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, - N_("Start Handle"), - -0.5f, - 0.5f, - 0.0f, - 0.0f, - -FLT_MAX, - FLT_MAX, - PROP_TRANSLATION}, - {SOCK_VECTOR, N_("End Handle"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("End"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_curve_primitive_bezier_segment_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Resolution").default_value(16).min(1).max(256).subtype(PROP_UNSIGNED); + b.add_input("Start").default_value({-1.0f, 0.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_input("Start Handle") + .default_value({-0.5f, 0.5f, 0.0f}) + .subtype(PROP_TRANSLATION); + b.add_input("End Handle").subtype(PROP_TRANSLATION); + b.add_input("End").default_value({1.0f, 0.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_output("Curve"); +} -static bNodeSocketTemplate geo_node_curve_primitive_bezier_segment_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; static void geo_node_curve_primitive_bezier_segment_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -49,8 +42,6 @@ static void geo_node_curve_primitive_bezier_segment_layout(uiLayout *layout, uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); } -namespace blender::nodes { - static void geo_node_curve_primitive_bezier_segment_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryCurvePrimitiveBezierSegment *data = (NodeGeometryCurvePrimitiveBezierSegment *) @@ -135,15 +126,13 @@ void register_node_type_geo_curve_primitive_bezier_segment() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT, "Bezier Segment", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, - geo_node_curve_primitive_bezier_segment_in, - geo_node_curve_primitive_bezier_segment_out); node_type_init(&ntype, blender::nodes::geo_node_curve_primitive_bezier_segment_init); node_type_storage(&ntype, "NodeGeometryCurvePrimitiveBezierSegment", node_free_standard_storage, node_copy_standard_storage); - ntype.draw_buttons = geo_node_curve_primitive_bezier_segment_layout; + ntype.declare = blender::nodes::geo_node_curve_primitive_bezier_segment_declare; + ntype.draw_buttons = blender::nodes::geo_node_curve_primitive_bezier_segment_layout; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_bezier_segment_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index ae947b7aeed..f5eb83ea4fd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -21,20 +21,20 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_circle_in[] = { - {SOCK_INT, N_("Resolution"), 32.0f, 0.0f, 0.0f, 0.0f, 3.0f, 512.0f}, - {SOCK_VECTOR, N_("Point 1"), -1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("Point 2"), 0.0f, 1.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("Point 3"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_primitive_circle_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {SOCK_VECTOR, N_("Center")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_curve_primitive_circle_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Resolution").default_value(32).min(3).max(512); + b.add_input("Point 1") + .default_value({-1.0f, 0.0f, 0.0f}) + .subtype(PROP_TRANSLATION); + b.add_input("Point 2").default_value({0.0f, 1.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_input("Point 3").default_value({1.0f, 0.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_input("Radius").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_output("Curve"); + b.add_output("Center"); +} static void geo_node_curve_primitive_circle_layout(uiLayout *layout, bContext *UNUSED(C), @@ -43,8 +43,6 @@ static void geo_node_curve_primitive_circle_layout(uiLayout *layout, uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); } -namespace blender::nodes { - static void geo_node_curve_primitive_circle_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryCurvePrimitiveCircle *data = (NodeGeometryCurvePrimitiveCircle *)MEM_callocN( @@ -209,8 +207,6 @@ void register_node_type_geo_curve_primitive_circle() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_CURVE_PRIMITIVE_CIRCLE, "Curve Circle", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_curve_primitive_circle_in, geo_node_curve_primitive_circle_out); node_type_init(&ntype, blender::nodes::geo_node_curve_primitive_circle_init); node_type_update(&ntype, blender::nodes::geo_node_curve_primitive_circle_update); @@ -218,8 +214,8 @@ void register_node_type_geo_curve_primitive_circle() "NodeGeometryCurvePrimitiveCircle", node_free_standard_storage, node_copy_standard_storage); - + ntype.declare = blender::nodes::geo_node_curve_primitive_circle_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_circle_exec; - ntype.draw_buttons = geo_node_curve_primitive_circle_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_primitive_circle_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index eed3a998ef6..a3d2ada612f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -21,18 +21,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_line_in[] = { - {SOCK_VECTOR, N_("Start"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("End"), 0.0f, 0.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("Direction"), 0.0f, 0.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("Length"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_primitive_line_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_curve_primitive_line_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Start").subtype(PROP_TRANSLATION); + b.add_input("End").default_value({0.0f, 0.0f, 1.0f}).subtype(PROP_TRANSLATION); + b.add_input("Direction").default_value({0.0f, 0.0f, 1.0f}); + b.add_input("Length").default_value(1.0f).subtype(PROP_DISTANCE); + b.add_output("Curve"); +} static void geo_node_curve_primitive_line_layout(uiLayout *layout, bContext *UNUSED(C), @@ -41,8 +39,6 @@ static void geo_node_curve_primitive_line_layout(uiLayout *layout, uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); } -namespace blender::nodes { - static void geo_node_curve_primitive_line_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryCurvePrimitiveLine *data = (NodeGeometryCurvePrimitiveLine *)MEM_callocN( @@ -132,15 +128,14 @@ void register_node_type_geo_curve_primitive_line() { static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_LINE, "Curve Line", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_curve_primitive_line_in, geo_node_curve_primitive_line_out); node_type_init(&ntype, blender::nodes::geo_node_curve_primitive_line_init); node_type_update(&ntype, blender::nodes::geo_node_curve_primitive_line_update); node_type_storage(&ntype, "NodeGeometryCurvePrimitiveLine", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_curve_primitive_line_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_line_exec; - ntype.draw_buttons = geo_node_curve_primitive_line_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_primitive_line_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc index 10211cb2287..a54fd971ac4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadratic_bezier.cc @@ -17,21 +17,17 @@ #include "BKE_spline.hh" #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_quadratic_bezier_in[] = { - {SOCK_INT, N_("Resolution"), 16.0f, 0.0f, 0.0f, 0.0f, 3, 256, PROP_UNSIGNED}, - {SOCK_VECTOR, N_("Start"), -1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("Middle"), 0.0f, 2.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {SOCK_VECTOR, N_("End"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_primitive_quadratic_bezier_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_primitive_quadratic_bezier_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Resolution").default_value(16).min(3).max(256).subtype(PROP_UNSIGNED); + b.add_input("Start").default_value({-1.0f, 0.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_input("Middle").default_value({0.0f, 2.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_input("End").default_value({1.0f, 0.0f, 0.0f}).subtype(PROP_TRANSLATION); + b.add_output("Curve"); +} + static std::unique_ptr create_quadratic_bezier_curve(const float3 p1, const float3 p2, const float3 p3, @@ -74,9 +70,7 @@ void register_node_type_geo_curve_primitive_quadratic_bezier() "Quadratic Bezier", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, - geo_node_curve_primitive_quadratic_bezier_in, - geo_node_curve_primitive_quadratic_bezier_out); + ntype.declare = blender::nodes::geo_node_curve_primitive_quadratic_bezier_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_quadratic_bezier_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index 5f3f159c305..0d78d6c08d1 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -19,25 +19,23 @@ #include "UI_resources.h" #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_quadrilateral_in[] = { - {SOCK_FLOAT, N_("Width"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Height"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Bottom Width"), 4.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Top Width"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Offset"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Bottom Height"), 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Top Height"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_VECTOR, N_("Point 1"), -1.0f, 1.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_VECTOR, N_("Point 2"), 1.0f, 1.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_VECTOR, N_("Point 3"), 1.0f, -1.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_VECTOR, N_("Point 4"), -1.0f, -1.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_primitive_quadrilateral_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_curve_primitive_quadrilateral_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Width").default_value(2.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Height").default_value(2.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Bottom Width").default_value(4.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Top Width").default_value(2.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Offset").default_value(1.0f).subtype(PROP_DISTANCE); + b.add_input("Bottom Height").default_value(3.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Top Height").default_value(1.0f).subtype(PROP_DISTANCE); + b.add_input("Point 1").default_value({-1.0f, 1.0f, 0.0f}).subtype(PROP_DISTANCE); + b.add_input("Point 2").default_value({1.0f, 1.0f, 0.0f}).subtype(PROP_DISTANCE); + b.add_input("Point 3").default_value({1.0f, -1.0f, 0.0f}).subtype(PROP_DISTANCE); + b.add_input("Point 4").default_value({-1.0f, -1.0f, 0.0f}).subtype(PROP_DISTANCE); + b.add_output("Curve"); +} static void geo_node_curve_primitive_quadrilateral_layout(uiLayout *layout, bContext *UNUSED(C), @@ -54,8 +52,6 @@ static void geo_node_curve_primitive_quadrilateral_init(bNodeTree *UNUSED(tree), node->storage = data; } -namespace blender::nodes { - static void geo_node_curve_primitive_quadrilateral_update(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryCurvePrimitiveQuad &node_storage = *(NodeGeometryCurvePrimitiveQuad *)node->storage; @@ -226,13 +222,11 @@ void register_node_type_geo_curve_primitive_quadrilateral() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_CURVE_PRIMITIVE_QUADRILATERAL, "Quadrilateral", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, - geo_node_curve_primitive_quadrilateral_in, - geo_node_curve_primitive_quadrilateral_out); + ntype.declare = blender::nodes::geo_node_curve_primitive_quadrilateral_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_quadrilateral_exec; - ntype.draw_buttons = geo_node_curve_primitive_quadrilateral_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_primitive_quadrilateral_layout; node_type_update(&ntype, blender::nodes::geo_node_curve_primitive_quadrilateral_update); - node_type_init(&ntype, geo_node_curve_primitive_quadrilateral_init); + node_type_init(&ntype, blender::nodes::geo_node_curve_primitive_quadrilateral_init); node_type_storage(&ntype, "NodeGeometryCurvePrimitiveQuad", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc index 8e25fb7f403..169a169bb1c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_spiral.cc @@ -18,23 +18,19 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_spiral_in[] = { - {SOCK_INT, N_("Resolution"), 32.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1024.0f, PROP_UNSIGNED}, - {SOCK_FLOAT, N_("Rotations"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_FLOAT}, - {SOCK_FLOAT, N_("Start Radius"), 1.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("End Radius"), 2.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Height"), 2.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_DISTANCE}, - {SOCK_BOOLEAN, N_("Reverse")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_primitive_spiral_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_primitive_spiral_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Resolution").default_value(32).min(1).max(1024).subtype(PROP_UNSIGNED); + b.add_input("Rotations").default_value(2.0f).min(0.0f); + b.add_input("Start Radius").default_value(1.0f).subtype(PROP_DISTANCE); + b.add_input("End Radius").default_value(2.0f).subtype(PROP_DISTANCE); + b.add_input("Height").default_value(2.0f).subtype(PROP_DISTANCE); + b.add_input("Reverse"); + b.add_output("Curve"); +} + static std::unique_ptr create_spiral_curve(const float rotations, const int resolution, const float start_radius, @@ -100,8 +96,7 @@ void register_node_type_geo_curve_primitive_spiral() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_SPIRAL, "Spiral", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_curve_primitive_spiral_in, geo_node_curve_primitive_spiral_out); + ntype.declare = blender::nodes::geo_node_curve_primitive_spiral_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_spiral_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc index 2e2bb247e2b..6261146562d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc @@ -18,21 +18,17 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_primitive_star_in[] = { - {SOCK_INT, N_("Points"), 8.0f, 0.0f, 0.0f, 0.0f, 3, 256, PROP_UNSIGNED}, - {SOCK_FLOAT, N_("Inner Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Outer Radius"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Twist"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_ANGLE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_primitive_star_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_primitive_star_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Points").default_value(8).min(3).max(256).subtype(PROP_UNSIGNED); + b.add_input("Inner Radius").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Outer Radius").default_value(2.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Twist").subtype(PROP_ANGLE); + b.add_output("Curve"); +} + static std::unique_ptr create_star_curve(const float inner_radius, const float outer_radius, const float twist, @@ -74,8 +70,7 @@ void register_node_type_geo_curve_primitive_star() { static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_STAR, "Star", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_curve_primitive_star_in, geo_node_curve_primitive_star_out); + ntype.declare = blender::nodes::geo_node_curve_primitive_star_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_primitive_star_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index ad0c453c2af..0b71a8cb03a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -30,17 +30,15 @@ using blender::fn::GVArray_For_GSpan; using blender::fn::GVArray_For_Span; using blender::fn::GVArray_Typed; -static bNodeSocketTemplate geo_node_curve_resample_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_INT, N_("Count"), 10, 0, 0, 0, 1, 100000}, - {SOCK_FLOAT, N_("Length"), 0.1f, 0.0f, 0.0f, 0.0f, 0.001f, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_curve_resample_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +static void geo_node_curve_resample_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Count").default_value(10).min(1).max(100000); + b.add_input("Length").default_value(0.1f).min(0.001f).subtype(PROP_DISTANCE); + b.add_output("Geometry"); +} static void geo_node_curve_resample_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -68,8 +66,6 @@ static void geo_node_curve_resample_update(bNodeTree *UNUSED(ntree), bNode *node nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); } -namespace blender::nodes { - struct SampleModeParam { GeometryNodeCurveSampleMode mode; std::optional length; @@ -226,12 +222,12 @@ void register_node_type_geo_curve_resample() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_RESAMPLE, "Resample Curve", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_resample_in, geo_node_curve_resample_out); - ntype.draw_buttons = geo_node_curve_resample_layout; + ntype.declare = blender::nodes::geo_node_curve_resample_declare; + ntype.draw_buttons = blender::nodes::geo_node_curve_resample_layout; node_type_storage( &ntype, "NodeGeometryCurveResample", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, geo_node_curve_resample_init); - node_type_update(&ntype, geo_node_curve_resample_update); + node_type_init(&ntype, blender::nodes::geo_node_curve_resample_init); + node_type_update(&ntype, blender::nodes::geo_node_curve_resample_update); ntype.geometry_node_execute = blender::nodes::geo_node_resample_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc index e92d22a6064..b826e1c6510 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc @@ -20,19 +20,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_reverse_in[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_reverse_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_reverse_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Curve"); + b.add_input("Selection"); + b.add_output("Curve"); +} + /** * Reverse the data in a MutableSpan object. */ @@ -126,7 +122,7 @@ void register_node_type_geo_curve_reverse() { static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_REVERSE, "Curve Reverse", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_reverse_in, geo_node_curve_reverse_out); + ntype.declare = blender::nodes::geo_node_curve_reverse_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_reverse_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_select_by_handle_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_select_by_handle_type.cc index fb21c05b0c0..bf33cf0294e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_select_by_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_select_by_handle_type.cc @@ -23,16 +23,14 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_select_by_handle_type_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_select_by_handle_type_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +static void geo_node_select_by_handle_type_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Selection"); + b.add_output("Geometry"); +} static void geo_node_curve_select_by_handle_type_layout(uiLayout *layout, bContext *UNUSED(C), @@ -68,8 +66,6 @@ static BezierSpline::HandleType handle_type_from_input_type(const GeometryNodeCu return BezierSpline::HandleType::Auto; } -namespace blender::nodes { - static void select_curve_by_handle_type(const CurveEval &curve, const BezierSpline::HandleType type, const GeometryNodeCurveHandleMode mode, @@ -133,15 +129,14 @@ void register_node_type_geo_select_by_handle_type() geo_node_type_base( &ntype, GEO_NODE_CURVE_SELECT_HANDLES, "Select by Handle Type", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_select_by_handle_type_in, geo_node_select_by_handle_type_out); + ntype.declare = blender::nodes::geo_node_select_by_handle_type_declare; ntype.geometry_node_execute = blender::nodes::geo_node_select_by_handle_type_exec; - node_type_init(&ntype, geo_node_curve_select_by_handle_type_init); + node_type_init(&ntype, blender::nodes::geo_node_curve_select_by_handle_type_init); node_type_storage(&ntype, "NodeGeometryCurveSelectHandles", node_free_standard_storage, node_copy_standard_storage); - ntype.draw_buttons = geo_node_curve_select_by_handle_type_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_select_by_handle_type_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc index 72bd8ab188d..0b5be7addaf 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handles.cc @@ -21,16 +21,14 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_set_handles_in[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_curve_set_handles_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; +static void geo_node_curve_set_handles_decalre(NodeDeclarationBuilder &b) +{ + b.add_input("Curve"); + b.add_input("Selection"); + b.add_output("Curve"); +} static void geo_node_curve_set_handles_layout(uiLayout *layout, bContext *UNUSED(C), @@ -40,8 +38,6 @@ static void geo_node_curve_set_handles_layout(uiLayout *layout, uiItemR(layout, ptr, "handle_type", 0, "", ICON_NONE); } -namespace blender::nodes { - static void geo_node_curve_set_handles_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryCurveSetHandles *data = (NodeGeometryCurveSetHandles *)MEM_callocN( @@ -135,15 +131,14 @@ void register_node_type_geo_curve_set_handles() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_CURVE_SET_HANDLES, "Set Handle Type", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_curve_set_handles_in, geo_node_curve_set_handles_out); + ntype.declare = blender::nodes::geo_node_curve_set_handles_decalre; ntype.geometry_node_execute = blender::nodes::geo_node_curve_set_handles_exec; node_type_init(&ntype, blender::nodes::geo_node_curve_set_handles_init); node_type_storage(&ntype, "NodeGeometryCurveSetHandles", node_free_standard_storage, node_copy_standard_storage); - ntype.draw_buttons = geo_node_curve_set_handles_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_set_handles_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index fe3f42625ae..6a093f442cb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -23,16 +23,14 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_spline_type_in[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_curve_spline_type_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; +static void geo_node_curve_spline_type_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Curve"); + b.add_input("Selection"); + b.add_output("Curve"); +} static void geo_node_curve_spline_type_layout(uiLayout *layout, bContext *UNUSED(C), @@ -41,8 +39,6 @@ static void geo_node_curve_spline_type_layout(uiLayout *layout, uiItemR(layout, ptr, "spline_type", 0, "", ICON_NONE); } -namespace blender::nodes { - static void geo_node_curve_spline_type_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryCurveSplineType *data = (NodeGeometryCurveSplineType *)MEM_callocN( @@ -293,15 +289,14 @@ void register_node_type_geo_curve_spline_type() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_CURVE_SPLINE_TYPE, "Set Spline Type", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_curve_spline_type_in, geo_node_curve_spline_type_out); + ntype.declare = blender::nodes::geo_node_curve_spline_type_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_spline_type_exec; node_type_init(&ntype, blender::nodes::geo_node_curve_spline_type_init); node_type_storage(&ntype, "NodeGeometryCurveSplineType", node_free_standard_storage, node_copy_standard_storage); - ntype.draw_buttons = geo_node_curve_spline_type_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_spline_type_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc index 7908c26e2dc..958d83e2967 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc @@ -29,17 +29,15 @@ using blender::fn::GVArray_For_GSpan; using blender::fn::GVArray_For_Span; using blender::fn::GVArray_Typed; -static bNodeSocketTemplate geo_node_curve_subdivide_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Cuts")}, - {SOCK_INT, N_("Cuts"), 1, 0, 0, 0, 0, 1000}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_subdivide_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_curve_subdivide_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Cuts"); + b.add_input("Cuts", "Cuts_001").default_value(1).min(0).max(1000); + b.add_output("Geometry"); +} static void geo_node_curve_subdivide_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -57,8 +55,6 @@ static void geo_node_curve_subdivide_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -namespace blender::nodes { - static void geo_node_curve_subdivide_update(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryPointTranslate &node_storage = *(NodeGeometryPointTranslate *)node->storage; @@ -382,13 +378,13 @@ void register_node_type_geo_curve_subdivide() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_SUBDIVIDE, "Curve Subdivide", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_subdivide_in, geo_node_curve_subdivide_out); - ntype.draw_buttons = geo_node_curve_subdivide_layout; + ntype.declare = blender::nodes::geo_node_curve_subdivide_declare; + ntype.draw_buttons = blender::nodes::geo_node_curve_subdivide_layout; node_type_storage(&ntype, "NodeGeometryCurveSubdivide", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, geo_node_curve_subdivide_init); + node_type_init(&ntype, blender::nodes::geo_node_curve_subdivide_init); node_type_update(&ntype, blender::nodes::geo_node_curve_subdivide_update); ntype.geometry_node_execute = blender::nodes::geo_node_subdivide_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc index ae5ad4e350b..ebaae59fbd6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc @@ -30,19 +30,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_to_mesh_in[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {SOCK_GEOMETRY, N_("Profile Curve")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_to_mesh_out[] = { - {SOCK_GEOMETRY, N_("Mesh")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_curve_to_mesh_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Curve"); + b.add_input("Profile Curve"); + b.add_output("Mesh"); +} + static void vert_extrude_to_mesh_data(const Spline &spline, const float3 profile_vert, MutableSpan r_verts, @@ -374,7 +370,7 @@ void register_node_type_geo_curve_to_mesh() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_TO_MESH, "Curve to Mesh", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_to_mesh_in, geo_node_curve_to_mesh_out); + ntype.declare = blender::nodes::geo_node_curve_to_mesh_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_to_mesh_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index bb8f560f92d..052eb92d269 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -26,17 +26,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_curve_to_points_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_INT, N_("Count"), 10, 0, 0, 0, 2, 100000}, - {SOCK_FLOAT, N_("Length"), 0.1f, 0.0f, 0.0f, 0.0f, 0.001f, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_curve_to_points_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_curve_to_points_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Count").default_value(10).min(2).max(100000); + b.add_input("Length").default_value(0.1f).min(0.001f).subtype(PROP_DISTANCE); + b.add_output("Geometry"); +} static void geo_node_curve_to_points_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -64,8 +62,6 @@ static void geo_node_curve_to_points_update(bNodeTree *UNUSED(ntree), bNode *nod nodeSetSocketAvailability(length_socket, mode == GEO_NODE_CURVE_SAMPLE_LENGTH); } -namespace blender::nodes { - /** * Evaluate splines in parallel to speed up the rest of the node's execution. */ @@ -361,13 +357,13 @@ void register_node_type_geo_curve_to_points() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_TO_POINTS, "Curve to Points", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_curve_to_points_in, geo_node_curve_to_points_out); + ntype.declare = blender::nodes::geo_node_curve_to_points_declare; ntype.geometry_node_execute = blender::nodes::geo_node_curve_to_points_exec; - ntype.draw_buttons = geo_node_curve_to_points_layout; + ntype.draw_buttons = blender::nodes::geo_node_curve_to_points_layout; node_type_storage( &ntype, "NodeGeometryCurveToPoints", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, geo_node_curve_to_points_init); - node_type_update(&ntype, geo_node_curve_to_points_update); + node_type_init(&ntype, blender::nodes::geo_node_curve_to_points_init); + node_type_update(&ntype, blender::nodes::geo_node_curve_to_points_update); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 8c697275f88..6bc0ab49959 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -43,20 +43,16 @@ extern void copy_masked_polys_to_new_mesh(const Mesh &src_mesh, blender::Span masked_poly_indices, blender::Span new_loop_starts); -static bNodeSocketTemplate geo_node_delete_geometry_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Selection")}, - {SOCK_BOOLEAN, N_("Invert")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_delete_geometry_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_delete_geometry_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Selection"); + b.add_input("Invert"); + b.add_output("Geometry"); +} + template static void copy_data(Span data, MutableSpan r_data, IndexMask mask) { for (const int i_out : mask.index_range()) { @@ -102,7 +98,8 @@ static void copy_dynamic_attributes(const CustomDataAttributes &src, BLI_assert(src_attribute); if (!dst.create(name, meta_data.data_type)) { - /* Since the source spline of the same type had the attribute, adding it should work. */ + /* Since the source spline of the same type had the attribute, adding it should work. + */ BLI_assert_unreachable(); } @@ -304,8 +301,8 @@ static void compute_selected_polygons_from_vertex_selection(const Mesh &mesh, } /** - * Checks for every edge if it is in `edge_selection`. If it is, then the two vertices of the edge - * are kept along with the edge. + * Checks for every edge if it is in `edge_selection`. If it is, then the two vertices of the + * edge are kept along with the edge. */ static void compute_selected_vertices_and_edges_from_edge_selection( const Mesh &mesh, @@ -672,7 +669,8 @@ void register_node_type_geo_delete_geometry() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_DELETE_GEOMETRY, "Delete Geometry", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_delete_geometry_in, geo_node_delete_geometry_out); + + ntype.declare = blender::nodes::geo_node_delete_geometry_declare; ntype.geometry_node_execute = blender::nodes::geo_node_delete_geometry_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_assign.cc b/source/blender/nodes/geometry/nodes/node_geo_material_assign.cc index 02b2d685bdd..4d0b4cfecbc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_assign.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_assign.cc @@ -24,29 +24,16 @@ #include "BKE_material.h" -static bNodeSocketTemplate geo_node_material_assign_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_MATERIAL, - N_("Material"), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - PROP_NONE, - SOCK_HIDE_LABEL}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_material_assign_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_material_assign_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Material").hide_label(true); + b.add_input("Selection"); + b.add_output("Geometry"); +} + static void assign_material_to_faces(Mesh &mesh, const VArray &face_mask, Material *material) { int new_material_index = -1; @@ -101,7 +88,7 @@ void register_node_type_geo_material_assign() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MATERIAL_ASSIGN, "Material Assign", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_material_assign_in, geo_node_material_assign_out); + ntype.declare = blender::nodes::geo_node_material_assign_declare; ntype.geometry_node_execute = blender::nodes::geo_node_material_assign_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc b/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc index 40ecab98dea..a9c3bfc6ce0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc @@ -24,20 +24,16 @@ #include "BKE_material.h" -static bNodeSocketTemplate geo_node_material_replace_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_MATERIAL, N_("Old")}, - {SOCK_MATERIAL, N_("New")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_material_replace_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_material_replace_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Old"); + b.add_input("New"); + b.add_output("Geometry"); +} + static void geo_node_material_replace_exec(GeoNodeExecParams params) { Material *old_material = params.extract_input("Old"); @@ -69,7 +65,7 @@ void register_node_type_geo_material_replace() geo_node_type_base( &ntype, GEO_NODE_MATERIAL_REPLACE, "Material Replace", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_material_replace_in, geo_node_material_replace_out); + ntype.declare = blender::nodes::geo_node_material_replace_declare; ntype.geometry_node_execute = blender::nodes::geo_node_material_replace_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc index 1de3942b462..f5d9ed2d6a9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc @@ -22,21 +22,17 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_primitive_cube_in[] = { - {SOCK_VECTOR, N_("Size"), 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, FLT_MAX, PROP_TRANSLATION}, - {SOCK_INT, N_("Vertices X"), 2, 0.0f, 0.0f, 0.0f, 2, 1000}, - {SOCK_INT, N_("Vertices Y"), 2, 0.0f, 0.0f, 0.0f, 2, 1000}, - {SOCK_INT, N_("Vertices Z"), 2, 0.0f, 0.0f, 0.0f, 2, 1000}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_primitive_cube_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_mesh_primitive_cube_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Size").default_value({1.0f, 1.0f, 1.0f}).subtype(PROP_TRANSLATION); + b.add_input("Vertices X").default_value(2).min(2).max(1000); + b.add_input("Vertices Y").default_value(2).min(2).max(1000); + b.add_input("Vertices Z").default_value(2).min(2).max(1000); + b.add_output("Geometry"); +} + struct CuboidConfig { float3 size; int verts_x; @@ -496,8 +492,7 @@ void register_node_type_geo_mesh_primitive_cube() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_CUBE, "Cube", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_mesh_primitive_cube_in, geo_node_mesh_primitive_cube_out); + ntype.declare = blender::nodes::geo_node_mesh_primitive_cube_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_cube_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index b40cb478b03..ed701c921ca 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -25,17 +25,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_primitive_cylinder_in[] = { - {SOCK_INT, N_("Vertices"), 32, 0.0f, 0.0f, 0.0f, 3, 4096}, - {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Depth"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_primitive_cylinder_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_mesh_primitive_cylinder_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Vertices").default_value(32).min(3).max(4096); + b.add_input("Radius").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Depth").default_value(2.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_output("Geometry"); +} static void geo_node_mesh_primitive_cylinder_layout(uiLayout *layout, bContext *UNUSED(C), @@ -56,8 +54,6 @@ static void geo_node_mesh_primitive_cylinder_init(bNodeTree *UNUSED(ntree), bNod node->storage = node_storage; } -namespace blender::nodes { - static void geo_node_mesh_primitive_cylinder_exec(GeoNodeExecParams params) { const bNode &node = params.node(); @@ -86,14 +82,12 @@ static void geo_node_mesh_primitive_cylinder_exec(GeoNodeExecParams params) void register_node_type_geo_mesh_primitive_cylinder() { static bNodeType ntype; - geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_CYLINDER, "Cylinder", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_mesh_primitive_cylinder_in, geo_node_mesh_primitive_cylinder_out); - node_type_init(&ntype, geo_node_mesh_primitive_cylinder_init); + node_type_init(&ntype, blender::nodes::geo_node_mesh_primitive_cylinder_init); node_type_storage( &ntype, "NodeGeometryMeshCylinder", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_mesh_primitive_cylinder_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_cylinder_exec; - ntype.draw_buttons = geo_node_mesh_primitive_cylinder_layout; + ntype.draw_buttons = blender::nodes::geo_node_mesh_primitive_cylinder_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc index ad963898138..858ef8648f8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc @@ -25,21 +25,17 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_primitive_grid_in[] = { - {SOCK_FLOAT, N_("Size X"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Size Y"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_INT, N_("Vertices X"), 3, 0.0f, 0.0f, 0.0f, 2, 1000}, - {SOCK_INT, N_("Vertices Y"), 3, 0.0f, 0.0f, 0.0f, 2, 1000}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_primitive_grid_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_mesh_primitive_grid_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Size X").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Size Y").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Vertices X").default_value(3).min(2).max(1000); + b.add_input("Vertices Y").default_value(3).min(2).max(1000); + b.add_output("Geometry"); +} + static void calculate_uvs( Mesh *mesh, Span verts, Span loops, const float size_x, const float size_y) { @@ -182,8 +178,7 @@ void register_node_type_geo_mesh_primitive_grid() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_GRID, "Grid", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_mesh_primitive_grid_in, geo_node_mesh_primitive_grid_out); + ntype.declare = blender::nodes::geo_node_mesh_primitive_grid_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_grid_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc index 22195b9e8db..d77551367a9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc @@ -24,19 +24,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_primitive_ico_sphere_in[] = { - {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_INT, N_("Subdivisions"), 1, 0, 0, 0, 1, 7}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_primitive_ico_sphere_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_mesh_primitive_ico_sphere_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Radius").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_input("Subdivisions").default_value(1).min(1).max(7); + b.add_output("Geometry"); +} + static Mesh *create_ico_sphere_mesh(const int subdivisions, const float radius) { const float4x4 transform = float4x4::identity(); @@ -81,8 +77,7 @@ void register_node_type_geo_mesh_primitive_ico_sphere() geo_node_type_base( &ntype, GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE, "Ico Sphere", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_mesh_primitive_ico_sphere_in, geo_node_mesh_primitive_ico_sphere_out); + ntype.declare = blender::nodes::geo_node_mesh_primitive_ico_sphere_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_ico_sphere_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index ad0bd854a8f..031223b5ca6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -25,26 +25,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_primitive_line_in[] = { - {SOCK_INT, N_("Count"), 10, 0.0f, 0.0f, 0.0f, 1, 10000}, - {SOCK_FLOAT, N_("Resolution"), 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX, PROP_DISTANCE}, - {SOCK_VECTOR, - N_("Start Location"), - 0.0f, - 0.0f, - 0.0f, - 1.0f, - -FLT_MAX, - FLT_MAX, - PROP_TRANSLATION}, - {SOCK_VECTOR, N_("Offset"), 0.0f, 0.0f, 1.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_primitive_line_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_mesh_primitive_line_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Count").default_value(10).min(1).max(10000); + b.add_input("Resolution").default_value(1.0f).min(0.1f).subtype(PROP_DISTANCE); + b.add_input("Start Location").subtype(PROP_TRANSLATION); + b.add_input("Offset").default_value({0.0f, 0.0f, 1.0f}).subtype(PROP_TRANSLATION); + b.add_output("Geometry"); +} static void geo_node_mesh_primitive_line_layout(uiLayout *layout, bContext *UNUSED(C), @@ -93,8 +83,6 @@ static void geo_node_mesh_primitive_line_update(bNodeTree *UNUSED(tree), bNode * count_mode == GEO_NODE_MESH_LINE_COUNT_TOTAL); } -namespace blender::nodes { - static void fill_edge_data(MutableSpan edges) { for (const int i : edges.index_range()) { @@ -176,13 +164,12 @@ void register_node_type_geo_mesh_primitive_line() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_LINE, "Mesh Line", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_mesh_primitive_line_in, geo_node_mesh_primitive_line_out); - node_type_init(&ntype, geo_node_mesh_primitive_line_init); - node_type_update(&ntype, geo_node_mesh_primitive_line_update); + ntype.declare = blender::nodes::geo_node_mesh_primitive_line_declare; + node_type_init(&ntype, blender::nodes::geo_node_mesh_primitive_line_init); + node_type_update(&ntype, blender::nodes::geo_node_mesh_primitive_line_update); node_type_storage( &ntype, "NodeGeometryMeshLine", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_line_exec; - ntype.draw_buttons = geo_node_mesh_primitive_line_layout; + ntype.draw_buttons = blender::nodes::geo_node_mesh_primitive_line_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index affba602234..6fd6cdf5747 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -25,20 +25,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_primitive_uv_sphere_in[] = { - {SOCK_INT, N_("Segments"), 32, 0.0f, 0.0f, 0.0f, 3, 1024}, - {SOCK_INT, N_("Rings"), 16, 0.0f, 0.0f, 0.0f, 2, 1024}, - {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_primitive_uv_sphere_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_mesh_primitive_uv_shpere_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Segments").default_value(32).min(3).max(1024); + b.add_input("Rings").default_value(16).min(2).max(1024); + b.add_input("Radius").default_value(1.0f).min(0.0f).subtype(PROP_DISTANCE); + b.add_output("Geometry"); +} + static int sphere_vert_total(const int segments, const int rings) { return segments * (rings - 1) + 2; @@ -313,8 +309,7 @@ void register_node_type_geo_mesh_primitive_uv_sphere() geo_node_type_base( &ntype, GEO_NODE_MESH_PRIMITIVE_UV_SPHERE, "UV Sphere", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_mesh_primitive_uv_sphere_in, geo_node_mesh_primitive_uv_sphere_out); + ntype.declare = blender::nodes::geo_node_mesh_primitive_uv_shpere_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_primitive_uv_sphere_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc index 165da8ec9f2..9ca74fed9a7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc @@ -23,19 +23,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_mesh_subdivide_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_INT, N_("Level"), 1, 0, 0, 0, 0, 6}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_subdivide_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_mesh_subdivide_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Level").default_value(1).min(0).max(6); + b.add_output("Geometry"); +} + static void geo_node_mesh_subdivide_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); @@ -105,7 +101,7 @@ void register_node_type_geo_mesh_subdivide() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_SUBDIVIDE, "Mesh Subdivide", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_mesh_subdivide_in, geo_node_mesh_subdivide_out); + ntype.declare = blender::nodes::geo_node_mesh_subdivide_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_subdivide_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc index 637003a46c7..2cea60ea112 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc @@ -27,19 +27,15 @@ using blender::Array; -static bNodeSocketTemplate geo_node_mesh_to_curve_in[] = { - {SOCK_GEOMETRY, N_("Mesh")}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_mesh_to_curve_out[] = { - {SOCK_GEOMETRY, N_("Curve")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_mesh_to_curve_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Mesh"); + b.add_input("Selection"); + b.add_output("Curve"); +} + template static void copy_attribute_to_points(const VArray &source_data, Span map, @@ -310,7 +306,7 @@ void register_node_type_geo_mesh_to_curve() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_TO_CURVE, "Mesh to Curve", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_mesh_to_curve_in, geo_node_mesh_to_curve_out); + ntype.declare = blender::nodes::geo_node_mesh_to_curve_declare; ntype.geometry_node_execute = blender::nodes::geo_node_mesh_to_curve_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc index 99930b5ae46..cf874bea718 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc @@ -39,19 +39,21 @@ using blender::bke::AttributeKind; using blender::bke::GeometryInstanceGroup; -static bNodeSocketTemplate geo_node_point_distribute_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_FLOAT, N_("Distance Min"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 100000.0f, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Density Max"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 100000.0f, PROP_NONE}, - {SOCK_STRING, N_("Density Attribute")}, - {SOCK_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_point_distribute_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_point_distribute_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Distance Min").min(0.0f).max(100000.0f).subtype(PROP_DISTANCE); + b.add_input("Density Max") + .default_value(1.0f) + .min(0.0f) + .max(100000.0f) + .subtype(PROP_NONE); + b.add_input("Density Attribute"); + b.add_input("Seed").min(-10000).max(10000); + b.add_output("Geometry"); +} static void geo_node_point_distribute_layout(uiLayout *layout, bContext *UNUSED(C), @@ -67,8 +69,6 @@ static void node_point_distribute_update(bNodeTree *UNUSED(ntree), bNode *node) nodeSetSocketAvailability(sock_min_dist, ELEM(node->custom1, GEO_NODE_POINT_DISTRIBUTE_POISSON)); } -namespace blender::nodes { - /** * Use an arbitrary choice of axes for a usable rotation attribute directly out of this node. */ @@ -650,9 +650,9 @@ void register_node_type_geo_point_distribute() geo_node_type_base( &ntype, GEO_NODE_POINT_DISTRIBUTE, "Point Distribute", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_point_distribute_in, geo_node_point_distribute_out); - node_type_update(&ntype, node_point_distribute_update); + node_type_update(&ntype, blender::nodes::node_point_distribute_update); + ntype.declare = blender::nodes::geo_node_point_distribute_declare; ntype.geometry_node_execute = blender::nodes::geo_node_point_distribute_exec; - ntype.draw_buttons = geo_node_point_distribute_layout; + ntype.draw_buttons = blender::nodes::geo_node_point_distribute_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc index b119b7b31e9..36017307739 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc @@ -24,27 +24,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_point_instance_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_OBJECT, N_("Object"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, PROP_NONE, SOCK_HIDE_LABEL}, - {SOCK_COLLECTION, - N_("Collection"), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - PROP_NONE, - SOCK_HIDE_LABEL}, - {SOCK_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_point_instance_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_point_instance_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Object").hide_label(true); + b.add_input("Collection").hide_label(true); + b.add_input("Seed").min(-10000).max(10000); + b.add_output("Geometry"); +} static void geo_node_point_instance_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -54,8 +43,6 @@ static void geo_node_point_instance_layout(uiLayout *layout, bContext *UNUSED(C) } } -namespace blender::nodes { - static void geo_node_point_instance_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryPointInstance *data = (NodeGeometryPointInstance *)MEM_callocN( @@ -259,11 +246,11 @@ void register_node_type_geo_point_instance() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_POINT_INSTANCE, "Point Instance", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_point_instance_in, geo_node_point_instance_out); node_type_init(&ntype, blender::nodes::geo_node_point_instance_init); node_type_storage( &ntype, "NodeGeometryPointInstance", node_free_standard_storage, node_copy_standard_storage); - ntype.draw_buttons = geo_node_point_instance_layout; + ntype.declare = blender::nodes::geo_node_point_instance_declare; + ntype.draw_buttons = blender::nodes::geo_node_point_instance_layout; node_type_update(&ntype, blender::nodes::geo_node_point_instance_update); ntype.geometry_node_execute = blender::nodes::geo_node_point_instance_exec; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc index 828d3f50551..4d77bcc132f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc @@ -21,21 +21,19 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_point_rotate_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Axis")}, - {SOCK_VECTOR, N_("Axis"), 0.0, 0.0, 1.0, 0.0, -FLT_MAX, FLT_MAX, PROP_XYZ}, - {SOCK_STRING, N_("Angle")}, - {SOCK_FLOAT, N_("Angle"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX, PROP_ANGLE}, - {SOCK_STRING, N_("Rotation")}, - {SOCK_VECTOR, N_("Rotation"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX, PROP_EULER}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_point_rotate_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_point_rotate_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Axis"); + b.add_input("Axis", "Axis_001").default_value({0.0, 0.0, 1.0}).subtype(PROP_XYZ); + b.add_input("Angle"); + b.add_input("Angle", "Angle_001").subtype(PROP_ANGLE); + b.add_input("Rotation"); + b.add_input("Rotation", "Rotation_001").subtype(PROP_EULER); + b.add_output("Geometry"); +} static void geo_node_point_rotate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -57,8 +55,6 @@ static void geo_node_point_rotate_layout(uiLayout *layout, bContext *UNUSED(C), } } -namespace blender::nodes { - static void geo_node_point_rotate_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryRotatePoints *node_storage = (NodeGeometryRotatePoints *)MEM_callocN( @@ -224,12 +220,12 @@ void register_node_type_geo_point_rotate() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_POINT_ROTATE, "Point Rotate", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_point_rotate_in, geo_node_point_rotate_out); node_type_init(&ntype, blender::nodes::geo_node_point_rotate_init); node_type_update(&ntype, blender::nodes::geo_node_point_rotate_update); node_type_storage( &ntype, "NodeGeometryRotatePoints", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_point_rotate_declare; ntype.geometry_node_execute = blender::nodes::geo_node_point_rotate_exec; - ntype.draw_buttons = geo_node_point_rotate_layout; + ntype.draw_buttons = blender::nodes::geo_node_point_rotate_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc index 265ec9fb776..1a7ab9817d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc @@ -21,18 +21,18 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_point_scale_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Factor")}, - {SOCK_VECTOR, N_("Factor"), 1.0f, 1.0f, 1.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_XYZ}, - {SOCK_FLOAT, N_("Factor"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_point_scale_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_point_scale_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Factor"); + b.add_input("Factor", "Factor_001") + .default_value({1.0f, 1.0f, 1.0f}) + .subtype(PROP_XYZ); + b.add_input("Factor", "Factor_002").default_value(1.0f).min(0.0f); + b.add_output("Geometry"); +} static void geo_node_point_scale_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -41,8 +41,6 @@ static void geo_node_point_scale_layout(uiLayout *layout, bContext *UNUSED(C), P uiItemR(layout, ptr, "input_type", 0, IFACE_("Type"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_point_scale_init(bNodeTree *UNUSED(tree), bNode *node) { NodeGeometryPointScale *data = (NodeGeometryPointScale *)MEM_callocN( @@ -129,12 +127,13 @@ void register_node_type_geo_point_scale() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_POINT_SCALE, "Point Scale", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_point_scale_in, geo_node_point_scale_out); + + ntype.declare = blender::nodes::geo_node_point_scale_declare; node_type_init(&ntype, blender::nodes::geo_node_point_scale_init); node_type_update(&ntype, blender::nodes::geo_node_point_scale_update); node_type_storage( &ntype, "NodeGeometryPointScale", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_point_scale_exec; - ntype.draw_buttons = geo_node_point_scale_layout; + ntype.draw_buttons = blender::nodes::geo_node_point_scale_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index fc04d1e275f..1b0061346c4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -23,20 +23,16 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_point_instance_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Mask")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_point_instance_out[] = { - {SOCK_GEOMETRY, N_("Geometry 1")}, - {SOCK_GEOMETRY, N_("Geometry 2")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_point_instance_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Mask"); + b.add_output("Geometry 1"); + b.add_output("Geometry 2"); +} + template static void copy_data_based_on_mask(Span data, Span masks, @@ -169,7 +165,7 @@ void register_node_type_geo_point_separate() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_POINT_SEPARATE, "Point Separate", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_point_instance_in, geo_node_point_instance_out); + ntype.declare = blender::nodes::geo_node_point_instance_declare; ntype.geometry_node_execute = blender::nodes::geo_node_point_separate_exec; ntype.geometry_node_execute_supports_laziness = true; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc index 293f151fe19..d187bf0fa71 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc @@ -19,17 +19,15 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_point_translate_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Translation")}, - {SOCK_VECTOR, N_("Translation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_point_translate_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_point_translate_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Translation"); + b.add_input("Translation", "Translation_001").subtype(PROP_TRANSLATION); + b.add_output("Geometry"); +} static void geo_node_point_translate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -38,8 +36,6 @@ static void geo_node_point_translate_layout(uiLayout *layout, bContext *UNUSED(C uiItemR(layout, ptr, "input_type", 0, IFACE_("Type"), ICON_NONE); } -namespace blender::nodes { - static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) { OutputAttribute_Typed position_attribute = @@ -100,14 +96,14 @@ void register_node_type_geo_point_translate() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_POINT_TRANSLATE, "Point Translate", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_point_translate_in, geo_node_point_translate_out); node_type_init(&ntype, blender::nodes::geo_node_point_translate_init); node_type_update(&ntype, blender::nodes::geo_node_point_translate_update); node_type_storage(&ntype, "NodeGeometryPointTranslate", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_point_translate_declare; ntype.geometry_node_execute = blender::nodes::geo_node_point_translate_exec; - ntype.draw_buttons = geo_node_point_translate_layout; + ntype.draw_buttons = blender::nodes::geo_node_point_translate_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index 65306b1c452..8f34fff9f66 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -28,20 +28,18 @@ #include "UI_interface.h" #include "UI_resources.h" -static bNodeSocketTemplate geo_node_points_to_volume_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_FLOAT, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {SOCK_FLOAT, N_("Voxel Size"), 0.3f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Voxel Amount"), 64.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {SOCK_STRING, N_("Radius")}, - {SOCK_FLOAT, N_("Radius"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_points_to_volume_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +static void geo_node_points_to_volume_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Density").default_value(1.0f).min(0.0f); + b.add_input("Voxel Size").default_value(0.3f).min(0.01f).subtype(PROP_DISTANCE); + b.add_input("Voxel Amount").default_value(64.0f).min(0.0f); + b.add_input("Radius"); + b.add_input("Radius", "Radius_001").default_value(0.5f).min(0.0f); + b.add_output("Geometry"); +} static void geo_node_points_to_volume_layout(uiLayout *layout, bContext *UNUSED(C), @@ -53,8 +51,6 @@ static void geo_node_points_to_volume_layout(uiLayout *layout, uiItemR(layout, ptr, "input_type_radius", 0, IFACE_("Radius"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_points_to_volume_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryPointsToVolume *data = (NodeGeometryPointsToVolume *)MEM_callocN( @@ -268,7 +264,6 @@ void register_node_type_geo_points_to_volume() geo_node_type_base( &ntype, GEO_NODE_POINTS_TO_VOLUME, "Points to Volume", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_points_to_volume_in, geo_node_points_to_volume_out); node_type_storage(&ntype, "NodeGeometryPointsToVolume", node_free_standard_storage, @@ -276,7 +271,8 @@ void register_node_type_geo_points_to_volume() node_type_size(&ntype, 170, 120, 700); node_type_init(&ntype, blender::nodes::geo_node_points_to_volume_init); node_type_update(&ntype, blender::nodes::geo_node_points_to_volume_update); + ntype.declare = blender::nodes::geo_node_points_to_volume_declare; ntype.geometry_node_execute = blender::nodes::geo_node_points_to_volume_exec; - ntype.draw_buttons = geo_node_points_to_volume_layout; + ntype.draw_buttons = blender::nodes::geo_node_points_to_volume_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index 88e3bf17d43..ed7ed87fa46 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -24,26 +24,28 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_raycast_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_GEOMETRY, N_("Target Geometry")}, - {SOCK_STRING, N_("Ray Direction")}, - {SOCK_VECTOR, N_("Ray Direction"), 0.0, 0.0, 1.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_STRING, N_("Ray Length")}, - {SOCK_FLOAT, N_("Ray Length"), 100.0, 0.0, 0.0, 0.0, 0.0f, FLT_MAX, PROP_DISTANCE}, - {SOCK_STRING, N_("Target Attribute")}, - {SOCK_STRING, N_("Is Hit")}, - {SOCK_STRING, N_("Hit Position")}, - {SOCK_STRING, N_("Hit Normal")}, - {SOCK_STRING, N_("Hit Distance")}, - {SOCK_STRING, N_("Hit Attribute")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_raycast_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_raycast_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Target Geometry"); + b.add_input("Ray Direction"); + b.add_input("Ray Direction", "Ray Direction_001") + .default_value({0.0f, 0.0f, 1.0f}); + b.add_input("Ray Length"); + b.add_input("Ray Length", "Ray Length_001") + .default_value(100.0f) + .min(0.0f) + .subtype(PROP_DISTANCE); + b.add_input("Target Attribute"); + b.add_input("Is Hit"); + b.add_input("Hit Position"); + b.add_input("Hit Normal"); + b.add_input("Hit Distance"); + b.add_input("Hit Attribute"); + b.add_output("Geometry"); +} static void geo_node_raycast_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -63,8 +65,6 @@ static void geo_node_raycast_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -namespace blender::nodes { - static void geo_node_raycast_update(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryRaycast *node_storage = (NodeGeometryRaycast *)node->storage; @@ -309,13 +309,13 @@ void register_node_type_geo_raycast() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_RAYCAST, "Raycast", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_raycast_in, geo_node_raycast_out); node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, geo_node_raycast_init); + node_type_init(&ntype, blender::nodes::geo_node_raycast_init); node_type_update(&ntype, blender::nodes::geo_node_raycast_update); node_type_storage( &ntype, "NodeGeometryRaycast", node_free_standard_storage, node_copy_standard_storage); + ntype.declare = blender::nodes::geo_node_raycast_declare; ntype.geometry_node_execute = blender::nodes::geo_node_raycast_exec; - ntype.draw_buttons = geo_node_raycast_layout; + ntype.draw_buttons = blender::nodes::geo_node_raycast_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_select_by_material.cc b/source/blender/nodes/geometry/nodes/node_geo_select_by_material.cc index ee114741a77..79b93502103 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_select_by_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_select_by_material.cc @@ -26,29 +26,16 @@ #include "BKE_material.h" -static bNodeSocketTemplate geo_node_select_by_material_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_MATERIAL, - N_("Material"), - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - PROP_NONE, - SOCK_HIDE_LABEL}, - {SOCK_STRING, N_("Selection")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_select_by_material_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_select_by_material_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Material").hide_label(true); + b.add_input("Selection"); + b.add_output("Geometry"); +} + static void select_mesh_by_material(const Mesh &mesh, const Material *material, const MutableSpan r_selection) @@ -99,8 +86,7 @@ void register_node_type_geo_select_by_material() geo_node_type_base( &ntype, GEO_NODE_SELECT_BY_MATERIAL, "Select by Material", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_select_by_material_in, geo_node_select_by_material_out); + ntype.declare = blender::nodes::geo_node_select_by_material_declare; ntype.geometry_node_execute = blender::nodes::geo_node_select_by_material_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_separate_components.cc b/source/blender/nodes/geometry/nodes/node_geo_separate_components.cc index bdc3e56783c..c63e4ec49d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_separate_components.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_separate_components.cc @@ -16,21 +16,17 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_join_geometry_in[]{ - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_join_geometry_out[]{ - {SOCK_GEOMETRY, N_("Mesh")}, - {SOCK_GEOMETRY, N_("Point Cloud")}, - {SOCK_GEOMETRY, N_("Curve")}, - {SOCK_GEOMETRY, N_("Volume")}, - {-1, ""}, -}; - namespace blender::nodes { +static void geo_node_join_geometry_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_output("Mesh"); + b.add_output("Point Cloud"); + b.add_output("Curve"); + b.add_output("Volume"); +} + static void geo_node_separate_components_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); @@ -71,7 +67,7 @@ void register_node_type_geo_separate_components() geo_node_type_base( &ntype, GEO_NODE_SEPARATE_COMPONENTS, "Separate Components", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_join_geometry_in, geo_node_join_geometry_out); + ntype.declare = blender::nodes::geo_node_join_geometry_declare; ntype.geometry_node_execute = blender::nodes::geo_node_separate_components_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index 4f70252ae75..d127f7dc0ba 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -23,17 +23,15 @@ #include "UI_resources.h" #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_subdivision_surface_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_INT, N_("Level"), 1, 0, 0, 0, 0, 6}, - {SOCK_BOOLEAN, N_("Use Creases")}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_subdivision_surface_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_subdivision_surface_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Level").default_value(1).min(0).max(6); + b.add_input("Use Creases"); + b.add_output("Geometry"); +} static void geo_node_subdivision_surface_layout(uiLayout *layout, bContext *UNUSED(C), @@ -59,7 +57,6 @@ static void geo_node_subdivision_surface_init(bNodeTree *UNUSED(ntree), bNode *n node->storage = data; } -namespace blender::nodes { static void geo_node_subdivision_surface_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); @@ -138,11 +135,10 @@ void register_node_type_geo_subdivision_surface() geo_node_type_base( &ntype, GEO_NODE_SUBDIVISION_SURFACE, "Subdivision Surface", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates( - &ntype, geo_node_subdivision_surface_in, geo_node_subdivision_surface_out); + ntype.declare = blender::nodes::geo_node_subdivision_surface_declare; ntype.geometry_node_execute = blender::nodes::geo_node_subdivision_surface_exec; - ntype.draw_buttons = geo_node_subdivision_surface_layout; - node_type_init(&ntype, geo_node_subdivision_surface_init); + ntype.draw_buttons = blender::nodes::geo_node_subdivision_surface_layout; + node_type_init(&ntype, blender::nodes::geo_node_subdivision_surface_init); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_storage(&ntype, "NodeGeometrySubdivisionSurface", diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_switch.cc index c9ce2de1ea1..ca857c4d2e3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc @@ -19,48 +19,47 @@ #include "UI_interface.h" #include "UI_resources.h" -static bNodeSocketTemplate geo_node_switch_in[] = { - {SOCK_BOOLEAN, N_("Switch")}, +namespace blender::nodes { + +static void geo_node_switch_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Switch"); - {SOCK_FLOAT, N_("False"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_FLOAT, N_("True"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_INT, N_("False"), 0, 0, 0, 0, -100000, 100000}, - {SOCK_INT, N_("True"), 0, 0, 0, 0, -100000, 100000}, - {SOCK_BOOLEAN, N_("False")}, - {SOCK_BOOLEAN, N_("True")}, - {SOCK_VECTOR, N_("False"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_VECTOR, N_("True"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX}, - {SOCK_RGBA, N_("False"), 0.8, 0.8, 0.8, 1.0}, - {SOCK_RGBA, N_("True"), 0.8, 0.8, 0.8, 1.0}, - {SOCK_STRING, N_("False")}, - {SOCK_STRING, N_("True")}, - {SOCK_GEOMETRY, N_("False")}, - {SOCK_GEOMETRY, N_("True")}, - {SOCK_OBJECT, N_("False")}, - {SOCK_OBJECT, N_("True")}, - {SOCK_COLLECTION, N_("False")}, - {SOCK_COLLECTION, N_("True")}, - {SOCK_TEXTURE, N_("False")}, - {SOCK_TEXTURE, N_("True")}, - {SOCK_MATERIAL, N_("False")}, - {SOCK_MATERIAL, N_("True")}, - {-1, ""}, -}; + b.add_input("False"); + b.add_input("True"); + b.add_input("False", "False_001").min(-100000).max(100000); + b.add_input("True", "True_001").min(-100000).max(100000); + b.add_input("False", "False_002"); + b.add_input("True", "True_002"); + b.add_input("False", "False_003"); + b.add_input("True", "True_003"); + b.add_input("False", "False_004").default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input("True", "True_004").default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input("False", "False_005"); + b.add_input("True", "True_005"); + b.add_input("False", "False_006"); + b.add_input("True", "True_006"); + b.add_input("False", "False_007"); + b.add_input("True", "True_007"); + b.add_input("False", "False_008"); + b.add_input("True", "True_008"); + b.add_input("False", "False_009"); + b.add_input("True", "True_009"); + b.add_input("False", "False_010"); + b.add_input("True", "True_010"); -static bNodeSocketTemplate geo_node_switch_out[] = { - {SOCK_FLOAT, N_("Output")}, - {SOCK_INT, N_("Output")}, - {SOCK_BOOLEAN, N_("Output")}, - {SOCK_VECTOR, N_("Output")}, - {SOCK_RGBA, N_("Output")}, - {SOCK_STRING, N_("Output")}, - {SOCK_GEOMETRY, N_("Output")}, - {SOCK_OBJECT, N_("Output")}, - {SOCK_COLLECTION, N_("Output")}, - {SOCK_TEXTURE, N_("Output")}, - {SOCK_MATERIAL, N_("Output")}, - {-1, ""}, -}; + b.add_output("Output"); + b.add_output("Output", "Output_001"); + b.add_output("Output", "Output_002"); + b.add_output("Output", "Output_003"); + b.add_output("Output", "Output_004"); + b.add_output("Output", "Output_005"); + b.add_output("Output", "Output_006"); + b.add_output("Output", "Output_007"); + b.add_output("Output", "Output_008"); + b.add_output("Output", "Output_009"); + b.add_output("Output", "Output_010"); +} static void geo_node_switch_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -74,8 +73,6 @@ static void geo_node_switch_init(bNodeTree *UNUSED(tree), bNode *node) node->storage = data; } -namespace blender::nodes { - static void geo_node_switch_update(bNodeTree *UNUSED(ntree), bNode *node) { NodeSwitch *node_storage = (NodeSwitch *)node->storage; @@ -180,12 +177,12 @@ void register_node_type_geo_switch() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_SWITCH, "Switch", NODE_CLASS_CONVERTER, 0); - node_type_socket_templates(&ntype, geo_node_switch_in, geo_node_switch_out); - node_type_init(&ntype, geo_node_switch_init); + ntype.declare = blender::nodes::geo_node_switch_declare; + node_type_init(&ntype, blender::nodes::geo_node_switch_init); node_type_update(&ntype, blender::nodes::geo_node_switch_update); node_type_storage(&ntype, "NodeSwitch", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = blender::nodes::geo_node_switch_exec; ntype.geometry_node_execute_supports_laziness = true; - ntype.draw_buttons = geo_node_switch_layout; + ntype.draw_buttons = blender::nodes::geo_node_switch_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc index 03581b28f18..8886c7194db 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc @@ -27,16 +27,14 @@ Mesh *triangulate_mesh(Mesh *mesh, const int flag); } -static bNodeSocketTemplate geo_node_triangulate_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_INT, N_("Minimum Vertices"), 4, 0, 0, 0, 4, 10000}, - {-1, ""}, -}; +namespace blender::nodes { -static bNodeSocketTemplate geo_node_triangulate_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +static void geo_node_triangulate_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Minimum Vertices").default_value(4).min(4).max(10000); + b.add_output("Geometry"); +} static void geo_node_triangulate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -50,7 +48,6 @@ static void geo_triangulate_init(bNodeTree *UNUSED(ntree), bNode *node) node->custom2 = GEO_NODE_TRIANGULATE_NGON_BEAUTY; } -namespace blender::nodes { static void geo_node_triangulate_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); @@ -79,9 +76,9 @@ void register_node_type_geo_triangulate() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_TRIANGULATE, "Triangulate", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_triangulate_in, geo_node_triangulate_out); - node_type_init(&ntype, geo_triangulate_init); + ntype.declare = blender::nodes::geo_node_triangulate_declare; + node_type_init(&ntype, blender::nodes::geo_triangulate_init); ntype.geometry_node_execute = blender::nodes::geo_node_triangulate_exec; - ntype.draw_buttons = geo_node_triangulate_layout; + ntype.draw_buttons = blender::nodes::geo_node_triangulate_layout; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index f0b91f49f52..3331962341f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -16,16 +16,18 @@ #include "node_geometry_util.hh" -static bNodeSocketTemplate geo_node_viewer_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { +static void geo_node_viewer_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); +} +} // namespace blender::nodes void register_node_type_geo_viewer() { static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, 0); - node_type_socket_templates(&ntype, geo_node_viewer_in, nullptr); + ntype.declare = blender::nodes::geo_node_viewer_declare; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index 4c1151bf6c2..229a35e0007 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -35,20 +35,18 @@ #include "UI_interface.h" #include "UI_resources.h" -static bNodeSocketTemplate geo_node_volume_to_mesh_in[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {SOCK_STRING, N_("Density")}, - {SOCK_FLOAT, N_("Voxel Size"), 0.3f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX, PROP_DISTANCE}, - {SOCK_FLOAT, N_("Voxel Amount"), 64.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {SOCK_FLOAT, N_("Threshold"), 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX}, - {SOCK_FLOAT, N_("Adaptivity"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - {-1, ""}, -}; - -static bNodeSocketTemplate geo_node_volume_to_mesh_out[] = { - {SOCK_GEOMETRY, N_("Geometry")}, - {-1, ""}, -}; +namespace blender::nodes { + +static void geo_node_volume_to_mesh_declare(NodeDeclarationBuilder &b) +{ + b.add_input("Geometry"); + b.add_input("Density"); + b.add_input("Voxel Size").default_value(0.3f).min(0.01f).subtype(PROP_DISTANCE); + b.add_input("Voxel Amount").default_value(64.0f).min(0.0f); + b.add_input("Threshold").default_value(0.1f).min(0.0f); + b.add_input("Adaptivity").min(0.0f).max(1.0f).subtype(PROP_FACTOR); + b.add_output("Geometry"); +} static void geo_node_volume_to_mesh_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { @@ -57,8 +55,6 @@ static void geo_node_volume_to_mesh_layout(uiLayout *layout, bContext *UNUSED(C) uiItemR(layout, ptr, "resolution_mode", 0, IFACE_("Resolution"), ICON_NONE); } -namespace blender::nodes { - static void geo_node_volume_to_mesh_init(bNodeTree *UNUSED(ntree), bNode *node) { NodeGeometryVolumeToMesh *data = (NodeGeometryVolumeToMesh *)MEM_callocN( @@ -164,13 +160,13 @@ void register_node_type_geo_volume_to_mesh() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_VOLUME_TO_MESH, "Volume to Mesh", NODE_CLASS_GEOMETRY, 0); - node_type_socket_templates(&ntype, geo_node_volume_to_mesh_in, geo_node_volume_to_mesh_out); + ntype.declare = blender::nodes::geo_node_volume_to_mesh_declare; node_type_storage( &ntype, "NodeGeometryVolumeToMesh", node_free_standard_storage, node_copy_standard_storage); node_type_size(&ntype, 200, 120, 700); node_type_init(&ntype, blender::nodes::geo_node_volume_to_mesh_init); node_type_update(&ntype, blender::nodes::geo_node_volume_to_mesh_update); ntype.geometry_node_execute = blender::nodes::geo_node_volume_to_mesh_exec; - ntype.draw_buttons = geo_node_volume_to_mesh_layout; + ntype.draw_buttons = blender::nodes::geo_node_volume_to_mesh_layout; nodeRegisterType(&ntype); } -- cgit v1.2.3