Blender V4.3
drawnode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include "BLI_color.hh"
11#include "BLI_string.h"
12#include "BLI_system.h"
13#include "BLI_threads.h"
14
15#include "DNA_node_types.h"
16#include "DNA_object_types.h"
17#include "DNA_screen_types.h"
18#include "DNA_space_types.h"
19#include "DNA_userdef_types.h"
20
21#include "BKE_context.hh"
22#include "BKE_curve.hh"
23#include "BKE_image.hh"
24#include "BKE_main.hh"
25#include "BKE_node.hh"
26#include "BKE_node_enum.hh"
27#include "BKE_node_runtime.hh"
29#include "BKE_scene.hh"
30#include "BKE_tracking.h"
31
32#include "BLF_api.hh"
33#include "BLT_translation.hh"
34
35#include "BIF_glutil.hh"
36
37#include "GPU_batch.hh"
38#include "GPU_batch_presets.hh"
39#include "GPU_framebuffer.hh"
40#include "GPU_immediate.hh"
41#include "GPU_matrix.hh"
42#include "GPU_platform.hh"
43#include "GPU_shader_shared.hh"
44#include "GPU_state.hh"
45#include "GPU_uniform_buffer.hh"
46
47#include "DRW_engine.hh"
48
49#include "RNA_access.hh"
50#include "RNA_define.hh"
51#include "RNA_prototypes.hh"
52
53#include "ED_node.hh"
54#include "ED_space_api.hh"
55
56#include "WM_api.hh"
57#include "WM_types.hh"
58
59#include "UI_resources.hh"
60#include "UI_view2d.hh"
61
63#include "IMB_imbuf_types.hh"
64
65#include "NOD_composite.hh"
66#include "NOD_geometry.hh"
69#include "NOD_partial_eval.hh"
70#include "NOD_shader.h"
71#include "NOD_socket.hh"
72#include "NOD_texture.h"
73#include "node_intern.hh" /* own include */
74
76
77/* Default flags for uiItemR(). Name is kept short since this is used a lot in this file. */
78#define DEFAULT_FLAGS UI_ITEM_R_SPLIT_EMPTY_NAME
79
80/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
81
83 uiLayout *layout,
84 PointerRNA * /*ptr*/,
85 PointerRNA * /*node_ptr*/,
86 const char *text)
87{
88 uiItemL(layout, text, ICON_NONE);
89}
90
91/* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
92
93static void node_buts_value(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
94{
95 bNode *node = (bNode *)ptr->data;
96 /* first output stores value */
97 bNodeSocket *output = (bNodeSocket *)node->outputs.first;
98 PointerRNA sockptr = RNA_pointer_create(ptr->owner_id, &RNA_NodeSocket, output);
99
100 uiLayout *row = uiLayoutRow(layout, true);
101 uiItemR(row, &sockptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
102}
103
104static void node_buts_rgb(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
105{
106 bNode *node = (bNode *)ptr->data;
107 /* first output stores value */
108 bNodeSocket *output = (bNodeSocket *)node->outputs.first;
109 uiLayout *col;
110 PointerRNA sockptr = RNA_pointer_create(ptr->owner_id, &RNA_NodeSocket, output);
111
112 col = uiLayoutColumn(layout, false);
113 uiTemplateColorPicker(col, &sockptr, "default_value", true, false, false, false);
114 uiItemR(col, &sockptr, "default_value", DEFAULT_FLAGS | UI_ITEM_R_SLIDER, "", ICON_NONE);
115}
116
117static void node_buts_mix_rgb(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
118{
119 bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
120
121 uiLayout *col = uiLayoutColumn(layout, false);
122 uiLayout *row = uiLayoutRow(col, true);
123 uiItemR(row, ptr, "blend_type", DEFAULT_FLAGS, "", ICON_NONE);
124 if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE)) {
125 uiItemR(row, ptr, "use_alpha", DEFAULT_FLAGS, "", ICON_IMAGE_RGB_ALPHA);
126 }
127
128 uiItemR(col, ptr, "use_clamp", DEFAULT_FLAGS, nullptr, ICON_NONE);
129}
130
131static void node_buts_time(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
132{
133 uiTemplateCurveMapping(layout, ptr, "curve", 's', false, false, false, false);
134
135 uiLayout *col = uiLayoutColumn(layout, true);
136 uiItemR(col, ptr, "frame_start", DEFAULT_FLAGS, IFACE_("Start"), ICON_NONE);
137 uiItemR(col, ptr, "frame_end", DEFAULT_FLAGS, IFACE_("End"), ICON_NONE);
138}
139
140static void node_buts_colorramp(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
141{
142 uiTemplateColorRamp(layout, ptr, "color_ramp", false);
143}
144
145static void node_buts_curvevec(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
146{
147 uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false, false);
148}
149
150static void node_buts_curvefloat(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
151{
152 uiTemplateCurveMapping(layout, ptr, "mapping", 0, false, false, false, false);
153}
154
155} // namespace blender::ed::space_node
156
157#define SAMPLE_FLT_ISNONE FLT_MAX
158/* Bad! 2.5 will do better? ... no it won't! */
159static float _sample_col[4] = {SAMPLE_FLT_ISNONE};
160void ED_node_sample_set(const float col[4])
161{
162 if (col) {
164 }
165 else {
167 }
168}
169
170namespace blender::ed::space_node {
171
172static void node_buts_curvecol(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
173{
174 bNode *node = (bNode *)ptr->data;
175 CurveMapping *cumap = (CurveMapping *)node->storage;
176
177 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
178 cumap->flag |= CUMA_DRAW_SAMPLE;
180 }
181 else {
182 cumap->flag &= ~CUMA_DRAW_SAMPLE;
183 }
184
185 /* "Tone" (Standard/Film-like) only used in the Compositor. */
186 bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
188 layout, ptr, "mapping", 'c', false, false, false, (ntree->type == NTREE_COMPOSIT));
189}
190
191static void node_buts_normal(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
192{
193 bNode *node = (bNode *)ptr->data;
194 /* first output stores normal */
195 bNodeSocket *output = (bNodeSocket *)node->outputs.first;
196 PointerRNA sockptr = RNA_pointer_create(ptr->owner_id, &RNA_NodeSocket, output);
197
198 uiItemR(layout, &sockptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
199}
200
202{
203 bNode *node = (bNode *)ptr->data;
204
205 short multi = (node->id && ((Tex *)node->id)->use_nodes && (node->type != CMP_NODE_TEXTURE) &&
206 (node->type != TEX_NODE_TEXTURE));
207
208 uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr);
209
210 if (multi) {
211 /* Number Drawing not optimal here, better have a list. */
212 uiItemR(layout, ptr, "node_output", DEFAULT_FLAGS, "", ICON_NONE);
213 }
214}
215
216static void node_buts_math(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
217{
218 uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
219 uiItemR(layout, ptr, "use_clamp", DEFAULT_FLAGS, nullptr, ICON_NONE);
220}
221
223{
224 uiItemR(layout, ptr, "mode", DEFAULT_FLAGS, "", ICON_NONE);
225}
226
228 const bNode *node,
229 const int x,
230 const int y)
231{
232 const float size = NODE_RESIZE_MARGIN * math::max(snode.runtime->aspect, 1.0f);
233
234 if (node->type == NODE_FRAME) {
235 NodeFrame *data = (NodeFrame *)node->storage;
236
237 /* shrinking frame size is determined by child nodes */
238 if (!(data->flag & NODE_FRAME_RESIZEABLE)) {
239 return NODE_RESIZE_NONE;
240 }
241
243
244 const rctf &totr = node->runtime->totr;
245
246 if (x > totr.xmax - size && x <= totr.xmax && y >= totr.ymin && y < totr.ymax) {
247 dir |= NODE_RESIZE_RIGHT;
248 }
249 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
250 dir |= NODE_RESIZE_LEFT;
251 }
252 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax) {
253 dir |= NODE_RESIZE_TOP;
254 }
255 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) {
256 dir |= NODE_RESIZE_BOTTOM;
257 }
258
259 return dir;
260 }
261
262 if (node->flag & NODE_HIDDEN) {
263 /* right part of node */
264 rctf totr = node->runtime->totr;
265 totr.xmin = node->runtime->totr.xmax - 1.0f * U.widget_unit;
266 if (BLI_rctf_isect_pt(&totr, x, y)) {
267 return NODE_RESIZE_RIGHT;
268 }
269
270 return NODE_RESIZE_NONE;
271 }
272
273 const rctf &totr = node->runtime->totr;
275
276 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
277 dir |= NODE_RESIZE_RIGHT;
278 }
279 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
280 dir |= NODE_RESIZE_LEFT;
281 }
282 return dir;
283}
284
285/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
286
288{
289 uiTemplateIDBrowse(layout, C, ptr, "node_tree", nullptr, nullptr, nullptr);
290}
291
292static void node_buts_frame_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
293{
294 uiItemR(layout, ptr, "label_size", DEFAULT_FLAGS, IFACE_("Label Size"), ICON_NONE);
295 uiItemR(layout, ptr, "shrink", DEFAULT_FLAGS, IFACE_("Shrink"), ICON_NONE);
296 uiItemR(layout, ptr, "text", DEFAULT_FLAGS, nullptr, ICON_NONE);
297}
298
300{
301 switch (ntype->type) {
302 case NODE_GROUP:
304 break;
305 case NODE_FRAME:
307 break;
308 }
309}
310
311/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
312
313static void node_buts_image_user(uiLayout *layout,
314 bContext *C,
316 PointerRNA *imaptr,
317 PointerRNA *iuserptr,
318 const bool show_layer_selection,
319 const bool show_color_management)
320{
321 Image *image = (Image *)imaptr->data;
322 if (!image) {
323 return;
324 }
325 ImageUser *iuser = (ImageUser *)iuserptr->data;
326
327 uiLayout *col = uiLayoutColumn(layout, false);
328
329 uiItemR(col, imaptr, "source", DEFAULT_FLAGS, "", ICON_NONE);
330
331 const int source = RNA_enum_get(imaptr, "source");
332
333 if (source == IMA_SRC_SEQUENCE) {
334 /* don't use iuser->framenr directly
335 * because it may not be updated if auto-refresh is off */
336 Scene *scene = CTX_data_scene(C);
337
338 char numstr[32];
339 const int framenr = BKE_image_user_frame_get(iuser, scene->r.cfra, nullptr);
340 SNPRINTF(numstr, IFACE_("Frame: %d"), framenr);
341 uiItemL(layout, numstr, ICON_NONE);
342 }
343
344 if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
345 col = uiLayoutColumn(layout, true);
346 uiItemR(col, ptr, "frame_duration", DEFAULT_FLAGS, nullptr, ICON_NONE);
347 uiItemR(col, ptr, "frame_start", DEFAULT_FLAGS, nullptr, ICON_NONE);
348 uiItemR(col, ptr, "frame_offset", DEFAULT_FLAGS, nullptr, ICON_NONE);
349 uiItemR(col, ptr, "use_cyclic", DEFAULT_FLAGS, nullptr, ICON_NONE);
350 uiItemR(col, ptr, "use_auto_refresh", DEFAULT_FLAGS, nullptr, ICON_NONE);
351 }
352
353 if (show_layer_selection && RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER &&
354 RNA_boolean_get(ptr, "has_layers"))
355 {
356 col = uiLayoutColumn(layout, false);
357 uiItemR(col, ptr, "layer", DEFAULT_FLAGS, nullptr, ICON_NONE);
358 }
359
360 if (show_color_management) {
361 uiLayout *split = uiLayoutSplit(layout, 0.33f, true);
362 PointerRNA colorspace_settings_ptr = RNA_pointer_get(imaptr, "colorspace_settings");
363 uiItemL(split, IFACE_("Color Space"), ICON_NONE);
364 uiItemR(split, &colorspace_settings_ptr, "name", DEFAULT_FLAGS, "", ICON_NONE);
365
366 if (image->source != IMA_SRC_GENERATED) {
367 split = uiLayoutSplit(layout, 0.33f, true);
368 uiItemL(split, IFACE_("Alpha"), ICON_NONE);
369 uiItemR(split, imaptr, "alpha_mode", DEFAULT_FLAGS, "", ICON_NONE);
370
371 bool is_data = IMB_colormanagement_space_name_is_data(image->colorspace_settings.name);
372 uiLayoutSetActive(split, !is_data);
373 }
374
375 /* Avoid losing changes image is painted. */
376 if (BKE_image_is_dirty((Image *)imaptr->data)) {
377 uiLayoutSetEnabled(split, false);
378 }
379 }
380}
381
383{
384 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
385 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
386
387 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
388 uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", nullptr);
389 uiItemR(layout, ptr, "interpolation", DEFAULT_FLAGS, "", ICON_NONE);
390 uiItemR(layout, ptr, "projection", DEFAULT_FLAGS, "", ICON_NONE);
391
392 if (RNA_enum_get(ptr, "projection") == SHD_PROJ_BOX) {
393 uiItemR(layout, ptr, "projection_blend", DEFAULT_FLAGS, IFACE_("Blend"), ICON_NONE);
394 }
395
396 uiItemR(layout, ptr, "extension", DEFAULT_FLAGS, "", ICON_NONE);
397
398 /* NOTE: image user properties used directly here, unlike compositor image node,
399 * which redefines them in the node struct RNA to get proper updates.
400 */
401 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr, false, true);
402}
403
405{
406 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
407 uiTemplateImage(layout, C, ptr, "image", &iuserptr, false, false);
408}
409
411{
412 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
413 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
414
415 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
416 uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", nullptr);
417
418 uiItemR(layout, ptr, "interpolation", DEFAULT_FLAGS, "", ICON_NONE);
419 uiItemR(layout, ptr, "projection", DEFAULT_FLAGS, "", ICON_NONE);
420
421 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr, false, true);
422}
423
425{
426 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
427 uiTemplateImage(layout, C, ptr, "image", &iuserptr, false, false);
428
429 uiItemR(layout, ptr, "interpolation", DEFAULT_FLAGS, IFACE_("Interpolation"), ICON_NONE);
430 uiItemR(layout, ptr, "projection", DEFAULT_FLAGS, IFACE_("Projection"), ICON_NONE);
431}
432
434{
435 uiItemR(layout, ptr, "space", DEFAULT_FLAGS, "", ICON_NONE);
436}
437
439{
440 uiItemR(layout, ptr, "distribution", DEFAULT_FLAGS, "", ICON_NONE);
441}
442
444{
445 uiItemR(layout, ptr, "target", DEFAULT_FLAGS, "", ICON_NONE);
446}
447
449{
450 uiItemR(layout, ptr, "phase", DEFAULT_FLAGS, "", ICON_NONE);
451}
452
453/* only once called */
455{
456 switch (ntype->type) {
457 case SH_NODE_NORMAL:
459 break;
462 break;
465 break;
468 break;
469 case SH_NODE_VALUE:
471 break;
472 case SH_NODE_RGB:
474 break;
477 break;
478 case SH_NODE_VALTORGB:
480 break;
481 case SH_NODE_MATH:
483 break;
487 break;
491 break;
495 break;
499 break;
503 break;
508 break;
511 break;
512 }
513}
514
515/* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
516
517static void node_buts_image_views(uiLayout *layout,
518 bContext * /*C*/,
520 PointerRNA *imaptr)
521{
522 uiLayout *col;
523
524 if (!imaptr->data) {
525 return;
526 }
527
528 col = uiLayoutColumn(layout, false);
529
530 if (RNA_boolean_get(ptr, "has_views")) {
531 if (RNA_enum_get(ptr, "view") == 0) {
532 uiItemR(col, ptr, "view", DEFAULT_FLAGS, nullptr, ICON_CAMERA_STEREO);
533 }
534 else {
535 uiItemR(col, ptr, "view", DEFAULT_FLAGS, nullptr, ICON_SCENE);
536 }
537 }
538}
539
541{
542 bNode *node = (bNode *)ptr->data;
543
544 PointerRNA iuserptr = RNA_pointer_create(ptr->owner_id, &RNA_ImageUser, node->storage);
545 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
546 uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", nullptr);
547 if (!node->id) {
548 return;
549 }
550
551 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
552
553 node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr, true, true);
554
555 node_buts_image_views(layout, C, ptr, &imaptr);
556}
557
559{
560 bNode *node = (bNode *)ptr->data;
561
562 PointerRNA iuserptr = RNA_pointer_create(ptr->owner_id, &RNA_ImageUser, node->storage);
563 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
564 uiTemplateImage(layout, C, ptr, "image", &iuserptr, false, true);
565}
566
568{
569 bNode *node = (bNode *)ptr->data;
570 CurveMapping *cumap = (CurveMapping *)node->storage;
571
572 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
573 cumap->flag |= CUMA_DRAW_SAMPLE;
575 }
576 else {
577 cumap->flag &= ~CUMA_DRAW_SAMPLE;
578 }
579
580 uiTemplateCurveMapping(layout, ptr, "mapping", 'h', false, false, false, false);
581}
582
584{
585 uiItemR(layout, ptr, "mode", DEFAULT_FLAGS, "", ICON_NONE);
586}
587
589{
590 bNode *node = (bNode *)ptr->data;
591 NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)node->storage;
592
593 uiItemR(layout, ptr, "mode", DEFAULT_FLAGS, "", ICON_NONE);
594 if (storage->mode == CMP_NODE_COMBSEP_COLOR_YCC) {
595 uiItemR(layout, ptr, "ycc_mode", DEFAULT_FLAGS, "", ICON_NONE);
596 }
597}
598
600 SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
601{
602 NodeBoxMask *boxmask = (NodeBoxMask *)node->storage;
603 const float backdropWidth = backdrop->x;
604 const float backdropHeight = backdrop->y;
605 const float aspect = backdropWidth / backdropHeight;
606 const float rad = -boxmask->rotation;
607 const float cosine = cosf(rad);
608 const float sine = sinf(rad);
609 const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
610 const float halveBoxHeight = backdropHeight * (boxmask->height / 2.0f) * aspect;
611
612 float cx, cy, x1, x2, x3, x4;
613 float y1, y2, y3, y4;
614
615 cx = x + snode->zoom * backdropWidth * boxmask->x;
616 cy = y + snode->zoom * backdropHeight * boxmask->y;
617
618 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
619 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
620 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
621 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
622 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
623 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
624 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
625 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
626
629
631
632 immUniformColor3f(1.0f, 1.0f, 1.0f);
633
635 immVertex2f(pos, x1, y1);
636 immVertex2f(pos, x2, y2);
637 immVertex2f(pos, x3, y3);
638 immVertex2f(pos, x4, y4);
639 immEnd();
640
642}
643
645 SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
646{
647 NodeEllipseMask *ellipsemask = (NodeEllipseMask *)node->storage;
648 const float backdropWidth = backdrop->x;
649 const float backdropHeight = backdrop->y;
650 const float aspect = backdropWidth / backdropHeight;
651 const float rad = -ellipsemask->rotation;
652 const float cosine = cosf(rad);
653 const float sine = sinf(rad);
654 const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
655 const float halveBoxHeight = backdropHeight * (ellipsemask->height / 2.0f) * aspect;
656
657 float cx, cy, x1, x2, x3, x4;
658 float y1, y2, y3, y4;
659
660 cx = x + snode->zoom * backdropWidth * ellipsemask->x;
661 cy = y + snode->zoom * backdropHeight * ellipsemask->y;
662
663 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
664 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
665 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
666 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
667 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
668 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
669 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
670 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
671
674
676
677 immUniformColor3f(1.0f, 1.0f, 1.0f);
678
680 immVertex2f(pos, x1, y1);
681 immVertex2f(pos, x2, y2);
682 immVertex2f(pos, x3, y3);
683 immVertex2f(pos, x4, y4);
684 immEnd();
685
687}
688
690 bContext * /*C*/,
692{
693 uiLayout *col = uiLayoutColumn(layout, true);
694
695 uiItemL(col, IFACE_("Matte Objects:"), ICON_NONE);
696
697 uiLayout *row = uiLayoutRow(col, true);
698 uiTemplateCryptoPicker(row, ptr, "add", ICON_ADD);
699 uiTemplateCryptoPicker(row, ptr, "remove", ICON_REMOVE);
700
701 uiItemR(col, ptr, "matte_id", DEFAULT_FLAGS, "", ICON_NONE);
702}
703
705 bContext * /*C*/,
706 PointerRNA * /*ptr*/)
707{
708 uiItemO(layout, IFACE_("Add Crypto Layer"), ICON_ADD, "NODE_OT_cryptomatte_layer_add");
709 uiItemO(layout, IFACE_("Remove Crypto Layer"), ICON_REMOVE, "NODE_OT_cryptomatte_layer_remove");
710}
711
713{
714 bNode *node = (bNode *)ptr->data;
715
716 uiLayout *row = uiLayoutRow(layout, true);
717 uiItemR(row, ptr, "source", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
718
719 uiLayout *col = uiLayoutColumn(layout, false);
720 if (node->custom1 == CMP_NODE_CRYPTOMATTE_SOURCE_RENDER) {
721 uiTemplateID(col, C, ptr, "scene", nullptr, nullptr, nullptr);
722 }
723 else {
724 uiTemplateID(col, C, ptr, "image", nullptr, "IMAGE_OT_open", nullptr);
725
726 NodeCryptomatte *crypto = (NodeCryptomatte *)node->storage;
727 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
728 PointerRNA iuserptr = RNA_pointer_create((ID *)ptr->owner_id, &RNA_ImageUser, &crypto->iuser);
729 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
730
731 node_buts_image_user(col, C, ptr, &imaptr, &iuserptr, false, false);
732 node_buts_image_views(col, C, ptr, &imaptr);
733 }
734
735 col = uiLayoutColumn(layout, true);
736 uiItemR(col, ptr, "layer_name", UI_ITEM_NONE, "", ICON_NONE);
737 uiItemL(col, IFACE_("Matte ID:"), ICON_NONE);
738
739 row = uiLayoutRow(col, true);
740 uiItemR(row, ptr, "matte_id", DEFAULT_FLAGS, "", ICON_NONE);
741 uiTemplateCryptoPicker(row, ptr, "add", ICON_ADD);
742 uiTemplateCryptoPicker(row, ptr, "remove", ICON_REMOVE);
743}
744
745/* only once called */
747{
748 switch (ntype->type) {
749 case CMP_NODE_IMAGE:
752 break;
753 case CMP_NODE_NORMAL:
755 break;
758 break;
759 case CMP_NODE_VALUE:
761 break;
762 case CMP_NODE_RGB:
764 break;
765 case CMP_NODE_MIX_RGB:
767 break;
770 break;
771 case CMP_NODE_TIME:
773 break;
774 case CMP_NODE_TEXTURE:
776 break;
777 case CMP_NODE_MATH:
779 break;
782 break;
786 break;
790 break;
793 break;
796 break;
799 break;
803 break;
804 }
805}
806
807/* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */
808
810{
811 uiLayout *col;
812
813 col = uiLayoutColumn(layout, true);
814 uiItemR(col, ptr, "offset", DEFAULT_FLAGS | UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
815 uiItemR(col, ptr, "offset_frequency", DEFAULT_FLAGS, IFACE_("Frequency"), ICON_NONE);
816
817 col = uiLayoutColumn(layout, true);
818 uiItemR(col, ptr, "squash", DEFAULT_FLAGS, IFACE_("Squash"), ICON_NONE);
819 uiItemR(col, ptr, "squash_frequency", DEFAULT_FLAGS, IFACE_("Frequency"), ICON_NONE);
820}
821
823{
824 bNode *node = (bNode *)ptr->data;
825 ID *id = ptr->owner_id;
826 Tex *tex = (Tex *)node->storage;
827 uiLayout *col, *row;
828
829 PointerRNA tex_ptr = RNA_pointer_create(id, &RNA_Texture, tex);
830
831 col = uiLayoutColumn(layout, false);
832
833 switch (tex->type) {
834 case TEX_BLEND:
835 uiItemR(col, &tex_ptr, "progression", DEFAULT_FLAGS, "", ICON_NONE);
836 row = uiLayoutRow(col, false);
837 uiItemR(
838 row, &tex_ptr, "use_flip_axis", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
839 break;
840
841 case TEX_MARBLE:
842 row = uiLayoutRow(col, false);
843 uiItemR(row, &tex_ptr, "marble_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
844 row = uiLayoutRow(col, false);
845 uiItemR(row, &tex_ptr, "noise_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
846 row = uiLayoutRow(col, false);
847 uiItemR(row, &tex_ptr, "noise_basis", DEFAULT_FLAGS, "", ICON_NONE);
848 row = uiLayoutRow(col, false);
849 uiItemR(
850 row, &tex_ptr, "noise_basis_2", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
851 break;
852
853 case TEX_MAGIC:
854 uiItemR(col, &tex_ptr, "noise_depth", DEFAULT_FLAGS, nullptr, ICON_NONE);
855 break;
856
857 case TEX_STUCCI:
858 row = uiLayoutRow(col, false);
859 uiItemR(row, &tex_ptr, "stucci_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
860 row = uiLayoutRow(col, false);
861 uiItemR(row, &tex_ptr, "noise_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
862 uiItemR(col, &tex_ptr, "noise_basis", DEFAULT_FLAGS, "", ICON_NONE);
863 break;
864
865 case TEX_WOOD:
866 uiItemR(col, &tex_ptr, "noise_basis", DEFAULT_FLAGS, "", ICON_NONE);
867 uiItemR(col, &tex_ptr, "wood_type", DEFAULT_FLAGS, "", ICON_NONE);
868 row = uiLayoutRow(col, false);
869 uiItemR(
870 row, &tex_ptr, "noise_basis_2", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
871 row = uiLayoutRow(col, false);
873 uiItemR(row, &tex_ptr, "noise_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
874 break;
875
876 case TEX_CLOUDS:
877 uiItemR(col, &tex_ptr, "noise_basis", DEFAULT_FLAGS, "", ICON_NONE);
878 row = uiLayoutRow(col, false);
879 uiItemR(row, &tex_ptr, "cloud_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
880 row = uiLayoutRow(col, false);
881 uiItemR(row, &tex_ptr, "noise_type", DEFAULT_FLAGS | UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
882 uiItemR(col,
883 &tex_ptr,
884 "noise_depth",
886 IFACE_("Depth"),
887 ICON_NONE);
888 break;
889
890 case TEX_DISTNOISE:
891 uiItemR(col, &tex_ptr, "noise_basis", DEFAULT_FLAGS, "", ICON_NONE);
892 uiItemR(col, &tex_ptr, "noise_distortion", DEFAULT_FLAGS, "", ICON_NONE);
893 break;
894
895 case TEX_MUSGRAVE:
896 uiItemR(col, &tex_ptr, "musgrave_type", DEFAULT_FLAGS, "", ICON_NONE);
897 uiItemR(col, &tex_ptr, "noise_basis", DEFAULT_FLAGS, "", ICON_NONE);
898 break;
899 case TEX_VORONOI:
900 uiItemR(col, &tex_ptr, "distance_metric", DEFAULT_FLAGS, "", ICON_NONE);
901 if (tex->vn_distm == TEX_MINKOVSKY) {
902 uiItemR(col, &tex_ptr, "minkovsky_exponent", DEFAULT_FLAGS, nullptr, ICON_NONE);
903 }
904 uiItemR(col, &tex_ptr, "color_mode", DEFAULT_FLAGS, "", ICON_NONE);
905 break;
906 }
907}
908
910{
911 uiTemplateID(layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", nullptr);
912}
913
915{
916 bNode *node = (bNode *)ptr->data;
917 PointerRNA iuserptr = RNA_pointer_create(ptr->owner_id, &RNA_ImageUser, node->storage);
918 uiTemplateImage(layout, C, ptr, "image", &iuserptr, false, false);
919}
920
922{
923 uiItemR(layout, ptr, "filepath", DEFAULT_FLAGS, "", ICON_NONE);
924}
925
927{
928 uiItemR(layout, ptr, "mode", DEFAULT_FLAGS, "", ICON_NONE);
929}
930
931/* only once called */
933{
934 if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
936 }
937 else {
938 switch (ntype->type) {
939
940 case TEX_NODE_MATH:
942 break;
943
944 case TEX_NODE_MIX_RGB:
946 break;
947
950 break;
951
954 break;
955
958 break;
959
960 case TEX_NODE_TEXTURE:
962 break;
963
964 case TEX_NODE_BRICKS:
966 break;
967
968 case TEX_NODE_IMAGE:
971 break;
972
973 case TEX_NODE_OUTPUT:
975 break;
976
980 break;
981 }
982 }
983}
984
985/* -------------------------------------------------------------------- */
991static void node_property_update_default(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
992{
993 bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
994 bNode *node = (bNode *)ptr->data;
996 ED_node_tree_propagate_change(nullptr, bmain, ntree);
997}
998
1009
1011{
1013
1014 if (ntype->inputs) {
1015 for (stemp = ntype->inputs; stemp->type >= 0; stemp++) {
1017 }
1018 }
1019 if (ntype->outputs) {
1020 for (stemp = ntype->outputs; stemp->type >= 0; stemp++) {
1022 }
1023 }
1024}
1025
1027 uiLayout *layout,
1028 PointerRNA * /*ptr*/,
1029 PointerRNA * /*node_ptr*/,
1030 const char * /*text*/)
1031{
1032 uiItemL(layout, IFACE_("Undefined Socket Type"), ICON_ERROR);
1033}
1034
1036 PointerRNA * /*ptr*/,
1037 PointerRNA * /*node_ptr*/,
1038 float *r_color)
1039{
1040 r_color[0] = 1.0f;
1041 r_color[1] = 0.0f;
1042 r_color[2] = 0.0f;
1043 r_color[3] = 1.0f;
1044}
1045
1047 float *r_color)
1048{
1049 r_color[0] = 1.0f;
1050 r_color[1] = 0.0f;
1051 r_color[2] = 0.0f;
1052 r_color[3] = 1.0f;
1053}
1054
1056 bNodeTreeInterfaceSocket * /*interface_socket*/,
1057 bContext * /*C*/,
1058 uiLayout *layout)
1059{
1060 uiItemL(layout, IFACE_("Undefined Socket Type"), ICON_ERROR);
1061}
1062
1065} // namespace blender::ed::space_node
1066
1068{
1069 using namespace blender::ed::space_node;
1070
1071 /* Fallback types for undefined tree, nodes, sockets
1072 * Defined in blenkernel, but not registered in type hashes.
1073 */
1074
1077
1078 NodeTypeUndefined.draw_buttons = nullptr;
1079 NodeTypeUndefined.draw_buttons_ex = nullptr;
1080
1081 NodeSocketTypeUndefined.draw = node_socket_undefined_draw;
1082 NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color;
1083 NodeSocketTypeUndefined.draw_color_simple = node_socket_undefined_draw_color_simple;
1084 NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw;
1085
1086 /* node type ui functions */
1087 NODE_TYPES_BEGIN (ntype) {
1088 node_common_set_butfunc(ntype);
1089
1090 node_composit_set_butfunc(ntype);
1091 node_shader_set_butfunc(ntype);
1092 node_texture_set_butfunc(ntype);
1093
1094 /* define update callbacks for socket properties */
1095 node_template_properties_update(ntype);
1096 }
1098}
1099
1101
1106
1107namespace blender::ed::space_node {
1108
1109static const float virtual_node_socket_color[4] = {0.2, 0.2, 0.2, 1.0};
1110
1111/* maps standard socket integer type to a color */
1112static const float std_node_socket_colors[][4] = {
1113 {0.63, 0.63, 0.63, 1.0}, /* SOCK_FLOAT */
1114 {0.39, 0.39, 0.78, 1.0}, /* SOCK_VECTOR */
1115 {0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */
1116 {0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */
1117 {0.80, 0.65, 0.84, 1.0}, /* SOCK_BOOLEAN */
1118 {0.0, 0.0, 0.0, 0.0}, /* UNUSED */
1119 {0.35, 0.55, 0.36, 1.0}, /* SOCK_INT */
1120 {0.44, 0.70, 1.00, 1.0}, /* SOCK_STRING */
1121 {0.93, 0.62, 0.36, 1.0}, /* SOCK_OBJECT */
1122 {0.39, 0.22, 0.39, 1.0}, /* SOCK_IMAGE */
1123 {0.00, 0.84, 0.64, 1.0}, /* SOCK_GEOMETRY */
1124 {0.96, 0.96, 0.96, 1.0}, /* SOCK_COLLECTION */
1125 {0.62, 0.31, 0.64, 1.0}, /* SOCK_TEXTURE */
1126 {0.92, 0.46, 0.51, 1.0}, /* SOCK_MATERIAL */
1127 {0.65, 0.39, 0.78, 1.0}, /* SOCK_ROTATION */
1128 {0.40, 0.40, 0.40, 1.0}, /* SOCK_MENU */
1129 {0.72, 0.20, 0.52, 1.0}, /* SOCK_MATRIX */
1130};
1131
1132/* Callback for colors that does not depend on the socket pointer argument to get the type. */
1133template<int socket_type>
1135 PointerRNA * /*ptr*/,
1136 PointerRNA * /*node_ptr*/,
1137 float *r_color)
1138{
1139 copy_v4_v4(r_color, std_node_socket_colors[socket_type]);
1140};
1141static void std_node_socket_color_simple_fn(const bke::bNodeSocketType *type, float *r_color)
1142{
1143 copy_v4_v4(r_color, std_node_socket_colors[type->type]);
1144};
1145
1146using SocketColorFn = void (*)(bContext *C, PointerRNA *ptr, PointerRNA *node_ptr, float *r_color);
1147/* Callbacks for all built-in socket types. */
1167
1168/* draw function for file output node sockets,
1169 * displays only sub-path and format, no value button */
1171 uiLayout *layout,
1172 PointerRNA *ptr,
1173 PointerRNA *node_ptr)
1174{
1175 bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
1176 bNodeSocket *sock = (bNodeSocket *)ptr->data;
1177 uiLayout *row;
1178 PointerRNA inputptr;
1179
1180 row = uiLayoutRow(layout, false);
1181
1182 PointerRNA imfptr = RNA_pointer_get(node_ptr, "format");
1183 int imtype = RNA_enum_get(&imfptr, "file_format");
1184
1185 if (imtype == R_IMF_IMTYPE_MULTILAYER) {
1187 inputptr = RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input);
1188
1189 uiItemL(row, input->layer, ICON_NONE);
1190 }
1191 else {
1193 uiBlock *block;
1194 inputptr = RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input);
1195
1196 uiItemL(row, input->path, ICON_NONE);
1197
1198 if (!RNA_boolean_get(&inputptr, "use_node_format")) {
1199 imfptr = RNA_pointer_get(&inputptr, "format");
1200 }
1201
1202 const char *imtype_name;
1203 PropertyRNA *imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
1205 &imfptr,
1206 imtype_prop,
1207 RNA_property_enum_get(&imfptr, imtype_prop),
1208 &imtype_name);
1209 block = uiLayoutGetBlock(row);
1211 uiItemL(row, imtype_name, ICON_NONE);
1213 }
1214}
1215
1217{
1218 const nodes::NodeDeclaration *node_decl = node.declaration();
1219 if (node_decl == nullptr) {
1220 return false;
1221 }
1222 if (node_decl->skip_updating_sockets) {
1223 return false;
1224 }
1225 if (socket.in_out == SOCK_OUT) {
1226 return false;
1227 }
1228 const int socket_index = BLI_findindex(&node.inputs, &socket);
1229 return node_decl->inputs[socket_index]->is_attribute_name;
1230}
1231
1232static void draw_gizmo_pin_icon(uiLayout *layout, PointerRNA *socket_ptr)
1233{
1234 uiItemR(layout, socket_ptr, "pin_gizmo", UI_ITEM_NONE, "", ICON_GIZMO);
1235}
1236
1237static void draw_node_socket_name_editable(uiLayout *layout, bNodeSocket *sock, const char *text)
1238{
1239 if (sock->runtime->declaration) {
1240 if (sock->runtime->declaration->socket_name_rna) {
1242 uiItemR(layout,
1243 const_cast<PointerRNA *>(&sock->runtime->declaration->socket_name_rna->owner),
1244 sock->runtime->declaration->socket_name_rna->property_name.c_str(),
1246 "",
1247 ICON_NONE);
1248 return;
1249 }
1250 }
1251 uiItemL(layout, text, ICON_NONE);
1252}
1253
1254static void draw_node_socket_without_value(uiLayout *layout, bNodeSocket *sock, const char *text)
1255{
1256 draw_node_socket_name_editable(layout, sock, text);
1257}
1258
1260 bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
1261{
1262 bNode *node = (bNode *)node_ptr->data;
1263 bNodeSocket *sock = (bNodeSocket *)ptr->data;
1264 bNodeTree *tree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
1265 int type = sock->typeinfo->type;
1266 // int subtype = sock->typeinfo->subtype;
1267
1268 /* XXX not nice, eventually give this node its own socket type ... */
1269 if (node->type == CMP_NODE_OUTPUT_FILE) {
1270 node_file_output_socket_draw(C, layout, ptr, node_ptr);
1271 return;
1272 }
1273
1274 const bool has_gizmo = tree->runtime->gizmo_propagation ?
1275 tree->runtime->gizmo_propagation->gizmo_endpoint_sockets.contains(
1276 sock) :
1277 false;
1278
1279 if (has_gizmo) {
1280 if (sock->in_out == SOCK_OUT && ELEM(node->type,
1282 FN_NODE_INPUT_VECTOR,
1283 FN_NODE_INPUT_INT,
1284 FN_NODE_INPUT_BOOL,
1285 FN_NODE_INPUT_ROTATION,
1287 {
1288 if (node->is_group_input()) {
1289 uiLayout *row = uiLayoutRow(layout, false);
1291 node_socket_button_label(C, row, ptr, node_ptr, text);
1292 uiItemL(row, "", ICON_GIZMO);
1293 }
1295 uiLayout *row = uiLayoutRow(layout, false);
1297 node_socket_button_label(C, row, ptr, node_ptr, text);
1299 }
1300 return;
1301 }
1302 if (sock->in_out == SOCK_IN && sock->index() == 0 &&
1304 {
1305 uiLayout *row = uiLayoutRow(layout, false);
1306 node_socket_button_label(C, row, ptr, node_ptr, text);
1308 return;
1309 }
1310 }
1311
1312 if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_HIDE_VALUE) ||
1313 ((sock->flag & SOCK_IS_LINKED) && !all_links_muted(*sock)))
1314 {
1315 draw_node_socket_without_value(layout, sock, text);
1316 return;
1317 }
1318
1319 const char *label = text;
1320 text = (sock->flag & SOCK_HIDE_LABEL) ? "" : text;
1321
1322 /* Some socket types draw the gizmo icon in a special way to look better. All others use a
1323 * fallback default code path. */
1324 bool gizmo_handled = false;
1325
1326 switch (type) {
1327 case SOCK_FLOAT:
1328 case SOCK_INT:
1329 case SOCK_BOOLEAN:
1330 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE);
1331 break;
1332 case SOCK_VECTOR:
1333 if (sock->flag & SOCK_COMPACT) {
1334 uiTemplateComponentMenu(layout, ptr, "default_value", text);
1335 }
1336 else {
1337 if (sock->typeinfo->subtype == PROP_DIRECTION) {
1338 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1339 }
1340 else {
1341 uiLayout *column = uiLayoutColumn(layout, false);
1342 {
1343 uiLayout *row = uiLayoutRow(column, true);
1344 draw_node_socket_name_editable(row, sock, text);
1345 if (has_gizmo) {
1347 gizmo_handled = true;
1348 }
1349 }
1350 uiItemR(column, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1351 }
1352 }
1353 break;
1354 case SOCK_ROTATION: {
1355 uiLayout *column = uiLayoutColumn(layout, false);
1356 {
1357 uiLayout *row = uiLayoutRow(column, true);
1358 draw_node_socket_name_editable(row, sock, text);
1359 if (has_gizmo) {
1361 gizmo_handled = true;
1362 }
1363 }
1364 uiItemR(column, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1365 break;
1366 }
1367 case SOCK_MATRIX: {
1368 draw_node_socket_name_editable(layout, sock, text);
1369 break;
1370 }
1371 case SOCK_RGBA: {
1372 if (text[0] == '\0') {
1373 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1374 }
1375 else {
1376 uiLayout *row = uiLayoutSplit(layout, 0.4f, false);
1377 uiItemL(row, text, ICON_NONE);
1378 uiItemR(row, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1379 }
1380 break;
1381 }
1382 case SOCK_STRING: {
1383 if (socket_needs_attribute_search(*node, *sock)) {
1384 if (text[0] == '\0') {
1386 }
1387 else {
1388 uiLayout *row = uiLayoutSplit(layout, 0.4f, false);
1389 uiItemL(row, text, ICON_NONE);
1391 }
1392 }
1393 else {
1394 if (text[0] == '\0') {
1395 uiItemFullR(layout,
1396 ptr,
1397 RNA_struct_find_property(ptr, "default_value"),
1398 -1,
1399 0,
1401 "",
1402 ICON_NONE,
1403 label);
1404 }
1405 else {
1406 uiLayout *row = uiLayoutSplit(layout, 0.4f, false);
1407 uiItemL(row, text, ICON_NONE);
1408 uiItemR(row, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1409 }
1410 }
1411 break;
1412 }
1413 case SOCK_MENU: {
1414 const bNodeSocketValueMenu *default_value =
1415 sock->default_value_typed<bNodeSocketValueMenu>();
1416 if (default_value->enum_items) {
1417 if (default_value->enum_items->items.is_empty()) {
1418 uiLayout *row = uiLayoutSplit(layout, 0.4f, false);
1419 uiItemL(row, text, ICON_NONE);
1420 uiItemL(row, IFACE_("No Items"), ICON_NONE);
1421 }
1422 else {
1423 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE);
1424 }
1425 }
1426 else if (default_value->has_conflict()) {
1427 uiItemL(layout, IFACE_("Menu Error"), ICON_ERROR);
1428 }
1429 else {
1430 uiItemL(layout, IFACE_("Menu Undefined"), ICON_QUESTION);
1431 }
1432 break;
1433 }
1434 case SOCK_OBJECT: {
1435 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE);
1436 break;
1437 }
1438 case SOCK_IMAGE: {
1439 const bNodeTree *node_tree = (const bNodeTree *)node_ptr->owner_id;
1440 if (node_tree->type == NTREE_GEOMETRY) {
1441 if (text[0] == '\0') {
1442 uiTemplateID(layout, C, ptr, "default_value", "image.new", "image.open", nullptr);
1443 }
1444 else {
1445 /* 0.3 split ratio is inconsistent, but use it here because the "New" button is large. */
1446 uiLayout *row = uiLayoutSplit(layout, 0.3f, false);
1447 uiItemL(row, text, ICON_NONE);
1448 uiTemplateID(row, C, ptr, "default_value", "image.new", "image.open", nullptr);
1449 }
1450 }
1451 else {
1452 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE);
1453 }
1454 break;
1455 }
1456 case SOCK_COLLECTION: {
1457 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE);
1458 break;
1459 }
1460 case SOCK_TEXTURE: {
1461 if (text[0] == '\0') {
1462 uiTemplateID(layout, C, ptr, "default_value", "texture.new", nullptr, nullptr);
1463 }
1464 else {
1465 /* 0.3 split ratio is inconsistent, but use it here because the "New" button is large. */
1466 uiLayout *row = uiLayoutSplit(layout, 0.3f, false);
1467 uiItemL(row, text, ICON_NONE);
1468 uiTemplateID(row, C, ptr, "default_value", "texture.new", nullptr, nullptr);
1469 }
1470
1471 break;
1472 }
1473 case SOCK_MATERIAL: {
1474 uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE);
1475 break;
1476 }
1477 default:
1478 draw_node_socket_without_value(layout, sock, text);
1479 break;
1480 }
1481
1482 if (has_gizmo && !gizmo_handled) {
1483 draw_gizmo_pin_icon(layout, ptr);
1484 }
1485}
1486
1488 bNodeTreeInterfaceSocket *interface_socket,
1489 bContext * /*C*/,
1490 uiLayout *layout)
1491{
1492 PointerRNA ptr = RNA_pointer_create(id, &RNA_NodeTreeInterfaceSocket, interface_socket);
1493
1494 const bke::bNodeSocketType *typeinfo = interface_socket->socket_typeinfo();
1495 BLI_assert(typeinfo != nullptr);
1497
1498 uiLayout *col = uiLayoutColumn(layout, false);
1499
1500 switch (type) {
1501 case SOCK_FLOAT: {
1502 uiItemR(col, &ptr, "subtype", DEFAULT_FLAGS, IFACE_("Subtype"), ICON_NONE);
1503 uiItemR(col, &ptr, "default_value", DEFAULT_FLAGS, IFACE_("Default"), ICON_NONE);
1504 uiLayout *sub = uiLayoutColumn(col, true);
1505 uiItemR(sub, &ptr, "min_value", DEFAULT_FLAGS, IFACE_("Min"), ICON_NONE);
1506 uiItemR(sub, &ptr, "max_value", DEFAULT_FLAGS, IFACE_("Max"), ICON_NONE);
1507 break;
1508 }
1509 case SOCK_INT: {
1510 uiItemR(col, &ptr, "subtype", DEFAULT_FLAGS, IFACE_("Subtype"), ICON_NONE);
1511 uiItemR(col, &ptr, "default_value", DEFAULT_FLAGS, IFACE_("Default"), ICON_NONE);
1512 uiLayout *sub = uiLayoutColumn(col, true);
1513 uiItemR(sub, &ptr, "min_value", DEFAULT_FLAGS, IFACE_("Min"), ICON_NONE);
1514 uiItemR(sub, &ptr, "max_value", DEFAULT_FLAGS, IFACE_("Max"), ICON_NONE);
1515 break;
1516 }
1517 case SOCK_VECTOR: {
1518 uiItemR(col, &ptr, "subtype", DEFAULT_FLAGS, IFACE_("Subtype"), ICON_NONE);
1519 uiItemR(col, &ptr, "default_value", UI_ITEM_R_EXPAND, IFACE_("Default"), ICON_NONE);
1520 uiLayout *sub = uiLayoutColumn(col, true);
1521 uiItemR(sub, &ptr, "min_value", DEFAULT_FLAGS, IFACE_("Min"), ICON_NONE);
1522 uiItemR(sub, &ptr, "max_value", DEFAULT_FLAGS, IFACE_("Max"), ICON_NONE);
1523 break;
1524 }
1525 case SOCK_STRING: {
1526 uiItemR(col, &ptr, "subtype", DEFAULT_FLAGS, IFACE_("Subtype"), ICON_NONE);
1527 uiItemR(col, &ptr, "default_value", DEFAULT_FLAGS, IFACE_("Default"), ICON_NONE);
1528 break;
1529 }
1530 case SOCK_BOOLEAN:
1531 case SOCK_ROTATION:
1532 case SOCK_RGBA:
1533 case SOCK_OBJECT:
1534 case SOCK_COLLECTION:
1535 case SOCK_IMAGE:
1536 case SOCK_TEXTURE:
1537 case SOCK_MATERIAL: {
1538 uiItemR(col, &ptr, "default_value", DEFAULT_FLAGS, IFACE_("Default"), ICON_NONE);
1539 break;
1540 }
1541 case SOCK_MENU: {
1542 uiItemR(col, &ptr, "default_value", DEFAULT_FLAGS, IFACE_("Default"), ICON_NONE);
1543 break;
1544 }
1545 case SOCK_SHADER:
1546 case SOCK_GEOMETRY:
1547 case SOCK_MATRIX:
1548 break;
1549
1550 case SOCK_CUSTOM:
1552 break;
1553 }
1554
1555 col = uiLayoutColumn(layout, false);
1556
1557 const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(id);
1558 if (interface_socket->flag & NODE_INTERFACE_SOCKET_INPUT && node_tree->type == NTREE_GEOMETRY) {
1559 if (ELEM(type, SOCK_INT, SOCK_VECTOR, SOCK_MATRIX)) {
1560 uiItemR(col, &ptr, "default_input", DEFAULT_FLAGS, nullptr, ICON_NONE);
1561 }
1562 }
1563
1564 {
1565 uiLayout *sub = uiLayoutColumn(col, false);
1566 uiLayoutSetActive(sub, interface_socket->default_input == NODE_INPUT_DEFAULT_VALUE);
1567 uiItemR(sub, &ptr, "hide_value", DEFAULT_FLAGS, nullptr, ICON_NONE);
1568 }
1569
1570 if (interface_socket->flag & NODE_INTERFACE_SOCKET_INPUT && node_tree->type == NTREE_GEOMETRY) {
1571 if (type == SOCK_BOOLEAN) {
1572 uiItemR(col, &ptr, "layer_selection_field", DEFAULT_FLAGS, nullptr, ICON_NONE);
1573 }
1574 uiLayout *sub = uiLayoutColumn(col, false);
1575 uiLayoutSetActive(sub, !is_layer_selection_field(*interface_socket));
1576 uiItemR(sub, &ptr, "hide_in_modifier", DEFAULT_FLAGS, nullptr, ICON_NONE);
1578 uiLayout *sub_sub = uiLayoutColumn(col, false);
1579 uiLayoutSetActive(sub_sub,
1580 (interface_socket->default_input == NODE_INPUT_DEFAULT_VALUE) &&
1581 !is_layer_selection_field(*interface_socket));
1582 uiItemR(sub_sub, &ptr, "force_non_field", DEFAULT_FLAGS, nullptr, ICON_NONE);
1583 }
1584 }
1585}
1586
1588 PointerRNA * /*ptr*/,
1589 PointerRNA * /*node_ptr*/,
1590 float *r_color)
1591{
1593}
1594
1596 float *r_color)
1597{
1599}
1600
1601} // namespace blender::ed::space_node
1602
1604{
1605 using namespace blender::ed::space_node;
1606 stype->draw = std_node_socket_draw;
1607 stype->draw_color = std_node_socket_color_funcs[stype->type];
1608 stype->draw_color_simple = std_node_socket_color_simple_fn;
1609 stype->interface_draw = std_node_socket_interface_draw;
1610}
1611
1613{
1614 using namespace blender::ed::space_node;
1615 stype->draw = node_socket_button_label;
1616 stype->draw_color = node_socket_virtual_draw_color;
1617 stype->draw_color_simple = node_socket_virtual_draw_color_simple;
1618}
1619
1620void ED_node_type_draw_color(const char *idname, float *r_color)
1621{
1622 using namespace blender::ed::space_node;
1623
1625 if (!typeinfo || typeinfo->type == SOCK_CUSTOM) {
1626 r_color[0] = 0.0f;
1627 r_color[1] = 0.0f;
1628 r_color[2] = 0.0f;
1629 r_color[3] = 0.0f;
1630 return;
1631 }
1632
1633 BLI_assert(typeinfo->type < ARRAY_SIZE(std_node_socket_colors));
1634 copy_v4_v4(r_color, std_node_socket_colors[typeinfo->type]);
1635}
1636
1637namespace blender::ed::space_node {
1638
1639/* ************** Generic drawing ************** */
1640
1642 ARegion &region,
1643 SpaceNode &snode,
1644 bNodeInstanceKey parent_key)
1645{
1646 Main *bmain = CTX_data_main(&C);
1647 bNodeInstanceKey active_viewer_key = (snode.nodetree ? snode.nodetree->active_viewer_key :
1656
1657 if (!(snode.flag & SNODE_BACKDRAW) || !ED_node_is_compositor(&snode)) {
1658 return;
1659 }
1660
1661 if (parent_key.value != active_viewer_key.value) {
1662 return;
1663 }
1664
1667
1668 /* The draw manager is used to draw the backdrop image. */
1669 GPUFrameBuffer *old_fb = GPU_framebuffer_active_get();
1672 DRW_draw_view(&C);
1675 /* Draw manager changes the depth state. Set it back to NONE. Without this the
1676 * node preview images aren't drawn correctly. */
1678
1679 void *lock;
1680 Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
1681 ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
1682 if (ibuf) {
1683 /* somehow the offset has to be calculated inverse */
1685 const float offset_x = snode.xof + ima->runtime.backdrop_offset[0] * snode.zoom;
1686 const float offset_y = snode.yof + ima->runtime.backdrop_offset[1] * snode.zoom;
1687 const float x = (region.winx - snode.zoom * ibuf->x) / 2 + offset_x;
1688 const float y = (region.winy - snode.zoom * ibuf->y) / 2 + offset_y;
1689
1692 if (snode.edittree) {
1693 bNode *node = (bNode *)snode.edittree->nodes.first;
1694 const rctf *viewer_border = &snode.nodetree->viewer_border;
1695 while (node) {
1696 if (node->flag & NODE_SELECT) {
1697 if (node->typeinfo->draw_backdrop) {
1698 node->typeinfo->draw_backdrop(&snode, ibuf, node, x, y);
1699 }
1700 }
1701 node = node->next;
1702 }
1703
1704 if ((snode.nodetree->flag & NTREE_VIEWER_BORDER) &&
1705 viewer_border->xmin < viewer_border->xmax && viewer_border->ymin < viewer_border->ymax)
1706 {
1707 rcti pixel_border;
1708 BLI_rcti_init(&pixel_border,
1709 x + snode.zoom * viewer_border->xmin * ibuf->x,
1710 x + snode.zoom * viewer_border->xmax * ibuf->x,
1711 y + snode.zoom * viewer_border->ymin * ibuf->y,
1712 y + snode.zoom * viewer_border->ymax * ibuf->y);
1713
1718
1719 immDrawBorderCorners(pos, &pixel_border, 1.0f, 1.0f);
1720
1722 }
1723 }
1724 }
1725
1726 BKE_image_release_ibuf(ima, ibuf, lock);
1729}
1730
1732 const bNodeSocket &socket,
1733 const bNodeLink &link)
1734{
1735 const float2 socket_location = socket.runtime->location;
1736 if (socket.is_multi_input() && socket.is_input() && !(node.flag & NODE_HIDDEN)) {
1737 /* For internal link case, handle number of links as at least 1. */
1738 const int clamped_total_inputs = math::max<int>(1, socket.runtime->total_inputs);
1740 socket_location, link.multi_input_sort_id, clamped_total_inputs);
1741 }
1742 return socket_location;
1743}
1744
1745static void calculate_inner_link_bezier_points(std::array<float2, 4> &points)
1746{
1747 const int curving = UI_GetThemeValueType(TH_NODE_CURVING, SPACE_NODE);
1748 if (curving == 0) {
1749 /* Straight line: align all points. */
1750 points[1] = math::interpolate(points[0], points[3], 1.0f / 3.0f);
1751 points[2] = math::interpolate(points[0], points[3], 2.0f / 3.0f);
1752 }
1753 else {
1754 const float dist_x = math::distance(points[0].x, points[3].x);
1755 const float dist_y = math::distance(points[0].y, points[3].y);
1756
1757 /* Reduce the handle offset when the link endpoints are close to horizontal. */
1758 const float slope = math::safe_divide(dist_y, dist_x);
1759 const float clamp_factor = math::min(1.0f, slope * (4.5f - 0.25f * float(curving)));
1760
1761 const float handle_offset = curving * 0.1f * dist_x * clamp_factor;
1762
1763 points[1].x = points[0].x + handle_offset;
1764 points[1].y = points[0].y;
1765
1766 points[2].x = points[3].x - handle_offset;
1767 points[2].y = points[3].y;
1768 }
1769}
1770
1771static std::array<float2, 4> node_link_bezier_points(const bNodeLink &link)
1772{
1773 std::array<float2, 4> points;
1774 points[0] = socket_link_connection_location(*link.fromnode, *link.fromsock, link);
1775 points[3] = socket_link_connection_location(*link.tonode, *link.tosock, link);
1777 return points;
1778}
1779
1780static bool node_link_draw_is_visible(const View2D &v2d, const std::array<float2, 4> &points)
1781{
1782 if (min_ffff(points[0].x, points[1].x, points[2].x, points[3].x) > v2d.cur.xmax) {
1783 return false;
1784 }
1785 if (max_ffff(points[0].x, points[1].x, points[2].x, points[3].x) < v2d.cur.xmin) {
1786 return false;
1787 }
1788 return true;
1789}
1790
1792 std::array<float2, NODE_LINK_RESOL + 1> &coords)
1793{
1794 const std::array<float2, 4> points = node_link_bezier_points(link);
1795
1796 /* The extra +1 in size is required by these functions and would be removed ideally. */
1798 points[1].x,
1799 points[2].x,
1800 points[3].x,
1801 &coords[0].x,
1803 sizeof(float2));
1805 points[1].y,
1806 points[2].y,
1807 points[3].y,
1808 &coords[0].y,
1810 sizeof(float2));
1811}
1812
1813#define NODELINK_GROUP_SIZE 256
1814#define LINK_RESOL 24
1815#define LINK_WIDTH 2.5f
1816#define ARROW_SIZE (7 * UI_SCALE_FAC)
1817
1818/* Reroute arrow shape and mute bar. These are expanded here and shrunk in the GLSL code.
1819 * See: `gpu_shader_2D_nodelink_vert.glsl`. */
1820static float arrow_verts[3][2] = {{-1.0f, 1.0f}, {0.0f, 0.0f}, {-1.0f, -1.0f}};
1821static float arrow_expand_axis[3][2] = {{0.7071f, 0.7071f}, {M_SQRT2, 0.0f}, {0.7071f, -0.7071f}};
1822static float mute_verts[3][2] = {{0.7071f, 1.0f}, {0.7071f, 0.0f}, {0.7071f, -1.0f}};
1823static float mute_expand_axis[3][2] = {{1.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, -0.0f}};
1824
1825/* Is zero initialized because it is static data. */
1826static struct {
1827 gpu::Batch *batch; /* for batching line together */
1828 gpu::Batch *batch_single; /* for single line */
1845
1847{
1853 g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step);
1855 g_batch_link.inst_vbo, g_batch_link.muted_id, &g_batch_link.muted_step);
1857 g_batch_link.inst_vbo, g_batch_link.dim_factor_id, &g_batch_link.dim_factor_step);
1859 g_batch_link.inst_vbo, g_batch_link.thickness_id, &g_batch_link.thickness_step);
1861 g_batch_link.inst_vbo, g_batch_link.dash_params_id, &g_batch_link.dash_params_step);
1863 g_batch_link.inst_vbo, g_batch_link.has_back_link_id, &g_batch_link.has_back_link_step);
1865 g_batch_link.inst_vbo, g_batch_link.start_color_id, &g_batch_link.start_color_step);
1867 g_batch_link.inst_vbo, g_batch_link.end_color_id, &g_batch_link.end_color_step);
1868 g_batch_link.count = 0;
1869}
1870
1872 uint uv_id,
1873 uint pos_id,
1874 uint exp_id,
1875 uint v,
1876 const uchar uv[2],
1877 const float pos[2],
1878 const float exp[2])
1879{
1880 GPU_vertbuf_attr_set(vbo, uv_id, v, uv);
1881 GPU_vertbuf_attr_set(vbo, pos_id, v, pos);
1882 GPU_vertbuf_attr_set(vbo, exp_id, v, exp);
1883}
1884
1886{
1887 GPUVertFormat format = {0};
1890 uint expand_id = GPU_vertformat_attr_add(&format, "expand", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1892 int vcount = LINK_RESOL * 2; /* curve */
1893 vcount += 2; /* restart strip */
1894 vcount += 3 * 2; /* arrow */
1895 vcount += 2; /* restart strip */
1896 vcount += 3 * 2; /* mute */
1897 vcount *= 2; /* shadow */
1898 vcount += 2; /* restart strip */
1899 GPU_vertbuf_data_alloc(*vbo, vcount);
1900 int v = 0;
1901
1902 for (int k = 0; k < 2; k++) {
1903 uchar uv[2] = {0, 0};
1904 float pos[2] = {0.0f, 0.0f};
1905 float exp[2] = {0.0f, 1.0f};
1906
1907 /* restart */
1908 if (k == 1) {
1909 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1910 }
1911
1912 /* curve strip */
1913 for (int i = 0; i < LINK_RESOL; i++) {
1914 uv[0] = 255 * (i / float(LINK_RESOL - 1));
1915 uv[1] = 0;
1916 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1917 uv[1] = 255;
1918 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1919 }
1920 /* restart */
1921 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1922
1923 uv[0] = 127;
1924 uv[1] = 0;
1927 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1928 /* arrow */
1929 for (int i = 0; i < 3; i++) {
1930 uv[1] = 0;
1933 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1934
1935 uv[1] = 255;
1936 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1937 }
1938
1939 /* restart */
1940 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1941
1942 uv[0] = 127;
1943 uv[1] = 0;
1946 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1947 /* bar */
1948 for (int i = 0; i < 3; ++i) {
1949 uv[1] = 0;
1952 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1953
1954 uv[1] = 255;
1955 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1956 }
1957
1958 /* restart */
1959 if (k == 0) {
1960 set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp);
1961 }
1962 }
1963
1966
1967 g_batch_link.batch_single = GPU_batch_create_ex(
1968 GPU_PRIM_TRI_STRIP, vbo, nullptr, GPU_BATCH_INVALID);
1970
1971 /* Instances data */
1972 GPUVertFormat format_inst = {0};
1974 &format_inst, "P0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1976 &format_inst, "P1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1978 &format_inst, "P2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1980 &format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
1982 &format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT);
1983 g_batch_link.start_color_id = GPU_vertformat_attr_add(
1984 &format_inst, "start_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
1986 &format_inst, "end_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
1988 &format_inst, "domuted", GPU_COMP_U8, 2, GPU_FETCH_INT);
1989 g_batch_link.dim_factor_id = GPU_vertformat_attr_add(
1990 &format_inst, "dim_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
1992 &format_inst, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
1993 g_batch_link.dash_params_id = GPU_vertformat_attr_add(
1994 &format_inst, "dash_params", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
1995 g_batch_link.has_back_link_id = GPU_vertformat_attr_add(
1996 &format_inst, "has_back_link", GPU_COMP_I32, 1, GPU_FETCH_INT);
1998 /* Alloc max count but only draw the range we need. */
2000
2001 GPU_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true);
2002
2004}
2005
2006static char nodelink_get_color_id(int th_col)
2007{
2008 switch (th_col) {
2009 case TH_WIRE:
2010 return 1;
2011 case TH_WIRE_INNER:
2012 return 2;
2013 case TH_ACTIVE:
2014 return 3;
2015 case TH_EDGE_SELECT:
2016 return 4;
2017 case TH_REDALERT:
2018 return 5;
2019 }
2020 return 0;
2021}
2022
2023static void nodelink_batch_draw(const SpaceNode &snode)
2024{
2025 if (g_batch_link.count == 0) {
2026 return;
2027 }
2028
2030 NodeLinkInstanceData node_link_data;
2031
2038 node_link_data.aspect = snode.runtime->aspect;
2039 node_link_data.arrowSize = ARROW_SIZE;
2040
2041 GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(sizeof(node_link_data), &node_link_data, __func__);
2042
2044 GPU_vertbuf_use(g_batch_link.inst_vbo); /* force update. */
2045
2047 GPU_batch_uniformbuf_bind(g_batch_link.batch, "node_link_data", ubo);
2049
2052
2054
2056}
2057
2059{
2060 g_batch_link.enabled = true;
2061}
2062
2064{
2065 nodelink_batch_draw(snode);
2066 g_batch_link.enabled = false;
2067}
2068
2089
2090static void nodelink_batch_add_link(const SpaceNode &snode,
2091 const std::array<float2, 4> &points,
2092 const NodeLinkDrawConfig &draw_config)
2093{
2094 /* Only allow these colors. If more is needed, you need to modify the shader accordingly. */
2095 BLI_assert(
2097 BLI_assert(
2099 BLI_assert(ELEM(draw_config.th_col3, TH_WIRE, TH_REDALERT, -1));
2100
2101 g_batch_link.count++;
2102 copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p0_step), points[0]);
2103 copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p1_step), points[1]);
2104 copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p2_step), points[2]);
2105 copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p3_step), points[3]);
2106 char *colid = (char *)GPU_vertbuf_raw_step(&g_batch_link.colid_step);
2107 colid[0] = nodelink_get_color_id(draw_config.th_col1);
2108 colid[1] = nodelink_get_color_id(draw_config.th_col2);
2109 colid[2] = nodelink_get_color_id(draw_config.th_col3);
2110 colid[3] = draw_config.drawarrow;
2111 copy_v4_v4((float *)GPU_vertbuf_raw_step(&g_batch_link.start_color_step),
2112 draw_config.start_color);
2113 copy_v4_v4((float *)GPU_vertbuf_raw_step(&g_batch_link.end_color_step), draw_config.end_color);
2114 char *muted = (char *)GPU_vertbuf_raw_step(&g_batch_link.muted_step);
2115 muted[0] = draw_config.drawmuted;
2116 *(float *)GPU_vertbuf_raw_step(&g_batch_link.dim_factor_step) = draw_config.dim_factor;
2117 *(float *)GPU_vertbuf_raw_step(&g_batch_link.thickness_step) = draw_config.thickness;
2118 float3 dash_params(draw_config.dash_length, draw_config.dash_factor, draw_config.dash_alpha);
2119 copy_v3_v3((float *)GPU_vertbuf_raw_step(&g_batch_link.dash_params_step), dash_params);
2120 *(int *)GPU_vertbuf_raw_step(&g_batch_link.has_back_link_step) = draw_config.has_back_link;
2121
2122 if (g_batch_link.count == NODELINK_GROUP_SIZE) {
2123 nodelink_batch_draw(snode);
2124 }
2125}
2126
2127static void node_draw_link_end_marker(const float2 center,
2128 const float radius,
2129 const ColorTheme4f &color)
2130{
2131 rctf rect;
2132 BLI_rctf_init(&rect, center.x - radius, center.x + radius, center.y - radius, center.y + radius);
2133
2135 UI_draw_roundbox_4fv(&rect, true, radius, color);
2136 /* Round-box disables alpha. Re-enable it for node links that are drawn after this one. */
2138}
2139
2141 const NodeLinkDrawConfig &draw_config,
2142 const std::array<float2, 4> &points,
2143 const bool outline)
2144{
2145 const float radius = (outline ? 0.65f : 0.45f) * NODE_SOCKSIZE;
2146 if (link.fromsock) {
2148 points[0], radius, outline ? draw_config.outline_color : draw_config.start_color);
2149 }
2150 if (link.tosock) {
2152 points[3], radius, outline ? draw_config.outline_color : draw_config.end_color);
2153 }
2154}
2155
2156static bool node_link_is_field_link(const SpaceNode &snode, const bNodeLink &link)
2157{
2158 if (snode.edittree->type != NTREE_GEOMETRY) {
2159 return false;
2160 }
2161 if (link.fromsock && link.fromsock->runtime->field_state == bke::FieldSocketState::IsField) {
2162 return true;
2163 }
2164 return false;
2165}
2166
2167static bool node_link_is_gizmo_link(const SpaceNode &snode, const bNodeLink &link)
2168{
2169 if (snode.edittree->type != NTREE_GEOMETRY) {
2170 return false;
2171 }
2172 if (!link.fromsock || !link.tosock) {
2173 return false;
2174 }
2175 const bNodeTree &tree = *snode.edittree;
2176 return tree.runtime->sockets_on_active_gizmo_paths.contains(link.fromsock) &&
2177 tree.runtime->sockets_on_active_gizmo_paths.contains(link.tosock);
2178}
2179
2181 const View2D &v2d,
2182 const SpaceNode &snode,
2183 const bNodeLink &link,
2184 const int th_col1,
2185 const int th_col2,
2186 const int th_col3,
2187 const bool selected)
2188{
2189 NodeLinkDrawConfig draw_config;
2190
2191 draw_config.th_col1 = th_col1;
2192 draw_config.th_col2 = th_col2;
2193 draw_config.th_col3 = th_col3;
2194
2195 draw_config.dim_factor = selected ? 1.0f : node_link_dim_factor(v2d, link);
2196
2197 bTheme *btheme = UI_GetTheme();
2198 draw_config.dash_alpha = btheme->space_node.dash_alpha;
2199
2200 const bool field_link = node_link_is_field_link(snode, link);
2201 const bool gizmo_link = node_link_is_gizmo_link(snode, link);
2202
2203 draw_config.dash_factor = field_link ? 0.75f : 1.0f;
2204 draw_config.dash_length = 10.0f * UI_SCALE_FAC;
2205
2206 const float scale = UI_view2d_scale_get_x(&v2d);
2207 /* Clamp the thickness to make the links more readable when zooming out. */
2208 draw_config.thickness = LINK_WIDTH * max_ff(UI_SCALE_FAC * scale, 1.0f) *
2209 (field_link ? 0.7f : 1.0f);
2210 draw_config.has_back_link = gizmo_link;
2211 draw_config.highlighted = link.flag & NODE_LINK_TEMP_HIGHLIGHT;
2212 draw_config.drawarrow = ((link.tonode && (link.tonode->type == NODE_REROUTE)) &&
2213 (link.fromnode && (link.fromnode->type == NODE_REROUTE)));
2214 draw_config.drawmuted = (link.flag & NODE_LINK_MUTED);
2215
2216 UI_GetThemeColor4fv(th_col3, draw_config.outline_color);
2217
2220 {
2221 const bNodeTree &node_tree = *snode.edittree;
2222 PointerRNA from_node_ptr = RNA_pointer_create(
2223 &const_cast<ID &>(node_tree.id), &RNA_Node, link.fromnode);
2224 PointerRNA to_node_ptr = RNA_pointer_create(
2225 &const_cast<ID &>(node_tree.id), &RNA_Node, link.tonode);
2226
2227 if (link.fromsock) {
2228 node_socket_color_get(C, node_tree, from_node_ptr, *link.fromsock, draw_config.start_color);
2229 }
2230 else {
2231 node_socket_color_get(C, node_tree, to_node_ptr, *link.tosock, draw_config.start_color);
2232 }
2233
2234 if (link.tosock) {
2235 node_socket_color_get(C, node_tree, to_node_ptr, *link.tosock, draw_config.end_color);
2236 }
2237 else {
2238 node_socket_color_get(C, node_tree, from_node_ptr, *link.fromsock, draw_config.end_color);
2239 }
2240 }
2241 else {
2242 UI_GetThemeColor4fv(th_col1, draw_config.start_color);
2243 UI_GetThemeColor4fv(th_col2, draw_config.end_color);
2244 }
2245
2246 /* Highlight links connected to selected nodes. */
2247 if (selected) {
2248 ColorTheme4f color_selected;
2249 UI_GetThemeColor4fv(TH_EDGE_SELECT, color_selected);
2250 const float alpha = color_selected.a;
2251
2252 /* Interpolate color if highlight color is not fully transparent. */
2253 if (alpha != 0.0) {
2254 if (link.fromsock) {
2255 interp_v3_v3v3(draw_config.start_color, draw_config.start_color, color_selected, alpha);
2256 }
2257 if (link.tosock) {
2258 interp_v3_v3v3(draw_config.end_color, draw_config.end_color, color_selected, alpha);
2259 }
2260 }
2261 }
2262
2263 if (draw_config.highlighted) {
2264 ColorTheme4f link_preselection_highlight_color;
2265 UI_GetThemeColor4fv(TH_SELECT, link_preselection_highlight_color);
2266 /* Multi sockets can only be inputs. So we only have to highlight the end of the link. */
2267 copy_v4_v4(draw_config.end_color, link_preselection_highlight_color);
2268 }
2269
2270 return draw_config;
2271}
2272
2273static void node_draw_link_bezier_ex(const SpaceNode &snode,
2274 const NodeLinkDrawConfig &draw_config,
2275 const std::array<float2, 4> &points)
2276{
2277 if (g_batch_link.batch == nullptr) {
2279 }
2280
2281 if (g_batch_link.enabled && !draw_config.highlighted) {
2282 /* Add link to batch. */
2283 nodelink_batch_add_link(snode, points, draw_config);
2284 }
2285 else {
2286 NodeLinkData node_link_data;
2287 for (const int i : IndexRange(points.size())) {
2288 copy_v2_v2(node_link_data.bezierPts[i], points[i]);
2289 }
2290
2291 copy_v4_v4(node_link_data.colors[0], draw_config.outline_color);
2292 copy_v4_v4(node_link_data.colors[1], draw_config.start_color);
2293 copy_v4_v4(node_link_data.colors[2], draw_config.end_color);
2294
2295 node_link_data.doArrow = draw_config.drawarrow;
2296 node_link_data.doMuted = draw_config.drawmuted;
2297 node_link_data.dim_factor = draw_config.dim_factor;
2298 node_link_data.thickness = draw_config.thickness;
2299 node_link_data.dash_params[0] = draw_config.dash_length;
2300 node_link_data.dash_params[1] = draw_config.dash_factor;
2301 node_link_data.dash_params[2] = draw_config.dash_alpha;
2302 node_link_data.has_back_link = draw_config.has_back_link;
2303 node_link_data.aspect = snode.runtime->aspect;
2304 node_link_data.arrowSize = ARROW_SIZE;
2305
2306 gpu::Batch *batch = g_batch_link.batch_single;
2307 GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(sizeof(NodeLinkData), &node_link_data, __func__);
2308
2310 GPU_batch_uniformbuf_bind(batch, "node_link_data", ubo);
2312
2315 }
2316}
2317
2319 const View2D &v2d,
2320 const SpaceNode &snode,
2321 const bNodeLink &link,
2322 const int th_col1,
2323 const int th_col2,
2324 const int th_col3,
2325 const bool selected)
2326{
2327 const std::array<float2, 4> points = node_link_bezier_points(link);
2328 if (!node_link_draw_is_visible(v2d, points)) {
2329 return;
2330 }
2331 const NodeLinkDrawConfig draw_config = nodelink_get_draw_config(
2332 C, v2d, snode, link, th_col1, th_col2, th_col3, selected);
2333
2334 node_draw_link_bezier_ex(snode, draw_config, points);
2335}
2336
2338 const View2D &v2d,
2339 const SpaceNode &snode,
2340 const bNodeLink &link,
2341 const bool selected)
2342{
2343 int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE;
2344
2345 if (link.fromsock == nullptr && link.tosock == nullptr) {
2346 return;
2347 }
2348
2349 /* going to give issues once... */
2350 if (link.tosock->flag & SOCK_UNAVAIL) {
2351 return;
2352 }
2353 if (link.fromsock->flag & SOCK_UNAVAIL) {
2354 return;
2355 }
2356
2357 if (link.flag & NODE_LINK_VALID) {
2358 /* special indicated link, on drop-node */
2360 th_col1 = th_col2 = TH_ACTIVE;
2361 }
2362 else if (link.flag & NODE_LINK_MUTED) {
2363 th_col1 = th_col2 = TH_REDALERT;
2364 }
2365 }
2366 else {
2367 /* Invalid link. */
2368 th_col1 = th_col2 = th_col3 = TH_REDALERT;
2369 // th_col3 = -1; /* no shadow */
2370 }
2371
2372 node_draw_link_bezier(C, v2d, snode, link, th_col1, th_col2, th_col3, selected);
2373}
2374
2375std::array<float2, 4> node_link_bezier_points_dragged(const SpaceNode &snode,
2376 const bNodeLink &link)
2377{
2378 const float2 cursor = snode.runtime->cursor * UI_SCALE_FAC;
2379 std::array<float2, 4> points;
2380 points[0] = link.fromsock ?
2382 cursor;
2383 points[3] = link.tosock ? socket_link_connection_location(*link.tonode, *link.tosock, link) :
2384 cursor;
2386 return points;
2387}
2388
2390 const View2D &v2d,
2391 const SpaceNode &snode,
2392 const bNodeLink &link)
2393{
2394 if (link.fromsock == nullptr && link.tosock == nullptr) {
2395 return;
2396 }
2397
2398 const std::array<float2, 4> points = node_link_bezier_points_dragged(snode, link);
2399
2400 const NodeLinkDrawConfig draw_config = nodelink_get_draw_config(
2401 C, v2d, snode, link, TH_ACTIVE, TH_ACTIVE, TH_WIRE, true);
2402 /* End marker outline. */
2403 node_draw_link_end_markers(link, draw_config, points, true);
2404 /* Link. */
2405 node_draw_link_bezier_ex(snode, draw_config, points);
2406 /* End marker fill. */
2407 node_draw_link_end_markers(link, draw_config, points, false);
2408}
2409
2410} // namespace blender::ed::space_node
2411
2412void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, uint pos)
2413{
2415
2416 if (border & (NODE_LEFT | NODE_RIGHT)) {
2417 immVertex2f(pos, cent[0], v2d->cur.ymin);
2418 immVertex2f(pos, cent[0], v2d->cur.ymax);
2419 }
2420 else {
2421 immVertex2f(pos, cent[0], cent[1] - size);
2422 immVertex2f(pos, cent[0], cent[1] + size);
2423 }
2424
2425 if (border & (NODE_TOP | NODE_BOTTOM)) {
2426 immVertex2f(pos, v2d->cur.xmin, cent[1]);
2427 immVertex2f(pos, v2d->cur.xmax, cent[1]);
2428 }
2429 else {
2430 immVertex2f(pos, cent[0] - size, cent[1]);
2431 immVertex2f(pos, cent[0] + size, cent[1]);
2432 }
2433
2434 immEnd();
2435}
void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, float zoomy)
Definition glutil.cc:623
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
Definition curve.cc:1663
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
Image * BKE_image_ensure_viewer(Main *bmain, int type, const char *name)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
bool BKE_image_is_dirty(Image *image)
int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, bool *r_is_in_range)
#define CMP_NODE_VALTORGB
Definition BKE_node.hh:1016
#define SH_NODE_COMBINE_COLOR
Definition BKE_node.hh:994
#define NODE_TYPES_BEGIN(ntype)
Definition BKE_node.hh:597
#define SH_NODE_MIX_RGB_LEGACY
Definition BKE_node.hh:893
#define SH_NODE_CURVE_FLOAT
Definition BKE_node.hh:992
#define CMP_NODE_MIX_RGB
Definition BKE_node.hh:1015
#define NODE_REROUTE
Definition BKE_node.hh:804
#define CMP_NODE_TIME
Definition BKE_node.hh:1025
#define SH_NODE_OUTPUT_WORLD
Definition BKE_node.hh:914
#define SH_NODE_NORMAL
Definition BKE_node.hh:898
#define CMP_NODE_MASK_ELLIPSE
Definition BKE_node.hh:1098
#define SH_NODE_TEX_IMAGE
Definition BKE_node.hh:930
#define TEX_NODE_PROC_MAX
Definition BKE_node.hh:1163
#define CMP_NODE_COMBYCCA_LEGACY
Definition BKE_node.hh:1043
#define CMP_NODE_SEPARATE_COLOR
Definition BKE_node.hh:1118
#define CMP_NODE_CRYPTOMATTE
Definition BKE_node.hh:1111
#define SH_NODE_SEPARATE_COLOR
Definition BKE_node.hh:995
#define TEX_NODE_BRICKS
Definition BKE_node.hh:1138
#define SH_NODE_TEX_ENVIRONMENT
Definition BKE_node.hh:940
#define SH_NODE_VALUE
Definition BKE_node.hh:892
#define SH_NODE_CURVE_VEC
Definition BKE_node.hh:901
#define CMP_NODE_TEXTURE
Definition BKE_node.hh:1035
#define CMP_NODE_HUECORRECT
Definition BKE_node.hh:1073
#define TEX_NODE_COMBINE_COLOR
Definition BKE_node.hh:1158
#define SH_NODE_MATH
Definition BKE_node.hh:904
#define TEX_NODE_TEXTURE
Definition BKE_node.hh:1137
#define TEX_NODE_SEPARATE_COLOR
Definition BKE_node.hh:1159
#define CMP_NODE_VALUE
Definition BKE_node.hh:1014
#define CMP_NODE_MATH
Definition BKE_node.hh:1059
#define CMP_NODE_CRYPTOMATTE_LEGACY
Definition BKE_node.hh:1108
#define SH_NODE_OUTPUT_MATERIAL
Definition BKE_node.hh:913
#define TEX_NODE_IMAGE
Definition BKE_node.hh:1143
#define CMP_NODE_CURVE_RGB
Definition BKE_node.hh:1020
#define CMP_NODE_COMBINE_COLOR
Definition BKE_node.hh:1117
#define SH_NODE_VECTOR_DISPLACEMENT
Definition BKE_node.hh:981
#define SH_NODE_RGB
Definition BKE_node.hh:891
#define SH_NODE_VALTORGB
Definition BKE_node.hh:894
#define SH_NODE_CURVE_RGB
Definition BKE_node.hh:902
#define NODE_GROUP
Definition BKE_node.hh:800
#define CMP_NODE_RGB
Definition BKE_node.hh:1013
#define CMP_NODE_MASK_BOX
Definition BKE_node.hh:1097
#define TEX_NODE_OUTPUT
Definition BKE_node.hh:1135
#define TEX_NODE_CURVE_TIME
Definition BKE_node.hh:1147
#define SH_NODE_BSDF_GLASS
Definition BKE_node.hh:923
#define NODE_FRAME
Definition BKE_node.hh:803
#define SH_NODE_DISPLACEMENT
Definition BKE_node.hh:980
#define CMP_NODE_SEPYCCA_LEGACY
Definition BKE_node.hh:1042
#define TEX_NODE_MATH
Definition BKE_node.hh:1139
#define NODE_GROUP_INPUT
Definition BKE_node.hh:805
#define NODE_TYPES_END
Definition BKE_node.hh:605
#define SH_NODE_BSDF_REFRACTION
Definition BKE_node.hh:956
#define CMP_NODE_IMAGE
Definition BKE_node.hh:1031
#define CMP_NODE_NORMAL
Definition BKE_node.hh:1018
#define SH_NODE_OUTPUT_LIGHT
Definition BKE_node.hh:915
#define SH_NODE_VOLUME_SCATTER
Definition BKE_node.hh:945
#define TEX_NODE_MIX_RGB
Definition BKE_node.hh:1140
#define TEX_NODE_VALTORGB
Definition BKE_node.hh:1142
#define TEX_NODE_CURVE_RGB
Definition BKE_node.hh:1144
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define BLI_assert(a)
Definition BLI_assert.h:50
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ffff(float a, float b, float c, float d)
MINLINE float max_ff(float a, float b)
MINLINE float min_ffff(float a, float b, float c, float d)
#define M_SQRT2
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
Definition math_vector.c:36
MINLINE void copy_v4_fl(float r[4], float f)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.c:418
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.c:408
bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y)
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
unsigned char uchar
unsigned int uint
void BLI_thread_unlock(int type)
Definition threads.cc:333
void BLI_thread_lock(int type)
Definition threads.cc:328
@ LOCK_DRAW_IMAGE
Definition BLI_threads.h:68
#define ARRAY_SIZE(arr)
#define ELEM(...)
#define IFACE_(msgid)
@ CUMA_DRAW_SAMPLE
@ IMA_SRC_MOVIE
@ IMA_SRC_GENERATED
@ IMA_SRC_SEQUENCE
@ IMA_TYPE_MULTILAYER
@ IMA_TYPE_COMPOSITE
#define NODE_INPUT_DEFAULT_VALUE
@ NTREE_TEXTURE
@ NTREE_GEOMETRY
@ NTREE_COMPOSIT
@ CMP_NODE_COMBSEP_COLOR_YCC
@ NODE_HIDDEN
@ NODE_SELECT
@ NODE_LINK_TEMP_HIGHLIGHT
@ NODE_LINK_MUTED
@ NODE_LINK_INSERT_TARGET
@ NODE_LINK_INSERT_TARGET_INVALID
@ NODE_LINK_VALID
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
@ NTREE_VIEWER_BORDER
@ SHD_PROJ_BOX
@ SOCK_OUT
@ SOCK_IN
@ SOCK_HIDE_LABEL
@ SOCK_HIDE_VALUE
@ SOCK_IS_LINKED
@ SOCK_COMPACT
@ SOCK_UNAVAIL
eNodeSocketDatatype
@ SOCK_INT
@ SOCK_TEXTURE
@ SOCK_VECTOR
@ SOCK_BOOLEAN
@ SOCK_MATERIAL
@ SOCK_SHADER
@ SOCK_MATRIX
@ SOCK_FLOAT
@ SOCK_IMAGE
@ SOCK_COLLECTION
@ SOCK_CUSTOM
@ SOCK_GEOMETRY
@ SOCK_ROTATION
@ SOCK_OBJECT
@ SOCK_STRING
@ SOCK_RGBA
@ SOCK_MENU
@ NODE_FRAME_RESIZEABLE
Object is a sort of wrapper for general info.
@ R_IMF_IMTYPE_MULTILAYER
@ SN_OVERLAY_SHOW_WIRE_COLORS
@ SN_OVERLAY_SHOW_OVERLAYS
@ SNODE_BACKDRAW
@ SPACE_NODE
@ TEX_BLEND
@ TEX_MARBLE
@ TEX_WOOD
@ TEX_CLOUDS
@ TEX_DISTNOISE
@ TEX_VORONOI
@ TEX_STUCCI
@ TEX_MAGIC
@ TEX_MUSGRAVE
@ TEX_RING
@ TEX_BAND
@ TEX_MINKOVSKY
#define UI_SCALE_FAC
void DRW_draw_view(const bContext *C)
void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ntree)
Definition node_edit.cc:492
bool ED_node_is_compositor(const SpaceNode *snode)
Definition node_edit.cc:523
NodeBorder
Definition ED_node_c.hh:27
@ NODE_LEFT
Definition ED_node_c.hh:30
@ NODE_RIGHT
Definition ED_node_c.hh:31
@ NODE_BOTTOM
Definition ED_node_c.hh:29
@ NODE_TOP
Definition ED_node_c.hh:28
void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
#define REGION_DRAW_BACKDROP
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
Definition gpu_batch.cc:56
void GPU_batch_instbuf_set(blender::gpu::Batch *batch, blender::gpu::VertBuf *vertex_buf, bool own_vbo)
#define GPU_batch_uniformbuf_bind(batch, name, ubo)
Definition GPU_batch.hh:314
void GPU_batch_program_set_builtin(blender::gpu::Batch *batch, eGPUBuiltinShader shader_id)
void GPU_batch_draw(blender::gpu::Batch *batch)
@ GPU_BATCH_INVALID
Definition GPU_batch.hh:39
@ GPU_BATCH_OWNS_VBO
Definition GPU_batch.hh:42
void gpu_batch_presets_register(blender::gpu::Batch *preset_batch)
GPUFrameBuffer * GPU_framebuffer_active_get()
void GPU_framebuffer_restore()
void GPU_framebuffer_bind_no_srgb(GPUFrameBuffer *framebuffer)
void immEnd()
void immUnbindProgram()
void immVertex2f(uint attr_id, float x, float y)
void immUniformThemeColor(int color_id)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
GPUVertFormat * immVertexFormat()
void immUniformColor3f(float r, float g, float b)
void immBegin(GPUPrimType, uint vertex_len)
void GPU_matrix_identity_set()
void GPU_matrix_push()
void GPU_matrix_push_projection()
void GPU_matrix_pop_projection()
void GPU_matrix_pop()
@ GPU_PRIM_LINE_LOOP
@ GPU_PRIM_LINES
@ GPU_PRIM_TRI_STRIP
@ GPU_SHADER_2D_NODELINK_INST
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_2D_NODELINK
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(eGPUBlend blend)
Definition gpu_state.cc:42
@ GPU_DEPTH_NONE
Definition GPU_state.hh:108
void GPU_depth_test(eGPUDepthTest test)
Definition gpu_state.cc:68
GPUUniformBuf * GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name)
void GPU_uniformbuf_unbind(GPUUniformBuf *ubo)
void GPU_uniformbuf_free(GPUUniformBuf *ubo)
void GPU_vertbuf_attr_get_raw_data(blender::gpu::VertBuf *, uint a_idx, GPUVertBufRaw *access)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
void GPU_vertbuf_use(blender::gpu::VertBuf *)
blender::gpu::VertBuf * GPU_vertbuf_create_with_format_ex(const GPUVertFormat &format, GPUUsageType usage)
void GPU_vertbuf_data_len_set(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_attr_set(blender::gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
@ GPU_USAGE_STATIC
@ GPU_USAGE_STREAM
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
@ GPU_FETCH_INT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_U8
bool IMB_colormanagement_space_name_is_data(const char *name)
Contains defines and structs used throughout the imbuf module.
@ PROP_DIRECTION
Definition RNA_types.hh:165
#define C
Definition RandGen.cpp:29
void uiLayoutSetActive(uiLayout *layout, bool active)
void UI_draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
@ UI_EMBOSS_NONE
@ UI_EMBOSS_PULLDOWN
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
@ UI_LAYOUT_ALIGN_RIGHT
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, bool compact, bool multiview)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, bool levels, bool brush, bool neg_slope, bool tone)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, const char *name, int icon, const char *placeholder=nullptr)
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
void UI_draw_roundbox_corner_set(int type)
void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter=UI_TEMPLATE_ID_FILTER_ALL, const char *text=nullptr)
void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, bool expand)
#define UI_ITEM_NONE
void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int icon)
void UI_block_emboss_set(uiBlock *block, eUIEmbossType emboss)
void uiLayoutSetEmboss(uiLayout *layout, eUIEmbossType emboss)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic)
void uiTemplateID(uiLayout *layout, const bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter=UI_TEMPLATE_ID_FILTER_ALL, bool live_icon=false, const char *text=nullptr)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
uiLayout * uiLayoutSplit(uiLayout *layout, float percentage, bool align)
@ UI_CNR_ALL
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_EXPAND
@ UI_ITEM_R_SLIDER
void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name)
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *ptr)
int UI_GetThemeValueType(int colorid, int spacetype)
@ TH_WIRE
@ TH_EDGE_SELECT
@ TH_REDALERT
@ TH_NODE_CURVING
@ TH_SELECT
@ TH_WIRE_INNER
@ TH_ACTIVE
void UI_GetThemeColor4fv(int colorid, float col[4])
bTheme * UI_GetTheme()
float UI_view2d_scale_get_x(const View2D *v2d)
Definition view2d.cc:1916
volatile int lock
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned int U
Definition btGjkEpa3.h:78
ChannelStorageType a
Definition BLI_color.hh:88
Vector< SocketDeclaration * > inputs
const char * label
#define sinf(x)
#define cosf(x)
#define LINK_RESOL
Definition drawnode.cc:1814
void ED_node_sample_set(const float col[4])
Definition drawnode.cc:160
#define ARROW_SIZE
Definition drawnode.cc:1816
#define NODELINK_GROUP_SIZE
Definition drawnode.cc:1813
void ED_init_standard_node_socket_type(blender::bke::bNodeSocketType *stype)
Definition drawnode.cc:1603
static float _sample_col[4]
Definition drawnode.cc:159
void ED_init_custom_node_socket_type(blender::bke::bNodeSocketType *stype)
Definition drawnode.cc:1102
void ED_init_node_socket_type_virtual(blender::bke::bNodeSocketType *stype)
Definition drawnode.cc:1612
void ED_node_type_draw_color(const char *idname, float *r_color)
Definition drawnode.cc:1620
void ED_init_custom_node_type(blender::bke::bNodeType *)
Definition drawnode.cc:1100
void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, uint pos)
Definition drawnode.cc:2412
#define DEFAULT_FLAGS
Definition drawnode.cc:78
void ED_node_init_butfuncs()
Definition drawnode.cc:1067
#define SAMPLE_FLT_ISNONE
Definition drawnode.cc:157
#define LINK_WIDTH
Definition drawnode.cc:1815
KDTree_3d * tree
draw_view in_light_buf[] float
uint col
format
ccl_device_inline float3 exp(float3 v)
bNodeSocketType NodeSocketTypeUndefined
Definition node.cc:136
bNodeSocketType * node_socket_type_find(const char *idname)
Definition node.cc:1763
bNodeType NodeTypeUndefined
Definition node.cc:135
const bNodeInstanceKey NODE_INSTANCE_KEY_NONE
Definition node.cc:4021
static void node_buts_rgb(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:104
static void node_texture_buts_bricks(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:809
static const float virtual_node_socket_color[4]
Definition drawnode.cc:1109
static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:424
static void node_composit_buts_cryptomatte_legacy_ex(uiLayout *layout, bContext *, PointerRNA *)
Definition drawnode.cc:704
static void node_shader_buts_scatter(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:448
static void node_socket_template_properties_update(blender::bke::bNodeType *ntype, blender::bke::bNodeSocketTemplate *stemp)
Definition drawnode.cc:999
static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:540
static void node_composit_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:558
void nodelink_batch_start(SpaceNode &)
Definition drawnode.cc:2058
static const float std_node_socket_colors[][4]
Definition drawnode.cc:1112
static void node_shader_buts_displacement(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:433
static void node_buts_frame_ex(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:292
static void node_buts_time(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:131
static void node_buts_curvevec(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:145
static void std_node_socket_interface_draw(ID *id, bNodeTreeInterfaceSocket *interface_socket, bContext *, uiLayout *layout)
Definition drawnode.cc:1487
static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
Definition drawnode.cc:1259
GPUVertBufRaw dash_params_step
Definition drawnode.cc:1840
static float mute_expand_axis[3][2]
Definition drawnode.cc:1823
static void node_buts_math(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:216
static void calculate_inner_link_bezier_points(std::array< float2, 4 > &points)
Definition drawnode.cc:1745
static void node_texture_buts_proc(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:822
static void node_buts_combsep_color(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:222
static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:914
static float2 socket_link_connection_location(const bNode &node, const bNodeSocket &socket, const bNodeLink &link)
Definition drawnode.cc:1731
static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
Definition drawnode.cc:599
void node_draw_link_bezier(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link, const int th_col1, const int th_col2, const int th_col3, const bool selected)
Definition drawnode.cc:2318
static void node_composit_buts_ycc(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:583
bool all_links_muted(const bNodeSocket &socket)
void nodelink_batch_end(SpaceNode &snode)
Definition drawnode.cc:2063
static bool node_link_is_gizmo_link(const SpaceNode &snode, const bNodeLink &link)
Definition drawnode.cc:2167
std::array< float2, 4 > node_link_bezier_points_dragged(const SpaceNode &snode, const bNodeLink &link)
Definition drawnode.cc:2375
GPUVertBufRaw p1_step
Definition drawnode.cc:1836
static float arrow_expand_axis[3][2]
Definition drawnode.cc:1821
GPUVertBufRaw has_back_link_step
Definition drawnode.cc:1841
void node_socket_color_get(const bContext &C, const bNodeTree &ntree, PointerRNA &node_ptr, const bNodeSocket &sock, float r_color[4])
static NodeLinkDrawConfig nodelink_get_draw_config(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link, const int th_col1, const int th_col2, const int th_col3, const bool selected)
Definition drawnode.cc:2180
void node_draw_link(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link, const bool selected)
Definition drawnode.cc:2337
static void nodelink_batch_reset()
Definition drawnode.cc:1846
static void draw_gizmo_pin_icon(uiLayout *layout, PointerRNA *socket_ptr)
Definition drawnode.cc:1232
gpu::Batch * batch_single
Definition drawnode.cc:1828
float2 node_link_calculate_multi_input_position(const float2 &socket_position, const int index, const int total_inputs)
Definition node_edit.cc:118
static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:287
static void nodelink_batch_init()
Definition drawnode.cc:1885
static void node_buts_colorramp(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:140
void node_draw_link_dragged(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link)
Definition drawnode.cc:2389
static char nodelink_get_color_id(int th_col)
Definition drawnode.cc:2006
GPUVertBufRaw p2_step
Definition drawnode.cc:1836
static void nodelink_batch_add_link(const SpaceNode &snode, const std::array< float2, 4 > &points, const NodeLinkDrawConfig &draw_config)
Definition drawnode.cc:2090
static void node_buts_output_shader(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:443
GPUVertBufRaw end_color_step
Definition drawnode.cc:1837
static void node_buts_curvefloat(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:150
static void node_buts_texture(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:201
static void node_composit_set_butfunc(blender::bke::bNodeType *ntype)
Definition drawnode.cc:746
GPUVertBufRaw dim_factor_step
Definition drawnode.cc:1838
void draw_nodespace_back_pix(const bContext &C, ARegion &region, SpaceNode &snode, bNodeInstanceKey parent_key)
Definition drawnode.cc:1641
static void node_socket_undefined_draw_color_simple(const bke::bNodeSocketType *, float *r_color)
Definition drawnode.cc:1046
float node_link_dim_factor(const View2D &v2d, const bNodeLink &link)
static void node_texture_buts_output(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:921
GPUVertBufRaw thickness_step
Definition drawnode.cc:1839
static void node_shader_buts_tex_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:404
static void draw_node_socket_name_editable(uiLayout *layout, bNodeSocket *sock, const char *text)
Definition drawnode.cc:1237
static bool node_link_is_field_link(const SpaceNode &snode, const bNodeLink &link)
Definition drawnode.cc:2156
static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:909
static const SocketColorFn std_node_socket_color_funcs[]
Definition drawnode.cc:1148
static float arrow_verts[3][2]
Definition drawnode.cc:1820
static std::array< float2, 4 > node_link_bezier_points(const bNodeLink &link)
Definition drawnode.cc:1771
static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
Definition drawnode.cc:644
static void node_buts_mix_rgb(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:117
static void node_shader_buts_glossy(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:438
static void node_socket_undefined_interface_draw(ID *, bNodeTreeInterfaceSocket *, bContext *, uiLayout *layout)
Definition drawnode.cc:1055
GPUVertBufRaw muted_step
Definition drawnode.cc:1837
static void std_node_socket_color_simple_fn(const bke::bNodeSocketType *type, float *r_color)
Definition drawnode.cc:1141
static bool node_link_draw_is_visible(const View2D &v2d, const std::array< float2, 4 > &points)
Definition drawnode.cc:1780
static void node_buts_image_views(uiLayout *layout, bContext *, PointerRNA *ptr, PointerRNA *imaptr)
Definition drawnode.cc:517
void node_link_bezier_points_evaluated(const bNodeLink &link, std::array< float2, NODE_LINK_RESOL+1 > &coords)
Definition drawnode.cc:1791
static void node_composit_buts_cryptomatte(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:712
static void node_texture_buts_combsep_color(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:926
static void node_buts_value(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:93
static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
Definition drawnode.cc:1170
static void node_socket_virtual_draw_color(bContext *, PointerRNA *, PointerRNA *, float *r_color)
Definition drawnode.cc:1587
static void nodelink_batch_draw(const SpaceNode &snode)
Definition drawnode.cc:2023
static struct blender::ed::space_node::@502 g_batch_link
static void node_draw_link_bezier_ex(const SpaceNode &snode, const NodeLinkDrawConfig &draw_config, const std::array< float2, 4 > &points)
Definition drawnode.cc:2273
static void node_texture_set_butfunc(blender::bke::bNodeType *ntype)
Definition drawnode.cc:932
static void node_socket_undefined_draw_color(bContext *, PointerRNA *, PointerRNA *, float *r_color)
Definition drawnode.cc:1035
static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, PointerRNA *imaptr, PointerRNA *iuserptr, const bool show_layer_selection, const bool show_color_management)
Definition drawnode.cc:313
NodeResizeDirection node_get_resize_direction(const SpaceNode &snode, const bNode *node, const int x, const int y)
Definition drawnode.cc:227
void node_geometry_add_attribute_search_button(const bContext &, const bNode &node, PointerRNA &socket_ptr, uiLayout &layout, const StringRefNull placeholder)
void std_node_socket_color_fn(bContext *, PointerRNA *, PointerRNA *, float *r_color)
Definition drawnode.cc:1134
static void node_composit_buts_huecorrect(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:567
static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:410
static void node_buts_curvecol(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:172
GPUVertBufRaw p3_step
Definition drawnode.cc:1836
static void node_common_set_butfunc(blender::bke::bNodeType *ntype)
Definition drawnode.cc:299
static void node_socket_button_label(bContext *, uiLayout *layout, PointerRNA *, PointerRNA *, const char *text)
Definition drawnode.cc:82
static void node_draw_link_end_marker(const float2 center, const float radius, const ColorTheme4f &color)
Definition drawnode.cc:2127
static void draw_node_socket_without_value(uiLayout *layout, bNodeSocket *sock, const char *text)
Definition drawnode.cc:1254
static void node_template_properties_update(blender::bke::bNodeType *ntype)
Definition drawnode.cc:1010
void(*)(bContext *C, PointerRNA *ptr, PointerRNA *node_ptr, float *r_color) SocketColorFn
Definition drawnode.cc:1146
GPUVertBufRaw colid_step
Definition drawnode.cc:1837
GPUVertBufRaw start_color_step
Definition drawnode.cc:1837
static void set_nodelink_vertex(gpu::VertBuf *vbo, uint uv_id, uint pos_id, uint exp_id, uint v, const uchar uv[2], const float pos[2], const float exp[2])
Definition drawnode.cc:1871
static void node_composit_buts_cryptomatte_legacy(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:689
static void node_socket_virtual_draw_color_simple(const bke::bNodeSocketType *, float *r_color)
Definition drawnode.cc:1595
static void node_socket_undefined_draw(bContext *, uiLayout *layout, PointerRNA *, PointerRNA *, const char *)
Definition drawnode.cc:1026
static void node_composit_buts_combsep_color(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:588
gpu::VertBuf * inst_vbo
Definition drawnode.cc:1829
static float mute_verts[3][2]
Definition drawnode.cc:1822
static void node_draw_link_end_markers(const bNodeLink &link, const NodeLinkDrawConfig &draw_config, const std::array< float2, 4 > &points, const bool outline)
Definition drawnode.cc:2140
GPUVertBufRaw p0_step
Definition drawnode.cc:1836
static void node_buts_normal(uiLayout *layout, bContext *, PointerRNA *ptr)
Definition drawnode.cc:191
static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
Definition drawnode.cc:382
static void node_property_update_default(Main *bmain, Scene *, PointerRNA *ptr)
Definition drawnode.cc:991
static void node_shader_set_butfunc(blender::bke::bNodeType *ntype)
Definition drawnode.cc:454
static bool socket_needs_attribute_search(bNode &node, bNodeSocket &socket)
Definition drawnode.cc:1216
T safe_divide(const T &a, const T &b)
T distance(const T &a, const T &b)
T min(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
T max(const T &a, const T &b)
bool is_builtin_gizmo_node(const bNode &node)
bool is_supported_value_node(const bNode &node)
bool socket_type_supports_fields(const eNodeSocketDatatype socket_type)
bool is_layer_selection_field(const bNodeTreeInterfaceSocket &socket)
#define NODE_LINK_RESOL
#define NODE_RESIZE_MARGIN
#define NODE_SOCKSIZE
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_name)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
StructRNA * srna
Definition RNA_types.hh:780
Definition DNA_ID.h:413
float backdrop_offset[2]
Image_Runtime runtime
void * first
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
SpaceNode_Runtime * runtime
struct bNodeTree * edittree
SpaceNodeOverlay overlay
struct bNodeTree * nodetree
short stype
short vn_distm
unsigned int value
const RuntimeNodeEnumItemsHandle * enum_items
bNodeSocketRuntimeHandle * runtime
bNodeSocketTypeHandle * typeinfo
bNodeTreeRuntimeHandle * runtime
ListBase nodes
bNodeInstanceKey active_viewer_key
int16_t type
ThemeSpace space_node
Compact definition of a node socket.
Definition BKE_node.hh:103
Defines a socket type.
Definition BKE_node.hh:151
void(* draw_color)(bContext *C, PointerRNA *ptr, PointerRNA *node_ptr, float *r_color)
Definition BKE_node.hh:161
void(* draw_color_simple)(const bNodeSocketType *socket_type, float *r_color)
Definition BKE_node.hh:162
void(* interface_draw)(ID *id, bNodeTreeInterfaceSocket *socket, bContext *C, uiLayout *layout)
Definition BKE_node.hh:164
void(* draw)(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
Definition BKE_node.hh:159
Defines a node type.
Definition BKE_node.hh:218
bNodeSocketTemplate * inputs
Definition BKE_node.hh:233
void(* draw_backdrop)(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
Definition BKE_node.hh:243
void(* draw_buttons_ex)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:240
bNodeSocketTemplate * outputs
Definition BKE_node.hh:233
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
float xmax
float xmin
float ymax
float ymin
PointerRNA * ptr
Definition wm_files.cc:4126
void wmOrtho2_region_pixelspace(const ARegion *region)