Node: Add blend modes to Mix node link drag search

Allows searching for Mix blend modes
e.g. Overlay when using link drag search

Requested by @simonthommes in GN chat

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D16209
This commit is contained in:
Charlie Jolly 2022-10-10 14:25:12 +01:00 committed by Charlie Jolly
parent 25b745ae85
commit f5e1a2119d
1 changed files with 22 additions and 0 deletions

View File

@ -123,6 +123,19 @@ static void sh_node_mix_update(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, sock_factor_vec, use_vector_factor);
}
class SocketSearchOp {
public:
std::string socket_name;
int type = MA_RAMP_BLEND;
void operator()(LinkSearchOpParams &params)
{
bNode &node = params.add_node("ShaderNodeMix");
node_storage(node).data_type = SOCK_RGBA;
node_storage(node).blend_type = type;
params.update_and_connect_available_socket(node, socket_name);
}
};
static void node_mix_gather_link_searches(GatherLinkSearchOpParams &params)
{
const eNodeSocketDatatype sock_type = static_cast<eNodeSocketDatatype>(
@ -132,6 +145,15 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams &params)
const eNodeSocketDatatype type = ELEM(sock_type, SOCK_BOOLEAN, SOCK_INT) ? SOCK_FLOAT :
sock_type;
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});
}
}
if (params.in_out() == SOCK_OUT) {
params.add_item(IFACE_("Result"), [type](LinkSearchOpParams &params) {
bNode &node = params.add_node("ShaderNodeMix");