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:
parent
25b745ae85
commit
f5e1a2119d
|
@ -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 ¶ms)
|
||||
{
|
||||
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 ¶ms)
|
||||
{
|
||||
const eNodeSocketDatatype sock_type = static_cast<eNodeSocketDatatype>(
|
||||
|
@ -132,6 +145,15 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
|||
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 ¶ms) {
|
||||
bNode &node = params.add_node("ShaderNodeMix");
|
||||
|
|
Loading…
Reference in New Issue