Blender V5.3
node_socket.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 <climits>
10
11#include <fmt/format.h>
12
13#include "DNA_ID.h"
14#include "DNA_node_types.h"
15
16#include "BLI_color_types.hh"
17#include "BLI_listbase.hh"
18#include "BLI_math_euler.hh"
20#include "BLI_math_vector_c.hh"
22#include "BLI_string.hh"
23#include "BLI_string_utf8.hh"
24#include "BLI_utildefines.hh"
25
26#include "BKE_action.hh"
27#include "BKE_animsys.hh"
28#include "BKE_compositor.hh"
29#include "BKE_geometry_set.hh"
30#include "BKE_idprop.hh"
31#include "BKE_lib_id.hh"
32#include "BKE_node.hh"
33#include "BKE_node_enum.hh"
35#include "BKE_node_runtime.hh"
38
39#include "DNA_anim_types.h"
41#include "DNA_mask_types.h"
42#include "DNA_material_types.h"
43#include "DNA_sequence_types.h"
44#include "DNA_sound_types.h"
45#include "DNA_text_types.h"
46#include "DNA_vfont_types.h"
47
48#include "RNA_access.hh"
49#include "RNA_define.hh"
50#include "RNA_enum_types.hh"
51#include "RNA_prototypes.hh"
52
53#include "MEM_guardedalloc.h"
54
56#include "NOD_geometry.hh"
60#include "NOD_menu_value.hh"
62#include "NOD_socket.hh"
63
64#include "SEQ_iterator.hh"
65#include "SEQ_modifier.hh"
66#include "SEQ_relations.hh"
67#include "SEQ_sequencer.hh"
68
69#include "WM_types.hh"
70
71#include "DEG_depsgraph.hh"
73
74#include "ANIM_action.hh"
76
77namespace blender {
78
81
83 bNode *node,
85 eNodeSocketInOut in_out)
86{
88 *ntree, *node, in_out, stemp->type, stemp->subtype, stemp->identifier, stemp->name);
89
90 sock->flag |= stemp->flag;
91
92 /* initialize default_value */
93 switch (stemp->type) {
94 case SOCK_FLOAT: {
95 bNodeSocketValueFloat *dval = static_cast<bNodeSocketValueFloat *>(sock->default_value);
96 dval->value = stemp->val1;
97 dval->min = stemp->min;
98 dval->max = stemp->max;
99 break;
100 }
101 case SOCK_INT: {
102 bNodeSocketValueInt *dval = static_cast<bNodeSocketValueInt *>(sock->default_value);
103 dval->value = int(stemp->val1);
104 dval->min = int(stemp->min);
105 dval->max = int(stemp->max);
106 break;
107 }
108 case SOCK_BOOLEAN: {
110 dval->value = int(stemp->val1);
111 break;
112 }
113 case SOCK_VECTOR: {
114 bNodeSocketValueVector *dval = static_cast<bNodeSocketValueVector *>(sock->default_value);
115 dval->value[0] = stemp->val1;
116 dval->value[1] = stemp->val2;
117 dval->value[2] = stemp->val3;
118 dval->dimensions = 3;
119 dval->min = stemp->min;
120 dval->max = stemp->max;
121 break;
122 }
123 case SOCK_RGBA: {
124 bNodeSocketValueRGBA *dval = static_cast<bNodeSocketValueRGBA *>(sock->default_value);
125 dval->value[0] = stemp->val1;
126 dval->value[1] = stemp->val2;
127 dval->value[2] = stemp->val3;
128 dval->value[3] = stemp->val4;
129 break;
130 }
131 }
132
133 return sock;
134}
135
137 bNode *node,
138 eNodeSocketInOut in_out,
139 ListBaseT<bNodeSocket> *socklist,
141{
142 bNodeSocket *sock;
143
144 for (sock = socklist->first(); sock; sock = sock->next) {
145 if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR)) {
146 break;
147 }
148 }
149 if (sock) {
150 if (sock->type != stemp->type) {
151 bke::node_modify_socket_type_static(ntree, node, sock, stemp->type, stemp->subtype);
152 }
153 sock->flag |= stemp->flag;
154 }
155 else {
156 /* no socket for this template found, make a new one */
157 sock = node_add_socket_from_template(ntree, node, stemp, in_out);
158 }
159
160 /* remove the new socket from the node socket list first,
161 * will be added back after verification. */
162 BLI_remlink(socklist, sock);
163
164 return sock;
165}
166
168 bNode *node,
169 eNodeSocketInOut in_out,
170 ListBaseT<bNodeSocket> *socklist,
171 bke::bNodeSocketTemplate *stemp_first)
172{
173 bNodeSocket *sock, *nextsock;
175
176 /* no inputs anymore? */
177 if (stemp_first == nullptr) {
178 for (sock = socklist->first(); sock; sock = nextsock) {
179 nextsock = sock->next;
180 bke::node_remove_socket(*ntree, *node, *sock);
181 }
182 }
183 else {
184 /* step by step compare */
185 stemp = stemp_first;
186 while (stemp->type != -1) {
187 stemp->sock = verify_socket_template(ntree, node, in_out, socklist, stemp);
188 stemp++;
189 }
190 /* leftovers are removed */
191 for (sock = socklist->first(); sock; sock = nextsock) {
192 nextsock = sock->next;
193 bke::node_remove_socket(*ntree, *node, *sock);
194 }
195
196 /* and we put back the verified sockets */
197 stemp = stemp_first;
198 if (socklist->first_) {
199 /* Some dynamic sockets left, store the list start
200 * so we can add static sockets in front of it. */
201 sock = socklist->first();
202 while (stemp->type != -1) {
203 /* Put static sockets in front of dynamic. */
204 BLI_insertlinkbefore(socklist, sock, stemp->sock);
205 stemp++;
206 }
207 }
208 else {
209 while (stemp->type != -1) {
210 BLI_addtail(socklist, stemp->sock);
211 stemp++;
212 }
213 }
214 }
215}
216
217namespace nodes {
218
220 bNode &node,
221 const SocketDeclaration &socket_decl,
222 Vector<bNodeSocket *> &old_sockets,
223 VectorSet<bNodeSocket *> &new_sockets,
224 const bool hide_new_sockets)
225{
226 /* Try to find a socket that corresponds to the declaration. */
227 bNodeSocket *old_socket_with_same_identifier = nullptr;
228 for (const int i : old_sockets.index_range()) {
229 bNodeSocket &old_socket = *old_sockets[i];
230 if (old_socket.identifier == socket_decl.identifier) {
231 old_sockets.remove_and_reorder(i);
232 old_socket_with_same_identifier = &old_socket;
233 break;
234 }
235 }
236 bNodeSocket *new_socket = nullptr;
237 if (old_socket_with_same_identifier == nullptr) {
238 /* Create a completely new socket. */
239 new_socket = &socket_decl.build(ntree, node);
240 SET_FLAG_FROM_TEST(new_socket->flag, hide_new_sockets, SOCK_HIDDEN);
241 }
242 else {
243 STRNCPY_UTF8(old_socket_with_same_identifier->name, socket_decl.name.c_str());
244 if (socket_decl.matches(*old_socket_with_same_identifier)) {
245 /* The existing socket matches exactly, just use it. */
246 new_socket = old_socket_with_same_identifier;
247 }
248 else {
249 /* Clear out identifier to avoid name collisions when a new socket is created. */
250 old_socket_with_same_identifier->identifier[0] = '\0';
251 new_socket = &socket_decl.update_or_build(ntree, node, *old_socket_with_same_identifier);
252
253 if (new_socket == old_socket_with_same_identifier) {
254 /* The existing socket has been updated, set the correct identifier again. */
255 STRNCPY_UTF8(new_socket->identifier, socket_decl.identifier.c_str());
256 new_socket->runtime->identifier_ustr = UString(new_socket->identifier);
257 }
258 else {
259 /* Move links to new socket with same identifier. */
260 for (bNodeLink &link : ntree.links) {
261 if (link.fromsock == old_socket_with_same_identifier) {
262 link.fromsock = new_socket;
263 }
264 else if (link.tosock == old_socket_with_same_identifier) {
265 link.tosock = new_socket;
266 }
267 }
268 for (bNodeInternalLink &internal_link : node.runtime->internal_links) {
269 if (internal_link.in == old_socket_with_same_identifier) {
270 internal_link.in = new_socket;
271 }
272 else if (internal_link.out == old_socket_with_same_identifier) {
273 internal_link.out = new_socket;
274 }
275 }
276 }
277 }
279 new_socket->flag, old_socket_with_same_identifier->is_user_hidden(), SOCK_HIDDEN);
280 }
281 new_sockets.add_new(new_socket);
282 BKE_ntree_update_tag_socket_new(&ntree, new_socket);
283}
284
285static void refresh_node_panel(const PanelDeclaration &panel_decl,
286 Vector<bNodePanelState> &old_panels,
287 bNodePanelState &new_panel)
288{
289 /* Try to find a panel that corresponds to the declaration. */
290 bNodePanelState *old_panel_with_same_identifier = nullptr;
291 for (const int i : old_panels.index_range()) {
292 bNodePanelState &old_panel = old_panels[i];
293 if (old_panel.identifier == panel_decl.identifier) {
294 /* Panel is removed after copying to #new_panel. */
295 old_panel_with_same_identifier = &old_panel;
296 break;
297 }
298 }
299
300 if (old_panel_with_same_identifier == nullptr) {
301 /* Create a completely new panel. */
302 panel_decl.build(new_panel);
303 }
304 else {
305 if (panel_decl.matches(*old_panel_with_same_identifier)) {
306 /* The existing socket matches exactly, just use it. */
307 new_panel = *old_panel_with_same_identifier;
308 }
309 else {
310 /* Clear out identifier to avoid name collisions when a new panel is created. */
311 old_panel_with_same_identifier->identifier = -1;
312 panel_decl.update_or_build(*old_panel_with_same_identifier, new_panel);
313 }
314
315 /* Remove from old panels. */
316 const int64_t old_panel_index = old_panel_with_same_identifier - old_panels.begin();
317 old_panels.remove_and_reorder(old_panel_index);
318 }
319}
320
321static const char *get_identifier_from_decl(const char *identifier_prefix,
322 const bNodeSocket &socket,
323 const Span<const SocketDeclaration *> socket_decls)
324{
325 if (!BLI_str_startswith(socket.identifier, identifier_prefix)) {
326 return nullptr;
327 }
328 for (const SocketDeclaration *socket_decl : socket_decls) {
329 if (BLI_str_startswith(socket_decl->identifier.c_str(), identifier_prefix)) {
330 if (socket.type == socket_decl->socket_type) {
331 return socket_decl->identifier.c_str();
332 }
333 }
334 }
335 return nullptr;
336}
337
338static const char *get_identifier_from_decl(const Span<const char *> identifier_prefixes,
339 const bNodeSocket &socket,
340 const Span<const SocketDeclaration *> socket_decls)
341{
342 for (const char *identifier_prefix : identifier_prefixes) {
343 if (const char *identifier = get_identifier_from_decl(identifier_prefix, socket, socket_decls))
344 {
345 return identifier;
346 }
347 }
348 return nullptr;
349}
350
364 const bNode &node,
365 const bNodeSocket &socket,
366 const Span<const SocketDeclaration *> socket_decls)
367{
368 switch (node.type_legacy) {
369 case SH_NODE_MIX: {
370 return get_identifier_from_decl({"A", "B", "Result"}, socket, socket_decls);
371 }
372 case SH_NODE_MAP_RANGE: {
373 if (socket.type == SOCK_VECTOR) {
374 if (STREQ(socket.identifier, "Value")) {
375 return "Vector";
376 }
377 if (STREQ(socket.identifier, "From Min")) {
378 return "From_Min_FLOAT3";
379 }
380 if (STREQ(socket.identifier, "From Max")) {
381 return "From_Max_FLOAT3";
382 }
383 if (STREQ(socket.identifier, "To Min")) {
384 return "To_Min_FLOAT3";
385 }
386 if (STREQ(socket.identifier, "To Max")) {
387 return "To_Max_FLOAT3";
388 }
389 if (STREQ(socket.identifier, "Steps")) {
390 return "Steps_FLOAT3";
391 }
392 if (STREQ(socket.identifier, "Result")) {
393 return "Vector";
394 }
395 }
396 return nullptr;
397 }
398 }
399 return nullptr;
400}
401
406{
407 for (bNodeSocket &socket : node.inputs) {
408 if (socket.is_available()) {
409 if (const char *new_identifier = get_current_socket_identifier_for_future_socket(
410 node, socket, node_decl.inputs))
411 {
412 STRNCPY_UTF8(socket.identifier, new_identifier);
413 socket.runtime->identifier_ustr = UString(socket.identifier);
414 }
415 }
416 }
417 for (bNodeSocket &socket : node.outputs) {
418 if (socket.is_available()) {
419 if (const char *new_identifier = get_current_socket_identifier_for_future_socket(
420 node, socket, node_decl.outputs))
421 {
422 STRNCPY_UTF8(socket.identifier, new_identifier);
423 socket.runtime->identifier_ustr = UString(socket.identifier);
424 }
425 }
426 }
427}
428
434{
435 BLI_assert(node.is_group_input());
436 /* Check needed to handle newly added group input nodes. */
437 if (const bNodeSocket *extension_socket = node.outputs.last()) {
438 return extension_socket->is_user_hidden();
439 }
440 return false;
441}
442
444 bNodeTree &ntree,
445 bNode &node,
446 const eNodeSocketInOut in_out,
447 const Span<bNodeSocket *> old_sockets,
448 const Span<bNodeSocket *> new_sockets)
449{
450 std::optional<std::pair<animrig::Action *, animrig::Slot *>> action_and_slot =
452 if (!action_and_slot) {
453 return;
454 }
455 animrig::Action &action = *action_and_slot->first;
456 animrig::Slot &slot = *action_and_slot->second;
457
458 Map<UString, int> new_index_by_identifier;
459 for (const int new_i : new_sockets.index_range()) {
460 const bNodeSocket &new_socket = *new_sockets[new_i];
461 new_index_by_identifier.add_new(new_socket.identifier_ustr(), new_i);
462 }
463
464 struct IndexMove {
465 int old_i;
466 int new_i;
467 };
468 Vector<IndexMove> moved_indices;
469 Vector<int> removed_indices;
470 for (const int old_i : old_sockets.index_range()) {
471 bNodeSocket &old_socket = *old_sockets[old_i];
472 const std::optional<int> new_i = new_index_by_identifier.lookup_try(
473 old_socket.identifier_ustr());
474 if (!new_i) {
475 removed_indices.append(old_i);
476 continue;
477 }
478 if (new_i == old_i) {
479 continue;
480 }
481 moved_indices.append({old_i, *new_i});
482 }
483 if (moved_indices.is_empty() && removed_indices.is_empty()) {
484 return;
485 }
486
487 const std::string node_path = fmt::format("nodes[\"{}\"]", BLI_str_escape(node.name));
488 const StringRef inout_str = in_out == SOCK_IN ? "inputs" : "outputs";
489 bool animation_changed = false;
490
491 if (!removed_indices.is_empty()) {
492 for (const int removed_i : removed_indices) {
493 const std::string old_path = fmt::format("{}.{}[{}]", node_path, inout_str, removed_i);
494 if (BKE_animdata_fix_paths_remove(&ntree.id, old_path.c_str())) {
495 animation_changed = true;
496 }
497 }
498 }
499 if (!moved_indices.is_empty()) {
500 auto construct_new_rna_path = [&](const StringRef old_path) -> char * {
501 if (!old_path.startswith(node_path)) {
502 return nullptr;
503 }
504 for (const IndexMove &index_move : moved_indices) {
505 const std::string old_path_prefix = fmt::format(
506 "{}.{}[{}]", node_path, inout_str, index_move.old_i);
507 if (!old_path.startswith(old_path_prefix)) {
508 continue;
509 }
510 const std::string new_path = fmt::format("{}.{}[{}]{}",
511 node_path,
512 inout_str,
513 index_move.new_i,
514 old_path.substr(old_path_prefix.size()));
515 animation_changed = true;
516 return BLI_strdup(new_path.c_str());
517 }
518 return nullptr;
519 };
520
521 /* All index changes have to be applied in a single pass over the fcurves. Otherwise, when
522 * sockets swap their position, the same fcurve may be modified twice and ends up with its
523 * original rna path. */
524 animrig::foreach_fcurve_in_action_slot(action, slot.handle, [&](FCurve &fcurve) {
525 if (char *new_path = construct_new_rna_path(fcurve.rna_path())) {
526 fcurve.rna_path_set_move(new_path);
527 }
528 });
529 for (FCurve &driver_fcurve : ntree.adt->drivers) {
530 if (char *new_path = construct_new_rna_path(driver_fcurve.rna_path())) {
531 driver_fcurve.rna_path_set_move(new_path);
532 }
533 }
534 }
535
536 if (animation_changed) {
540 }
541}
542
544 bNodeTree &ntree,
545 bNode &node,
546 const NodeDeclaration &node_decl,
547 const bool do_id_user)
548{
549 if (!node.runtime->forward_compatible_versioning_done) {
551 node.runtime->forward_compatible_versioning_done = true;
552 }
553
554 /* Count panels */
555 int new_num_panels = 0;
556 for (const ItemDeclarationPtr &item_decl : node_decl.all_items) {
557 if (dynamic_cast<const PanelDeclaration *>(item_decl.get())) {
558 ++new_num_panels;
559 }
560 }
561
562 Vector<bNodeSocket *> old_inputs;
563 for (bNodeSocket &socket : node.inputs) {
564 old_inputs.append(&socket);
565 }
566
567 Vector<bNodeSocket *> old_outputs;
568 for (bNodeSocket &socket : node.outputs) {
569 old_outputs.append(&socket);
570 }
571
572 const bool hide_new_sockets = node.is_group_input() ? hide_new_group_input_sockets(node) : false;
573
574 Vector<bNodePanelState> old_panels = Vector<bNodePanelState>(node.panel_states());
575
576 /* New panel states buffer. */
577 MEM_SAFE_DELETE(node.panel_states_array);
578 node.num_panel_states = new_num_panels;
579 node.panel_states_array = MEM_new_array<bNodePanelState>(new_num_panels, __func__);
580
581 /* Find list of sockets to add, mixture of old and new sockets. */
582 VectorSet<bNodeSocket *> new_inputs;
583 VectorSet<bNodeSocket *> new_outputs;
584 bNodePanelState *new_panel = node.panel_states_array;
585 Vector<bNodeSocket *> remaining_old_inputs = old_inputs;
586 Vector<bNodeSocket *> remaining_old_outputs = old_outputs;
587 for (const ItemDeclarationPtr &item_decl : node_decl.all_items) {
588 if (const SocketDeclaration *socket_decl = dynamic_cast<const SocketDeclaration *>(
589 item_decl.get()))
590 {
591 if (socket_decl->in_out == SOCK_IN) {
593 ntree, node, *socket_decl, remaining_old_inputs, new_inputs, hide_new_sockets);
594 }
595 else {
597 ntree, node, *socket_decl, remaining_old_outputs, new_outputs, hide_new_sockets);
598 }
599 }
600 else if (const PanelDeclaration *panel_decl = dynamic_cast<const PanelDeclaration *>(
601 item_decl.get()))
602 {
603 refresh_node_panel(*panel_decl, old_panels, *new_panel);
604 ++new_panel;
605 }
606 }
607
608 /* Animation rna paths use the socket index, so they need to be updated when the socket order
609 * changes. */
610 if (bmain) {
611 refresh_node_sockets_animation_inout(*bmain, ntree, node, SOCK_IN, old_inputs, new_inputs);
612 refresh_node_sockets_animation_inout(*bmain, ntree, node, SOCK_OUT, old_outputs, new_outputs);
613 }
614
615 /* Destroy any remaining sockets that are no longer in the declaration. */
616 for (bNodeSocket &old_socket : node.inputs.items_mutable()) {
617 if (!new_inputs.contains(&old_socket)) {
618 bke::node_remove_socket_ex(ntree, node, old_socket, do_id_user);
619 }
620 }
621 for (bNodeSocket &old_socket : node.outputs.items_mutable()) {
622 if (!new_outputs.contains(&old_socket)) {
623 bke::node_remove_socket_ex(ntree, node, old_socket, do_id_user);
624 }
625 }
626
627 /* Clear and reinsert sockets in the new order. */
628 node.inputs.clear_no_delete();
629 node.outputs.clear_no_delete();
630 for (bNodeSocket *socket : new_inputs) {
631 BLI_addtail(&node.inputs, socket);
632 }
633 for (bNodeSocket *socket : new_outputs) {
634 BLI_addtail(&node.outputs, socket);
635 }
636}
637
638static void refresh_node(
639 Main *bmain, bNodeTree &ntree, bNode &node, nodes::NodeDeclaration &node_decl, bool do_id_user)
640{
641 if (node_decl.skip_updating_sockets) {
642 return;
643 }
644 if (!node_decl.matches(node)) {
645 refresh_node_sockets_and_panels(bmain, ntree, node, node_decl, do_id_user);
646 }
648}
649
651{
652 if (node.typeinfo->declare) {
653 if (node.typeinfo->static_declaration->is_context_dependent) {
654 if (!node.runtime->declaration) {
655 node.runtime->declaration = new NodeDeclaration();
656 }
657 build_node_declaration(*node.typeinfo, *node.runtime->declaration, &ntree, &node);
658 }
659 }
660 refresh_node(bmain, ntree, node, *node.runtime->declaration, true);
661}
662
664{
665 return ELEM(socket_type,
668 SOCK_RGBA,
670 SOCK_INT,
672 SOCK_MENU,
675}
676
678{
679 return ELEM(socket_type,
682 SOCK_RGBA,
684 SOCK_INT,
687}
688
690{
691 return ELEM(socket_type, SOCK_FLOAT, SOCK_VECTOR, SOCK_INT, SOCK_BOOLEAN);
692}
693
694} // namespace nodes
695
696void node_verify_sockets(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
697{
698 bke::bNodeType *ntype = node->typeinfo;
699 if (ntype == nullptr) {
700 return;
701 }
702 if (ntype->declare) {
704 refresh_node(bmain, *ntree, *node, *node->runtime->declaration, do_id_user);
705 return;
706 }
707 /* Don't try to match socket lists when there are no templates.
708 * This prevents dynamically generated sockets to be removed, like for
709 * group, image or render layer nodes. We have an explicit check for the
710 * render layer node since it still has fixed sockets too.
711 */
712 if (ntype) {
713 if (ntype->inputs && ntype->inputs[0].type >= 0) {
714 verify_socket_template_list(ntree, node, SOCK_IN, &node->inputs, ntype->inputs);
715 }
716 if (ntype->outputs && ntype->outputs[0].type >= 0 && node->type_legacy != CMP_NODE_R_LAYERS) {
717 verify_socket_template_list(ntree, node, SOCK_OUT, &node->outputs, ntype->outputs);
718 }
719 }
720}
721
723 ID * /*id*/,
724 const bNodeTreeInterfaceSocket *interface_socket,
725 bNode * /*node*/,
726 bNodeSocket *sock,
727 StringRefNull /*data_path*/)
728{
729 /* initialize the type value */
730 sock->type = sock->typeinfo->type;
731 sock->default_value = bke::socket_value_copy(sock->type, interface_socket->socket_data, true);
732}
733
736 const bNode * /*node*/,
737 const bNodeSocket *sock)
738{
739 /* initialize settings */
740 iosock->init_from_socket_instance(sock);
741}
742
743void ED_init_standard_node_socket_type(bke::bNodeSocketType *);
744
746 const eNodeSocketDatatype type, int subtype, std::optional<int> dimensions = std::nullopt)
747{
748 const StringRefNull socket_idname = *bke::node_static_socket_type(type, subtype, dimensions);
750 type, subtype, dimensions);
751 const StringRefNull socket_label = *bke::node_static_socket_label(type, subtype);
752 const StringRefNull socket_subtype_label = bke::node_socket_sub_type_label(subtype);
754 StructRNA *srna;
755
756 stype = MEM_new<bke::bNodeSocketType>(__func__);
757 stype->free_self = [](bke::bNodeSocketType *type) { MEM_delete(type); };
758 stype->idname = UString(socket_idname);
759 stype->label = socket_label;
760 stype->subtype_label = socket_subtype_label;
761
762 /* set the RNA type
763 * uses the exact same identifier as the socket type idname */
764 srna = stype->ext_socket.srna = RNA_struct_find(socket_idname.c_str());
765 BLI_assert(srna != nullptr);
766 /* associate the RNA type with the socket type */
767 RNA_struct_blender_type_set(srna, stype);
768
769 /* set the interface RNA type */
770 srna = stype->ext_interface.srna = RNA_struct_find(interface_idname.c_str());
771 BLI_assert(srna != nullptr);
772 /* associate the RNA type with the socket type */
773 RNA_struct_blender_type_set(srna, stype);
774
775 /* extra type info for standard socket types */
776 stype->type = type;
777 stype->subtype = subtype;
778
779 /* XXX bad-level call! needed for setting draw callbacks */
781
784
785 stype->use_link_limits_of_type = true;
786 stype->input_link_limit = 1;
787 stype->output_link_limit = 0xFFF;
788
789 return stype;
790}
791
792void ED_init_node_socket_type_virtual(bke::bNodeSocketType *);
793
795{
796 const char *socket_idname = "NodeSocketVirtual";
798 StructRNA *srna;
799
800 stype = MEM_new<bke::bNodeSocketType>(__func__);
801 stype->free_self = [](bke::bNodeSocketType *type) { MEM_delete(type); };
802 stype->idname = UString(socket_idname);
803
804 /* set the RNA type
805 * uses the exact same identifier as the socket type idname */
806 srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
807 BLI_assert(srna != nullptr);
808 /* associate the RNA type with the socket type */
809 RNA_struct_blender_type_set(srna, stype);
810
811 /* extra type info for standard socket types */
812 stype->type = SOCK_CUSTOM;
813
815
816 stype->use_link_limits_of_type = true;
817 stype->input_link_limit = 0xFFF;
818 stype->output_link_limit = 0xFFF;
819
820 return stype;
821}
822
824 const bNodeTreeInterfaceSocket &socket,
825 const EnumPropertyItem *items,
826 const nodes::GeometryNodesInputType default_type,
827 nodes::GeneratedTreeSrnaData &r_generated)
828{
830 &srna,
831 "type",
832 items,
833 int(default_type),
834 r_generated.scope.add_value(fmt::format(fmt::runtime(TIP_("Type for {}")), socket.name()))
835 .c_str(),
836 "");
841}
843 const bNodeTreeInterfaceSocket &socket,
844 const EnumPropertyItem *items,
845 const nodes::CompositorNodesInputType default_type,
846 nodes::GeneratedTreeSrnaData &r_generated)
847{
849 &srna,
850 "type",
851 items,
852 int(default_type),
853 r_generated.scope.add_value(fmt::format("{} {}", TIP_("Type for"), socket.name())).c_str(),
854 "");
856}
857
858/* Find the strip that owns the compositor properties an input value belongs to. Works both
859 * for strip modifiers and compositor effects. */
861{
862 if (const std::optional<AncestorPointerRNA> strip = RNA_struct_search_closest_ancestor_by_type(
863 ptr, RNA_Strip))
864 {
865 return static_cast<Strip *>(strip->data);
866 }
867
868 /* Modifier fallback for properties pointers created without a strip ancestor. */
869 if (const std::optional<AncestorPointerRNA> ancestor =
871 RNA_SequencerCompositorModifierProperties))
872 {
873 auto *cmd = static_cast<SequencerCompositorModifierData *>(ancestor->data);
874 Strip *found_strip = nullptr;
875 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
876 if (BLI_findindex(&strip->modifiers, cmd) != -1) {
877 found_strip = strip;
878 return false;
879 }
880 return true;
881 });
882 return found_strip;
883 }
884
885 /* Effect fallback for properties pointers created without a strip ancestor. */
886 if (const std::optional<AncestorPointerRNA> ancestor =
887 RNA_struct_search_closest_ancestor_by_type(ptr, RNA_SequencerCompositorEffectProperties))
888 {
889 const void *effectdata = ancestor->data;
890 Strip *found_strip = nullptr;
891 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
892 if (strip->effectdata == effectdata) {
893 found_strip = strip;
894 return false;
895 }
896 return true;
897 });
898 return found_strip;
899 }
900 return nullptr;
901}
903{
904 RNA_def_property_update_runtime(prop, [](Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr) {
905 Scene *sequencer_scene = reinterpret_cast<Scene *>(ptr->owner_id);
906 Editing *ed = seq::editing_get(sequencer_scene);
907 if (!ed) {
908 return;
909 }
910 Strip *properties_strip = find_compositor_properties_strip(ptr, ed);
911 if (properties_strip) {
912 seq::relations_invalidate_cache(sequencer_scene, properties_strip);
913 }
914 });
916}
917
919 const bNodeTreeInterfaceSocket &socket,
920 nodes::GeneratedTreeSrnaData &r_generated)
921{
923 &srna,
924 "attribute_name",
926 0,
927 r_generated.scope
928 .add_value(fmt::format(fmt::runtime(TIP_("Attribute for {}")), socket.name()))
929 .c_str(),
930 socket.description().c_str());
934}
935
949
960
971
972static void data_block_pointer_update(Main *bmain, Scene * /*scene*/, PointerRNA * /*ptr*/)
973{
975}
976
986
988{
990 socktype->base_cpp_type = &CPPType::get<bool>();
991 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
992 *static_cast<bool *>(r_value) =
993 (static_cast<bNodeSocketValueBoolean *>(const_cast<void *>(socket_value)))->value;
994 };
995 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
996 const bool value =
997 (static_cast<bNodeSocketValueBoolean *>(const_cast<void *>(socket_value)))->value;
998 return SocketValueVariant(value);
999 };
1000 static SocketValueVariant default_value{false};
1001 socktype->geometry_nodes_default_value = &default_value;
1002 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1003 StructRNA &srna,
1004 const bNodeTreeInterfaceSocket &socket,
1005 nodes::GeneratedTreeSrnaData &r_generated) {
1006 const auto *data = static_cast<const bNodeSocketValueBoolean *>(socket.socket_data);
1008 &srna, "value", data->value, socket.name().c_str(), socket.description().c_str());
1013 srna,
1014 socket,
1016 is_layer_selection_field(socket) ?
1018 (socket.default_attribute_name && socket.default_attribute_name[0] != '\0' ?
1021 r_generated);
1022 make_common_attribute_name_prop(srna, socket, r_generated);
1023 prop = RNA_def_string(
1024 &srna,
1025 "layer_name",
1026 nullptr,
1027 0,
1028 r_generated.scope.add_value(fmt::format(fmt::runtime(TIP_("Layer for {}")), socket.name()))
1029 .c_str(),
1030 socket.description().c_str());
1034 };
1035 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1036 StructRNA &srna,
1037 const bNodeTreeInterfaceSocket &socket,
1038 nodes::GeneratedTreeSrnaData &r_generated) {
1039 const auto *data = static_cast<const bNodeSocketValueBoolean *>(socket.socket_data);
1041 &srna, "value", data->value, socket.name().c_str(), socket.description().c_str());
1044 socket,
1047 r_generated);
1048 };
1050 [](const bNodeTree & /*tree*/,
1051 StructRNA &srna,
1052 const bNodeTreeInterfaceSocket &socket,
1053 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1054 const auto *data = static_cast<const bNodeSocketValueBoolean *>(socket.socket_data);
1055 PropertyRNA *property = RNA_def_boolean(
1056 &srna, "value", data->value, socket.name().c_str(), socket.description().c_str());
1058 };
1059 return socktype;
1060}
1061
1063{
1066 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1067 const auto &typed_value = *static_cast<bNodeSocketValueRotation *>(
1068 const_cast<void *>(socket_value));
1069 const math::EulerXYZ euler(float3(typed_value.value_euler));
1070 *static_cast<math::Quaternion *>(r_value) = math::to_quaternion(euler);
1071 };
1072 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1073 const auto &typed_value = *static_cast<bNodeSocketValueRotation *>(
1074 const_cast<void *>(socket_value));
1075 const math::EulerXYZ euler(float3(typed_value.value_euler));
1076 const math::Quaternion value = math::to_quaternion(euler);
1077 return SocketValueVariant(value);
1078 };
1079 static SocketValueVariant default_value{math::Quaternion::identity()};
1080 socktype->geometry_nodes_default_value = &default_value;
1081 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1082 StructRNA &srna,
1083 const bNodeTreeInterfaceSocket &socket,
1084 nodes::GeneratedTreeSrnaData &r_generated) {
1085 const auto *data = static_cast<const bNodeSocketValueRotation *>(socket.socket_data);
1086 PropertyRNA *prop = RNA_def_float_rotation(&srna,
1087 "value",
1088 3,
1089 data->value_euler,
1090 -FLT_MAX,
1091 FLT_MAX,
1092 socket.name().c_str(),
1093 socket.description().c_str(),
1094 -FLT_MAX,
1095 FLT_MAX);
1099 make_common_value_and_attribute_props(srna, socket, r_generated);
1100 };
1101 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1102 StructRNA &srna,
1103 const bNodeTreeInterfaceSocket &socket,
1104 nodes::GeneratedTreeSrnaData &r_generated) {
1105 const auto *data = static_cast<const bNodeSocketValueRotation *>(socket.socket_data);
1106 PropertyRNA *prop = RNA_def_float_rotation(&srna,
1107 "value",
1108 3,
1109 data->value_euler,
1110 -FLT_MAX,
1111 FLT_MAX,
1112 socket.name().c_str(),
1113 socket.description().c_str(),
1114 -FLT_MAX,
1115 FLT_MAX);
1118 socket,
1121 r_generated);
1122 };
1124 [](const bNodeTree & /*tree*/,
1125 StructRNA &srna,
1126 const bNodeTreeInterfaceSocket &socket,
1127 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1128 const auto *data = static_cast<const bNodeSocketValueRotation *>(socket.socket_data);
1129 PropertyRNA *property = RNA_def_float_rotation(&srna,
1130 "value",
1131 3,
1132 data->value_euler,
1133 -FLT_MAX,
1134 FLT_MAX,
1135 socket.name().c_str(),
1136 socket.description().c_str(),
1137 -FLT_MAX,
1138 FLT_MAX);
1140 };
1141 return socktype;
1142}
1143
1145{
1148 socktype->get_base_cpp_value = [](const void * /*socket_value*/, void *r_value) {
1149 *static_cast<float4x4 *>(r_value) = float4x4::identity();
1150 };
1151 socktype->get_geometry_nodes_cpp_value = [](const void * /*socket_value*/) {
1153 };
1154 static SocketValueVariant default_value{float4x4::identity()};
1155 socktype->geometry_nodes_default_value = &default_value;
1156 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1157 StructRNA &srna,
1158 const bNodeTreeInterfaceSocket &socket,
1159 nodes::GeneratedTreeSrnaData &r_generated) {
1160 make_common_fallback_props(srna, socket, r_generated);
1161 };
1162 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1163 StructRNA &srna,
1164 const bNodeTreeInterfaceSocket &socket,
1165 nodes::GeneratedTreeSrnaData &r_generated) {
1167 socket,
1170 r_generated);
1171 };
1172 return socktype;
1173}
1174
1176{
1179 socktype->get_base_cpp_value = [](const void * /*socket_value*/, void *r_value) {
1180 new (r_value) nodes::BundlePtr();
1181 };
1182 socktype->get_geometry_nodes_cpp_value = [](const void * /*socket_value*/) {
1184 };
1186 socktype->geometry_nodes_default_value = &default_value;
1187 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1188 StructRNA &srna,
1189 const bNodeTreeInterfaceSocket &socket,
1190 nodes::GeneratedTreeSrnaData &r_generated) {
1191 make_common_fallback_props(srna, socket, r_generated);
1192 };
1193 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1194 StructRNA &srna,
1195 const bNodeTreeInterfaceSocket &socket,
1196 nodes::GeneratedTreeSrnaData &r_generated) {
1198 socket,
1201 r_generated);
1202 };
1203 return socktype;
1204}
1205
1207{
1210 socktype->get_base_cpp_value = [](const void * /*socket_value*/, void *r_value) {
1211 new (r_value) nodes::ClosurePtr();
1212 };
1213 socktype->get_geometry_nodes_cpp_value = [](const void * /*socket_value*/) {
1215 };
1217 socktype->geometry_nodes_default_value = &default_value;
1218 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1219 StructRNA &srna,
1220 const bNodeTreeInterfaceSocket &socket,
1221 nodes::GeneratedTreeSrnaData &r_generated) {
1222 make_common_fallback_props(srna, socket, r_generated);
1223 };
1224 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1225 StructRNA &srna,
1226 const bNodeTreeInterfaceSocket &socket,
1227 nodes::GeneratedTreeSrnaData &r_generated) {
1229 socket,
1232 r_generated);
1233 };
1234 return socktype;
1235}
1236
1238{
1240 socktype->base_cpp_type = &CPPType::get<float>();
1241 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1242 *static_cast<float *>(
1243 r_value) = (static_cast<bNodeSocketValueFloat *>(const_cast<void *>(socket_value)))->value;
1244 };
1245 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1246 const float value =
1247 (static_cast<bNodeSocketValueFloat *>(const_cast<void *>(socket_value)))->value;
1248 return SocketValueVariant(value);
1249 };
1250 static SocketValueVariant default_value{0.0f};
1251 socktype->geometry_nodes_default_value = &default_value;
1252 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1253 StructRNA &srna,
1254 const bNodeTreeInterfaceSocket &socket,
1255 nodes::GeneratedTreeSrnaData &r_generated) {
1256 PropertyRNA *prop;
1257 const auto *data = static_cast<const bNodeSocketValueFloat *>(socket.socket_data);
1258 prop = RNA_def_float(&srna,
1259 "value",
1260 data->value,
1261 -FLT_MAX,
1262 FLT_MAX,
1263 socket.name().c_str(),
1264 socket.description().c_str(),
1265 data->min,
1266 data->max);
1271 make_common_value_and_attribute_props(srna, socket, r_generated);
1272 };
1273 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1274 StructRNA &srna,
1275 const bNodeTreeInterfaceSocket &socket,
1276 nodes::GeneratedTreeSrnaData &r_generated) {
1277 PropertyRNA *prop;
1278 const auto *data = static_cast<const bNodeSocketValueFloat *>(socket.socket_data);
1279 prop = RNA_def_float(&srna,
1280 "value",
1281 data->value,
1282 -FLT_MAX,
1283 FLT_MAX,
1284 socket.name().c_str(),
1285 socket.description().c_str(),
1286 data->min,
1287 data->max);
1291 socket,
1294 r_generated);
1295 };
1297 [](const bNodeTree & /*tree*/,
1298 StructRNA &srna,
1299 const bNodeTreeInterfaceSocket &socket,
1300 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1301 const auto *data = static_cast<const bNodeSocketValueFloat *>(socket.socket_data);
1302 PropertyRNA *property = RNA_def_float(&srna,
1303 "value",
1304 data->value,
1305 -FLT_MAX,
1306 FLT_MAX,
1307 socket.name().c_str(),
1308 socket.description().c_str(),
1309 data->min,
1310 data->max);
1311 RNA_def_property_subtype(property, PropertySubType(data->subtype));
1313 };
1314 return socktype;
1315}
1316
1318{
1320 socktype->base_cpp_type = &CPPType::get<int>();
1321 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1322 *static_cast<int *>(
1323 r_value) = (static_cast<bNodeSocketValueInt *>(const_cast<void *>(socket_value)))->value;
1324 };
1325 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1326 const int value =
1327 (static_cast<bNodeSocketValueInt *>(const_cast<void *>(socket_value)))->value;
1328 return SocketValueVariant(value);
1329 };
1330 static SocketValueVariant default_value{0};
1331 socktype->geometry_nodes_default_value = &default_value;
1332 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1333 StructRNA &srna,
1334 const bNodeTreeInterfaceSocket &socket,
1335 nodes::GeneratedTreeSrnaData &r_generated) {
1336 PropertyRNA *prop;
1337 const auto *data = static_cast<const bNodeSocketValueInt *>(socket.socket_data);
1338 prop = RNA_def_int(&srna,
1339 "value",
1340 data->value,
1341 INT32_MIN,
1342 INT32_MAX,
1343 socket.name().c_str(),
1344 socket.description().c_str(),
1345 data->min,
1346 data->max);
1351 make_common_value_and_attribute_props(srna, socket, r_generated);
1352 };
1353 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1354 StructRNA &srna,
1355 const bNodeTreeInterfaceSocket &socket,
1356 nodes::GeneratedTreeSrnaData &r_generated) {
1357 const auto *data = static_cast<const bNodeSocketValueInt *>(socket.socket_data);
1358 PropertyRNA *prop = RNA_def_int(&srna,
1359 "value",
1360 data->value,
1361 INT32_MIN,
1362 INT32_MAX,
1363 socket.name().c_str(),
1364 socket.description().c_str(),
1365 data->min,
1366 data->max);
1370 socket,
1373 r_generated);
1374 };
1376 [](const bNodeTree & /*tree*/,
1377 StructRNA &srna,
1378 const bNodeTreeInterfaceSocket &socket,
1379 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1380 const auto *data = static_cast<const bNodeSocketValueInt *>(socket.socket_data);
1381 PropertyRNA *property = RNA_def_int(&srna,
1382 "value",
1383 data->value,
1384 INT32_MIN,
1385 INT32_MAX,
1386 socket.name().c_str(),
1387 socket.description().c_str(),
1388 data->min,
1389 data->max);
1390 RNA_def_property_subtype(property, PropertySubType(data->subtype));
1392 };
1393 return socktype;
1394}
1395
1397{
1398 bke::bNodeSocketType *socktype = make_standard_socket_type(SOCK_VECTOR, subtype, dimensions);
1399 socktype->base_cpp_type = &CPPType::get<float3>();
1400 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1401 *static_cast<float3 *>(r_value) =
1402 (static_cast<bNodeSocketValueVector *>(const_cast<void *>(socket_value)))->value;
1403 };
1404 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1405 const float3 value =
1406 (static_cast<bNodeSocketValueVector *>(const_cast<void *>(socket_value)))->value;
1407 return SocketValueVariant(value);
1408 };
1409 static SocketValueVariant default_value{float3(0, 0, 0)};
1410 socktype->geometry_nodes_default_value = &default_value;
1411 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1412 StructRNA &srna,
1413 const bNodeTreeInterfaceSocket &socket,
1414 nodes::GeneratedTreeSrnaData &r_generated) {
1415 PropertyRNA *prop;
1416 const auto *data = static_cast<const bNodeSocketValueVector *>(socket.socket_data);
1417 prop = RNA_def_float_vector(&srna,
1418 "value",
1419 data->dimensions,
1420 data->value,
1421 -FLT_MAX,
1422 FLT_MAX,
1423 socket.name().c_str(),
1424 socket.description().c_str(),
1425 data->min,
1426 data->max);
1431 make_common_value_and_attribute_props(srna, socket, r_generated);
1432 };
1433 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1434 StructRNA &srna,
1435 const bNodeTreeInterfaceSocket &socket,
1436 nodes::GeneratedTreeSrnaData &r_generated) {
1437 PropertyRNA *prop;
1438 const auto *data = static_cast<const bNodeSocketValueVector *>(socket.socket_data);
1439 prop = RNA_def_float_vector(&srna,
1440 "value",
1441 data->dimensions,
1442 data->value,
1443 -FLT_MAX,
1444 FLT_MAX,
1445 socket.name().c_str(),
1446 socket.description().c_str(),
1447 data->min,
1448 data->max);
1452 socket,
1455 r_generated);
1456 };
1458 [](const bNodeTree & /*tree*/,
1459 StructRNA &srna,
1460 const bNodeTreeInterfaceSocket &socket,
1461 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1462 const auto *data = static_cast<const bNodeSocketValueVector *>(socket.socket_data);
1463 PropertyRNA *property = RNA_def_float_vector(&srna,
1464 "value",
1465 data->dimensions,
1466 data->value,
1467 -FLT_MAX,
1468 FLT_MAX,
1469 socket.name().c_str(),
1470 socket.description().c_str(),
1471 data->min,
1472 data->max);
1473 RNA_def_property_subtype(property, PropertySubType(data->subtype));
1475 };
1476 return socktype;
1477}
1478
1480 const int dimensions)
1481{
1482 bke::bNodeSocketType *socktype = make_standard_socket_type(SOCK_INT_VECTOR, subtype, dimensions);
1483 socktype->base_cpp_type = &CPPType::get<int3>();
1484 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1485 *static_cast<int3 *>(r_value) =
1486 (static_cast<bNodeSocketValueIntVector *>(const_cast<void *>(socket_value)))->value;
1487 };
1488 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1489 StructRNA &srna,
1490 const bNodeTreeInterfaceSocket &socket,
1491 nodes::GeneratedTreeSrnaData &r_generated) {
1492 PropertyRNA *prop;
1493 const auto *data = static_cast<const bNodeSocketValueIntVector *>(socket.socket_data);
1494 prop = RNA_def_int_vector(&srna,
1495 "value",
1496 data->dimensions,
1497 data->value,
1498 INT_MIN,
1499 INT_MAX,
1500 socket.name().c_str(),
1501 socket.description().c_str(),
1502 data->min,
1503 data->max);
1507 socket,
1510 r_generated);
1511 };
1513 [](const bNodeTree & /*tree*/,
1514 StructRNA &srna,
1515 const bNodeTreeInterfaceSocket &socket,
1516 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1517 const auto *data = static_cast<const bNodeSocketValueIntVector *>(socket.socket_data);
1518 PropertyRNA *property = RNA_def_int_vector(&srna,
1519 "value",
1520 data->dimensions,
1521 data->value,
1522 INT_MIN,
1523 INT_MAX,
1524 socket.name().c_str(),
1525 socket.description().c_str(),
1526 data->min,
1527 data->max);
1528 RNA_def_property_subtype(property, PropertySubType(data->subtype));
1530 };
1531 return socktype;
1532}
1533
1535{
1538 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1539 *static_cast<ColorGeometry4f *>(
1540 r_value) = (static_cast<bNodeSocketValueRGBA *>(const_cast<void *>(socket_value)))->value;
1541 };
1542 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1543 const ColorGeometry4f value =
1544 (static_cast<bNodeSocketValueRGBA *>(const_cast<void *>(socket_value)))->value;
1545 return SocketValueVariant(value);
1546 };
1547 static SocketValueVariant default_value{ColorGeometry4f(0, 0, 0, 0)};
1548 socktype->geometry_nodes_default_value = &default_value;
1549 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1550 StructRNA &srna,
1551 const bNodeTreeInterfaceSocket &socket,
1552 nodes::GeneratedTreeSrnaData &r_generated) {
1553 const auto *data = static_cast<const bNodeSocketValueRGBA *>(socket.socket_data);
1554 PropertyRNA *prop = RNA_def_float_color(&srna,
1555 "value",
1556 4,
1557 data->value,
1558 -FLT_MAX,
1559 FLT_MAX,
1560 socket.name().c_str(),
1561 socket.description().c_str(),
1562 0.0f,
1563 1.0f);
1567 make_common_value_and_attribute_props(srna, socket, r_generated);
1568 };
1569 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1570 StructRNA &srna,
1571 const bNodeTreeInterfaceSocket &socket,
1572 nodes::GeneratedTreeSrnaData &r_generated) {
1573 const auto *data = static_cast<const bNodeSocketValueRGBA *>(socket.socket_data);
1574 PropertyRNA *prop = RNA_def_float_color(&srna,
1575 "value",
1576 4,
1577 data->value,
1578 -FLT_MAX,
1579 FLT_MAX,
1580 socket.name().c_str(),
1581 socket.description().c_str(),
1582 0.0f,
1583 1.0f);
1586 socket,
1589 r_generated);
1590 };
1592 [](const bNodeTree & /*tree*/,
1593 StructRNA &srna,
1594 const bNodeTreeInterfaceSocket &socket,
1595 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1596 const auto *data = static_cast<const bNodeSocketValueRGBA *>(socket.socket_data);
1597 PropertyRNA *property = RNA_def_float_color(&srna,
1598 "value",
1599 4,
1600 data->value,
1601 -FLT_MAX,
1602 FLT_MAX,
1603 socket.name().c_str(),
1604 socket.description().c_str(),
1605 0.0f,
1606 1.0f);
1608 };
1609 return socktype;
1610}
1611
1613{
1616 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1617 new (r_value) std::string(
1618 (static_cast<bNodeSocketValueString *>(const_cast<void *>(socket_value)))->value);
1619 };
1620 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1621 std::string value =
1622 (static_cast<bNodeSocketValueString *>(const_cast<void *>(socket_value)))->value;
1623 return SocketValueVariant(value);
1624 };
1625 static SocketValueVariant default_value{std::string()};
1626 socktype->geometry_nodes_default_value = &default_value;
1627 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1628 StructRNA &srna,
1629 const bNodeTreeInterfaceSocket &socket,
1630 nodes::GeneratedTreeSrnaData &r_generated) {
1631 PropertyRNA *prop;
1632 const auto *data = static_cast<const bNodeSocketValueString *>(socket.socket_data);
1633 prop = RNA_def_string(&srna,
1634 "value",
1635 data->value[0] ? data->value : nullptr,
1636 0,
1637 socket.name().c_str(),
1638 socket.description().c_str());
1642 PropertySubType subtype = PropertySubType(data->subtype);
1643 RNA_def_property_subtype(prop, subtype);
1644 if (subtype == PROP_FILEPATH) {
1646 }
1647 make_common_value_props(srna, socket, r_generated);
1648 };
1649 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1650 StructRNA &srna,
1651 const bNodeTreeInterfaceSocket &socket,
1652 nodes::GeneratedTreeSrnaData &r_generated) {
1653 PropertyRNA *prop;
1654 const auto *data = static_cast<const bNodeSocketValueString *>(socket.socket_data);
1655 prop = RNA_def_string(&srna,
1656 "value",
1657 data->value[0] ? data->value : nullptr,
1658 0,
1659 socket.name().c_str(),
1660 socket.description().c_str());
1661 PropertySubType subtype = PropertySubType(data->subtype);
1662 RNA_def_property_subtype(prop, subtype);
1663 if (subtype == PROP_FILEPATH) {
1665 }
1668 socket,
1671 r_generated);
1672 };
1674 [](const bNodeTree & /*tree*/,
1675 StructRNA &srna,
1676 const bNodeTreeInterfaceSocket &socket,
1677 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1678 const auto *data = static_cast<const bNodeSocketValueString *>(socket.socket_data);
1679 PropertyRNA *property = RNA_def_string(&srna,
1680 "value",
1681 data->value[0] ? data->value : nullptr,
1682 0,
1683 socket.name().c_str(),
1684 socket.description().c_str());
1685 const PropertySubType subtype = PropertySubType(data->subtype);
1686 RNA_def_property_subtype(property, subtype);
1687 if (subtype == PROP_FILEPATH) {
1689 }
1691 };
1692
1693 return socktype;
1694}
1695
1697 const bNodeSocketValueMenu *menu,
1698 bool &r_default_value_found,
1699 nodes::GeneratedTreeSrnaData &r_generated)
1700{
1701 r_default_value_found = false;
1702 if (menu->has_conflict() || !menu->enum_items) {
1704 }
1707 menu->enum_items->items.size() + 1);
1708 for (const int i : menu->enum_items->items.index_range()) {
1709 const bke::RuntimeNodeEnumItem &item_data = menu->enum_items->items[i];
1710 EnumPropertyItem item{};
1711 item.value = item_data.identifier;
1712 if (item.value == menu->value) {
1713 r_default_value_found = true;
1714 }
1715 item.identifier = item_data.name.c_str();
1716 item.name = item_data.name.c_str();
1717 item.description = item_data.description.c_str();
1718 new_items[i] = item;
1719 }
1720 new_items.last() = {};
1721 return new_items.data();
1722}
1723
1725{
1728 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1729 new (r_value) nodes::MenuValue(
1730 (static_cast<bNodeSocketValueMenu *>(const_cast<void *>(socket_value)))->value);
1731 };
1732 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1733 const nodes::MenuValue value{
1734 (static_cast<bNodeSocketValueMenu *>(const_cast<void *>(socket_value)))->value};
1735 return SocketValueVariant::from(value);
1736 };
1738 socktype->geometry_nodes_default_value = &default_value;
1739 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1740 StructRNA &srna,
1741 const bNodeTreeInterfaceSocket &socket,
1742 nodes::GeneratedTreeSrnaData &r_generated) {
1743 const auto *data = static_cast<const bNodeSocketValueMenu *>(socket.socket_data);
1744 bool default_value_found = false;
1746 data, default_value_found, r_generated);
1747 PropertyRNA *prop = RNA_def_enum(&srna,
1748 "value",
1749 items,
1750 default_value_found ? data->value : 0,
1751 socket.name().c_str(),
1752 socket.description().c_str());
1756 make_common_value_props(srna, socket, r_generated);
1757 };
1758 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1759 StructRNA &srna,
1760 const bNodeTreeInterfaceSocket &socket,
1761 nodes::GeneratedTreeSrnaData &r_generated) {
1762 const auto *data = static_cast<const bNodeSocketValueMenu *>(socket.socket_data);
1763 bool default_value_found = false;
1765 data, default_value_found, r_generated);
1766 PropertyRNA *prop = RNA_def_enum(&srna,
1767 "value",
1768 items,
1769 default_value_found ? data->value : 0,
1770 socket.name().c_str(),
1771 socket.description().c_str());
1774 socket,
1777 r_generated);
1778 };
1780 [](const bNodeTree & /*tree*/,
1781 StructRNA &srna,
1782 const bNodeTreeInterfaceSocket &socket,
1783 nodes::GeneratedTreeSrnaData &r_generated) {
1784 const auto *data = static_cast<const bNodeSocketValueMenu *>(socket.socket_data);
1785 bool default_value_found = false;
1787 data, default_value_found, r_generated);
1788 PropertyRNA *property = RNA_def_enum(&srna,
1789 "value",
1790 items,
1791 default_value_found ? data->value : 0,
1792 socket.name().c_str(),
1793 socket.description().c_str());
1795 };
1796 return socktype;
1797}
1798
1800{
1803 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1804 *static_cast<Object **>(r_value) =
1805 (static_cast<bNodeSocketValueObject *>(const_cast<void *>(socket_value)))->value;
1806 };
1807 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1808 Object *object = static_cast<const bNodeSocketValueObject *>(socket_value)->value;
1809 return SocketValueVariant::from(object);
1810 };
1811 static SocketValueVariant default_value = SocketValueVariant::from(
1812 static_cast<Object *>(nullptr));
1813 socktype->geometry_nodes_default_value = &default_value;
1814 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1815 StructRNA &srna,
1816 const bNodeTreeInterfaceSocket &socket,
1817 nodes::GeneratedTreeSrnaData &r_generated) {
1819 &srna, "value", RNA_Object, socket.name().c_str(), socket.description().c_str());
1820 const auto *default_value = reinterpret_cast<const bNodeSocketValueObject *>(
1821 socket.socket_data);
1822 if (default_value->value) {
1823 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
1824 }
1828 make_common_value_props(srna, socket, r_generated);
1829 };
1830 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1831 StructRNA &srna,
1832 const bNodeTreeInterfaceSocket &socket,
1833 nodes::GeneratedTreeSrnaData &r_generated) {
1835 &srna, "value", RNA_Object, socket.name().c_str(), socket.description().c_str());
1836 const auto *default_value = reinterpret_cast<const bNodeSocketValueObject *>(
1837 socket.socket_data);
1838 if (default_value->value) {
1839 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
1840 }
1843 socket,
1846 r_generated);
1847 };
1849 [](const bNodeTree & /*tree*/,
1850 StructRNA &srna,
1851 const bNodeTreeInterfaceSocket &socket,
1852 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
1854 &srna, "value", RNA_Object, socket.name().c_str(), socket.description().c_str());
1855 const auto *default_value = reinterpret_cast<const bNodeSocketValueObject *>(
1856 socket.socket_data);
1857 if (default_value->value) {
1858 RNA_def_property_pointer_default_runtime(property, default_value->value->id.session_uid);
1859 }
1862 };
1863 return socktype;
1864}
1865
1867{
1870 socktype->get_base_cpp_value = [](const void * /*socket_value*/, void *r_value) {
1871 new (r_value) bke::GeometrySet();
1872 };
1873 socktype->get_geometry_nodes_cpp_value = [](const void * /*socket_value*/) {
1875 };
1877 socktype->geometry_nodes_default_value = &default_value;
1878 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1879 StructRNA &srna,
1880 const bNodeTreeInterfaceSocket &socket,
1881 nodes::GeneratedTreeSrnaData &r_generated) {
1882 make_common_fallback_props(srna, socket, r_generated);
1883 };
1884 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1885 StructRNA &srna,
1886 const bNodeTreeInterfaceSocket &socket,
1887 nodes::GeneratedTreeSrnaData &r_generated) {
1889 socket,
1892 r_generated);
1893 };
1894 return socktype;
1895}
1896
1898{
1901 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1902 *static_cast<Collection **>(r_value) =
1903 (static_cast<bNodeSocketValueCollection *>(const_cast<void *>(socket_value)))->value;
1904 };
1905 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1906 Collection *collection = static_cast<const bNodeSocketValueCollection *>(socket_value)->value;
1907 return SocketValueVariant::from(collection);
1908 };
1909 static SocketValueVariant default_value = SocketValueVariant::from(
1910 static_cast<Collection *>(nullptr));
1911 socktype->geometry_nodes_default_value = &default_value;
1912 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1913 StructRNA &srna,
1914 const bNodeTreeInterfaceSocket &socket,
1915 nodes::GeneratedTreeSrnaData &r_generated) {
1917 &srna, "value", RNA_Collection, socket.name().c_str(), socket.description().c_str());
1918 const auto *default_value = reinterpret_cast<const bNodeSocketValueCollection *>(
1919 socket.socket_data);
1920 if (default_value->value) {
1921 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
1922 }
1926 make_common_value_props(srna, socket, r_generated);
1927 };
1928 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1929 StructRNA &srna,
1930 const bNodeTreeInterfaceSocket &socket,
1931 nodes::GeneratedTreeSrnaData &r_generated) {
1933 socket,
1936 r_generated);
1937 };
1938 return socktype;
1939}
1940
1942{
1944 socktype->base_cpp_type = &CPPType::get<Tex *>();
1945 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1946 *static_cast<Tex **>(r_value) =
1947 (static_cast<bNodeSocketValueTexture *>(const_cast<void *>(socket_value)))->value;
1948 };
1949 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1950 Tex *texture = static_cast<const bNodeSocketValueTexture *>(socket_value)->value;
1952 };
1953 static SocketValueVariant default_value = SocketValueVariant::from(static_cast<Tex *>(nullptr));
1954 socktype->geometry_nodes_default_value = &default_value;
1955 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1956 StructRNA &srna,
1957 const bNodeTreeInterfaceSocket &socket,
1958 nodes::GeneratedTreeSrnaData &r_generated) {
1960 &srna, "value", RNA_Texture, socket.name().c_str(), socket.description().c_str());
1964 make_common_value_props(srna, socket, r_generated);
1965 };
1966 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
1967 StructRNA &srna,
1968 const bNodeTreeInterfaceSocket &socket,
1969 nodes::GeneratedTreeSrnaData &r_generated) {
1971 socket,
1974 r_generated);
1975 };
1976 return socktype;
1977}
1978
1980{
1982 socktype->base_cpp_type = &CPPType::get<Image *>();
1983 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
1984 *static_cast<Image **>(
1985 r_value) = (static_cast<bNodeSocketValueImage *>(const_cast<void *>(socket_value)))->value;
1986 };
1987 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
1988 Image *image = static_cast<const bNodeSocketValueImage *>(socket_value)->value;
1990 };
1991 static SocketValueVariant default_value = SocketValueVariant::from(
1992 static_cast<Image *>(nullptr));
1993 socktype->geometry_nodes_default_value = &default_value;
1994 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
1995 StructRNA &srna,
1996 const bNodeTreeInterfaceSocket &socket,
1997 nodes::GeneratedTreeSrnaData &r_generated) {
1999 &srna, "value", RNA_Image, socket.name().c_str(), socket.description().c_str());
2000 const auto *default_value = reinterpret_cast<const bNodeSocketValueImage *>(
2001 socket.socket_data);
2002 if (default_value->value) {
2003 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
2004 }
2008 make_common_value_props(srna, socket, r_generated);
2009 };
2010 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
2011 StructRNA &srna,
2012 const bNodeTreeInterfaceSocket &socket,
2013 nodes::GeneratedTreeSrnaData &r_generated) {
2015 socket,
2018 r_generated);
2019 };
2020 return socktype;
2021}
2022
2024{
2027 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
2028 *static_cast<Material **>(r_value) =
2029 (static_cast<bNodeSocketValueMaterial *>(const_cast<void *>(socket_value)))->value;
2030 };
2031 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
2032 Material *material = static_cast<const bNodeSocketValueMaterial *>(socket_value)->value;
2033 return SocketValueVariant::from(material);
2034 };
2035 static SocketValueVariant default_value = SocketValueVariant::from(
2036 static_cast<Material *>(nullptr));
2037 socktype->geometry_nodes_default_value = &default_value;
2038 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
2039 StructRNA &srna,
2040 const bNodeTreeInterfaceSocket &socket,
2041 nodes::GeneratedTreeSrnaData &r_generated) {
2043 &srna, "value", RNA_Material, socket.name().c_str(), socket.description().c_str());
2044 const auto *default_value = reinterpret_cast<const bNodeSocketValueMaterial *>(
2045 socket.socket_data);
2046 if (default_value->value) {
2047 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
2048 }
2052 make_common_value_props(srna, socket, r_generated);
2053 };
2054 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
2055 StructRNA &srna,
2056 const bNodeTreeInterfaceSocket &socket,
2057 nodes::GeneratedTreeSrnaData &r_generated) {
2059 socket,
2062 r_generated);
2063 };
2064 return socktype;
2065}
2066
2068{
2070 socktype->base_cpp_type = &CPPType::get<VFont *>();
2071 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
2072 *static_cast<VFont **>(
2073 r_value) = (static_cast<bNodeSocketValueFont *>(const_cast<void *>(socket_value)))->value;
2074 };
2075 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
2076 VFont *font = static_cast<const bNodeSocketValueFont *>(socket_value)->value;
2077 return SocketValueVariant::from(font);
2078 };
2079 static SocketValueVariant default_value = SocketValueVariant::from(
2080 static_cast<VFont *>(nullptr));
2081 socktype->geometry_nodes_default_value = &default_value;
2082 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
2083 StructRNA &srna,
2084 const bNodeTreeInterfaceSocket &socket,
2085 nodes::GeneratedTreeSrnaData &r_generated) {
2087 &srna, "value", RNA_VectorFont, socket.name().c_str(), socket.description().c_str());
2088 const auto *default_value = reinterpret_cast<const bNodeSocketValueFont *>(socket.socket_data);
2089 if (default_value->value) {
2090 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
2091 }
2095 make_common_value_props(srna, socket, r_generated);
2096 };
2097 socktype->make_compositor_nodes_input_srna = [](const bNodeTree & /*tree*/,
2098 StructRNA &srna,
2099 const bNodeTreeInterfaceSocket &socket,
2100 nodes::GeneratedTreeSrnaData &r_generated) {
2102 &srna, "value", RNA_VectorFont, socket.name().c_str(), socket.description().c_str());
2103 const auto *default_value = reinterpret_cast<const bNodeSocketValueFont *>(socket.socket_data);
2104 if (default_value->value) {
2105 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
2106 }
2109 socket,
2112 r_generated);
2113 };
2115 [](const bNodeTree & /*tree*/,
2116 StructRNA &srna,
2117 const bNodeTreeInterfaceSocket &socket,
2118 nodes::GeneratedTreeSrnaData & /*r_generated*/) {
2120 &srna, "value", RNA_VectorFont, socket.name().c_str(), socket.description().c_str());
2121 const auto *default_value = reinterpret_cast<const bNodeSocketValueFont *>(
2122 socket.socket_data);
2123 if (default_value->value) {
2124 RNA_def_property_pointer_default_runtime(property, default_value->value->id.session_uid);
2125 }
2128 };
2129 return socktype;
2130}
2131
2133{
2135 socktype->base_cpp_type = &CPPType::get<Scene *>();
2136 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
2137 *static_cast<Scene **>(
2138 r_value) = (static_cast<bNodeSocketValueScene *>(const_cast<void *>(socket_value)))->value;
2139 };
2140 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
2141 Scene *scene = static_cast<const bNodeSocketValueScene *>(socket_value)->value;
2142 return SocketValueVariant::from(scene);
2143 };
2144 static SocketValueVariant default_value = SocketValueVariant::from(
2145 static_cast<Scene *>(nullptr));
2146 socktype->geometry_nodes_default_value = &default_value;
2147 return socktype;
2148}
2149
2151{
2153 socktype->base_cpp_type = &CPPType::get<Text *>();
2154 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
2155 *static_cast<Text **>(
2156 r_value) = (static_cast<bNodeSocketValueText *>(const_cast<void *>(socket_value)))->value;
2157 };
2158 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
2159 Text *text = static_cast<const bNodeSocketValueText *>(socket_value)->value;
2160 return SocketValueVariant::from(text);
2161 };
2162 static SocketValueVariant default_value = SocketValueVariant::from(static_cast<Text *>(nullptr));
2163 socktype->geometry_nodes_default_value = &default_value;
2164 return socktype;
2165}
2166
2168{
2170 socktype->base_cpp_type = &CPPType::get<Mask *>();
2171 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
2172 *static_cast<Mask **>(
2173 r_value) = (static_cast<bNodeSocketValueMask *>(const_cast<void *>(socket_value)))->value;
2174 };
2175 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
2176 Mask *mask = static_cast<const bNodeSocketValueMask *>(socket_value)->value;
2178 };
2179 static SocketValueVariant default_value = SocketValueVariant::from(static_cast<Mask *>(nullptr));
2180 socktype->geometry_nodes_default_value = &default_value;
2181 return socktype;
2182}
2183
2185{
2188 socktype->get_base_cpp_value = [](const void *socket_value, void *r_value) {
2189 *static_cast<bSound **>(
2190 r_value) = (static_cast<bNodeSocketValueSound *>(const_cast<void *>(socket_value)))->value;
2191 };
2192 socktype->get_geometry_nodes_cpp_value = [](const void *socket_value) {
2193 bSound *sound = static_cast<const bNodeSocketValueSound *>(socket_value)->value;
2194 return SocketValueVariant::from(sound);
2195 };
2196 static SocketValueVariant default_value = SocketValueVariant::from(
2197 static_cast<bSound *>(nullptr));
2198 socktype->geometry_nodes_default_value = &default_value;
2199 socktype->make_geometry_nodes_input_srna = [](const bNodeTree & /*tree*/,
2200 StructRNA &srna,
2201 const bNodeTreeInterfaceSocket &socket,
2202 nodes::GeneratedTreeSrnaData &r_generated) {
2204 &srna, "value", RNA_Sound, socket.name().c_str(), socket.description().c_str());
2205 const auto *default_value = reinterpret_cast<const bNodeSocketValueObject *>(
2206 socket.socket_data);
2207 if (default_value->value) {
2208 RNA_def_property_pointer_default_runtime(prop, default_value->value->id.session_uid);
2209 }
2213 make_common_value_props(srna, socket, r_generated);
2214 };
2215 return socktype;
2216}
2217
2219{
2220 /* Draw callbacks are set in `drawnode.cc` to avoid bad-level calls. */
2221
2235
2241
2243
2254
2265
2276
2282
2288
2292
2295
2297
2299
2301
2312
2315
2317}
2318
2319} // namespace blender
Functions and classes to work with Actions.
Functionality to iterate an Action in various ways.
Blender kernel action and pose functionality.
#define SH_NODE_MAP_RANGE
#define SH_NODE_MIX
#define CMP_NODE_R_LAYERS
#define INT32_MAX
#define INT32_MIN
#define STRNCPY_UTF8(dst, src)
#define TIP_(msgid)
ID and Library types, which are fundamental for SDNA.
Object groups, one object can be in many groups at once.
#define NODE_MAXSTR
Read Blender memory allocation and freeing.
#define ND_SEQUENCER
Definition WM_types.hh:456
#define ND_COMPO_RESULT
Definition WM_types.hh:466
#define NC_SCENE
Definition WM_types.hh:391
#define STREQLEN(a, b, n)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define STREQ(a, b)
static const CPPType & get()
MutableSpan< T > allocate_array(int64_t size)
std::optional< Value > lookup_try(const Key &key) const
Definition BLI_map.hh:531
void add_new(const Key &key, const Value &value)
Definition BLI_map.hh:265
constexpr T * data() const
Definition BLI_span.hh:545
constexpr T & last(const int64_t n=0) const
Definition BLI_span.hh:695
LinearAllocator & allocator()
static SocketValueVariant from(T &&value)
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr const char * c_str() const
const char * c_str() const
UString()=default
bool contains(const Key &key) const
void add_new(const Key &key)
void remove_and_reorder(const int64_t index)
void append(const T &value)
friend class Vector
bool is_empty() const
IndexRange index_range() const
constexpr StringRef substr(int64_t start, int64_t size) const
Vector< SocketDeclaration * > inputs
bool matches(const bNode &node) const
Vector< SocketDeclaration * > outputs
Vector< ItemDeclarationPtr > all_items
void update_or_build(const bNodePanelState &old_panel, bNodePanelState &new_panel) const
bool matches(const bNodePanelState &panel) const
void build(bNodePanelState &panel) const
virtual bool matches(const bNodeSocket &socket) const =0
virtual bNodeSocket & update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
virtual bNodeSocket & build(bNodeTree &ntree, bNode &node) const =0
#define FLT_MAX
#define INT_MAX
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
void foreach_fcurve_in_action_slot(Action &action, slot_handle_t handle, FunctionRef< void(FCurve &fcurve)> callback)
std::optional< std::pair< Action *, Slot * > > get_action_slot_pair(ID &animated_id)
void * socket_value_copy(eNodeSocketDatatype type, const void *src, bool do_id_user)
Definition node.cc:3285
void node_socket_declarations_update(bNode *node)
Definition node.cc:5546
void node_modify_socket_type_static(bNodeTree *ntree, bNode *node, bNodeSocket *sock, int type, int subtype)
Definition node.cc:3448
void node_remove_socket(bNodeTree &ntree, bNode &node, bNodeSocket &sock)
Definition node.cc:4015
std::optional< StringRefNull > node_static_socket_interface_type_new(int type, int subtype, std::optional< int > dimensions=std::nullopt)
Definition node.cc:3709
bool node_declaration_ensure_on_outdated_node(bNodeTree &ntree, bNode &node)
Definition node.cc:5558
void node_register_socket_type(bNodeSocketType &stype)
Definition node.cc:2998
bNodeSocket * node_add_static_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out, int type, int subtype, StringRefNull identifier, StringRefNull name)
Definition node.cc:3980
void node_remove_socket_ex(bNodeTree &ntree, bNode &node, bNodeSocket &sock, bool do_id_user)
Definition node.cc:4020
std::optional< StringRefNull > node_static_socket_label(int type, int subtype)
Definition node.cc:3923
std::optional< StringRefNull > node_static_socket_type(int type, int subtype, std::optional< int > dimensions=std::nullopt)
Definition node.cc:3492
StringRefNull node_socket_sub_type_label(int subtype)
Definition node.cc:3027
QuaternionBase< float > Quaternion
QuaternionBase< T > to_quaternion(const AxisAngleBase< T, AngleT > &axis_angle)
EulerXYZBase< float > EulerXYZ
static void refresh_node(Main *bmain, bNodeTree &ntree, bNode &node, nodes::NodeDeclaration &node_decl, bool do_id_user)
static void refresh_node_sockets_animation_inout(Main &bmain, bNodeTree &ntree, bNode &node, const eNodeSocketInOut in_out, const Span< bNodeSocket * > old_sockets, const Span< bNodeSocket * > new_sockets)
std::unique_ptr< SocketDeclaration > SocketDeclarationPtr
const EnumPropertyItem compositor_nodes_input_type_items_value[]
const EnumPropertyItem compositor_nodes_input_type_items_fallback[]
const EnumPropertyItem geometry_nodes_input_type_items_value_or_attribute_or_layer[]
void update_node_declaration_and_sockets(bNodeTree &ntree, bNode &node, Main *bmain)
void geometry_nodes_property_update(Main *, Scene *, PointerRNA *ptr)
static void refresh_node_sockets_and_panels(Main *bmain, bNodeTree &ntree, bNode &node, const NodeDeclaration &node_decl, const bool do_id_user)
void build_node_declaration(const bke::bNodeType &typeinfo, NodeDeclaration &r_declaration, const bNodeTree *ntree, const bNode *node)
std::unique_ptr< ItemDeclaration > ItemDeclarationPtr
bool socket_type_supports_attributes(const eNodeSocketDatatype socket_type)
static void do_forward_compat_versioning(bNode &node, const NodeDeclaration &node_decl)
static void refresh_node_socket(bNodeTree &ntree, bNode &node, const SocketDeclaration &socket_decl, Vector< bNodeSocket * > &old_sockets, VectorSet< bNodeSocket * > &new_sockets, const bool hide_new_sockets)
bool socket_type_supports_fields(const eNodeSocketDatatype socket_type)
static bool hide_new_group_input_sockets(const bNode &node)
const EnumPropertyItem geometry_nodes_input_type_items_value[]
ImplicitSharingPtr< Closure > ClosurePtr
static void refresh_node_panel(const PanelDeclaration &panel_decl, Vector< bNodePanelState > &old_panels, bNodePanelState &new_panel)
const EnumPropertyItem geometry_nodes_input_type_items_fallback[]
static const char * get_identifier_from_decl(const char *identifier_prefix, const bNodeSocket &socket, const Span< const SocketDeclaration * > socket_decls)
bool socket_type_supports_grids(const eNodeSocketDatatype socket_type)
const EnumPropertyItem geometry_nodes_input_type_items_value_or_attribute[]
static const char * get_current_socket_identifier_for_future_socket(const bNode &node, const bNodeSocket &socket, const Span< const SocketDeclaration * > socket_decls)
ImplicitSharingPtr< Bundle > BundlePtr
void relations_invalidate_cache(Scene *scene, Strip *strip)
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
BMesh Iterators.
static bke::bNodeSocketType * make_socket_type_geometry()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static bNodeSocket * verify_socket_template(bNodeTree *ntree, bNode *node, eNodeSocketInOut in_out, ListBaseT< bNodeSocket > *socklist, bke::bNodeSocketTemplate *stemp)
static void make_common_value_and_attribute_props(StructRNA &srna, const bNodeTreeInterfaceSocket &socket, nodes::GeneratedTreeSrnaData &r_generated)
__int64 int64_t
Definition BKE_text.h:90
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
static void standard_node_socket_interface_init_socket(ID *, const bNodeTreeInterfaceSocket *interface_socket, bNode *, bNodeSocket *sock, StringRefNull)
static void make_common_fallback_props(StructRNA &srna, const bNodeTreeInterfaceSocket &socket, nodes::GeneratedTreeSrnaData &r_generated)
static bke::bNodeSocketType * make_socket_type_bundle()
void BKE_ntree_update_tag_socket_new(bNodeTree *ntree, bNodeSocket *socket)
static void data_block_pointer_update(Main *bmain, Scene *, PointerRNA *)
static void make_common_attribute_name_prop(StructRNA &srna, const bNodeTreeInterfaceSocket &socket, nodes::GeneratedTreeSrnaData &r_generated)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
static void standard_node_socket_interface_from_socket(ID *, bNodeTreeInterfaceSocket *iosock, const bNode *, const bNodeSocket *sock)
static bke::bNodeSocketType * make_socket_type_collection()
static bke::bNodeSocketType * make_socket_type_matrix()
static bke::bNodeSocketType * make_socket_type_texture()
static void make_common_value_props(StructRNA &srna, const bNodeTreeInterfaceSocket &socket, nodes::GeneratedTreeSrnaData &r_generated)
std::optional< AncestorPointerRNA > RNA_struct_search_closest_ancestor_by_type(const PointerRNA *ptr, const StructRNA *srna)
static bke::bNodeSocketType * make_socket_type_menu()
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static bke::bNodeSocketType * make_socket_type_font()
static bke::bNodeSocketType * make_socket_type_float(PropertySubType subtype)
static bke::bNodeSocketType * make_socket_type_sound()
static bke::bNodeSocketType * make_socket_type_int(PropertySubType subtype)
MatBase< float, 4, 4 > float4x4
static bke::bNodeSocketType * make_socket_type_closure()
static bke::bNodeSocketType * make_socket_type_material()
StructRNA * RNA_struct_find(const char *identifier)
PropertyRNA * RNA_def_pointer_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
static bke::bNodeSocketType * make_socket_type_int_vector(PropertySubType subtype, const int dimensions)
bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix)
bool is_layer_selection_field(const bNodeTreeInterfaceSocket &socket)
void RNA_def_property_pointer_default_runtime(PropertyRNA *prop, uint32_t id_session_uid)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:588
static bke::bNodeSocketType * make_socket_type_rgba()
static bke::bNodeSocketType * make_standard_socket_type(const eNodeSocketDatatype type, int subtype, std::optional< int > dimensions=std::nullopt)
VecBase< int32_t, 3 > int3
static void make_common_type_prop(StructRNA &srna, const bNodeTreeInterfaceSocket &socket, const EnumPropertyItem *items, const nodes::GeometryNodesInputType default_type, nodes::GeneratedTreeSrnaData &r_generated)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void DEG_id_tag_update(ID *id, unsigned int flags)
BMesh const char void * data
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
static bke::bNodeSocketType * make_socket_type_mask()
static bke::bNodeSocketType * make_socket_type_virtual()
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
static const EnumPropertyItem * enum_property_items_from_menu_node_socket(const bNodeSocketValueMenu *menu, bool &r_default_value_found, nodes::GeneratedTreeSrnaData &r_generated)
static bke::bNodeSocketType * make_socket_type_bool()
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
static void verify_socket_template_list(bNodeTree *ntree, bNode *node, eNodeSocketInOut in_out, ListBaseT< bNodeSocket > *socklist, bke::bNodeSocketTemplate *stemp_first)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:378
static void set_common_sequencer_update_function(PropertyRNA *prop)
static bke::bNodeSocketType * make_socket_type_scene()
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void ED_init_node_socket_type_virtual(bke::bNodeSocketType *stype)
Definition drawnode.cc:1691
static bke::bNodeSocketType * make_socket_type_image()
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static bke::bNodeSocketType * make_socket_type_vector(PropertySubType subtype, const int dimensions)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static bke::bNodeSocketType * make_socket_type_rotation()
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
bNodeSocket * node_add_socket_from_template(bNodeTree *ntree, bNode *node, bke::bNodeSocketTemplate *stemp, eNodeSocketInOut in_out)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
PropertyRNA * RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_COMPOSITOR
Definition DNA_ID.h:1161
@ PROP_FORCE_GEOMETRY_EVAL
Definition RNA_types.hh:546
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:526
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
void RNA_def_property_update_notifier(PropertyRNA *prop, const int noteflag)
static Strip * find_compositor_properties_strip(PointerRNA *ptr, Editing *ed)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
static bke::bNodeSocketType * make_socket_type_string(PropertySubType subtype)
void DEG_relations_tag_update(Main *bmain)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void ED_init_standard_node_socket_type(bke::bNodeSocketType *stype)
Definition drawnode.cc:1682
@ PROP_ACCELERATION
Definition RNA_types.hh:321
@ PROP_PERCENTAGE
Definition RNA_types.hh:307
@ PROP_TIME_ABSOLUTE
Definition RNA_types.hh:311
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_TRANSLATION
Definition RNA_types.hh:318
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ PROP_VELOCITY
Definition RNA_types.hh:320
@ PROP_FILEPATH
Definition RNA_types.hh:284
@ PROP_FREQUENCY
Definition RNA_types.hh:349
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:347
@ PROP_WAVELENGTH
Definition RNA_types.hh:344
@ PROP_DIRECTION
Definition RNA_types.hh:319
@ PROP_UNSIGNED
Definition RNA_types.hh:306
void register_standard_node_socket_types()
void node_verify_sockets(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
static void set_scene_compositor_effect_property_common_properties(PropertyRNA *property)
static bke::bNodeSocketType * make_socket_type_object()
static bke::bNodeSocketType * make_socket_type_text()
ListBaseT< FCurve > drivers
const bke::RuntimeNodeEnumItems * enum_items
bke::bNodeSocketType * typeinfo
eNodeSocketDatatype type
bke::bNodeSocketRuntime * runtime
struct bNodeSocket * next
ListBaseT< bNodeLink > links
struct AnimData * adt
Vector< RuntimeNodeEnumItem > items
Compact definition of a node socket.
Definition BKE_node.hh:102
Defines a socket type.
Definition BKE_node.hh:163
const CPPType * base_cpp_type
Definition BKE_node.hh:210
SocketMakeNodesInputSrnaFunction make_geometry_nodes_input_srna
Definition BKE_node.hh:218
SocketGetCPPValueFunction get_base_cpp_value
Definition BKE_node.hh:212
void(*) interface_init_socket(ID *id, const bNodeTreeInterfaceSocket *interface_socket, bNode *node, bNodeSocket *socket, StringRefNull data_path)
Definition BKE_node.hh:183
void(*) free_self(bNodeSocketType *stype)
Definition BKE_node.hh:207
SocketMakeNodesInputSrnaFunction make_compositor_nodes_input_srna
Definition BKE_node.hh:219
eNodeSocketDatatype type
Definition BKE_node.hh:198
SocketGetGeometryNodesCPPValueFunction get_geometry_nodes_cpp_value
Definition BKE_node.hh:214
const SocketValueVariant * geometry_nodes_default_value
Definition BKE_node.hh:216
SocketMakeNodesInputSrnaFunction make_scene_compositor_effect_input_srna
Definition BKE_node.hh:220
void(*) interface_from_socket(ID *id, bNodeTreeInterfaceSocket *interface_socket, const bNode *node, const bNodeSocket *socket)
Definition BKE_node.hh:188
Defines a node type.
Definition BKE_node.hh:265
bNodeSocketTemplate * inputs
Definition BKE_node.hh:285
bNodeSocketTemplate * outputs
Definition BKE_node.hh:285
NodeDeclareFunction declare
Definition BKE_node.hh:393