Compositor: Support link search for Glare node

This patch supports link search the glare node types, such that users
can add specific effects like Bloom quickly.

Pull Request: https://projects.blender.org/blender/blender/pulls/137988
This commit is contained in:
Omar Emara
2025-04-25 17:20:45 +02:00
parent 79d760fcae
commit 7066a8fdb8

View File

@@ -220,6 +220,31 @@ static void node_update(bNodeTree *ntree, bNode *node)
*ntree, *diagonal_star_input, glare_type == CMP_NODE_GLARE_SIMPLE_STAR);
}
class SocketSearchOp {
public:
CMPNodeGlareType type = CMP_NODE_GLARE_SIMPLE_STAR;
void operator()(LinkSearchOpParams &params)
{
bNode &node = params.add_node("CompositorNodeGlare");
node_storage(node).type = this->type;
params.update_and_connect_available_socket(node, "Image");
}
};
static void gather_link_searches(GatherLinkSearchOpParams &params)
{
const eNodeSocketDatatype from_socket_type = eNodeSocketDatatype(params.other_socket().type);
if (!params.node_tree().typeinfo->validate_link(from_socket_type, SOCK_RGBA)) {
return;
}
params.add_item(IFACE_("Simple Star"), SocketSearchOp{CMP_NODE_GLARE_SIMPLE_STAR});
params.add_item(IFACE_("Fog Glow"), SocketSearchOp{CMP_NODE_GLARE_FOG_GLOW});
params.add_item(IFACE_("Streaks"), SocketSearchOp{CMP_NODE_GLARE_STREAKS});
params.add_item(IFACE_("Ghost"), SocketSearchOp{CMP_NODE_GLARE_GHOST});
params.add_item(IFACE_("Bloom"), SocketSearchOp{CMP_NODE_GLARE_BLOOM});
}
using namespace blender::compositor;
class GlareOperation : public NodeOperation {
@@ -2397,6 +2422,7 @@ void register_node_type_cmp_glare()
ntype.declare = file_ns::cmp_node_glare_declare;
ntype.updatefunc = file_ns::node_update;
ntype.initfunc = file_ns::node_composit_init_glare;
ntype.gather_link_search_ops = file_ns::gather_link_searches;
blender::bke::node_type_storage(
ntype, "NodeGlare", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;