Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Matthews <guitargeek>2021-09-02 06:53:52 +0300
committerHans Goudey <h.goudey@me.com>2021-09-02 06:53:52 +0300
commit0ccbf5069431aaa323ca9c7f09cb62a0ea35ae86 (patch)
tree043a3e5da7c01c85aea9784f28af124b4cd7d287 /source/blender/nodes/geometry/nodes/node_geo_switch.cc
parent4170668776fc447c2204298ccb6928eeed0e4f55 (diff)
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
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_switch.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_switch.cc87
1 files changed, 42 insertions, 45 deletions
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<decl::Bool>("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<decl::Float>("False");
+ b.add_input<decl::Float>("True");
+ b.add_input<decl::Int>("False", "False_001").min(-100000).max(100000);
+ b.add_input<decl::Int>("True", "True_001").min(-100000).max(100000);
+ b.add_input<decl::Bool>("False", "False_002");
+ b.add_input<decl::Bool>("True", "True_002");
+ b.add_input<decl::Vector>("False", "False_003");
+ b.add_input<decl::Vector>("True", "True_003");
+ b.add_input<decl::Color>("False", "False_004").default_value({0.8f, 0.8f, 0.8f, 1.0f});
+ b.add_input<decl::Color>("True", "True_004").default_value({0.8f, 0.8f, 0.8f, 1.0f});
+ b.add_input<decl::String>("False", "False_005");
+ b.add_input<decl::String>("True", "True_005");
+ b.add_input<decl::Geometry>("False", "False_006");
+ b.add_input<decl::Geometry>("True", "True_006");
+ b.add_input<decl::Object>("False", "False_007");
+ b.add_input<decl::Object>("True", "True_007");
+ b.add_input<decl::Collection>("False", "False_008");
+ b.add_input<decl::Collection>("True", "True_008");
+ b.add_input<decl::Texture>("False", "False_009");
+ b.add_input<decl::Texture>("True", "True_009");
+ b.add_input<decl::Material>("False", "False_010");
+ b.add_input<decl::Material>("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<decl::Float>("Output");
+ b.add_output<decl::Int>("Output", "Output_001");
+ b.add_output<decl::Bool>("Output", "Output_002");
+ b.add_output<decl::Vector>("Output", "Output_003");
+ b.add_output<decl::Color>("Output", "Output_004");
+ b.add_output<decl::String>("Output", "Output_005");
+ b.add_output<decl::Geometry>("Output", "Output_006");
+ b.add_output<decl::Object>("Output", "Output_007");
+ b.add_output<decl::Collection>("Output", "Output_008");
+ b.add_output<decl::Texture>("Output", "Output_009");
+ b.add_output<decl::Material>("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);
}