Blender  V3.3
node_add.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "DNA_collection_types.h"
11 #include "DNA_node_types.h"
12 #include "DNA_texture_types.h"
13 
14 #include "BLI_listbase.h"
15 
16 #include "BLT_translation.h"
17 
18 #include "BKE_context.h"
19 #include "BKE_image.h"
20 #include "BKE_lib_id.h"
21 #include "BKE_main.h"
22 #include "BKE_node.h"
23 #include "BKE_node_tree_update.h"
24 #include "BKE_report.h"
25 #include "BKE_scene.h"
26 #include "BKE_texture.h"
27 
28 #include "DEG_depsgraph_build.h"
29 
30 #include "ED_node.h" /* own include */
31 #include "ED_render.h"
32 #include "ED_screen.h"
33 
34 #include "RNA_access.h"
35 #include "RNA_define.h"
36 #include "RNA_enum_types.h"
37 #include "RNA_prototypes.h"
38 
39 #include "WM_api.h"
40 #include "WM_types.h"
41 
42 #include "UI_view2d.h"
43 
44 #include "node_intern.hh" /* own include */
45 
46 namespace blender::ed::space_node {
47 
48 /* -------------------------------------------------------------------- */
52 bNode *node_add_node(const bContext &C, const char *idname, int type, float locx, float locy)
53 {
54  SpaceNode &snode = *CTX_wm_space_node(&C);
55  Main &bmain = *CTX_data_main(&C);
56  bNode *node = nullptr;
57 
58  node_deselect_all(snode);
59 
60  if (idname) {
61  node = nodeAddNode(&C, snode.edittree, idname);
62  }
63  else {
64  node = nodeAddStaticNode(&C, snode.edittree, type);
65  }
66  BLI_assert(node && node->typeinfo);
67 
68  /* Position mouse in node header. */
69  node->locx = locx - NODE_DY * 1.5f / UI_DPI_FAC;
70  node->locy = locy + NODE_DY * 0.5f / UI_DPI_FAC;
71 
72  nodeSetSelected(node, true);
73 
74  ED_node_set_active(&bmain, &snode, snode.edittree, node, nullptr);
75  ED_node_tree_propagate_change(&C, &bmain, snode.edittree);
76  return node;
77 }
78 
81 /* -------------------------------------------------------------------- */
85 static bool add_reroute_intersect_check(const bNodeLink &link,
86  float mcoords[][2],
87  int tot,
88  float result[2])
89 {
90  float coord_array[NODE_LINK_RESOL + 1][2];
91 
92  if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
93  for (int i = 0; i < tot - 1; i++) {
94  for (int b = 0; b < NODE_LINK_RESOL; b++) {
96  mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1], result) > 0) {
97  return true;
98  }
99  }
100  }
101  }
102  return false;
103 }
104 
107 
108  struct bNodeSocket *sock;
109  struct bNodeLink *link;
110  float point[2];
111 };
112 
114  bNodeSocket *sock,
115  bNodeLink *link,
116  const float point[2])
117 {
118  bNodeSocketLink *socklink, *prev;
119 
120  socklink = MEM_cnew<bNodeSocketLink>("socket link");
121  socklink->sock = sock;
122  socklink->link = link;
123  copy_v2_v2(socklink->point, point);
124 
125  for (prev = (bNodeSocketLink *)lb->last; prev; prev = prev->prev) {
126  if (prev->sock == sock) {
127  break;
128  }
129  }
130  BLI_insertlinkafter(lb, prev, socklink);
131  return socklink;
132 }
133 
135  bNodeSocketLink *socklink,
136  int in_out)
137 {
138  SpaceNode *snode = CTX_wm_space_node(C);
139  bNodeTree *ntree = snode->edittree;
140  bNode *reroute_node = nullptr;
141  bNodeSocket *cursock = socklink->sock;
142  float insert_point[2];
143  int num_links;
144 
145  zero_v2(insert_point);
146  num_links = 0;
147 
148  while (socklink && socklink->sock == cursock) {
149  if (!(socklink->link->flag & NODE_LINK_TEST)) {
150  socklink->link->flag |= NODE_LINK_TEST;
151 
152  /* create the reroute node for this cursock */
153  if (!reroute_node) {
154  reroute_node = nodeAddStaticNode(C, ntree, NODE_REROUTE);
155 
156  /* add a single link to/from the reroute node to replace multiple links */
157  if (in_out == SOCK_OUT) {
159  socklink->link->fromnode,
160  socklink->link->fromsock,
161  reroute_node,
162  (bNodeSocket *)reroute_node->inputs.first);
163  }
164  else {
166  reroute_node,
167  (bNodeSocket *)reroute_node->outputs.first,
168  socklink->link->tonode,
169  socklink->link->tosock);
170  }
171  }
172 
173  /* insert the reroute node into the link */
174  if (in_out == SOCK_OUT) {
175  socklink->link->fromnode = reroute_node;
176  socklink->link->fromsock = (bNodeSocket *)reroute_node->outputs.first;
177  }
178  else {
179  socklink->link->tonode = reroute_node;
180  socklink->link->tosock = (bNodeSocket *)reroute_node->inputs.first;
181  }
182 
183  add_v2_v2(insert_point, socklink->point);
184  num_links++;
185  }
186  socklink = socklink->next;
187  }
188 
189  if (num_links > 0) {
190  /* average cut point from shared links */
191  mul_v2_fl(insert_point, 1.0f / num_links);
192 
193  reroute_node->locx = insert_point[0] / UI_DPI_FAC;
194  reroute_node->locy = insert_point[1] / UI_DPI_FAC;
195 
196  LISTBASE_FOREACH_BACKWARD (bNode *, frame_node, &ntree->nodes) {
197  if (frame_node->type == NODE_FRAME && BLI_rctf_isect_pt_v(&frame_node->totr, insert_point)) {
198  nodeAttachNode(reroute_node, frame_node);
199  break;
200  }
201  }
202  }
203 
204  return socklink;
205 }
206 
208 {
209  SpaceNode &snode = *CTX_wm_space_node(C);
210  ARegion &region = *CTX_wm_region(C);
211  bNodeTree &ntree = *snode.edittree;
212  float mcoords[256][2];
213  int i = 0;
214 
215  /* Get the cut path */
216  RNA_BEGIN (op->ptr, itemptr, "path") {
217  float loc[2];
218 
219  RNA_float_get_array(&itemptr, "loc", loc);
221  &region.v2d, (short)loc[0], (short)loc[1], &mcoords[i][0], &mcoords[i][1]);
222  i++;
223  if (i >= 256) {
224  break;
225  }
226  }
227  RNA_END;
228 
229  if (i > 1) {
230  ListBase output_links, input_links;
231  bNodeSocketLink *socklink;
232  float insert_point[2];
233 
234  /* always first */
236 
237  node_deselect_all(snode);
238 
239  /* Find cut links and sort them by sockets */
240  BLI_listbase_clear(&output_links);
241  BLI_listbase_clear(&input_links);
242 
243  LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
244  if (node_link_is_hidden_or_dimmed(region.v2d, *link)) {
245  continue;
246  }
247  if (add_reroute_intersect_check(*link, mcoords, i, insert_point)) {
248  add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point);
249  add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point);
250 
251  /* Clear flag */
252  link->flag &= ~NODE_LINK_TEST;
253  }
254  }
255 
256  /* Create reroute nodes for intersected links.
257  * Only one reroute if links share the same input/output socket.
258  */
259  socklink = (bNodeSocketLink *)output_links.first;
260  while (socklink) {
261  socklink = add_reroute_do_socket_section(C, socklink, SOCK_OUT);
262  }
263  socklink = (bNodeSocketLink *)input_links.first;
264  while (socklink) {
265  socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN);
266  }
267 
268  BLI_freelistN(&output_links);
269  BLI_freelistN(&input_links);
270 
271  /* always last */
273  return OPERATOR_FINISHED;
274  }
275 
277 }
278 
280 {
281  ot->name = "Add Reroute";
282  ot->idname = "NODE_OT_add_reroute";
283  ot->description = "Add a reroute node";
284 
289 
291 
292  /* flags */
294 
295  /* properties */
296  PropertyRNA *prop;
297  prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
299  /* internal */
300  RNA_def_int(ot->srna, "cursor", WM_CURSOR_CROSS, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
301 }
302 
305 /* -------------------------------------------------------------------- */
310  wmOperator *op,
311  bNodeTree *ntree)
312 {
313  bNodeTree *node_group = reinterpret_cast<bNodeTree *>(
315  if (!node_group) {
316  return nullptr;
317  }
318 
319  const char *disabled_hint = nullptr;
320  if ((node_group->type != ntree->type) || !nodeGroupPoll(ntree, node_group, &disabled_hint)) {
321  if (disabled_hint) {
322  BKE_reportf(op->reports,
323  RPT_ERROR,
324  "Can not add node group '%s' to '%s':\n %s",
325  node_group->id.name + 2,
326  ntree->id.name + 2,
327  disabled_hint);
328  }
329  else {
330  BKE_reportf(op->reports,
331  RPT_ERROR,
332  "Can not add node group '%s' to '%s'",
333  node_group->id.name + 2,
334  ntree->id.name + 2);
335  }
336 
337  return nullptr;
338  }
339 
340  return node_group;
341 }
342 
344 {
345  Main *bmain = CTX_data_main(C);
346  SpaceNode *snode = CTX_wm_space_node(C);
347  bNodeTree *ntree = snode->edittree;
348  bNodeTree *node_group;
349 
350  if (!(node_group = node_add_group_get_and_poll_group_node_tree(bmain, op, ntree))) {
351  return OPERATOR_CANCELLED;
352  }
353 
355 
356  const char *node_idname = node_group_idname(C);
357  if (node_idname[0] == '\0') {
358  BKE_report(op->reports, RPT_WARNING, "Could not determine type of group node");
359  return OPERATOR_CANCELLED;
360  }
361 
362  bNode *group_node = node_add_node(*C,
363  node_idname,
364  (node_group->type == NTREE_CUSTOM) ? NODE_CUSTOM_GROUP :
365  NODE_GROUP,
366  snode->runtime->cursor[0],
367  snode->runtime->cursor[1]);
368  if (!group_node) {
369  BKE_report(op->reports, RPT_WARNING, "Could not add node group");
370  return OPERATOR_CANCELLED;
371  }
372 
373  group_node->id = &node_group->id;
374  id_us_plus(group_node->id);
375  BKE_ntree_update_tag_node_property(snode->edittree, group_node);
376 
377  nodeSetActive(ntree, group_node);
378  ED_node_tree_propagate_change(C, bmain, nullptr);
380  return OPERATOR_FINISHED;
381 }
382 
384 {
386  return false;
387  }
388  const SpaceNode *snode = CTX_wm_space_node(C);
389  if (snode->edittree->type == NTREE_CUSTOM) {
391  "This node editor displays a custom (Python defined) node tree. "
392  "Dropping node groups isn't supported for this");
393  return false;
394  }
395  return true;
396 }
397 
398 static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
399 {
400  ARegion *region = CTX_wm_region(C);
401  SpaceNode *snode = CTX_wm_space_node(C);
402 
403  /* Convert mouse coordinates to v2d space. */
404  UI_view2d_region_to_view(&region->v2d,
405  event->mval[0],
406  event->mval[1],
407  &snode->runtime->cursor[0],
408  &snode->runtime->cursor[1]);
409 
410  snode->runtime->cursor[0] /= UI_DPI_FAC;
411  snode->runtime->cursor[1] /= UI_DPI_FAC;
412 
413  return node_add_group_exec(C, op);
414 }
415 
417 {
418  /* identifiers */
419  ot->name = "Add Node Group";
420  ot->description = "Add an existing node group to the current node editor";
421  ot->idname = "NODE_OT_add_group";
422 
423  /* callbacks */
427 
428  /* flags */
430 
432 }
433 
436 /* -------------------------------------------------------------------- */
441 {
442  Main *bmain = CTX_data_main(C);
443  SpaceNode *snode = CTX_wm_space_node(C);
444  bNodeTree *ntree = snode->edittree;
445 
446  Object *object = reinterpret_cast<Object *>(
448 
449  if (!object) {
450  return OPERATOR_CANCELLED;
451  }
452 
454 
455  bNode *object_node = node_add_node(
456  *C, nullptr, GEO_NODE_OBJECT_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
457  if (!object_node) {
458  BKE_report(op->reports, RPT_WARNING, "Could not add node object");
459  return OPERATOR_CANCELLED;
460  }
461 
462  bNodeSocket *sock = nodeFindSocket(object_node, SOCK_IN, "Object");
463  if (!sock) {
464  BKE_report(op->reports, RPT_WARNING, "Could not find node object socket");
465  return OPERATOR_CANCELLED;
466  }
467 
469  socket_data->value = object;
470  id_us_plus(&object->id);
471 
472  nodeSetActive(ntree, object_node);
475 
476  return OPERATOR_FINISHED;
477 }
478 
479 static int node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event)
480 {
481  ARegion *region = CTX_wm_region(C);
482  SpaceNode *snode = CTX_wm_space_node(C);
483 
484  /* Convert mouse coordinates to v2d space. */
485  UI_view2d_region_to_view(&region->v2d,
486  event->mval[0],
487  event->mval[1],
488  &snode->runtime->cursor[0],
489  &snode->runtime->cursor[1]);
490 
491  snode->runtime->cursor[0] /= UI_DPI_FAC;
492  snode->runtime->cursor[1] /= UI_DPI_FAC;
493 
494  return node_add_object_exec(C, op);
495 }
496 
498 {
499  const SpaceNode *snode = CTX_wm_space_node(C);
501 }
502 
504 {
505  /* identifiers */
506  ot->name = "Add Node Object";
507  ot->description = "Add an object info node to the current node editor";
508  ot->idname = "NODE_OT_add_object";
509 
510  /* callbacks */
514 
515  /* flags */
517 
519 }
520 
523 /* -------------------------------------------------------------------- */
528 {
529  Main *bmain = CTX_data_main(C);
530  SpaceNode &snode = *CTX_wm_space_node(C);
531  bNodeTree *ntree = snode.edittree;
532 
533  Collection *collection = reinterpret_cast<Collection *>(
535 
536  if (!collection) {
537  return OPERATOR_CANCELLED;
538  }
539 
541 
542  bNode *collection_node = node_add_node(
543  *C, nullptr, GEO_NODE_COLLECTION_INFO, snode.runtime->cursor[0], snode.runtime->cursor[1]);
544  if (!collection_node) {
545  BKE_report(op->reports, RPT_WARNING, "Could not add node collection");
546  return OPERATOR_CANCELLED;
547  }
548 
549  bNodeSocket *sock = nodeFindSocket(collection_node, SOCK_IN, "Collection");
550  if (!sock) {
551  BKE_report(op->reports, RPT_WARNING, "Could not find node collection socket");
552  return OPERATOR_CANCELLED;
553  }
554 
556  socket_data->value = collection;
557  id_us_plus(&collection->id);
558 
559  nodeSetActive(ntree, collection_node);
562 
563  return OPERATOR_FINISHED;
564 }
565 
566 static int node_add_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event)
567 {
568  ARegion *region = CTX_wm_region(C);
569  SpaceNode *snode = CTX_wm_space_node(C);
570 
571  /* Convert mouse coordinates to v2d space. */
572  UI_view2d_region_to_view(&region->v2d,
573  event->mval[0],
574  event->mval[1],
575  &snode->runtime->cursor[0],
576  &snode->runtime->cursor[1]);
577 
578  snode->runtime->cursor[0] /= UI_DPI_FAC;
579  snode->runtime->cursor[1] /= UI_DPI_FAC;
580 
581  return node_add_collection_exec(C, op);
582 }
583 
585 {
586  const SpaceNode *snode = CTX_wm_space_node(C);
588 }
589 
591 {
592  /* identifiers */
593  ot->name = "Add Node Collection";
594  ot->description = "Add an collection info node to the current node editor";
595  ot->idname = "NODE_OT_add_collection";
596 
597  /* callbacks */
601 
602  /* flags */
604 
606 }
607 
610 /* -------------------------------------------------------------------- */
615 {
616  const SpaceNode *snode = CTX_wm_space_node(C);
617  return ED_operator_node_editable(C) &&
619 }
620 
622 {
623  Main *bmain = CTX_data_main(C);
624  SpaceNode &snode = *CTX_wm_space_node(C);
625  bNode *node;
626  Image *ima;
627  int type = 0;
628 
629  ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM);
630  if (!ima) {
631  return OPERATOR_CANCELLED;
632  }
633 
634  switch (snode.nodetree->type) {
635  case NTREE_SHADER:
637  break;
638  case NTREE_TEXTURE:
640  break;
641  case NTREE_COMPOSIT:
643  break;
644  case NTREE_GEOMETRY:
646  break;
647  default:
648  return OPERATOR_CANCELLED;
649  }
650 
652 
653  node = node_add_node(*C, nullptr, type, snode.runtime->cursor[0], snode.runtime->cursor[1]);
654 
655  if (!node) {
656  BKE_report(op->reports, RPT_WARNING, "Could not add an image node");
657  return OPERATOR_CANCELLED;
658  }
659 
660  if (type == GEO_NODE_IMAGE_TEXTURE) {
661  bNodeSocket *image_socket = (bNodeSocket *)node->inputs.first;
662  bNodeSocketValueImage *socket_value = (bNodeSocketValueImage *)image_socket->default_value;
663  socket_value->value = ima;
664  }
665  else {
666  node->id = (ID *)ima;
667  }
668 
669  /* When adding new image file via drag-drop we need to load imbuf in order
670  * to get proper image source.
671  */
672  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
673  BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_RELOAD);
675  }
676 
679 
680  return OPERATOR_FINISHED;
681 }
682 
683 static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *event)
684 {
685  ARegion *region = CTX_wm_region(C);
686  SpaceNode *snode = CTX_wm_space_node(C);
687 
688  /* convert mouse coordinates to v2d space */
689  UI_view2d_region_to_view(&region->v2d,
690  event->mval[0],
691  event->mval[1],
692  &snode->runtime->cursor[0],
693  &snode->runtime->cursor[1]);
694 
695  snode->runtime->cursor[0] /= UI_DPI_FAC;
696  snode->runtime->cursor[1] /= UI_DPI_FAC;
697 
699  RNA_struct_property_is_set(op->ptr, "filepath")) {
700  return node_add_file_exec(C, op);
701  }
702  return WM_operator_filesel(C, op, event);
703 }
704 
706 {
707  /* identifiers */
708  ot->name = "Add File Node";
709  ot->description = "Add a file node to the current node editor";
710  ot->idname = "NODE_OT_add_file";
711 
712  /* callbacks */
716 
717  /* flags */
719 
722  FILE_SPECIAL,
728 }
729 
732 /* -------------------------------------------------------------------- */
737 {
738  SpaceNode *snode = CTX_wm_space_node(C);
739 
741 }
742 
744 {
745  Main *bmain = CTX_data_main(C);
746  SpaceNode &snode = *CTX_wm_space_node(C);
747  bNode *node;
748 
750  if (!mask) {
751  return OPERATOR_CANCELLED;
752  }
753 
755 
757  *C, nullptr, CMP_NODE_MASK, snode.runtime->cursor[0], snode.runtime->cursor[1]);
758 
759  if (!node) {
760  BKE_report(op->reports, RPT_WARNING, "Could not add a mask node");
761  return OPERATOR_CANCELLED;
762  }
763 
764  node->id = mask;
765  id_us_plus(mask);
766 
769 
770  return OPERATOR_FINISHED;
771 }
772 
774 {
775  /* identifiers */
776  ot->name = "Add Mask Node";
777  ot->description = "Add a mask node to the current node editor";
778  ot->idname = "NODE_OT_add_mask";
779 
780  /* callbacks */
783 
784  /* flags */
786 
788 }
789 
792 /* -------------------------------------------------------------------- */
797 {
798  SpaceNode *snode = CTX_wm_space_node(C);
799  Main *bmain = CTX_data_main(C);
800  bNodeTree *ntree;
801  PointerRNA ptr, idptr;
802  PropertyRNA *prop;
803  const char *idname;
804  char treename_buf[MAX_ID_NAME - 2];
805  const char *treename;
806 
807  if (RNA_struct_property_is_set(op->ptr, "type")) {
808  prop = RNA_struct_find_property(op->ptr, "type");
809  RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname);
810  }
811  else if (snode) {
812  idname = snode->tree_idname;
813  }
814  else {
815  return OPERATOR_CANCELLED;
816  }
817 
818  if (RNA_struct_property_is_set(op->ptr, "name")) {
819  RNA_string_get(op->ptr, "name", treename_buf);
820  treename = treename_buf;
821  }
822  else {
823  treename = DATA_("NodeTree");
824  }
825 
826  if (!ntreeTypeFind(idname)) {
827  BKE_reportf(op->reports, RPT_ERROR, "Node tree type %s undefined", idname);
828  return OPERATOR_CANCELLED;
829  }
830 
831  ntree = ntreeAddTree(bmain, treename, idname);
832 
833  /* hook into UI */
835 
836  if (prop) {
837  /* RNA_property_pointer_set increases the user count,
838  * fixed here as the editor is the initial user.
839  */
840  id_us_min(&ntree->id);
841 
842  RNA_id_pointer_create(&ntree->id, &idptr);
843  RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
844  RNA_property_update(C, &ptr, prop);
845  }
846  else if (snode) {
847  snode->nodetree = ntree;
848 
850  }
851 
853 
854  return OPERATOR_FINISHED;
855 }
856 
859  PropertyRNA *UNUSED(prop),
860  bool *r_free)
861 {
862  return rna_node_tree_type_itemf(nullptr, nullptr, r_free);
863 }
864 
866 {
867  PropertyRNA *prop;
868 
869  /* identifiers */
870  ot->name = "New Node Tree";
871  ot->idname = "NODE_OT_new_node_tree";
872  ot->description = "Create a new node tree";
873 
874  /* api callbacks */
876 
877  /* flags */
879 
880  prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Tree Type", "");
882  RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", "");
883 }
884 
887 } // namespace blender::ed::space_node
struct SpaceNode * CTX_wm_space_node(const bContext *C)
Definition: context.c:878
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1042
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
#define IMA_SIGNAL_RELOAD
Definition: BKE_image.h:129
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
#define CMP_NODE_MASK
Definition: BKE_node.h:1264
#define GEO_NODE_OBJECT_INFO
Definition: BKE_node.h:1386
#define NODE_REROUTE
Definition: BKE_node.h:986
bool nodeGroupPoll(struct bNodeTree *nodetree, struct bNodeTree *grouptree, const char **r_disabled_hint)
Definition: node_common.cc:85
#define NODE_CUSTOM_GROUP
Definition: BKE_node.h:989
struct bNodeTreeType * ntreeTypeFind(const char *idname)
Definition: node.cc:1280
void nodeAttachNode(struct bNode *node, struct bNode *parent)
Definition: node.cc:2594
#define GEO_NODE_IMAGE_TEXTURE
Definition: BKE_node.h:1473
#define TEX_NODE_IMAGE
Definition: BKE_node.h:1355
struct bNodeLink * nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock)
Definition: node.cc:2296
struct bNodeSocket * nodeFindSocket(const struct bNode *node, eNodeSocketInOut in_out, const char *identifier)
struct bNode * nodeAddNode(const struct bContext *C, struct bNodeTree *ntree, const char *idname)
Definition: node.cc:2133
void nodeSetSelected(struct bNode *node, bool select)
Definition: node.cc:3615
struct bNodeTree * ntreeAddTree(struct Main *bmain, const char *name, const char *idname)
Definition: node.cc:2674
#define NODE_FRAME
Definition: BKE_node.h:985
struct bNode * nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type)
Definition: node.cc:2151
#define CMP_NODE_IMAGE
Definition: BKE_node.h:1215
#define GEO_NODE_COLLECTION_INFO
Definition: BKE_node.h:1388
void nodeSetActive(struct bNodeTree *ntree, struct bNode *node)
Definition: node.cc:3644
void BKE_ntree_update_tag_node_property(struct bNodeTree *ntree, struct bNode *node)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
Definition: BLI_listbase.h:348
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:301
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float vi[2])
Definition: math_geom.c:1296
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void zero_v2(float r[2])
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
#define UNUSED(x)
#define ELEM(...)
#define DATA_(msgid)
void DEG_relations_tag_update(struct Main *bmain)
#define MAX_ID_NAME
Definition: DNA_ID.h:337
@ ID_IM
Definition: DNA_ID_enums.h:53
@ ID_NT
Definition: DNA_ID_enums.h:68
@ ID_MSK
Definition: DNA_ID_enums.h:74
@ ID_GR
Definition: DNA_ID_enums.h:65
@ ID_OB
Definition: DNA_ID_enums.h:47
Object groups, one object can be in many groups at once.
#define NTREE_TEXTURE
#define NTREE_GEOMETRY
#define NTREE_CUSTOM
#define NTREE_COMPOSIT
#define NODE_LINK_TEST
@ SOCK_OUT
@ SOCK_IN
#define NTREE_SHADER
@ FILE_SORT_DEFAULT
@ FILE_SPECIAL
@ FILE_TYPE_MOVIE
@ FILE_TYPE_FOLDER
@ FILE_TYPE_IMAGE
@ FILE_DEFAULTDISPLAY
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_PASS_THROUGH
void ED_node_tree_update(const struct bContext *C)
void ED_node_set_active(struct Main *bmain, struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *node, bool *r_active_texture_changed)
Definition: node_edit.cc:659
void ED_node_tree_propagate_change(const struct bContext *C, struct Main *bmain, struct bNodeTree *ntree)
void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain)
bool ED_operator_node_editable(struct bContext *C)
Definition: screen_ops.c:318
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
NODE_GROUP
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block SH_NODE_TEX_IMAGE
#define RNA_BEGIN(sptr, itemptr, propname)
Definition: RNA_access.h:543
#define RNA_END
Definition: RNA_access.h:550
const EnumPropertyItem * rna_node_tree_type_itemf(void *data, bool(*poll)(void *data, struct bNodeTreeType *), bool *r_free)
PropertyFlag
Definition: RNA_types.h:183
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_HIDDEN
Definition: RNA_types.h:216
#define C
Definition: RandGen.cpp:25
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
#define UI_DPI_FAC
Definition: UI_interface.h:305
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
@ WM_FILESEL_RELPATH
Definition: WM_api.h:752
@ WM_FILESEL_FILEPATH
Definition: WM_api.h:755
@ FILE_OPENFILE
Definition: WM_api.h:764
@ OPTYPE_INTERNAL
Definition: WM_types.h:168
@ OPTYPE_DEPENDS_ON_CURSOR
Definition: WM_types.h:184
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_NODE
Definition: WM_types.h:344
#define NA_ADDED
Definition: WM_types.h:525
#define NA_EDITED
Definition: WM_types.h:523
#define NC_IMAGE
Definition: WM_types.h:334
OperationNode * node
bNodeTree * ntree
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
void NODE_OT_add_object(wmOperatorType *ot)
Definition: node_add.cc:503
static const EnumPropertyItem * new_node_tree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
Definition: node_add.cc:857
void NODE_OT_add_mask(wmOperatorType *ot)
Definition: node_add.cc:773
static bNodeSocketLink * add_reroute_insert_socket_link(ListBase *lb, bNodeSocket *sock, bNodeLink *link, const float point[2])
Definition: node_add.cc:113
static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: node_add.cc:683
static bool node_add_object_poll(bContext *C)
Definition: node_add.cc:497
static bool add_reroute_intersect_check(const bNodeLink &link, float mcoords[][2], int tot, float result[2])
Definition: node_add.cc:85
static bool node_add_group_poll(bContext *C)
Definition: node_add.cc:383
static bool node_add_file_poll(bContext *C)
Definition: node_add.cc:614
void NODE_OT_add_reroute(wmOperatorType *ot)
Definition: node_add.cc:279
void NODE_OT_add_collection(wmOperatorType *ot)
Definition: node_add.cc:590
static int add_reroute_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:207
static int node_add_mask_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:743
bool node_link_bezier_points(const View2D *v2d, const SpaceNode *snode, const bNodeLink &link, float coord_array[][2], const int resol)
Definition: drawnode.cc:1665
bNode * node_add_node(const bContext &C, const char *idname, int type, float locx, float locy)
Definition: node_add.cc:52
void node_deselect_all(SpaceNode &snode)
Definition: node_select.cc:250
static int new_node_tree_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:796
static bNodeSocketLink * add_reroute_do_socket_section(bContext *C, bNodeSocketLink *socklink, int in_out)
Definition: node_add.cc:134
static int node_add_group_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:343
bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link)
Definition: node_edit.cc:1320
const char * node_group_idname(bContext *C)
Definition: node_group.cc:98
static int node_add_object_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:440
static int node_add_file_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:621
static bool node_add_mask_poll(bContext *C)
Definition: node_add.cc:736
static int node_add_collection_exec(bContext *C, wmOperator *op)
Definition: node_add.cc:527
static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: node_add.cc:398
static int node_add_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: node_add.cc:566
static bNodeTree * node_add_group_get_and_poll_group_node_tree(Main *bmain, wmOperator *op, bNodeTree *ntree)
Definition: node_add.cc:309
void NODE_OT_add_group(wmOperatorType *ot)
Definition: node_add.cc:416
void NODE_OT_add_file(wmOperatorType *ot)
Definition: node_add.cc:705
static bool node_add_collection_poll(bContext *C)
Definition: node_add.cc:584
static int node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: node_add.cc:479
void NODE_OT_new_node_tree(wmOperatorType *ot)
Definition: node_add.cc:865
SymEdge< T > * prev(const SymEdge< T > *se)
Definition: delaunay_2d.cc:105
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
#define NODE_LINK_RESOL
Definition: node_intern.hh:123
#define NODE_DY
Definition: node_intern.hh:113
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:112
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
Definition: rna_access.c:3532
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2138
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
Definition: rna_access.c:1759
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3402
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:5301
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4221
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
Definition: rna_define.c:3830
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
const EnumPropertyItem DummyRNA_NULL_items[]
Definition: rna_rna.c:26
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
char tree_idname[64]
SpaceNode_Runtime * runtime
struct bNodeTree * edittree
struct bNodeTree * nodetree
struct Collection * value
struct Object * value
void * default_value
ListBase nodes
ListBase links
float locy
ListBase inputs
struct ID * id
float locx
ListBase outputs
int mval[2]
Definition: WM_types.h:684
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:935
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:927
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct ReportList * reports
struct PointerRNA * ptr
@ WM_CURSOR_CROSS
Definition: wm_cursors.h:26
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
int WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
int WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ID * WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain, PointerRNA *ptr, const ID_Type type)
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
ID * WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)