Blender V4.3
node_geo_evaluate_on_domain.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
6
7#include "NOD_rna_define.hh"
8
9#include "UI_interface.hh"
10#include "UI_resources.hh"
11
13
14#include "BLI_task.hh"
15
16#include "RNA_enum_types.hh"
17
19
21
23{
24 const bNode *node = b.node_or_null();
25
26 if (node != nullptr) {
27 const eCustomDataType data_type = eCustomDataType(node->custom2);
28 b.add_input(data_type, "Value").supports_field();
29
30 b.add_output(data_type, "Value").field_source_reference_all();
31 }
32}
33
34static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
35{
36 uiItemR(layout, ptr, "data_type", UI_ITEM_NONE, "", ICON_NONE);
37 uiItemR(layout, ptr, "domain", UI_ITEM_NONE, "", ICON_NONE);
38}
39
40static void node_init(bNodeTree * /*tree*/, bNode *node)
41{
42 node->custom1 = int(AttrDomain::Point);
43 node->custom2 = CD_PROP_FLOAT;
44}
45
47{
48 const blender::bke::bNodeType &node_type = params.node_type();
49 const std::optional<eCustomDataType> type = bke::socket_type_to_custom_data_type(
50 eNodeSocketDatatype(params.other_socket().type));
51 if (type && *type != CD_PROP_STRING) {
52 params.add_item(IFACE_("Value"), [node_type, type](LinkSearchOpParams &params) {
53 bNode &node = params.add_node(node_type);
54 node.custom2 = *type;
55 params.update_and_connect_available_socket(node, "Value");
56 });
57 }
58}
59
61{
62 const bNode &node = params.node();
63 const AttrDomain domain = AttrDomain(node.custom1);
64
65 GField src_field = params.extract_input<GField>("Value");
66 GField dst_field{std::make_shared<bke::EvaluateOnDomainInput>(std::move(src_field), domain)};
67 params.set_output<GField>("Value", std::move(dst_field));
68}
69
70static void node_rna(StructRNA *srna)
71{
73 "domain",
74 "Domain",
75 "Domain the field is evaluated in",
78 int(AttrDomain::Point));
79
81 "data_type",
82 "Data Type",
83 "",
88}
89
90static void node_register()
91{
92 static blender::bke::bNodeType ntype;
93
95 &ntype, GEO_NODE_EVALUATE_ON_DOMAIN, "Evaluate on Domain", NODE_CLASS_CONVERTER);
98 ntype.initfunc = node_init;
99 ntype.declare = node_declare;
102
103 node_rna(ntype.rna_ext.srna);
104}
106
107} // namespace blender::nodes::node_geo_evaluate_on_domain_cc
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
#define IFACE_(msgid)
@ CD_PROP_FLOAT
@ CD_PROP_STRING
eNodeSocketDatatype
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_inline_enum_accessors(member)
#define UI_ITEM_NONE
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
std::optional< eCustomDataType > socket_type_to_custom_data_type(eNodeSocketDatatype type)
Definition node.cc:4379
const EnumPropertyItem * attribute_type_type_with_socket_fn(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_gather_link_searches(GatherLinkSearchOpParams &params)
static void node_declare(NodeDeclarationBuilder &b)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
const EnumPropertyItem rna_enum_attribute_domain_items[]
const EnumPropertyItem rna_enum_attribute_type_items[]
StructRNA * srna
Definition RNA_types.hh:780
Defines a node type.
Definition BKE_node.hh:218
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:339
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:363
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126