Cleanup: Remove unnecessary "add node search"

Now that specific menus can be searched directly (see 7f9d51853c),
there is no need to maintain separate search functionality for adding
nodes. This PR removes the add node search. In a way this brings us
closer to the `NodeItem` situation before, but the setup is more
flexible since the menus are more standard and easier to customize.

In the few ways we customized the node search items before, this gives
us the same results as before. Overall the searching is less flexible,
but I think that is just a tradeoff we have to accept for the simplicity
of searching menus. In the future menus could be made more dynamic,
with each builtin node's menu path stored on the node type, similar to
assets. That might be a nice compromise. In the meantime this code
is just dead weight.

Pull Request: https://projects.blender.org/blender/blender/pulls/112056
This commit is contained in:
Hans Goudey 2023-09-11 18:36:09 +02:00 committed by Hans Goudey
parent d64e4a387a
commit 974edc5885
43 changed files with 0 additions and 679 deletions

View File

@ -1064,7 +1064,6 @@ def km_node_generic(_params):
items.extend([
op_panel("TOPBAR_PT_name", {"type": 'RET', "value": 'PRESS'}, [("keep_open", False)]),
("node.add_search", {"type": 'TAB', "value": 'PRESS'}, None),
])
return keymap

View File

@ -378,13 +378,6 @@ typedef struct bNodeType {
*/
NodeGatherSocketLinkOperationsFunction gather_link_search_ops;
/**
* Add to the list of search items gathered by the add-node search. The default behavior of
* adding a single item with the node name is usually enough, but node types can have any number
* of custom search items.
*/
NodeGatherAddOperationsFunction gather_add_node_search_ops;
/** True when the node cannot be muted. */
bool no_muting;

View File

@ -31,7 +31,6 @@ set(INC_SYS
set(SRC
add_menu_assets.cc
add_node_search.cc
clipboard.cc
drawnode.cc
link_drag_search.cc

View File

@ -1,314 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include <optional>
#include "AS_asset_catalog.hh"
#include "AS_asset_library.hh"
#include "AS_asset_representation.hh"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_search.hh"
#include "DNA_space_types.h"
#include "BKE_asset.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node_tree_update.h"
#include "BKE_screen.h"
#include "DEG_depsgraph_build.h"
#include "BLT_translation.h"
#include "RNA_access.hh"
#include "WM_api.hh"
#include "NOD_add_node_search.hh"
#include "ED_asset.hh"
#include "ED_node.hh"
#include "node_intern.hh"
struct bContext;
namespace blender::ed::space_node {
struct AddNodeSearchStorage {
float2 cursor;
bool use_transform;
Vector<nodes::AddNodeItem> search_add_items;
char search[256];
bool update_items_tag = true;
};
static void add_node_search_listen_fn(const wmRegionListenerParams *params, void *arg)
{
AddNodeSearchStorage &storage = *static_cast<AddNodeSearchStorage *>(arg);
const wmNotifier *wmn = params->notifier;
switch (wmn->category) {
case NC_ASSET:
if (wmn->data == ND_ASSET_LIST_READING) {
storage.update_items_tag = true;
}
break;
}
}
static void search_items_for_asset_metadata(const bNodeTree &node_tree,
const asset_system::AssetRepresentation &asset,
nodes::GatherAddNodeSearchParams &params)
{
const AssetMetaData &asset_data = asset.get_metadata();
const IDProperty *tree_type = BKE_asset_metadata_idprop_find(&asset_data, "type");
if (tree_type == nullptr || IDP_Int(tree_type) != node_tree.type) {
return;
}
params.add_single_node_item(IFACE_(asset.get_name().c_str()),
asset_data.description == nullptr ? "" :
IFACE_(asset_data.description),
[&asset](const bContext &C, bNodeTree &node_tree, bNode &node) {
Main &bmain = *CTX_data_main(&C);
node.flag &= ~NODE_OPTIONS;
node.id = asset::asset_local_id_ensure_imported(bmain, asset);
id_us_plus(node.id);
BKE_ntree_update_tag_node_property(&node_tree, &node);
DEG_relations_tag_update(&bmain);
});
}
static void gather_search_items_for_all_assets(const bContext &C,
const bNodeTree &node_tree,
Set<std::string> &r_added_assets,
Vector<nodes::AddNodeItem> &search_items)
{
const bNodeType &group_node_type = *nodeTypeFind(node_tree.typeinfo->group_idname);
nodes::GatherAddNodeSearchParams params(C, group_node_type, node_tree, search_items);
const AssetLibraryReference library_ref = asset_system::all_library_reference();
AssetFilterSettings filter_settings{};
filter_settings.id_types = FILTER_ID_NT;
ED_assetlist_storage_fetch(&library_ref, &C);
ED_assetlist_ensure_previews_job(&library_ref, &C);
ED_assetlist_iterate(library_ref, [&](asset_system::AssetRepresentation &asset) {
if (!ED_asset_filter_matches_asset(&filter_settings, asset)) {
return true;
}
if (!r_added_assets.add(asset.get_name())) {
/* If an asset with the same name has already been added, skip this. */
return true;
}
search_items_for_asset_metadata(node_tree, asset, params);
return true;
});
}
static void gather_search_items_for_node_groups(const bContext &C,
const bNodeTree &node_tree,
const Set<std::string> &local_assets,
Vector<nodes::AddNodeItem> &search_items)
{
const StringRefNull group_node_id = node_tree.typeinfo->group_idname;
const bNodeType &group_node_type = *nodeTypeFind(group_node_id.c_str());
nodes::GatherAddNodeSearchParams params(C, group_node_type, node_tree, search_items);
Main &bmain = *CTX_data_main(&C);
LISTBASE_FOREACH (bNodeTree *, node_group, &bmain.nodetrees) {
if (node_group->typeinfo->group_idname != group_node_id) {
continue;
}
if (local_assets.contains(node_group->id.name + 2)) {
continue;
}
if (!nodeGroupPoll(&node_tree, node_group, nullptr)) {
continue;
}
params.add_single_node_item(
node_group->id.name + 2,
"",
[node_group](const bContext &C, bNodeTree &node_tree, bNode &node) {
Main &bmain = *CTX_data_main(&C);
node.id = &node_group->id;
id_us_plus(node.id);
BKE_ntree_update_tag_node_property(&node_tree, &node);
DEG_relations_tag_update(&bmain);
});
}
}
static void gather_add_node_operations(const bContext &C,
bNodeTree &node_tree,
Vector<nodes::AddNodeItem> &r_search_items)
{
NODE_TYPES_BEGIN (node_type) {
const char *disabled_hint;
if (node_type->poll && !node_type->poll(node_type, &node_tree, &disabled_hint)) {
continue;
}
if (node_type->add_ui_poll && !node_type->add_ui_poll(&C)) {
continue;
}
if (!node_type->gather_add_node_search_ops) {
continue;
}
nodes::GatherAddNodeSearchParams params(C, *node_type, node_tree, r_search_items);
node_type->gather_add_node_search_ops(params);
}
NODE_TYPES_END;
/* Use a set to avoid adding items for node groups that are also assets. Using data-block
* names is a crutch, since different assets may have the same name. However, an alternative
* using #AssetRepresentation::local_id() didn't work in this case. */
Set<std::string> added_assets;
gather_search_items_for_all_assets(C, node_tree, added_assets, r_search_items);
gather_search_items_for_node_groups(C, node_tree, added_assets, r_search_items);
}
static void add_node_search_update_fn(
const bContext *C, void *arg, const char *str, uiSearchItems *items, const bool is_first)
{
AddNodeSearchStorage &storage = *static_cast<AddNodeSearchStorage *>(arg);
if (storage.update_items_tag) {
bNodeTree *node_tree = CTX_wm_space_node(C)->edittree;
storage.search_add_items.clear();
gather_add_node_operations(*C, *node_tree, storage.search_add_items);
storage.update_items_tag = false;
}
string_search::StringSearch<nodes::AddNodeItem> search;
for (nodes::AddNodeItem &item : storage.search_add_items) {
search.add(item.ui_name, &item, item.weight);
}
/* Don't filter when the menu is first opened, but still run the search
* so the items are in the same order they will appear in while searching. */
const char *string = is_first ? "" : str;
const Vector<nodes::AddNodeItem *> filtered_items = search.query(string);
for (nodes::AddNodeItem *item : filtered_items) {
if (!UI_search_item_add(items, item->ui_name.c_str(), item, ICON_NONE, 0, 0)) {
break;
}
}
}
static void add_node_search_exec_fn(bContext *C, void *arg1, void *arg2)
{
Main &bmain = *CTX_data_main(C);
SpaceNode &snode = *CTX_wm_space_node(C);
bNodeTree &node_tree = *snode.edittree;
AddNodeSearchStorage &storage = *static_cast<AddNodeSearchStorage *>(arg1);
nodes::AddNodeItem *item = static_cast<nodes::AddNodeItem *>(arg2);
if (item == nullptr) {
return;
}
node_deselect_all(node_tree);
item->add_fn(*C, node_tree, storage.cursor);
/* Ideally it would be possible to tag the node tree in some way so it updates only after the
* translate operation is finished, but normally moving nodes around doesn't cause updates. */
ED_node_tree_propagate_change(C, &bmain, &node_tree);
if (storage.use_transform) {
wmOperatorType *ot = WM_operatortype_find("NODE_OT_translate_attach_remove_on_cancel", true);
BLI_assert(ot);
PointerRNA ptr;
WM_operator_properties_create_ptr(&ptr, ot);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr, nullptr);
WM_operator_properties_free(&ptr);
}
}
static ARegion *add_node_search_tooltip_fn(
bContext *C, ARegion *region, const rcti *item_rect, void * /*arg*/, void *active)
{
const nodes::AddNodeItem *item = static_cast<const nodes::AddNodeItem *>(active);
uiSearchItemTooltipData tooltip_data{};
STRNCPY(tooltip_data.description, TIP_(item->description.c_str()));
return UI_tooltip_create_from_search_item_generic(C, region, item_rect, &tooltip_data);
}
static void add_node_search_free_fn(void *arg)
{
AddNodeSearchStorage *storage = static_cast<AddNodeSearchStorage *>(arg);
delete storage;
}
static uiBlock *create_search_popup_block(bContext *C, ARegion *region, void *arg_op)
{
AddNodeSearchStorage &storage = *(AddNodeSearchStorage *)arg_op;
uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
uiBut *but = uiDefSearchBut(block,
storage.search,
0,
ICON_VIEWZOOM,
sizeof(storage.search),
10,
10,
UI_searchbox_size_x(),
UI_UNIT_Y,
0,
0,
"");
UI_but_func_search_set_sep_string(but, UI_MENU_ARROW_SEP);
UI_but_func_search_set(but,
nullptr,
add_node_search_update_fn,
&storage,
false,
add_node_search_free_fn,
add_node_search_exec_fn,
nullptr);
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
UI_but_func_search_set_tooltip(but, add_node_search_tooltip_fn);
UI_but_func_search_set_listen(but, add_node_search_listen_fn);
/* Fake button to hold space for the search items. */
uiDefBut(block,
UI_BTYPE_LABEL,
0,
"",
10,
10 - UI_searchbox_size_y(),
UI_searchbox_size_x(),
UI_searchbox_size_y(),
nullptr,
0,
0,
0,
0,
nullptr);
const int offset[2] = {0, -UI_UNIT_Y};
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, offset);
return block;
}
void invoke_add_node_search_menu(bContext &C, const float2 &cursor, const bool use_transform)
{
AddNodeSearchStorage *storage = new AddNodeSearchStorage{cursor, use_transform};
/* Use the "_ex" variant with `can_refresh` false to avoid a double free when closing Blender. */
UI_popup_block_invoke_ex(&C, create_search_popup_block, storage, nullptr, false);
}
} // namespace blender::ed::space_node

View File

@ -1023,37 +1023,4 @@ void NODE_OT_new_node_tree(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Add Node Search
* \{ */
static int node_add_search_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const ARegion &region = *CTX_wm_region(C);
float2 cursor;
UI_view2d_region_to_view(&region.v2d, event->mval[0], event->mval[1], &cursor.x, &cursor.y);
invoke_add_node_search_menu(*C, cursor, RNA_boolean_get(op->ptr, "use_transform"));
return OPERATOR_FINISHED;
}
void NODE_OT_add_search(wmOperatorType *ot)
{
ot->name = "Search and Add Node";
ot->idname = "NODE_OT_add_search";
ot->description = "Search for nodes and add one to the active tree";
ot->invoke = node_add_search_invoke;
ot->poll = ED_operator_node_editable;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "use_transform", true, "Use Transform", "Start moving the node after adding it");
}
/** \} */
} // namespace blender::ed::space_node

