Blender V5.3
node_geometry_util.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include <optional>
6
7#include "BLI_string.hh"
8
10#include "node_util.hh"
11
12#include "DNA_space_types.h"
13#include "DNA_userdef_types.h"
14
15#include "BKE_node.hh"
16
17#include "NOD_rna_define.hh"
18#include "NOD_socket.hh"
20
21#include "RNA_access.hh"
22#include "RNA_enum_types.hh"
23
24namespace blender {
25
26namespace nodes {
27
29{
30 if (!params.user_data()->call_data->operator_data) {
31 params.error_message_add(NodeWarningType::Error, TIP_("Node must be run as tool"));
33 return false;
34 }
35 return true;
36}
37
44
46{
47 params.error_message_add(
49 "Input grid is not a valid level set. Use a signed distance field grid as input");
51}
52
53namespace enums {
54
56 PointerRNA * /*ptr*/,
57 PropertyRNA * /*prop*/,
58 bool *r_free)
59{
60 *r_free = true;
61 return enum_items_filter(
62 rna_enum_attribute_type_items, [](const EnumPropertyItem &item) -> bool {
65 });
66}
67
83
84} // namespace enums
85
87 PointerRNA * /*ptr*/,
88 PropertyRNA * /*prop*/,
89 bool *r_free)
90{
91 *r_free = true;
92 return enum_items_filter(
94 return bke::grid_type_to_socket_type(VolumeGridType(item.value)).has_value();
95 });
96}
97
99 PointerRNA * /*ptr*/,
100 PropertyRNA * /*prop*/,
101 bool *r_free)
102{
103 *r_free = true;
105 [](const EnumPropertyItem &item) -> bool {
107 });
108}
109
111{
114 TIP_("Disabled, Blender was compiled without OpenVDB"));
115}
116
118{
120 params.error_message_add(NodeWarningType::Error, TIP_("Disabled, OpenVDB version is too old"));
121}
122
123} // namespace nodes
124
126 const bNodeTree *ntree,
127 const char **r_disabled_hint)
128{
129 if (!STREQ(ntree->idname, "GeometryNodeTree")) {
130 *r_disabled_hint = RPT_("Not a geometry node tree");
131 return false;
132 }
133 return true;
134}
135
137 UString idname,
138 const std::optional<int16_t> legacy_type)
139{
140 bke::node_type_base(*ntype, idname, legacy_type);
144}
145
146static bool geo_cmp_node_poll_default(const bke::bNodeType * /*ntype*/,
147 const bNodeTree *ntree,
148 const char **r_disabled_hint)
149{
150 if (!STR_ELEM(ntree->idname, "GeometryNodeTree", "CompositorNodeTree")) {
151 *r_disabled_hint = RPT_("Not a geometry or compositor node tree");
152 return false;
153 }
154 return true;
155}
156
158 UString idname,
159 const std::optional<int16_t> legacy_type)
160{
161 bke::node_type_base(*ntype, idname, legacy_type);
165}
166
167} // namespace blender
#define STR_ELEM(...)
#define RPT_(msgid)
#define TIP_(msgid)
#define ELEM(...)
#define STREQ(a, b)
void error_message_add(const NodeWarningType type, StringRef message) const
GeoNodesUserData * user_data() const
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
Definition node.cc:6096
void node_type_base(bNodeType &ntype, UString idname, std::optional< int16_t > legacy_type=std::nullopt)
Definition node.cc:5866
bool generic_attribute_type_supported(const EnumPropertyItem &item)
const EnumPropertyItem * attribute_type_type_with_socket_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
void search_link_ops_for_basic_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
const EnumPropertyItem * grid_socket_type_items_filter_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
const EnumPropertyItem * grid_data_type_socket_items_filter_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
void node_geo_sdf_grid_error_not_levelset(GeoNodeExecParams &params)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams &params)
bool socket_type_supports_grids(const eNodeSocketDatatype socket_type)
const EnumPropertyItem * enum_items_filter(const EnumPropertyItem *original_item_array, FunctionRef< bool(const EnumPropertyItem &item)> fn)
void node_geo_exec_with_too_old_openvdb(GeoNodeExecParams &params)
BMesh Iterators.
static bool geo_cmp_node_poll_default(const bke::bNodeType *, const bNodeTree *ntree, const char **r_disabled_hint)
bool geo_node_poll_default(const bke::bNodeType *, const bNodeTree *ntree, const char **r_disabled_hint)
const EnumPropertyItem rna_enum_volume_grid_data_type_items[]
Definition rna_volume.cc:27
const EnumPropertyItem rna_enum_attribute_type_items[]
bool node_insert_link_default(bke::NodeInsertLinkParams &)
Definition node_util.cc:223
const EnumPropertyItem rna_enum_node_socket_data_type_items[]
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void geo_cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:265
bool(*) poll(const bNodeType *ntype, const bNodeTree *nodetree, const char **r_disabled_hint)
Definition BKE_node.hh:352
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
bool(*) insert_link(NodeInsertLinkParams &params)
Definition BKE_node.hh:364