Blender V5.0
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.h"
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::nodes {
25
27{
28 if (!params.user_data()->call_data->operator_data) {
29 params.error_message_add(NodeWarningType::Error, TIP_("Node must be run as tool"));
30 params.set_default_remaining_outputs();
31 return false;
32 }
33 return true;
34}
35
42
44{
45 params.error_message_add(
47 "Input grid is not a valid level set. Use a signed distance field grid as input");
48 params.set_default_remaining_outputs();
49}
50
51namespace enums {
52
54 PointerRNA * /*ptr*/,
55 PropertyRNA * /*prop*/,
56 bool *r_free)
57{
58 *r_free = true;
59 return enum_items_filter(
60 rna_enum_attribute_type_items, [](const EnumPropertyItem &item) -> bool {
63 });
64}
65
80
81} // namespace enums
82
84 PointerRNA * /*ptr*/,
85 PropertyRNA * /*prop*/,
86 bool *r_free)
87{
88 *r_free = true;
89 return enum_items_filter(
91 return bke::grid_type_to_socket_type(VolumeGridType(item.value)).has_value();
92 });
93}
94
96 PointerRNA * /*ptr*/,
97 PropertyRNA * /*prop*/,
98 bool *r_free)
99{
100 *r_free = true;
102 [](const EnumPropertyItem &item) -> bool {
104 });
105}
106
108{
109 params.set_default_remaining_outputs();
110 params.error_message_add(NodeWarningType::Error,
111 TIP_("Disabled, Blender was compiled without OpenVDB"));
112}
113
115{
116 params.set_default_remaining_outputs();
117 params.error_message_add(NodeWarningType::Error, TIP_("Disabled, OpenVDB version is too old"));
118}
119
120} // namespace blender::nodes
121
123 const bNodeTree *ntree,
124 const char **r_disabled_hint)
125{
126 if (!STREQ(ntree->idname, "GeometryNodeTree")) {
127 *r_disabled_hint = RPT_("Not a geometry node tree");
128 return false;
129 }
130 return true;
131}
132
134 std::string idname,
135 const std::optional<int16_t> legacy_type)
136{
137 blender::bke::node_type_base(*ntype, idname, legacy_type);
141}
142
144 const bNodeTree *ntree,
145 const char **r_disabled_hint)
146{
147 if (!STR_ELEM(ntree->idname, "GeometryNodeTree", "CompositorNodeTree")) {
148 *r_disabled_hint = RPT_("Not a geometry or compositor node tree");
149 return false;
150 }
151 return true;
152}
153
155 std::string idname,
156 const std::optional<int16_t> legacy_type)
157{
158 blender::bke::node_type_base(*ntype, idname, legacy_type);
162}
VolumeGridType
#define STR_ELEM(...)
Definition BLI_string.h:661
#define ELEM(...)
#define STREQ(a, b)
#define RPT_(msgid)
#define TIP_(msgid)
@ CD_PROP_BYTE_COLOR
@ CD_PROP_FLOAT
@ CD_PROP_FLOAT3
@ CD_PROP_COLOR
@ CD_PROP_QUATERNION
@ CD_PROP_INT32
@ CD_PROP_FLOAT2
@ CD_PROP_FLOAT4X4
eNodeSocketDatatype
@ SNODE_GEOMETRY_TOOL
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_type_base(bNodeType &ntype, std::string idname, std::optional< int16_t > legacy_type=std::nullopt)
Definition node.cc:5099
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
Definition node.cc:5314
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)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static bool geo_cmp_node_poll_default(const blender::bke::bNodeType *, const bNodeTree *ntree, const char **r_disabled_hint)
void geo_cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool geo_node_poll_default(const blender::bke::bNodeType *, const bNodeTree *ntree, const char **r_disabled_hint)
bool node_insert_link_default(blender::bke::NodeInsertLinkParams &)
Definition node_util.cc:266
const EnumPropertyItem rna_enum_attribute_type_items[]
const EnumPropertyItem rna_enum_node_socket_data_type_items[]
const EnumPropertyItem rna_enum_volume_grid_data_type_items[]
Definition rna_volume.cc:25
char idname[64]
Defines a node type.
Definition BKE_node.hh:238
bool(* insert_link)(NodeInsertLinkParams &params)
Definition BKE_node.hh:333
bool(* poll)(const bNodeType *ntype, const bNodeTree *nodetree, const char **r_disabled_hint)
Definition BKE_node.hh:321
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:378