Before the add node search refactor and link-drag-search, nodes were filtered out based on whether they worked with the active render engine. For example, the Principled Hair BSDF node doesn't work with EEVEE, so it isn't displayed in the UI. While we might want to relax this in the future, we have no better way to show that they don't work right now, so it's best to keep that behavior. The filtering is implemented with a new node type callback, mainly to reduce the boilerplate of implementing many node search callbacks otherwise. It's also relatively clear this way I think. The only downside is that now there are three poll functions. I didn't port the "eevee_cycles_shader_nodes_poll" to the new searches, since I don't understand the purpose of it. Pull Request: https://projects.blender.org/blender/blender/pulls/106829
69 lines
1.5 KiB
C++
69 lines
1.5 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
#include "BLI_function_ref.hh"
|
|
#include "BLI_string_ref.hh"
|
|
#include "BLI_vector.hh"
|
|
|
|
#include "DNA_node_types.h" /* Necessary for eNodeSocketInOut. */
|
|
|
|
#include "NOD_node_declaration.hh"
|
|
|
|
struct bContext;
|
|
|
|
namespace blender::nodes {
|
|
|
|
struct AddNodeInfo {
|
|
using AfterAddFn = std::function<void(const bContext &C, bNodeTree &node_tree, bNode &node)>;
|
|
std::string ui_name;
|
|
std::string description;
|
|
AfterAddFn after_add_fn;
|
|
int weight = 0;
|
|
};
|
|
|
|
class GatherAddNodeSearchParams {
|
|
const bContext &C_;
|
|
const bNodeType &node_type_;
|
|
const bNodeTree &node_tree_;
|
|
Vector<AddNodeInfo> &r_items;
|
|
|
|
public:
|
|
GatherAddNodeSearchParams(const bContext &C,
|
|
const bNodeType &node_type,
|
|
const bNodeTree &node_tree,
|
|
Vector<AddNodeInfo> &r_items)
|
|
: C_(C), node_type_(node_type), node_tree_(node_tree), r_items(r_items)
|
|
{
|
|
}
|
|
|
|
const bContext &context() const
|
|
{
|
|
return C_;
|
|
}
|
|
|
|
const bNodeTree &node_tree() const
|
|
{
|
|
return node_tree_;
|
|
}
|
|
|
|
const bNodeType &node_type() const
|
|
{
|
|
return node_type_;
|
|
}
|
|
|
|
/**
|
|
* \param weight: Used to customize the order when multiple search items match.
|
|
*/
|
|
void add_item(std::string ui_name,
|
|
std::string description,
|
|
AddNodeInfo::AfterAddFn fn = {},
|
|
int weight = 0);
|
|
};
|
|
|
|
void search_node_add_ops_for_basic_node(GatherAddNodeSearchParams ¶ms);
|
|
|
|
} // namespace blender::nodes
|