Blender V4.5
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
8#include "node_util.hh"
9
10#include "DNA_space_types.h"
11#include "DNA_userdef_types.h"
12
13#include "BKE_node.hh"
14
15#include "NOD_rna_define.hh"
16#include "NOD_socket.hh"
18
19#include "RNA_access.hh"
20#include "RNA_enum_types.hh"
21
22namespace blender::nodes {
23
25{
26 if (!params.user_data()->call_data->operator_data) {
27 params.error_message_add(NodeWarningType::Error, TIP_("Node must be run as tool"));
28 params.set_default_remaining_outputs();
29 return false;
30 }
31 return true;
32}
33
40
47
48namespace enums {
49
51 PointerRNA * /*ptr*/,
52 PropertyRNA * /*prop*/,
53 bool *r_free)
54{
55 *r_free = true;
56 return enum_items_filter(
57 rna_enum_attribute_type_items, [](const EnumPropertyItem &item) -> bool {
60 });
61}
62
77
78} // namespace enums
79
81 PointerRNA * /*ptr*/,
82 PropertyRNA * /*prop*/,
83 bool *r_free)
84{
85 *r_free = true;
86 return enum_items_filter(
88 return bke::grid_type_to_socket_type(VolumeGridType(item.value)).has_value();
89 });
90}
91
93 PointerRNA * /*ptr*/,
94 PropertyRNA * /*prop*/,
95 bool *r_free)
96{
97 *r_free = true;
99 [](const EnumPropertyItem &item) -> bool {
101 });
102}
103
105{
106 params.set_default_remaining_outputs();
107 params.error_message_add(NodeWarningType::Error,
108 TIP_("Disabled, Blender was compiled without OpenVDB"));
109}
110
111} // namespace blender::nodes
112
114 const bNodeTree *ntree,
115 const char **r_disabled_hint)
116{
117 if (!STREQ(ntree->idname, "GeometryNodeTree")) {
118 *r_disabled_hint = RPT_("Not a geometry node tree");
119 return false;
120 }
121 return true;
122}
123
125 std::string idname,
126 const std::optional<int16_t> legacy_type)
127{
128 blender::bke::node_type_base(*ntype, idname, legacy_type);
132}
VolumeGridType
#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
#define USER_EXPERIMENTAL_TEST(userdef, member)
#define U
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:5310
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
Definition node.cc:5503
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)
void search_link_ops_for_volume_grid_node(GatherLinkSearchOpParams &params)
const EnumPropertyItem * grid_data_type_socket_items_filter_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
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 geo_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(bNodeTree *, bNode *, bNodeLink *)
Definition node_util.cc:279
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:226
bool(* poll)(const bNodeType *ntype, const bNodeTree *nodetree, const char **r_disabled_hint)
Definition BKE_node.hh:309
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:371
bool(* insert_link)(bNodeTree *ntree, bNode *node, bNodeLink *link)
Definition BKE_node.hh:321