View File

@ -274,7 +274,6 @@ bNode *add_node(const bContext &C, StringRef idname, const float2 &location);
bNode *add_static_node(const bContext &C, int type, const float2 &location);
void NODE_OT_add_reroute(wmOperatorType *ot);
void NODE_OT_add_search(wmOperatorType *ot);
void NODE_OT_add_group(wmOperatorType *ot);
void NODE_OT_add_group_asset(wmOperatorType *ot);
void NODE_OT_add_object(wmOperatorType *ot);
@ -403,10 +402,6 @@ void invoke_node_link_drag_add_menu(bContext &C,
bNodeSocket &socket,
const float2 &cursor);
/* `add_node_search.cc` */
void invoke_add_node_search_menu(bContext &C, const float2 &cursor, bool use_transform);
/* `add_menu_assets.cc` */
MenuType add_catalog_assets_menu_type();

View File

@ -77,7 +77,6 @@ void node_operatortypes()
WM_operatortype_append(NODE_OT_backimage_fit);
WM_operatortype_append(NODE_OT_backimage_sample);
WM_operatortype_append(NODE_OT_add_search);
WM_operatortype_append(NODE_OT_add_group);
WM_operatortype_append(NODE_OT_add_group_asset);
WM_operatortype_append(NODE_OT_add_object);

