Blender V5.3
node_common.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2007 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstddef>
10#include <cstring>
11
12#include "DNA_asset_types.h"
13#include "DNA_node_types.h"
14#include "DNA_space_types.h"
15
16#include "BLI_array.hh"
17#include "BLI_disjoint_set.hh"
18#include "BLI_listbase.hh"
19#include "BLI_map.hh"
21#include "BLI_set.hh"
22#include "BLI_span.hh"
23#include "BLI_stack.hh"
24#include "BLI_string.hh"
25#include "BLI_string_ref.hh"
26#include "BLI_string_utf8.hh"
27#include "BLI_vector_set.hh"
28
29#include "BLT_translation.hh"
30
31#include "BLO_read_write.hh"
32
33#include "BKE_context.hh"
34#include "BKE_node.hh"
35#include "BKE_node_runtime.hh"
37
38#include "COM_node_operation.hh"
39#include "COM_result.hh"
40
41#include "MEM_guardedalloc.h"
42
43#include "NOD_common.hh"
44#include "NOD_composite.hh"
45#include "NOD_geometry_exec.hh"
49#include "NOD_register.hh"
50#include "NOD_socket.hh"
53
54#include "RNA_access.hh"
55#include "RNA_enum_types.hh"
56#include "RNA_prototypes.hh"
57
58#include "UI_resources.hh"
59
60#include "ED_node.hh"
61
63
64#include "node_common.h"
65#include "node_util.hh"
66
67namespace blender {
68
70
71/* -------------------------------------------------------------------- */
74
75static bNodeSocket *find_matching_socket(ListBaseT<bNodeSocket> &sockets, StringRef identifier)
76{
77 for (bNodeSocket &socket : sockets) {
78 if (socket.identifier == identifier) {
79 return &socket;
80 }
81 }
82 return nullptr;
83}
84
86{
87 return find_matching_socket(groupnode->inputs, identifier);
88}
89
91{
92 return find_matching_socket(groupnode->outputs, identifier);
93}
94
95void node_group_label(const bNodeTree * /*ntree*/,
96 const bNode *node,
97 char *label,
98 int label_maxncpy)
99{
101 label, (node->id) ? node->id->name + 2 : IFACE_("Missing Data-Block"), label_maxncpy);
102}
103
105{
106 const bNodeTree *group = reinterpret_cast<const bNodeTree *>(node->id);
107 if (!group) {
108 return NODE_CLASS_GROUP;
109 }
110 switch (bke::NodeColorTag(group->color_tag)) {
112 return NODE_CLASS_GROUP;
116 return NODE_CLASS_OP_COLOR;
120 return NODE_CLASS_DISTORT;
124 return NODE_CLASS_GEOMETRY;
126 return NODE_CLASS_INPUT;
128 return NODE_CLASS_MATTE;
130 return NODE_CLASS_OUTPUT;
132 return NODE_CLASS_SCRIPT;
134 return NODE_CLASS_SHADER;
136 return NODE_CLASS_TEXTURE;
140 return NODE_CLASS_PATTERN;
144 return NODE_CLASS_GROUP;
145 }
146 return NODE_CLASS_GROUP;
147}
148
150 const bNodeTree *nodetree,
151 const char **r_disabled_hint)
152{
153 if (!node->typeinfo->poll(node->typeinfo, nodetree, r_disabled_hint)) {
154 return false;
155 }
156 const bNodeTree *grouptree = reinterpret_cast<const bNodeTree *>(node->id);
157 if (!grouptree) {
158 return true;
159 }
160 return bke::node_group_poll(nodetree, grouptree, r_disabled_hint);
161}
162
164{
165 if (!node.id) {
166 return "";
167 }
168 const bNodeTree *group = reinterpret_cast<const bNodeTree *>(node.id);
169 if (group->id.asset_data) {
170 if (group->id.asset_data->description) {
171 return group->id.asset_data->description;
172 }
173 }
174 if (!group->description) {
175 return "";
176 }
177 return group->description;
178}
179
180bool bke::node_group_poll(const bNodeTree *nodetree,
181 const bNodeTree *grouptree,
182 const char **r_disabled_hint)
183{
184 /* unspecified node group, generally allowed
185 * (if anything, should be avoided on operator level)
186 */
187 if (grouptree == nullptr) {
188 return true;
189 }
190
191 if (nodetree == grouptree) {
192 if (r_disabled_hint) {
193 *r_disabled_hint = RPT_("Nesting a node group inside of itself is not allowed");
194 }
195 return false;
196 }
197 if (nodetree->type != grouptree->type) {
198 if (r_disabled_hint) {
199 *r_disabled_hint = RPT_("Node group has different type");
200 }
201 return false;
202 }
203
204 for (const bNode *node : grouptree->all_nodes()) {
205 if (node->typeinfo->poll_instance &&
206 !node->typeinfo->poll_instance(node, nodetree, r_disabled_hint))
207 {
208 return false;
209 }
210 }
211 return true;
212}
213
214namespace nodes {
215
216static std::function<ID *(const bNode &node)> get_default_id_getter(
217 const bNodeTreeInterface &tree_interface, const bNodeTreeInterfaceSocket &io_socket)
218{
219 const int item_index = tree_interface.find_item_index(io_socket.item);
220 BLI_assert(item_index >= 0);
221
222 /* Avoid capturing pointers that can become dangling. */
223 return [item_index](const bNode &node) -> ID * {
224 if (node.id == nullptr) {
225 return nullptr;
226 }
227 if (GS(node.id->name) != ID_NT) {
228 return nullptr;
229 }
230 const bNodeTree &ntree = *reinterpret_cast<const bNodeTree *>(node.id);
231 const bNodeTreeInterfaceItem *io_item = ntree.tree_interface.get_item_at_index(item_index);
232 const bNodeTreeInterfaceSocket *io_socket =
234 if (!io_socket) {
235 return nullptr;
236 }
237 return *static_cast<ID **>(io_socket->socket_data);
238 };
239}
240
241static std::function<void(bNode &node, bNodeSocket &socket, const char *data_path)>
243 const bNodeTreeInterfaceSocket &io_socket)
244{
245 const int item_index = tree_interface.find_item_index(io_socket.item);
246 BLI_assert(item_index >= 0);
247
248 /* Avoid capturing pointers that can become dangling. */
249 return [item_index](bNode &node, bNodeSocket &socket, const char *data_path) {
250 if (node.id == nullptr) {
251 return;
252 }
253 if (GS(node.id->name) != ID_NT) {
254 return;
255 }
256 bNodeTree &ntree = *reinterpret_cast<bNodeTree *>(node.id);
257 const bNodeTreeInterfaceItem *io_item = ntree.tree_interface.get_item_at_index(item_index);
258 if (io_item == nullptr || io_item->item_type != NodeTreeInterfaceItemType::Socket) {
259 return;
260 }
261 const bNodeTreeInterfaceSocket &io_socket =
263 bke::bNodeSocketType *typeinfo = io_socket.socket_typeinfo();
264 if (typeinfo && typeinfo->interface_init_socket) {
265 typeinfo->interface_init_socket(&ntree.id, &io_socket, &node, &socket, data_path);
266 }
267 };
268}
269
271 const bNodeTree &tree,
272 const bNodeTreeInterfaceSocket &io_socket,
273 const std::optional<StructureType> structure_type,
274 const eNodeSocketInOut in_out,
276{
279
280 const UString name(io_socket.name());
281 const UString identifier(io_socket.identifier);
282
284 if (base_typeinfo) {
285 datatype = base_typeinfo->type;
286 switch (datatype) {
287 case SOCK_FLOAT: {
289 decl = &b.add_socket<decl::Float>(name, identifier, in_out)
290 .subtype(PropertySubType(value.subtype))
291 .default_value(value.value)
292 .min(value.min)
293 .max(value.max);
294 break;
295 }
296 case SOCK_VECTOR: {
298 decl = &b.add_socket<decl::Vector>(name, identifier, in_out)
299 .subtype(PropertySubType(value.subtype))
300 .default_value(float4(value.value))
301 .dimensions(value.dimensions)
302 .min(value.min)
303 .max(value.max);
304 break;
305 }
306 case SOCK_INT_VECTOR: {
308 io_socket);
309 decl = &b.add_socket<decl::IntVector>(name, identifier, in_out)
310 .subtype(PropertySubType(value.subtype))
311 .default_value(int3(value.value))
312 .dimensions(value.dimensions)
313 .min(value.min)
314 .max(value.max);
315 break;
316 }
317 case SOCK_RGBA: {
319 decl = &b.add_socket<decl::Color>(name, identifier, in_out).default_value(value.value);
320 break;
321 }
322 case SOCK_SHADER: {
323 decl = &b.add_socket<decl::Shader>(name, identifier, in_out);
324 break;
325 }
326 case SOCK_BOOLEAN: {
328 decl = &b.add_socket<decl::Bool>(name, identifier, in_out).default_value(value.value);
329 break;
330 }
331 case SOCK_ROTATION: {
333 io_socket);
334 decl = &b.add_socket<decl::Rotation>(name, identifier, in_out)
335 .default_value(math::EulerXYZ(float3(value.value_euler)));
336 break;
337 }
338 case SOCK_MATRIX: {
339 decl = &b.add_socket<decl::Matrix>(name, identifier, in_out);
340 break;
341 }
342 case SOCK_INT: {
343 const auto &value = node_interface::get_socket_data_as<bNodeSocketValueInt>(io_socket);
344 decl = &b.add_socket<decl::Int>(name, identifier, in_out)
345 .subtype(PropertySubType(value.subtype))
346 .default_value(value.value)
347 .min(value.min)
348 .max(value.max);
349 break;
350 }
351 case SOCK_STRING: {
353 decl = &b.add_socket<decl::String>(name, identifier, in_out)
354 .subtype(PropertySubType(value.subtype))
355 .default_value(value.value);
356 break;
357 }
358 case SOCK_MENU: {
360 decl = &b.add_socket<decl::Menu>(name, identifier, in_out)
361 .default_value(MenuValue(value.value))
362 .expanded(io_socket.flag & NODE_INTERFACE_SOCKET_MENU_EXPANDED)
364 break;
365 }
366 case SOCK_OBJECT: {
367 decl = &b.add_socket<decl::Object>(name, identifier, in_out)
368 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
369 break;
370 }
371 case SOCK_IMAGE: {
372 decl = &b.add_socket<decl::Image>(name, identifier, in_out)
373 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
374 break;
375 }
376 case SOCK_GEOMETRY:
377 decl = &b.add_socket<decl::Geometry>(name, identifier, in_out);
378 break;
379 case SOCK_COLLECTION: {
380 decl = &b.add_socket<decl::Collection>(name, identifier, in_out)
381 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
382 break;
383 }
384 case SOCK_TEXTURE: {
385 decl = &b.add_socket<decl::Texture>(name, identifier, in_out)
386 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
387 break;
388 }
389 case SOCK_MATERIAL: {
390 decl = &b.add_socket<decl::Material>(name, identifier, in_out)
391 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
392 break;
393 }
394 case SOCK_FONT: {
395 decl = &b.add_socket<decl::Font>(name, identifier, in_out)
396 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
397 break;
398 }
399 case SOCK_SCENE: {
400 decl = &b.add_socket<decl::Scene>(name, identifier, in_out)
401 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
402 break;
403 }
404 case SOCK_TEXT_ID: {
405 decl = &b.add_socket<decl::Text>(name, identifier, in_out)
406 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
407 break;
408 }
409 case SOCK_MASK: {
410 decl = &b.add_socket<decl::Mask>(name, identifier, in_out)
411 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
412 break;
413 }
414 case SOCK_SOUND: {
415 decl = &b.add_socket<decl::Sound>(name, identifier, in_out)
416 .default_value_fn(get_default_id_getter(tree.tree_interface, io_socket));
417 break;
418 }
419 case SOCK_BUNDLE: {
420 decl = &b.add_socket<decl::Bundle>(name, identifier, in_out);
421 break;
422 }
423 case SOCK_CLOSURE: {
424 decl = &b.add_socket<decl::Closure>(name, identifier, in_out);
425 break;
426 }
427 case SOCK_CUSTOM: {
428 decl = &b.add_socket<decl::Custom>(name, identifier, in_out)
429 .idname(io_socket.socket_type)
431 break;
432 }
433 }
434 }
435 else {
436 decl = &b.add_socket<decl::Custom>(name, identifier, in_out)
437 .idname(io_socket.socket_type)
439 }
440 decl->description(io_socket.description());
441 decl->hide_value(io_socket.flag & NODE_INTERFACE_SOCKET_HIDE_VALUE);
442 decl->compact(io_socket.flag & NODE_INTERFACE_SOCKET_COMPACT);
443 decl->panel_toggle(io_socket.flag & NODE_INTERFACE_SOCKET_PANEL_TOGGLE);
444 decl->optional_label(io_socket.flag & NODE_INTERFACE_SOCKET_OPTIONAL_LABEL);
445 decl->default_input_type(NodeDefaultInputType(io_socket.default_input));
446 if (structure_type) {
447 decl->structure_type(*structure_type);
448 }
449 return *decl;
450}
451
454 const bNode &node,
455 const bNodeTree &group,
456 const Map<const bNodeTreeInterfaceSocket *, StructureType> &structure_type_by_socket,
457 const bNodeTreeInterfacePanel &io_parent_panel,
458 const bool is_root)
459{
460 bool layout_added = false;
461 auto add_layout_if_needed = [&]() {
462 /* Some custom group nodes don't have a draw function. */
463 if (node.typeinfo->draw_buttons) {
464 if (is_root && !layout_added) {
465 b.add_default_layout();
466 layout_added = true;
467 }
468 }
469 };
470
471 for (const bNodeTreeInterfaceItem *item : io_parent_panel.items()) {
472 switch (item->item_type) {
474 const auto &io_socket = node_interface::get_item_as<bNodeTreeInterfaceSocket>(*item);
475 const eNodeSocketInOut in_out = (io_socket.flag & NODE_INTERFACE_SOCKET_INPUT) ? SOCK_IN :
476 SOCK_OUT;
477 if (in_out == SOCK_IN) {
478 add_layout_if_needed();
479 }
481 group, io_socket, structure_type_by_socket.lookup_try(&io_socket), in_out, b);
482 break;
483 }
485 add_layout_if_needed();
486 const auto &io_panel = node_interface::get_item_as<bNodeTreeInterfacePanel>(*item);
487 auto &panel_b = b.add_panel(UString(io_panel.name()), io_panel.identifier)
488 .description(io_panel.description())
489 .default_closed(io_panel.flag & NODE_INTERFACE_PANEL_DEFAULT_CLOSED);
491 panel_b, node, group, structure_type_by_socket, io_panel, false);
492 break;
493 }
494 }
495 }
496
497 add_layout_if_needed();
498}
499
501{
502 const bNode *node = b.node_or_null();
503 if (node == nullptr) {
504 return;
505 }
506 NodeDeclaration &r_declaration = b.declaration();
507 const bNodeTree *group = reinterpret_cast<const bNodeTree *>(node->id);
508 if (!group) {
509 return;
510 }
511 if (ID_IS_LINKED(&group->id)) {
512 if (ID_MISSING(&group->id)) {
513 r_declaration.skip_updating_sockets = true;
514 return;
515 }
516 /* Currently the missing flag is only set on original data. */
517 if (const ID *orig_group = DEG_get_original_id(&group->id)) {
518 if (ID_MISSING(orig_group)) {
519 r_declaration.skip_updating_sockets = true;
520 return;
521 }
522 }
523 }
524 r_declaration.skip_updating_sockets = false;
525
526 /* Allow the node group interface to define the socket order. */
527 r_declaration.use_custom_socket_order = true;
528
529 group->ensure_interface_cache();
530
532 if (ELEM(group->type, NTREE_GEOMETRY, NTREE_COMPOSIT)) {
533 structure_type_by_socket.reserve(group->interface_items().size());
534
535 const Span<const bNodeTreeInterfaceSocket *> inputs = group->interface_inputs();
536 const Span<StructureType> input_structure_types =
537 group->runtime->structure_type_interface->inputs;
538 for (const int i : inputs.index_range()) {
539 structure_type_by_socket.add(inputs[i], input_structure_types[i]);
540 }
541
542 const Span<const bNodeTreeInterfaceSocket *> outputs = group->interface_outputs();
543 const Span<StructureTypeInterface::OutputDependency> output_structure_types =
544 group->runtime->structure_type_interface->outputs;
545 for (const int i : outputs.index_range()) {
546 structure_type_by_socket.add(outputs[i], output_structure_types[i].type);
547 }
548 }
549
551 b, *node, *group, structure_type_by_socket, group->tree_interface.root_panel, true);
552}
553
554} // namespace nodes
555
557
558/* -------------------------------------------------------------------- */
561
562static void node_frame_init(bNodeTree * /*ntree*/, bNode *node)
563{
564 NodeFrame *data = MEM_new<NodeFrame>("frame node storage");
565 node->storage = data;
566
567 data->flag |= NODE_FRAME_SHRINK;
568
569 data->label_size = 20;
570}
571
573{
574 /* frame type is used for all tree types, needs dynamic allocation */
575 bke::bNodeType *ntype = MEM_new<bke::bNodeType>("frame node type");
576 ntype->free_self = [](bke::bNodeType *type) { MEM_delete(type); };
577
578 bke::node_type_base(*ntype, "NodeFrame"_ustr, NODE_FRAME);
579 ntype->ui_name = "Frame";
580 ntype->ui_description =
581 "Collect related nodes together in a common area. Useful for organization when the "
582 "re-usability of a node group is not required";
583 ntype->nclass = NODE_CLASS_LAYOUT;
584 ntype->enum_name_legacy = "FRAME";
585 ntype->initfunc = node_frame_init;
589 ntype->minwidth = 100;
590 ntype->maxwidth = FLT_MAX;
591
593}
594
596
597/* -------------------------------------------------------------------- */
600
602{
603 const bNode *node = b.node_or_null();
604 if (node == nullptr) {
605 return;
606 }
607
608 const StringRefNull socket_idname(static_cast<const NodeReroute *>(node->storage)->type_idname);
609 b.add_input<nodes::decl::Custom>("Input"_ustr)
610 .idname(socket_idname.c_str())
611 .structure_type(nodes::StructureType::Dynamic);
612 b.add_output<nodes::decl::Custom>("Output"_ustr)
613 .idname(socket_idname.c_str())
614 .structure_type(nodes::StructureType::Dynamic);
615}
616
617static void node_reroute_init(bNodeTree * /*ntree*/, bNode *node)
618{
619 NodeReroute *data = MEM_new<NodeReroute>(__func__);
620 STRNCPY(data->type_idname, "NodeSocketColor");
621 node->storage = data;
622}
623
625 const bNodeTree *nodetree,
626 const char **r_disabled_hint)
627{
628 const NodeReroute &data = *static_cast<NodeReroute *>(node->storage);
629 bke::bNodeSocketType *socket_type = bke::node_socket_type_find(data.type_idname);
630 if (!socket_type) {
631 if (r_disabled_hint) {
632 *r_disabled_hint = "Socket type not found";
633 }
634 return false;
635 }
636 bke::bNodeTreeType &tree_type = *nodetree->typeinfo;
637 if (tree_type.valid_socket_type && !tree_type.valid_socket_type(&tree_type, socket_type)) {
638 if (r_disabled_hint) {
639 *r_disabled_hint = "Socket type not supported";
640 }
641 return false;
642 }
643 return true;
644}
645
647{
648 /* frame type is used for all tree types, needs dynamic allocation */
649 bke::bNodeType *ntype = MEM_new<bke::bNodeType>("frame node type");
650 ntype->free_self = [](bke::bNodeType *type) { MEM_delete(type); };
651
652 bke::node_type_base(*ntype, "NodeReroute"_ustr, NODE_REROUTE);
653 ntype->ui_name = "Reroute";
654 ntype->ui_description =
655 "A single-socket organization tool that supports one input and multiple outputs";
656 ntype->enum_name_legacy = "REROUTE";
657 ntype->nclass = NODE_CLASS_LAYOUT;
662
664}
665
667 int node_i = std::numeric_limits<int>::max();
668 int socket_in_node_i = std::numeric_limits<int>::max();
669
672 : node_i(socket.owner_node().index()), socket_in_node_i(socket.index())
673 {
674 }
675
677 {
678 if (this->node_i == other.node_i) {
679 return this->socket_in_node_i < other.socket_in_node_i;
680 }
681 return this->node_i < other.node_i;
682 }
683};
684
686{
687 ntree->ensure_topology_cache();
688
689 const Span<bNode *> all_reroute_nodes = ntree->nodes_by_type("NodeReroute"_ustr);
690
691 VectorSet<int> reroute_nodes;
692 for (const bNode *reroute : all_reroute_nodes) {
693 reroute_nodes.add(reroute->index());
694 }
695
696 /* Any reroute can be connected only to one source, or can be not connected at all.
697 * So reroute forms a trees. It is possible that there will be cycle, but such cycle
698 * can be only one in strongly connected set of reroutes. To propagate a types from
699 * some certain target to all the reroutes in such a tree we need to know all such
700 * a trees and all possible targets for each tree. */
701 DisjointSet reroutes_groups(reroute_nodes.size());
702
703 for (const bNode *src_reroute : all_reroute_nodes) {
704 const int src_reroute_i = reroute_nodes.index_of(src_reroute->index());
705 for (const bNodeSocket *dst_socket :
706 src_reroute->output_sockets().first()->directly_linked_sockets())
707 {
708 const bNode &dst_node = dst_socket->owner_node();
709 if (!dst_node.is_reroute()) {
710 continue;
711 }
712 const int dst_reroute_i = reroute_nodes.index_of(dst_node.index());
713 reroutes_groups.join(src_reroute_i, dst_reroute_i);
714 }
715 }
716
717 VectorSet<int> reroute_groups;
718 for (const int reroute_i : reroute_nodes.index_range()) {
719 const int root_reroute_i = reroutes_groups.find_root(reroute_i);
720 reroute_groups.add(root_reroute_i);
721 }
722
723 /* Any reroute can have only one source and many destination targets. Type propagation considers
724 * source as target with highest priority. */
725 Array<const bke::bNodeSocketType *> dst_type_by_reroute_group(reroute_groups.size(), nullptr);
726 Array<const bke::bNodeSocketType *> src_type_by_reroute_group(reroute_groups.size(), nullptr);
727
728 /* Reroute type priority based on the indices of target sockets in the node and the nodes in the
729 * tree. */
730 Array<RerouteTargetPriority> reroute_group_dst_type_priority(reroute_groups.size(),
732
733 for (const bNodeLink *link : ntree->all_links()) {
734 const bNode *src_node = link->fromnode;
735 const bNode *dst_node = link->tonode;
736
737 if (src_node->is_reroute() == dst_node->is_reroute()) {
738 continue;
739 }
740
741 if (!dst_node->is_reroute()) {
742 const int src_reroute_i = reroute_nodes.index_of(src_node->index());
743 const int src_reroute_root_i = reroutes_groups.find_root(src_reroute_i);
744 const int src_reroute_group_i = reroute_groups.index_of(src_reroute_root_i);
745
746 const RerouteTargetPriority type_priority(*link->tosock);
747 if (reroute_group_dst_type_priority[src_reroute_group_i] > type_priority) {
748 continue;
749 }
750
751 reroute_group_dst_type_priority[src_reroute_group_i] = type_priority;
752
753 const bNodeSocket *dst_socket = link->tosock;
754 /* There could be a function which will choose best from
755 * #dst_type_by_reroute_group and #dst_socket, but right now this match behavior as-is. */
756 dst_type_by_reroute_group[src_reroute_group_i] = dst_socket->typeinfo;
757 continue;
758 }
759
760 BLI_assert(!src_node->is_reroute());
761 const int dst_reroute_i = reroute_nodes.index_of(dst_node->index());
762 const int dst_reroute_root_i = reroutes_groups.find_root(dst_reroute_i);
763 const int dst_reroute_group_i = reroute_groups.index_of(dst_reroute_root_i);
764
765 const bNodeSocket *src_socket = link->fromsock;
766 /* There could be a function which will choose best from
767 * #src_type_by_reroute_group and #src_socket, but right now this match behavior as-is. */
768 src_type_by_reroute_group[dst_reroute_group_i] = src_socket->typeinfo;
769 }
770
771 const Span<bNode *> all_nodes = ntree->all_nodes();
772 for (const int reroute_i : reroute_nodes.index_range()) {
773 const int reroute_root_i = reroutes_groups.find_root(reroute_i);
774 const int reroute_group_i = reroute_groups.index_of(reroute_root_i);
775
776 const bke::bNodeSocketType *reroute_type = nullptr;
777 if (dst_type_by_reroute_group[reroute_group_i] != nullptr) {
778 reroute_type = dst_type_by_reroute_group[reroute_group_i];
779 }
780 if (src_type_by_reroute_group[reroute_group_i] != nullptr) {
781 reroute_type = src_type_by_reroute_group[reroute_group_i];
782 }
783
784 if (reroute_type == nullptr) {
785 const int root_node_index = reroute_nodes[reroute_root_i];
786 const bNode &root_reroute = *all_nodes[root_node_index];
787 const bNodeSocket *root_socket = root_reroute.inputs.first();
788 reroute_type = root_socket->typeinfo;
789 }
790
791 const int reroute_index = reroute_nodes[reroute_i];
792 bNode &reroute_node = *all_nodes[reroute_index];
793 NodeReroute *storage = static_cast<NodeReroute *>(reroute_node.storage);
794 if (reroute_type->idname != storage->type_idname) {
795 reroute_type->idname.ref().copy_utf8_truncated(storage->type_idname);
796 nodes::update_node_declaration_and_sockets(*ntree, reroute_node);
797 }
798 }
799}
800
802{
803 ntree.ensure_topology_cache();
804 Stack<const bNode *> nodes_to_check;
805 for (const bNodeSocket *socket : node.output_sockets()) {
806 for (const bNodeLink *link : socket->directly_linked_links()) {
807 nodes_to_check.push(link->tonode);
808 }
809 }
810 while (!nodes_to_check.is_empty()) {
811 const bNode *next_node = nodes_to_check.pop();
812 for (const bNodeSocket *socket : next_node->output_sockets()) {
813 for (const bNodeLink *link : socket->directly_linked_links()) {
814 if (link->tonode->typeinfo->nclass == NODE_CLASS_OUTPUT &&
815 link->tonode->flag & NODE_DO_OUTPUT)
816 {
817 return true;
818 }
819 nodes_to_check.push(link->tonode);
820 }
821 }
822 }
823
824 return false;
825}
826
828
829/* -------------------------------------------------------------------- */
832
834{
835 const bNode *node = b.node_or_null();
836 if (node == nullptr) {
837 return;
838 }
839
840 const StringRefNull socket_idname(
841 static_cast<const NodeImplicitConversion *>(node->storage)->type_idname);
842 b.use_custom_socket_order();
843 b.allow_any_socket_order();
844 b.add_default_layout();
845 b.add_input<nodes::decl::Custom>("Value"_ustr)
846 .idname(socket_idname.c_str())
847 .structure_type(nodes::StructureType::Dynamic)
848 .optional_label();
849 b.add_output<nodes::decl::Custom>("Value"_ustr)
850 .idname(socket_idname.c_str())
851 .structure_type(nodes::StructureType::Dynamic)
852 .propagate_all()
853 .align_with_previous();
854}
855
856static void node_implicit_conversion_label(const bNodeTree * /*ntree*/,
857 const bNode *node,
858 char *label,
859 int label_maxncpy)
860{
861 const auto &data = *static_cast<NodeImplicitConversion *>(node->storage);
862 const bke::bNodeSocketType *socket_type = bke::node_socket_type_find(data.type_idname);
863 if (!socket_type) {
864 BLI_strncpy(label, IFACE_(node->typeinfo->ui_name.c_str()), label_maxncpy);
865 return;
866 }
867
868 const char *name;
869 bool enum_label = RNA_enum_name(rna_enum_node_socket_data_type_items, socket_type->type, &name);
870 if (!enum_label) {
871 BLI_strncpy(label, IFACE_(node->typeinfo->ui_name.c_str()), label_maxncpy);
872 return;
873 }
874
875 BLI_snprintf_utf8(label, label_maxncpy, IFACE_("To %s"), IFACE_(name));
876}
877
879{
880 layout.use_property_split_set(true);
881 layout.use_property_decorate_set(false);
882 layout.prop(ptr, "data_type", UI_ITEM_NONE, "", ICON_NONE);
883}
884
886{
887 NodeImplicitConversion *data = MEM_new<NodeImplicitConversion>(__func__);
888 STRNCPY(data->type_idname, "NodeSocketColor");
889 node->storage = data;
890}
891
893 const bNodeTree *nodetree,
894 const char **r_disabled_hint)
895{
896 const auto &data = *static_cast<NodeImplicitConversion *>(node->storage);
897 bke::bNodeSocketType *socket_type = bke::node_socket_type_find(data.type_idname);
898 if (!socket_type) {
899 if (r_disabled_hint) {
900 *r_disabled_hint = "Socket type not found";
901 }
902 return false;
903 }
904 bke::bNodeTreeType &tree_type = *nodetree->typeinfo;
905 if (tree_type.valid_socket_type && !tree_type.valid_socket_type(&tree_type, socket_type)) {
906 if (r_disabled_hint) {
907 *r_disabled_hint = "Socket type not supported";
908 }
909 return false;
910 }
911 return true;
912}
913
915{
916 auto input_value = params.extract_input<bke::SocketValueVariant>("Value"_ustr);
917 params.set_output("Value"_ustr, std::move(input_value));
918}
919
921 public:
922 using NodeOperation::NodeOperation;
923
924 void execute() override
925 {
926 using namespace compositor;
927 const Result &input = this->get_input("Value");
928 Result &output = this->get_result("Value");
929 output.share_data(input);
930 }
931};
932
938
940{
941 /* Adapt type node is used for all tree types, needs dynamic allocation. */
942 bke::bNodeType *ntype = MEM_new<bke::bNodeType>(__func__);
943 ntype->free_self = [](bke::bNodeType *type) { MEM_delete(type); };
944
945 bke::node_type_base(*ntype, "NodeImplicitConversion"_ustr);
946 ntype->ui_name = "Implicit Conversion";
947 ntype->ui_description = "Implicitly convert the input value to a fixed socket type";
954 *ntype, "NodeImplicitConversion", node_free_standard_storage, node_copy_standard_storage);
958
960}
961
963
964/* -------------------------------------------------------------------- */
967
969{
970 for (bNodeSocket &sock : node->outputs) {
971 if (sock.identifier == identifier) {
972 return &sock;
973 }
974 }
975 return nullptr;
976}
977
978namespace nodes {
979
981{
982 const bNodeTree *node_tree = b.tree_or_null();
983 if (node_tree == nullptr) {
984 return;
985 }
986 node_tree->tree_interface.foreach_item([&](const bNodeTreeInterfaceItem &item) {
987 switch (item.item_type) {
989 const bNodeTreeInterfaceSocket &socket =
991 if (socket.flag & NODE_INTERFACE_SOCKET_INPUT) {
992 /* Trying to use the evaluated structure type for the group output node introduces a
993 * "dependency cycle" between this and the structure type inferencing which uses node
994 * declarations. The compromise is to not use the proper structure type in the group
995 * input/output declarations and instead use a special case for the choice of socket
996 * shapes. */
997 build_interface_socket_declaration(*node_tree, socket, std::nullopt, SOCK_OUT, b)
998 .socket_name_ptr(&node_tree->id, RNA_NodeTreeInterfaceSocket, &socket, "name");
999 }
1000 break;
1001 }
1003 break;
1004 }
1005 }
1006 return true;
1007 });
1008 b.add_output<decl::Extend>(""_ustr, "__extend__"_ustr);
1009}
1010
1012{
1013 const bNodeTree *node_tree = b.tree_or_null();
1014 if (node_tree == nullptr) {
1015 return;
1016 }
1017 node_tree->tree_interface.foreach_item([&](const bNodeTreeInterfaceItem &item) {
1018 switch (item.item_type) {
1020 const bNodeTreeInterfaceSocket &socket =
1022 if (socket.flag & NODE_INTERFACE_SOCKET_OUTPUT) {
1023 build_interface_socket_declaration(*node_tree, socket, std::nullopt, SOCK_IN, b)
1024 .socket_name_ptr(&node_tree->id, RNA_NodeTreeInterfaceSocket, &socket, "name");
1025 }
1026 break;
1027 }
1029 break;
1030 }
1031 }
1032 return true;
1033 });
1034 b.add_input<decl::Extend>(""_ustr, "__extend__"_ustr);
1035}
1036
1038{
1039 BLI_assert(params.link.tonode != &params.node);
1040 BLI_assert(params.link.tosock->in_out == SOCK_IN);
1041 if (!StringRef(params.link.fromsock->identifier).startswith("__extend__")) {
1042 return true;
1043 }
1044 if (StringRef(params.link.tosock->identifier).startswith("__extend__")) {
1045 /* Don't connect to other "extend" sockets. */
1046 return false;
1047 }
1049 params.ntree, *params.link.tonode, *params.link.tosock);
1050 if (!io_socket) {
1051 return false;
1052 }
1054 params.link.fromsock = node_group_input_find_socket(&params.node, io_socket->identifier);
1055
1056 params.ntree.tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
1057 item.set_selected(false);
1058 return true;
1059 });
1060 params.ntree.tree_interface.active_item_set(&io_socket->item);
1061
1062 return true;
1063}
1064
1066{
1067 BLI_assert(params.link.fromnode != &params.node);
1069 if (!StringRef(params.link.tosock->identifier).startswith("__extend__")) {
1070 return true;
1071 }
1072 if (StringRef(params.link.fromsock->identifier).startswith("__extend__")) {
1073 /* Don't connect to other "extend" sockets. */
1074 return false;
1075 }
1077 params.ntree, *params.link.fromnode, *params.link.fromsock);
1078 if (!io_socket) {
1079 return false;
1080 }
1082 params.link.tosock = node_group_output_find_socket(&params.node, io_socket->identifier);
1083
1084 params.ntree.tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
1085 item.set_selected(false);
1086 return true;
1087 });
1088 params.ntree.tree_interface.active_item_set(&io_socket->item);
1089
1090 return true;
1091}
1092
1094{
1095 ed::space_node::node_tree_interface_draw(*C, layout, *id_cast<bNodeTree *>(ptr->owner_id));
1096}
1097
1099{
1100 ed::space_node::node_tree_interface_draw(*C, layout, *id_cast<bNodeTree *>(ptr->owner_id));
1101}
1102
1103} // namespace nodes
1104
1106{
1107 /* used for all tree types, needs dynamic allocation */
1108 bke::bNodeType *ntype = MEM_new<bke::bNodeType>("node type");
1109 ntype->free_self = [](bke::bNodeType *type) { MEM_delete(type); };
1110
1111 bke::node_type_base(*ntype, "NodeGroupInput"_ustr, NODE_GROUP_INPUT);
1112 ntype->ui_name = "Group Input";
1113 ntype->ui_description =
1114 "Expose connected data from inside a node group as inputs to its interface";
1115 ntype->enum_name_legacy = "GROUP_INPUT";
1120 ntype->no_muting = true;
1121
1123}
1124
1126{
1127 for (bNodeSocket &sock : node->inputs) {
1128 if (sock.identifier == identifier) {
1129 return &sock;
1130 }
1131 }
1132 return nullptr;
1133}
1134
1136{
1137 if (parameters.tree.type != NTREE_COMPOSIT) {
1138 return;
1139 }
1140
1141 SpaceNode *space_node = CTX_wm_space_node(&parameters.C);
1142 if (space_node->edittree != space_node->nodetree) {
1143 return;
1144 }
1145
1146 blender::Span<const bNodeSocket *> group_outputs = parameters.node.input_sockets().drop_back(1);
1147 if (group_outputs.is_empty()) {
1148 return;
1149 }
1150
1151 if (group_outputs[0]->type != SOCK_RGBA) {
1153 row.text = IFACE_("Wrong Output Type");
1154 row.icon = ICON_STATUS_ERROR;
1155 row.tooltip = TIP_("Node group's first output must be a color output");
1156 parameters.rows.append(std::move(row));
1157 return;
1158 }
1159
1160 if (group_outputs.size() > 1) {
1162 row.text = IFACE_("Ignored Outputs");
1163 row.icon = ICON_STATUS_WARNING;
1164 row.tooltip = TIP_("Only the first output is considered while the rest are ignored");
1165 parameters.rows.append(std::move(row));
1166 return;
1167 }
1168}
1169
1171{
1173 const Span<const bNode *> group_output_nodes = params.tree.nodes_by_type("NodeGroupOutput"_ustr);
1174 if (group_output_nodes.size() <= 1) {
1175 return;
1176 }
1177 if (params.node.flag & NODE_DO_OUTPUT) {
1178 return;
1179 }
1181 row.text = IFACE_("Unused Output");
1182 row.icon = ICON_STATUS_ERROR;
1183 row.tooltip = TIP_("There are multiple group output nodes and this one is not active");
1184 params.rows.append(std::move(row));
1185}
1186
1188{
1189 /* used for all tree types, needs dynamic allocation */
1190 bke::bNodeType *ntype = MEM_new<bke::bNodeType>(__func__);
1191 ntype->free_self = [](bke::bNodeType *type) { MEM_delete(type); };
1192
1193 bke::node_type_base(*ntype, "NodeGroupOutput"_ustr, NODE_GROUP_OUTPUT);
1194 ntype->ui_name = "Group Output";
1195 ntype->ui_description = "Output data from inside of a node group";
1196 ntype->enum_name_legacy = "GROUP_OUTPUT";
1202
1203 ntype->no_muting = true;
1204
1206}
1207
1208static void node_comment_init(bNodeTree * /*tree*/, bNode *node)
1209{
1210 NodeComment *data = MEM_new<NodeComment>(__func__);
1211 data->text = BLI_strdup("## Comment");
1212 data->textbox_state_node.visible_lines = 5;
1213 data->textbox_state_panel.visible_lines = 5;
1214 node->storage = data;
1215}
1216
1218{
1219 NodeComment *storage = static_cast<NodeComment *>(node->storage);
1220 MEM_delete(storage->text);
1221 MEM_delete(storage);
1222}
1223
1224static void node_comment_copy(bNodeTree * /*dest_ntree*/, bNode *dst_node, const bNode *src_node)
1225{
1226 const NodeComment &src_data = *static_cast<NodeComment *>(src_node->storage);
1227 NodeComment *dst_data = MEM_new<NodeComment>(__func__, src_data);
1228 dst_data->text = BLI_strdup_null(src_data.text);
1229 dst_node->storage = dst_data;
1230}
1231
1232static void node_comment_layout_ex(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
1233{
1234 bNode &node = *ptr->data_as<bNode>();
1235 NodeComment &storage = *static_cast<NodeComment *>(node.storage);
1236 layout.textbox_with_state(ptr, "text", &storage.textbox_state_panel, "");
1237}
1238
1239static void node_comment_blend_write(const bNodeTree & /*ntree*/,
1240 const bNode &node,
1241 BlendWriter &writer)
1242{
1243 const NodeComment &data = *static_cast<NodeComment *>(node.storage);
1244 writer.write_string(data.text);
1245}
1246
1248{
1249 NodeComment *data = static_cast<NodeComment *>(node.storage);
1250 BLO_read_string(&reader, &data->text);
1251 data->flag &= ~NodeCommentFlag::Edit;
1252}
1253
1255{
1256 static bke::bNodeType ntype;
1257 bke::node_type_base(ntype, "NodeComment"_ustr);
1258 ntype.ui_name = "Comment";
1259 ntype.ui_description = "Add explanations to the node group";
1263 ntype.maxwidth = FLT_MAX;
1264 ntype.no_muting = true;
1270}
1271
1273
1274} // namespace blender
#define NODE_CLASS_OUTPUT
Definition BKE_node.hh:479
#define NODE_REROUTE
Definition BKE_node.hh:867
#define NODE_CLASS_INTERFACE
Definition BKE_node.hh:490
#define NODE_CLASS_MATTE
Definition BKE_node.hh:485
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define NODE_CLASS_PATTERN
Definition BKE_node.hh:487
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:492
#define NODE_GROUP_OUTPUT
Definition BKE_node.hh:869
#define NODE_CLASS_DISTORT
Definition BKE_node.hh:486
#define NODE_CLASS_OP_VECTOR
Definition BKE_node.hh:481
#define NODE_CLASS_LAYOUT
Definition BKE_node.hh:494
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define NODE_CLASS_OP_FILTER
Definition BKE_node.hh:482
#define NODE_FRAME
Definition BKE_node.hh:866
#define NODE_CLASS_GROUP
Definition BKE_node.hh:483
#define NODE_GROUP_INPUT
Definition BKE_node.hh:868
#define NODE_CLASS_ATTRIBUTE
Definition BKE_node.hh:493
#define NODE_CLASS_TEXTURE
Definition BKE_node.hh:488
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define NODE_CLASS_SCRIPT
Definition BKE_node.hh:489
#define RPT_(msgid)
#define TIP_(msgid)
#define IFACE_(msgid)
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_MISSING(_id)
Definition DNA_ID.h:695
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define ELEM(...)
#define output
T join(const T x, const T y)
std::optional< Value > lookup_try(const Key &key) const
Definition BLI_map.hh:531
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
void reserve(int64_t n)
Definition BLI_map.hh:1028
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
bool is_empty() const
Definition BLI_stack.hh:310
void push(const T &value)
Definition BLI_stack.hh:215
constexpr const char * c_str() const
constexpr StringRef()
StringRefNull ref() const
UString()=default
bool add(const Key &key)
int64_t size() const
int64_t index_of(const Key &key) const
IndexRange index_range() const
std::unique_ptr< nodes::StructureTypeInterface > structure_type_interface
constexpr bool is_empty() const
constexpr int64_t size() const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
Definition string_ref.cc:28
Result & get_result(StringRef identifier)
Definition operation.cc:40
Result & get_input(StringRef identifier) const
Definition operation.cc:35
BaseSocketDeclarationBuilder & socket_name_ptr(PointerRNA ptr, StringRef property_name)
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
std::function< void(bNode &node, bNodeSocket &socket, const char *data_path)> init_socket_fn
#define FLT_MAX
#define storage(slot, qualifiers)
T & get_item_as(bNodeTreeInterfaceItem &item)
T & get_socket_data_as(bNodeTreeInterfaceSocket &item)
bNodeTreeInterfaceSocket * add_interface_socket_from_node(bNodeTree &ntree, const bNode &from_node, const bNodeSocket &from_sock, std::optional< StringRef > name=std::nullopt, std::optional< eNodeSocketInOut > in_out=std::nullopt)
bool node_is_connected_to_output(const bNodeTree &ntree, const bNode &node)
bool node_group_poll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_type_base(bNodeType &ntype, UString idname, std::optional< int16_t > legacy_type=std::nullopt)
Definition node.cc:5866
bNodeSocketType * node_socket_type_find(StringRef idname)
Definition node.cc:2966
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:6166
void node_tree_interface_draw(bContext &C, ui::Layout &layout, bNodeTree &tree)
EulerXYZBase< float > EulerXYZ
static void group_input_declare(NodeDeclarationBuilder &b)
static std::function< ID *(const bNode &node)> get_default_id_getter(const bNodeTreeInterface &tree_interface, const bNodeTreeInterfaceSocket &io_socket)
static void node_group_input_layout(ui::Layout &layout, bContext *C, PointerRNA *ptr)
void update_node_declaration_and_sockets(bNodeTree &ntree, bNode &node, Main *bmain)
void node_group_declare(NodeDeclarationBuilder &b)
static bool group_input_insert_link(bke::NodeInsertLinkParams &params)
static bool group_output_insert_link(bke::NodeInsertLinkParams &params)
static void group_output_declare(NodeDeclarationBuilder &b)
static std::function< void(bNode &node, bNodeSocket &socket, const char *data_path)> get_init_socket_fn(const bNodeTreeInterface &tree_interface, const bNodeTreeInterfaceSocket &io_socket)
static void node_group_output_layout(ui::Layout &layout, bContext *C, PointerRNA *ptr)
static BaseSocketDeclarationBuilder & build_interface_socket_declaration(const bNodeTree &tree, const bNodeTreeInterfaceSocket &io_socket, const std::optional< StructureType > structure_type, const eNodeSocketInOut in_out, DeclarationListBuilder &b)
static void node_group_declare_panel_recursive(DeclarationListBuilder &b, const bNode &node, const bNodeTree &group, const Map< const bNodeTreeInterfaceSocket *, StructureType > &structure_type_by_socket, const bNodeTreeInterfacePanel &io_parent_panel, const bool is_root)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
static void node_frame_init(bNodeTree *, bNode *node)
static bool node_implicit_conversion_poll_instance(const bNode *node, const bNodeTree *nodetree, const char **r_disabled_hint)
char * STRNCPY(char(&dst)[N], const char *src)
ID * DEG_get_original_id(ID *id)
static void node_reroute_init(bNodeTree *, bNode *node)
void register_node_type_group_input()
int node_group_ui_class(const bNode *node)
static void node_implicit_conversion_declare(nodes::NodeDeclarationBuilder &b)
std::string node_group_ui_description(const bNode &node)
bNodeSocket * node_group_output_find_socket(bNode *node, const StringRef identifier)
void node_group_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
bNodeSocket * node_group_find_output_socket(bNode *groupnode, const StringRef identifier)
static compositor::NodeOperation * node_implicit_conversion_compositor_operation(compositor::Context &context, const bNode &node)
static void node_comment_layout_ex(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_implicit_conversion_geo_exec(nodes::GeoNodeExecParams params)
static void get_compositor_group_output_extra_info(blender::nodes::NodeExtraInfoParams &parameters)
static void node_comment_copy(bNodeTree *, bNode *dst_node, const bNode *src_node)
VecBase< float, 4 > float4
void register_node_type_reroute()
void register_node_type_frame()
static void node_comment_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
static bNodeSocket * find_matching_socket(ListBaseT< bNodeSocket > &sockets, StringRef identifier)
VecBase< int32_t, 3 > int3
static void node_implicit_conversion_init(bNodeTree *, bNode *node)
static void node_comment_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static void node_group_output_extra_info(nodes::NodeExtraInfoParams &params)
void register_node_type_group_output()
BMesh const char void * data
bool RNA_enum_name(const EnumPropertyItem *item, const int value, const char **r_name)
static void node_comment_free(bNode *node)
SpaceNode * CTX_wm_space_node(const bContext *C)
void register_node_type_implicit_conversion()
static void node_implicit_conversion_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static bool node_reroute_poll_instance(const bNode *node, const bNodeTree *nodetree, const char **r_disabled_hint)
static void node_reroute_declare(nodes::NodeDeclarationBuilder &b)
static void node_comment_init(bNodeTree *, bNode *node)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
void ntree_update_reroute_nodes(bNodeTree *ntree)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:57
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
const EnumPropertyItem rna_enum_node_socket_data_type_items[]
void node_free_standard_storage(bNode *node)
Definition node_util.cc:45
VecBase< float, 3 > float3
bNodeSocket * node_group_find_input_socket(bNode *groupnode, const StringRef identifier)
bNodeSocket * node_group_input_find_socket(bNode *node, const StringRef identifier)
static void node_implicit_conversion_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
bool node_group_poll_instance(const bNode *node, const bNodeTree *nodetree, const char **r_disabled_hint)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
Definition readfile.cc:6653
void register_node_type_comment()
void write_string(const char *data)
struct AssetMetaData * asset_data
Definition DNA_ID.h:424
T * data_as() const
Definition RNA_types.hh:139
bool operator>(const RerouteTargetPriority other)
RerouteTargetPriority(const bNodeSocket &socket)
struct bNodeTree * edittree
struct bNodeTree * nodetree
bke::bNodeSocketType * typeinfo
eNodeSocketInOut in_out
bke::bNodeTreeType * typeinfo
bNodeTreeInterface tree_interface
eNodeTree_Type type
bke::bNodeTreeRuntime * runtime
ListBaseT< bNodeSocket > outputs
ListBaseT< bNodeSocket > inputs
static constexpr int _160
Definition BKE_node.hh:246
static constexpr int _200
Definition BKE_node.hh:248
Defines a socket type.
Definition BKE_node.hh:163
void(*) interface_init_socket(ID *id, const bNodeTreeInterfaceSocket *interface_socket, bNode *node, bNodeSocket *socket, StringRefNull data_path)
Definition BKE_node.hh:183
eNodeSocketDatatype type
Definition BKE_node.hh:198
bool(*) valid_socket_type(bNodeTreeType *ntreetype, bNodeSocketType *socket_type)
Definition BKE_node.hh:569
Defines a node type.
Definition BKE_node.hh:265
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:290
NodeBlendWriteFunction blend_write_storage_content
Definition BKE_node.hh:421
std::string ui_description
Definition BKE_node.hh:271
NodeBlendDataReadFunction blend_data_read_storage_content
Definition BKE_node.hh:422
void(*) labelfunc(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
Definition BKE_node.hh:301
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:379
NodeExtraInfoFunction get_extra_info
Definition BKE_node.hh:412
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:292
void(*) initfunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:320
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393
void(*) free_self(bNodeType *ntype)
Definition BKE_node.hh:366
bool(*) insert_link(NodeInsertLinkParams &params)
Definition BKE_node.hh:364
bool(*) poll_instance(const bNode *node, const bNodeTree *nodetree, const char **r_disabled_hint)
Definition BKE_node.hh:359
Vector< NodeExtraInfoRow > & rows
void use_property_decorate_set(bool is_decorate)
void textbox_with_state(PointerRNA *ptr, StringRefNull propname, TextboxState *textbox_state, std::optional< StringRefNull > name_opt=std::nullopt, std::optional< StringRefNull > placeholder=std::nullopt)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)