Geometry Nodes: Polish switch node UI

Based on the task T88006, there are a few simple changes
to make to improve the switch node:
- Change the label to "False" / "True" for clarity
- Change default to geometry, as it's the basic data container in
  geometry nodes.
- Change node class to `NODE_CLASS_CONVERTOR`, which was an oversight
  in the original patch.

I will add the new socket types (material and texture) in a separate commit.
Thanks to @EitanSomething for the original patch.

Differential Revision: https://developer.blender.org/D11165
This commit is contained in:
2021-05-28 12:17:04 -04:00
parent c0ce7fce89
commit 653bbaa246
3 changed files with 67 additions and 34 deletions

View File

@@ -22,24 +22,24 @@
static bNodeSocketTemplate geo_node_switch_in[] = {
{SOCK_BOOLEAN, N_("Switch")},
{SOCK_FLOAT, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
{SOCK_FLOAT, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
{SOCK_INT, N_("A"), 0, 0, 0, 0, -100000, 100000},
{SOCK_INT, N_("B"), 0, 0, 0, 0, -100000, 100000},
{SOCK_BOOLEAN, N_("A")},
{SOCK_BOOLEAN, N_("B")},
{SOCK_VECTOR, N_("A"), 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_("A"), 0.8, 0.8, 0.8, 1.0},
{SOCK_RGBA, N_("B"), 0.8, 0.8, 0.8, 1.0},
{SOCK_STRING, N_("A")},
{SOCK_STRING, N_("B")},
{SOCK_GEOMETRY, N_("A")},
{SOCK_GEOMETRY, N_("B")},
{SOCK_OBJECT, N_("A")},
{SOCK_OBJECT, N_("B")},
{SOCK_COLLECTION, N_("A")},
{SOCK_COLLECTION, N_("B")},
{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")},
{-1, ""},
};
@@ -64,7 +64,7 @@ static void geo_node_switch_layout(uiLayout *layout, bContext *UNUSED(C), Pointe
static void geo_node_switch_init(bNodeTree *UNUSED(tree), bNode *node)
{
NodeSwitch *data = (NodeSwitch *)MEM_callocN(sizeof(NodeSwitch), __func__);
data->input_type = SOCK_FLOAT;
data->input_type = SOCK_GEOMETRY;
node->storage = data;
}
@@ -91,8 +91,8 @@ static void output_input(GeoNodeExecParams &params,
const StringRef input_suffix,
const StringRef output_identifier)
{
const std::string name_a = "A" + input_suffix;
const std::string name_b = "B" + input_suffix;
const std::string name_a = "False" + input_suffix;
const std::string name_b = "True" + input_suffix;
if (input) {
params.set_input_unused(name_a);
if (params.lazy_require_input(name_b)) {
@@ -165,7 +165,7 @@ void register_node_type_geo_switch()
{
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_SWITCH, "Switch", NODE_CLASS_GEOMETRY, 0);
geo_node_type_base(&ntype, GEO_NODE_SWITCH, "Switch", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, geo_node_switch_in, geo_node_switch_out);
node_type_init(&ntype, geo_node_switch_init);
node_type_update(&ntype, blender::nodes::geo_node_switch_update);