View File

@ -76,7 +76,6 @@ set(INC_SYS
)
set(SRC
intern/add_node_search.cc
intern/derived_node_tree.cc
intern/geometry_nodes_execute.cc
intern/geometry_nodes_lazy_function.cc
@ -94,7 +93,6 @@ set(SRC
intern/node_util.cc
intern/socket_search_link.cc
NOD_add_node_search.hh
NOD_common.h
NOD_composite.h
NOD_derived_node_tree.hh

View File

@ -1,74 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <functional>
#include "BLI_function_ref.hh"
#include "BLI_math_vector_types.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 AddNodeItem {
using AddFn =
std::function<Vector<bNode *>(const bContext &C, bNodeTree &node_tree, float2 cursor)>;
std::string ui_name;
std::string description;
int weight = 0;
AddFn add_fn;
};
class GatherAddNodeSearchParams {
using AfterAddFn = std::function<void(const bContext &C, bNodeTree &node_tree, bNode &node)>;
const bContext &C_;
const bNodeType &node_type_;
const bNodeTree &node_tree_;
Vector<AddNodeItem> &r_items;
public:
GatherAddNodeSearchParams(const bContext &C,
const bNodeType &node_type,
const bNodeTree &node_tree,
Vector<AddNodeItem> &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_single_node_item(std::string ui_name,
std::string description,
AfterAddFn after_add_fn = {},
int weight = 0);
void add_item(AddNodeItem item);
};
void search_node_add_ops_for_basic_node(GatherAddNodeSearchParams &params);
} // namespace blender::nodes

View File

@ -8,7 +8,6 @@
#include "BKE_node_runtime.hh"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "node_composite_util.hh"
@ -37,5 +36,4 @@ void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short ncla
ntype->updatefunc = cmp_node_update_default;
ntype->insert_link = node_insert_link_default;
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
}

