Files
test/source/blender/nodes/geometry/node_geometry_util.hh
Jacques Lucke 476b7ded9e Nodes: make explicit legacy type optional
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
2025-01-14 14:39:36 +01:00

86 lines
3.1 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <optional>
#include "MEM_guardedalloc.h"
#include "BKE_node.hh"
#include "BKE_node_legacy_types.hh" // IWYU pragma: export
#include "BKE_node_socket_value.hh"
#include "NOD_geometry_exec.hh"
#include "NOD_register.hh"
#include "NOD_socket_declarations.hh"
#include "NOD_socket_declarations_geometry.hh"
#include "node_util.hh"
namespace blender {
namespace bke {
struct BVHTreeFromMesh;
}
namespace nodes {
class GatherAddNodeSearchParams;
class GatherLinkSearchOpParams;
} // namespace nodes
} // namespace blender
void geo_node_type_base(blender::bke::bNodeType *ntype,
std::string idname,
std::optional<int16_t> legacy_type = std::nullopt);
bool geo_node_poll_default(const blender::bke::bNodeType *ntype,
const bNodeTree *ntree,
const char **r_disabled_hint);
namespace blender::nodes {
bool check_tool_context_and_error(GeoNodeExecParams &params);
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params);
void search_link_ops_for_volume_grid_node(GatherLinkSearchOpParams &params);
void search_link_ops_for_import_node(GatherLinkSearchOpParams &params);
void get_closest_in_bvhtree(bke::BVHTreeFromMesh &tree_data,
const VArray<float3> &positions,
const IndexMask &mask,
MutableSpan<int> r_indices,
MutableSpan<float> r_distances_sq,
MutableSpan<float3> r_positions);
int apply_offset_in_cyclic_range(IndexRange range, int start_index, int offset);
void mix_baked_data_item(eNodeSocketDatatype socket_type,
void *prev,
const void *next,
const float factor);
namespace enums {
const EnumPropertyItem *attribute_type_type_with_socket_fn(bContext * /*C*/,
PointerRNA * /*ptr*/,
PropertyRNA * /*prop*/,
bool *r_free);
bool generic_attribute_type_supported(const EnumPropertyItem &item);
} // namespace enums
bool custom_data_type_supports_grids(eCustomDataType data_type);
const EnumPropertyItem *grid_custom_data_type_items_filter_fn(bContext *C,
PointerRNA *ptr,
PropertyRNA *prop,
bool *r_free);
const EnumPropertyItem *grid_socket_type_items_filter_fn(bContext *C,
PointerRNA *ptr,
PropertyRNA *prop,
bool *r_free);
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams &params);
void draw_data_blocks(const bContext *C, uiLayout *layout, PointerRNA &bake_rna);
} // namespace blender::nodes