Compositor: support link search for filter node
Show filter types (Sobel, Diamond Sharpen, etc..) in the link search menu. Pull Request: https://projects.blender.org/blender/blender/pulls/139081
This commit is contained in:
@@ -41,6 +41,34 @@ static void node_composit_buts_filter(uiLayout *layout, bContext * /*C*/, Pointe
|
||||
layout->prop(ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
}
|
||||
|
||||
class SocketSearchOp {
|
||||
public:
|
||||
CMPNodeFilterMethod filter_type = CMP_NODE_FILTER_SOFT;
|
||||
void operator()(LinkSearchOpParams ¶ms)
|
||||
{
|
||||
bNode &node = params.add_node("CompositorNodeFilter");
|
||||
node.custom1 = filter_type;
|
||||
params.update_and_connect_available_socket(node, "Image");
|
||||
}
|
||||
};
|
||||
|
||||
static void gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
||||
{
|
||||
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_("Soften"), SocketSearchOp{CMP_NODE_FILTER_SOFT});
|
||||
params.add_item(IFACE_("Box Sharpen"), SocketSearchOp{CMP_NODE_FILTER_SHARP_BOX});
|
||||
params.add_item(IFACE_("Laplace"), SocketSearchOp{CMP_NODE_FILTER_LAPLACE});
|
||||
params.add_item(IFACE_("Sobel"), SocketSearchOp{CMP_NODE_FILTER_SOBEL});
|
||||
params.add_item(IFACE_("Prewitt"), SocketSearchOp{CMP_NODE_FILTER_PREWITT});
|
||||
params.add_item(IFACE_("Kirsch"), SocketSearchOp{CMP_NODE_FILTER_KIRSCH});
|
||||
params.add_item(IFACE_("Shadow"), SocketSearchOp{CMP_NODE_FILTER_SHADOW});
|
||||
params.add_item(IFACE_("Diamond Sharpen"), SocketSearchOp{CMP_NODE_FILTER_SHARP_DIAMOND});
|
||||
}
|
||||
|
||||
using namespace blender::compositor;
|
||||
|
||||
class FilterOperation : public NodeOperation {
|
||||
@@ -257,6 +285,7 @@ static void register_node_type_cmp_filter()
|
||||
ntype.labelfunc = node_filter_label;
|
||||
ntype.flag |= NODE_PREVIEW;
|
||||
ntype.get_compositor_operation = file_ns::get_compositor_operation;
|
||||
ntype.gather_link_search_ops = file_ns::gather_link_searches;
|
||||
|
||||
blender::bke::node_register_type(ntype);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user