View File

@ -431,7 +431,6 @@ void register_node_type_cmp_cryptomatte_legacy()
node_type_storage(
&ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte);
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_operation = legacy_file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");

View File

@ -59,7 +59,6 @@ void register_node_type_cmp_sephsva()
&ntype, CMP_NODE_SEPHSVA_LEGACY, "Separate HSVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_sephsva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
@ -111,7 +110,6 @@ void register_node_type_cmp_combhsva()
&ntype, CMP_NODE_COMBHSVA_LEGACY, "Combine HSVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combhsva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);

View File

@ -59,7 +59,6 @@ void register_node_type_cmp_seprgba()
&ntype, CMP_NODE_SEPRGBA_LEGACY, "Separate RGBA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_seprgba_declare;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
@ -111,7 +110,6 @@ void register_node_type_cmp_combrgba()
&ntype, CMP_NODE_COMBRGBA_LEGACY, "Combine RGBA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combrgba_declare;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);

View File

@ -87,7 +87,6 @@ void register_node_type_cmp_sepycca()
ntype.declare = file_ns::cmp_node_sepycca_declare;
ntype.initfunc = file_ns::node_composit_init_mode_sepycca;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
@ -173,7 +172,6 @@ void register_node_type_cmp_combycca()
ntype.declare = file_ns::cmp_node_combycca_declare;
ntype.initfunc = file_ns::node_composit_init_mode_combycca;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);

View File

@ -59,7 +59,6 @@ void register_node_type_cmp_sepyuva()
&ntype, CMP_NODE_SEPYUVA_LEGACY, "Separate YUVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_sepyuva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
@ -111,7 +110,6 @@ void register_node_type_cmp_combyuva()
&ntype, CMP_NODE_COMBYUVA_LEGACY, "Combine YUVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combyuva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);

View File

@ -5,7 +5,6 @@
#include "node_function_util.hh"
#include "node_util.hh"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
static bool fn_node_poll_default(const bNodeType * /*ntype*/,
@ -26,5 +25,4 @@ void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclas
ntype->poll = fn_node_poll_default;
ntype->insert_link = node_insert_link_default;
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
}

View File

@ -14,7 +14,6 @@
#include "BKE_mesh_runtime.hh"
#include "BKE_pointcloud.h"
#include "NOD_add_node_search.hh"
#include "NOD_rna_define.hh"
#include "NOD_socket_search_link.hh"
@ -59,13 +58,6 @@ bool check_tool_context_and_error(GeoNodeExecParams &params)
return true;
}
void search_link_ops_for_for_tool_node(GatherAddNodeSearchParams &params)
{
const SpaceNode &snode = *CTX_wm_space_node(&params.context());
if (snode.geometry_nodes_type == SNODE_GEOMETRY_TOOL) {
search_node_add_ops_for_basic_node(params);
}
}
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
{
if (params.space_node().geometry_nodes_type == SNODE_GEOMETRY_TOOL) {
@ -122,5 +114,4 @@ void geo_node_type_base(bNodeType *ntype, int type, const char *name, short ncla
ntype->poll = geo_node_poll_default;
ntype->insert_link = node_insert_link_default;
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
}

View File

@ -34,7 +34,6 @@ bool geo_node_poll_default(const bNodeType *ntype,
namespace blender::nodes {
bool check_tool_context_and_error(GeoNodeExecParams &params);
void search_link_ops_for_for_tool_node(GatherAddNodeSearchParams &params);
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params);
void transform_mesh(Mesh &mesh,

View File

@ -2,7 +2,6 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "node_geometry_util.hh"
@ -14,13 +13,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>("Signed Distance").field_source();
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
@ -41,7 +33,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_INPUT_SIGNED_DISTANCE, "Signed Distance", NODE_CLASS_INPUT);
ntype.geometry_node_execute = node_geo_exec;
ntype.declare = node_declare;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
nodeRegisterType(&ntype);
}

View File

@ -14,7 +14,6 @@
#include "DNA_node_types.h"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "UI_interface.hh"
@ -32,13 +31,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Geometry>("Volume").translation_context(BLT_I18NCONTEXT_ID_ID);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
@ -100,7 +92,6 @@ static void node_register()
blender::bke::node_type_size(&ntype, 160, 120, 700);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
nodeRegisterType(&ntype);
}

View File

@ -17,7 +17,6 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "NOD_rna_define.hh"
@ -46,13 +45,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Geometry>("Volume").translation_context(BLT_I18NCONTEXT_ID_ID);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
@ -200,7 +192,6 @@ static void node_register()
ntype.updatefunc = node_update;
ntype.geometry_node_execute = node_geo_exec;
ntype.draw_buttons = node_layout;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
node_type_storage(
&ntype, "NodeGeometryMeshToVolume", node_free_standard_storage, node_copy_standard_storage);

View File

@ -14,7 +14,6 @@
#include "DNA_node_types.h"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "UI_interface.hh"
@ -31,13 +30,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Geometry>("Volume").translation_context(BLT_I18NCONTEXT_ID_ID);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
@ -94,7 +86,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_OFFSET_SDF_VOLUME, "Offset SDF Volume", NODE_CLASS_GEOMETRY);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
nodeRegisterType(&ntype);
}

View File

@ -10,7 +10,6 @@
#include "GEO_points_to_volume.hh"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "NOD_rna_define.hh"
@ -46,13 +45,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Geometry>("Volume").translation_context(BLT_I18NCONTEXT_ID_ID);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
@ -147,7 +139,6 @@ static void node_register()
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.draw_buttons = node_layout;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
nodeRegisterType(&ntype);

View File

@ -87,7 +87,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_REPEAT_INPUT, "Repeat Input", NODE_CLASS_INTERFACE);
ntype.initfunc = node_init;
ntype.declare_dynamic = node_declare_dynamic;
ntype.gather_add_node_search_ops = nullptr;
ntype.gather_link_search_ops = nullptr;
ntype.insert_link = node_insert_link;
node_type_storage(

View File

@ -12,7 +12,6 @@
#include "UI_interface.hh"
#include "UI_resources.hh"
#include "NOD_add_node_search.hh"
#include "NOD_geometry.hh"
#include "NOD_socket.hh"
@ -128,38 +127,6 @@ static void node_declare_dynamic(const bNodeTree & /*node_tree*/,
socket_declarations_for_repeat_items(storage.items_span(), r_declaration);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
AddNodeItem item;
item.ui_name = IFACE_("Repeat Zone");
item.description = TIP_("Add new repeat input and output nodes to the node tree");
item.add_fn = [](const bContext &C, bNodeTree &node_tree, float2 cursor) {
bNode *input = nodeAddNode(&C, &node_tree, "GeometryNodeRepeatInput");
bNode *output = nodeAddNode(&C, &node_tree, "GeometryNodeRepeatOutput");
static_cast<NodeGeometryRepeatInput *>(input->storage)->output_node_id = output->identifier;
NodeRepeatItem &item = node_storage(*output).items[0];
update_node_declaration_and_sockets(node_tree, *input);
update_node_declaration_and_sockets(node_tree, *output);
const std::string identifier = item.identifier_str();
nodeAddLink(&node_tree,
input,
nodeFindSocket(input, SOCK_OUT, identifier.c_str()),
output,
nodeFindSocket(output, SOCK_IN, identifier.c_str()));
input->locx = cursor.x / UI_SCALE_FAC - 150;
input->locy = cursor.y / UI_SCALE_FAC + 20;
output->locx = cursor.x / UI_SCALE_FAC + 150;
output->locy = cursor.y / UI_SCALE_FAC + 20;
return Vector<bNode *>({input, output});
};
params.add_item(std::move(item));
}
static void node_init(bNodeTree * /*tree*/, bNode *node)
{
NodeGeometryRepeatOutput *data = MEM_cnew<NodeGeometryRepeatOutput>(__func__);
@ -245,7 +212,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_REPEAT_OUTPUT, "Repeat Output", NODE_CLASS_INTERFACE);
ntype.initfunc = node_init;
ntype.declare_dynamic = node_declare_dynamic;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.insert_link = node_insert_link;
node_type_storage(&ntype, "NodeGeometryRepeatOutput", node_free_storage, node_copy_storage);
nodeRegisterType(&ntype);

View File

@ -10,7 +10,6 @@
#include "BLI_virtual_array.hh"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "node_geometry_util.hh"
@ -63,14 +62,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Int>("Value", "Value_Int").dependent_field({5});
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (!U.experimental.use_new_volume_nodes) {
return;
}
blender::nodes::search_node_add_ops_for_basic_node(params);
}
static std::optional<eCustomDataType> other_socket_type_to_grid_type(
const eNodeSocketDatatype type)
{
@ -429,7 +420,6 @@ static void node_register()
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.draw_buttons = node_layout;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
ntype.geometry_node_execute = node_geo_exec;
nodeRegisterType(&ntype);

View File

@ -14,7 +14,6 @@
#include "BKE_volume.h"
#include "BKE_volume_openvdb.hh"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
namespace blender::nodes::node_geo_sdf_volume_sphere_cc {
@ -31,13 +30,6 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Geometry>("Volume").translation_context(BLT_I18NCONTEXT_ID_ID);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
if (U.experimental.use_new_volume_nodes) {
blender::nodes::search_node_add_ops_for_basic_node(params);
}
}
static void search_link_ops(GatherLinkSearchOpParams &params)
{
if (U.experimental.use_new_volume_nodes) {
@ -95,7 +87,6 @@ static void node_register()
ntype.declare = node_declare;
blender::bke::node_type_size(&ntype, 180, 120, 300);
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = search_link_ops;
nodeRegisterType(&ntype);
}

View File

@ -258,7 +258,6 @@ static void node_register()
ntype.initfunc = node_init;
ntype.declare_dynamic = node_declare_dynamic;
ntype.insert_link = node_insert_link;
ntype.gather_add_node_search_ops = nullptr;
ntype.gather_link_search_ops = nullptr;
node_type_storage(&ntype,
"NodeGeometrySimulationInput",

View File

@ -28,8 +28,6 @@
#include "DNA_mesh_types.h"
#include "DNA_pointcloud_types.h"
#include "NOD_add_node_search.hh"
#include "BLT_translation.h"
#include "node_geometry_util.hh"
@ -788,39 +786,6 @@ static void node_declare_dynamic(const bNodeTree & /*node_tree*/,
socket_declarations_for_simulation_items({storage.items, storage.items_num}, r_declaration);
}
static void search_node_add_ops(GatherAddNodeSearchParams &params)
{
AddNodeItem item;
item.ui_name = IFACE_("Simulation Zone");
item.description = TIP_("Add a new simulation input and output nodes to the node tree");
item.add_fn = [](const bContext &C, bNodeTree &node_tree, float2 cursor) {
bNode *input = nodeAddNode(&C, &node_tree, "GeometryNodeSimulationInput");
bNode *output = nodeAddNode(&C, &node_tree, "GeometryNodeSimulationOutput");
static_cast<NodeGeometrySimulationInput *>(input->storage)->output_node_id =
output->identifier;
NodeSimulationItem &item = node_storage(*output).items[0];
update_node_declaration_and_sockets(node_tree, *input);
update_node_declaration_and_sockets(node_tree, *output);
nodeAddLink(
&node_tree,
input,
nodeFindSocket(input, SOCK_OUT, socket_identifier_for_simulation_item(item).c_str()),
output,
nodeFindSocket(output, SOCK_IN, socket_identifier_for_simulation_item(item).c_str()));
input->locx = cursor.x / UI_SCALE_FAC - 150;
input->locy = cursor.y / UI_SCALE_FAC + 20;
output->locx = cursor.x / UI_SCALE_FAC + 150;
output->locy = cursor.y / UI_SCALE_FAC + 20;
return Vector<bNode *>({input, output});
};
params.add_item(std::move(item));
}
static void node_init(bNodeTree * /*tree*/, bNode *node)
{
NodeGeometrySimulationOutput *data = MEM_cnew<NodeGeometrySimulationOutput>(__func__);
@ -913,7 +878,6 @@ static void node_register()
&ntype, GEO_NODE_SIMULATION_OUTPUT, "Simulation Output", NODE_CLASS_INTERFACE);
ntype.initfunc = node_init;
ntype.declare_dynamic = node_declare_dynamic;
ntype.gather_add_node_search_ops = search_node_add_ops;
ntype.gather_link_search_ops = nullptr;
ntype.insert_link = node_insert_link;
node_type_storage(&ntype, "NodeGeometrySimulationOutput", node_free_storage, node_copy_storage);

View File

@ -40,7 +40,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_TOOL_3D_CURSOR, "3D Cursor", NODE_CLASS_INPUT);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_link_ops_for_for_tool_node;
ntype.gather_link_search_ops = search_link_ops_for_tool_node;
nodeRegisterType(&ntype);
}

View File

@ -29,7 +29,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_TOOL_FACE_SET, "Face Set", NODE_CLASS_INPUT);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_link_ops_for_for_tool_node;
ntype.gather_link_search_ops = search_link_ops_for_tool_node;
nodeRegisterType(&ntype);
}

View File

@ -62,7 +62,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_TOOL_SELECTION, "Selection", NODE_CLASS_INPUT);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_link_ops_for_for_tool_node;
ntype.gather_link_search_ops = search_link_ops_for_tool_node;
nodeRegisterType(&ntype);
}

View File

@ -60,7 +60,6 @@ static void node_register()
geo_node_type_base(&ntype, GEO_NODE_TOOL_SET_FACE_SET, "Set Face Set", NODE_CLASS_GEOMETRY);
ntype.declare = node_declare;
ntype.geometry_node_execute = node_geo_exec;
ntype.gather_add_node_search_ops = search_link_ops_for_for_tool_node;
ntype.gather_link_search_ops = search_link_ops_for_tool_node;
nodeRegisterType(&ntype);
}

View File

@ -98,7 +98,6 @@ static void node_register()
ntype.initfunc = node_init;
ntype.geometry_node_execute = node_geo_exec;
ntype.draw_buttons = node_layout;
ntype.gather_add_node_search_ops = search_link_ops_for_for_tool_node;
ntype.gather_link_search_ops = search_link_ops_for_tool_node;
nodeRegisterType(&ntype);

View File

@ -1,49 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_node.hh"
#include "BLT_translation.h"
#include "NOD_add_node_search.hh"
#include "NOD_node_declaration.hh"
namespace blender::nodes {
void GatherAddNodeSearchParams::add_single_node_item(std::string ui_name,
std::string description,
AfterAddFn after_add_fn,
int weight)
{
AddNodeItem item;
item.ui_name = std::move(ui_name);
item.description = std::move(description);
item.weight = weight;
item.add_fn = [after_add_fn = std::move(after_add_fn), node_type = node_type_](
const bContext &C, bNodeTree &node_tree, const float2 cursor) {
bNode *new_node = nodeAddNode(&C, &node_tree, node_type.idname);
new_node->locx = cursor.x / UI_SCALE_FAC;
new_node->locy = cursor.y / UI_SCALE_FAC + 20;
nodeSetSelected(new_node, true);
nodeSetActive(&node_tree, new_node);
if (after_add_fn) {
after_add_fn(C, node_tree, *new_node);
}
return Vector<bNode *>{new_node};
};
r_items.append(std::move(item));
}
void GatherAddNodeSearchParams::add_item(AddNodeItem item)
{
r_items.append(std::move(item));
}
void search_node_add_ops_for_basic_node(GatherAddNodeSearchParams &params)
{
params.add_single_node_item(IFACE_(params.node_type().ui_name),
TIP_(params.node_type().ui_description));
}
} // namespace blender::nodes

View File

@ -32,7 +32,6 @@
#include "MEM_guardedalloc.h"
#include "NOD_add_node_search.hh"
#include "NOD_common.h"
#include "NOD_node_declaration.hh"
#include "NOD_register.hh"
@ -434,7 +433,6 @@ void register_node_type_frame()
blender::bke::node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT);
ntype->initfunc = node_frame_init;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage);
blender::bke::node_type_size(ntype, 150, 100, 0);
ntype->flag |= NODE_BACKGROUND;
@ -465,7 +463,6 @@ void register_node_type_reroute()
blender::bke::node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT);
ntype->initfunc = node_reroute_init;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
nodeRegisterType(ntype);
}
@ -706,7 +703,6 @@ void register_node_type_group_input()
blender::bke::node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE);
blender::bke::node_type_size(ntype, 140, 80, 400);
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
ntype->declare_dynamic = blender::nodes::group_input_declare_dynamic;
ntype->insert_link = blender::nodes::group_input_insert_link;
@ -731,7 +727,6 @@ void register_node_type_group_output()
blender::bke::node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE);
blender::bke::node_type_size(ntype, 140, 80, 400);
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
ntype->declare_dynamic = blender::nodes::group_output_declare_dynamic;
ntype->insert_link = blender::nodes::group_output_insert_link;

View File

@ -19,7 +19,6 @@
#include "node_shader_util.hh"
#include "NOD_add_node_search.hh"
#include "NOD_socket_search_link.hh"
#include "RE_engine.h"
@ -55,7 +54,6 @@ void sh_node_type_base(bNodeType *ntype, int type, const char *name, short nclas
ntype->poll = sh_node_poll_default;
ntype->insert_link = node_insert_link_default;
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
}
void sh_fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
@ -63,7 +61,6 @@ void sh_fn_node_type_base(bNodeType *ntype, int type, const char *name, short nc
sh_node_type_base(ntype, type, name, nclass);
ntype->poll = sh_fn_poll_default;
ntype->gather_link_search_ops = blender::nodes::search_link_ops_for_basic_node;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
}
bool line_style_shader_nodes_poll(const bContext *C)

View File

@ -24,7 +24,6 @@
#include "FN_multi_function_builder.hh"
#include "NOD_add_node_search.hh"
#include "NOD_multi_function.hh"
#include "NOD_socket_search_link.hh"
@ -268,16 +267,6 @@ static void node_mix_gather_link_searches(GatherLinkSearchOpParams &params)
}
}
static void gather_add_node_searches(GatherAddNodeSearchParams &params)
{
params.add_single_node_item(IFACE_("Mix"), params.node_type().ui_description);
params.add_single_node_item(IFACE_("Mix Color"),
params.node_type().ui_description,
[](const bContext & /*C*/, bNodeTree & /*node_tree*/, bNode &node) {
node_storage(node).data_type = SOCK_RGBA;
});
}
static void node_mix_init(bNodeTree * /*tree*/, bNode *node)
{
NodeShaderMix *data = MEM_cnew<NodeShaderMix>(__func__);
@ -573,6 +562,5 @@ void register_node_type_sh_mix()
ntype.draw_buttons = file_ns::sh_node_mix_layout;
ntype.labelfunc = file_ns::sh_node_mix_label;
ntype.gather_link_search_ops = file_ns::node_mix_gather_link_searches;
ntype.gather_add_node_search_ops = file_ns::gather_add_node_searches;
nodeRegisterType(&ntype);
}

View File

@ -164,6 +164,5 @@ void register_node_type_sh_mix_rgb()
ntype.gpu_fn = file_ns::gpu_shader_mix_rgb;
ntype.build_multi_function = file_ns::sh_node_mix_rgb_build_multi_function;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
nodeRegisterType(&ntype);
}

View File

@ -41,7 +41,6 @@ void register_node_type_sh_sephsv()
ntype.declare = file_ns::node_declare_sephsv;
ntype.gpu_fn = file_ns::gpu_shader_sephsv;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
nodeRegisterType(&ntype);
}
@ -79,7 +78,6 @@ void register_node_type_sh_combhsv()
ntype.declare = file_ns::node_declare_combhsv;
ntype.gpu_fn = file_ns::gpu_shader_combhsv;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
nodeRegisterType(&ntype);
}

View File

@ -85,7 +85,6 @@ void register_node_type_sh_seprgb()
ntype.gpu_fn = file_ns::gpu_shader_seprgb;
ntype.build_multi_function = file_ns::sh_node_seprgb_build_multi_function;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
nodeRegisterType(&ntype);
}
@ -131,7 +130,6 @@ void register_node_type_sh_combrgb()
ntype.gpu_fn = file_ns::gpu_shader_combrgb;
ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
nodeRegisterType(&ntype);
}

View File

@ -37,7 +37,6 @@ void register_node_type_sh_squeeze()
sh_node_type_base(&ntype, SH_NODE_SQUEEZE, "Squeeze Value (Legacy)", NODE_CLASS_CONVERTER);
ntype.gather_link_search_ops = nullptr;
ntype.gather_add_node_search_ops = nullptr;
ntype.declare = file_ns::node_declare;
ntype.gpu_fn = file_ns::gpu_shader_squeeze;

View File

@ -24,7 +24,6 @@
#include "BKE_node_runtime.hh"
#include "NOD_add_node_search.hh"
#include "NOD_texture.h"
#include "node_texture_util.hh"
@ -47,7 +46,6 @@ void tex_node_type_base(bNodeType *ntype, int type, const char *name, short ncla
ntype->poll = tex_node_poll_default;
ntype->insert_link = node_insert_link_default;
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
}
static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread)