This makes specifying a legacy type for new node types optional (e.g. `GEO_NODE_MESH_TO_CURVE`). Instead, only the `idname` is used as a stable identifier for node types. So there is less redundancy for now. This change helps with the decentralized definition of nodes and reduces the number minimum number of files that need to be changed for a new node from 5 to 4. It especially helps when multiple nodes are worked on at the same time, because the legacy type definition was very prone to have merge conflicts. For compatibility reasons and because it's still used by existing code, the `legacy_type` is not removed. All existing nodes keep their current `legacy_type`. New nodes will receive an auto-incremented legacy type. It's still necessary to give nodes unique legacy types, because some code checks if two nodes have the same type by comparing their `legacy_type`. These types only have to be unique at run-time though. Some randomness is used to avoid depending on stable generated legacy types accidentally. Pull Request: https://projects.blender.org/blender/blender/pulls/133044
33 lines
1.0 KiB
C++
33 lines
1.0 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include <optional>
|
|
|
|
#include "node_function_util.hh"
|
|
#include "node_util.hh"
|
|
|
|
#include "NOD_socket_search_link.hh"
|
|
|
|
static bool fn_node_poll_default(const blender::bke::bNodeType * /*ntype*/,
|
|
const bNodeTree *ntree,
|
|
const char **r_disabled_hint)
|
|
{
|
|
/* Function nodes are only supported in simulation node trees so far. */
|
|
if (!STREQ(ntree->idname, "GeometryNodeTree")) {
|
|
*r_disabled_hint = RPT_("Not a geometry node tree");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void fn_node_type_base(blender::bke::bNodeType *ntype,
|
|
std::string idname,
|
|
const std::optional<int16_t> legacy_type)
|
|
{
|
|
blender::bke::node_type_base(ntype, idname, legacy_type);
|
|
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;
|
|
}
|