Nodes: Improve search weights for mix node sockets
Based on feedback from Simon Thommes, for link-drag-serach it's most useful to have the A and B sockets connected, first, then the factor sockets, then the special color mix operations. This addresses that by adding the search items in order and decrementing a weight manually as items are added.
This commit is contained in:
parent
62434a9d21
commit
01fb8a555b
|
@ -158,17 +158,7 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
|||
return;
|
||||
}
|
||||
|
||||
const int weight = ELEM(params.other_socket().type, SOCK_RGBA) ? 0 : -1;
|
||||
const std::string socket_name = params.in_out() == SOCK_IN ? "A" : "Result";
|
||||
for (const EnumPropertyItem *item = rna_enum_ramp_blend_items; item->identifier != nullptr;
|
||||
item++) {
|
||||
if (item->name != nullptr && item->identifier[0] != '\0') {
|
||||
params.add_item(CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, item->name),
|
||||
SocketSearchOp{socket_name, item->value},
|
||||
weight);
|
||||
}
|
||||
}
|
||||
|
||||
int weight = 0;
|
||||
if (params.in_out() == SOCK_OUT) {
|
||||
params.add_item(IFACE_("Result"), [type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
|
@ -177,29 +167,58 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
|||
});
|
||||
}
|
||||
else {
|
||||
params.add_item(
|
||||
IFACE_("A"),
|
||||
[type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = type;
|
||||
params.update_and_connect_available_socket(node, "A");
|
||||
},
|
||||
weight);
|
||||
weight--;
|
||||
params.add_item(
|
||||
IFACE_("B"),
|
||||
[type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = type;
|
||||
params.update_and_connect_available_socket(node, "B");
|
||||
},
|
||||
weight);
|
||||
weight--;
|
||||
if (ELEM(type, SOCK_VECTOR, SOCK_RGBA)) {
|
||||
params.add_item(IFACE_("Factor (Non-Uniform)"), [](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = SOCK_VECTOR;
|
||||
node_storage(node).factor_mode = NODE_MIX_MODE_NON_UNIFORM;
|
||||
params.update_and_connect_available_socket(node, "Factor");
|
||||
});
|
||||
params.add_item(
|
||||
IFACE_("Factor (Non-Uniform)"),
|
||||
[](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = SOCK_VECTOR;
|
||||
node_storage(node).factor_mode = NODE_MIX_MODE_NON_UNIFORM;
|
||||
params.update_and_connect_available_socket(node, "Factor");
|
||||
},
|
||||
weight);
|
||||
weight--;
|
||||
}
|
||||
params.add_item(
|
||||
IFACE_("Factor"),
|
||||
[type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = type;
|
||||
params.update_and_connect_available_socket(node, "Factor");
|
||||
},
|
||||
weight);
|
||||
weight--;
|
||||
}
|
||||
|
||||
if (type != SOCK_RGBA) {
|
||||
weight--;
|
||||
}
|
||||
const std::string socket_name = params.in_out() == SOCK_IN ? "A" : "Result";
|
||||
for (const EnumPropertyItem *item = rna_enum_ramp_blend_items; item->identifier != nullptr;
|
||||
item++) {
|
||||
if (item->name != nullptr && item->identifier[0] != '\0') {
|
||||
params.add_item(CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, item->name),
|
||||
SocketSearchOp{socket_name, item->value},
|
||||
weight);
|
||||
}
|
||||
params.add_item(IFACE_("Factor"), [type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = type;
|
||||
params.update_and_connect_available_socket(node, "Factor");
|
||||
});
|
||||
params.add_item(IFACE_("A"), [type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = type;
|
||||
params.update_and_connect_available_socket(node, "A");
|
||||
});
|
||||
params.add_item(IFACE_("B"), [type](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
node_storage(node).data_type = type;
|
||||
params.update_and_connect_available_socket(node, "B");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue