Blender V5.3
paint_cursor.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 by Nicholas Bishop. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8#include "paint_cursor.hh"
9
10#include <algorithm>
11
12#include "MEM_guardedalloc.h"
13
14#include "BLI_listbase.hh"
16#include "BLI_math_color_c.hh"
18#include "BLI_rect.hh"
19#include "BLI_task_c.hh"
20#include "BLI_utildefines.hh"
21
22#include "DNA_brush_types.h"
23#include "DNA_mesh_types.h"
24#include "DNA_object_types.h"
25#include "DNA_scene_types.h"
26#include "DNA_screen_types.h"
27#include "DNA_space_types.h"
28#include "DNA_userdef_types.h"
29#include "DNA_view3d_types.h"
30
31#include "BKE_brush.hh"
32#include "BKE_colortools.hh"
33#include "BKE_context.hh"
34#include "BKE_curve.hh"
35#include "BKE_image.hh"
36#include "BKE_node_runtime.hh"
37#include "BKE_object_types.hh"
38#include "BKE_paint.hh"
39#include "BKE_paint_types.hh"
40#include "BKE_screen.hh"
41
42#include "NOD_texture.h"
43
44#include "WM_api.hh"
45#include "wm_cursors.hh"
46
48#include "IMB_imbuf_types.hh"
49
50#include "ED_paint.hh"
51#include "ED_view3d.hh"
52
53#include "GPU_immediate.hh"
54#include "GPU_immediate_util.hh"
55#include "GPU_matrix.hh"
56#include "GPU_state.hh"
57#include "GPU_texture.hh"
58
59#include "PRF_profile.hh"
60
61#include "UI_resources.hh"
62
63#include "paint_intern.hh"
64
65namespace blender {
66
67/* TODOs:
68 *
69 * Some of the cursor drawing code is doing non-draw stuff
70 * (e.g. updating the brush rake angle). This should be cleaned up
71 * still.
72 *
73 * There is also some ugliness with sculpt-specific code.
74 */
75
76namespace ed::sculpt_paint {
77
78static int same_tex_snap(
79 bke::paint::TexSnapshot *snap, MTex *mtex, ViewContext *vc, bool col, float zoom)
80{
81 return (/* make brush smaller shouldn't cause a resample */
82 //(mtex->brush_map_mode != MTEX_MAP_MODE_VIEW ||
83 //(BKE_brush_size_get(vc->scene, brush) <= snap->BKE_brush_size_get)) &&
84
86 (vc->region->winx == snap->winx && vc->region->winy == snap->winy)) &&
87 (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL || snap->old_zoom == zoom) &&
88 snap->old_col == col);
89}
90
92{
93 snap->old_zoom = zoom;
94 snap->winx = vc->region->winx;
95 snap->winy = vc->region->winy;
96}
97
111
112static void load_tex_task_cb_ex(void *__restrict userdata,
113 const int j,
114 const TaskParallelTLS *__restrict tls)
115{
116 LoadTexData *data = static_cast<LoadTexData *>(userdata);
117 Brush *br = data->br;
118 ViewContext *vc = data->vc;
119
120 MTex *mtex = data->mtex;
121 uchar *buffer = data->buffer;
122 const bool col = data->col;
123
124 ImagePool *pool = data->pool;
125 const int size = data->size;
126 const float rotation = data->rotation;
127 const float radius = data->radius;
128
129 bool convert_to_linear = false;
130 const ColorSpace *colorspace = nullptr;
131
132 const int thread_id = BLI_task_parallel_thread_id(tls);
133
134 if (mtex->tex && mtex->tex->type == TEX_IMAGE && mtex->tex->ima) {
135 ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool);
136 /* For consistency, sampling always returns color in linear space. */
137 if (tex_ibuf && tex_ibuf->float_data() == nullptr) {
138 convert_to_linear = true;
140 }
141 BKE_image_pool_release_ibuf(mtex->tex->ima, tex_ibuf, pool);
142 }
143
144 for (int i = 0; i < size; i++) {
145 /* Largely duplicated from tex_strength. */
146
147 int index = j * size + i;
148
149 float x = float(i) / size;
150 float y = float(j) / size;
151 float len;
152
153 if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
154 x *= vc->region->winx / radius;
155 y *= vc->region->winy / radius;
156 }
157 else {
158 x = (x - 0.5f) * 2.0f;
159 y = (y - 0.5f) * 2.0f;
160 }
161
162 len = sqrtf(x * x + y * y);
163
165 /* It is probably worth optimizing for those cases where the texture is not rotated by
166 * skipping the calls to atan2, sqrtf, sin, and cos. */
167 if (mtex->tex && (rotation > 0.001f || rotation < -0.001f)) {
168 const float angle = atan2f(y, x) + rotation;
169
170 x = len * cosf(angle);
171 y = len * sinf(angle);
172 }
173
174 float avg;
175 float rgba[4];
176 paint_get_tex_pixel(mtex, x, y, pool, thread_id, &avg, rgba);
177
178 if (col) {
179 if (convert_to_linear) {
181 }
182
183 linearrgb_to_srgb_v3_v3(rgba, rgba);
184
185 clamp_v4(rgba, 0.0f, 1.0f);
186
187 buffer[index * 4] = rgba[0] * 255;
188 buffer[index * 4 + 1] = rgba[1] * 255;
189 buffer[index * 4 + 2] = rgba[2] * 255;
190 buffer[index * 4 + 3] = rgba[3] * 255;
191 }
192 else {
193 avg += br->texture_sample_bias;
194
195 /* Clamp to avoid precision overflow. */
196 CLAMP(avg, 0.0f, 1.0f);
197 buffer[index] = 255 - uchar(255 * avg);
198 }
199 }
200 else {
201 if (col) {
202 buffer[index * 4] = 0;
203 buffer[index * 4 + 1] = 0;
204 buffer[index * 4 + 2] = 0;
205 buffer[index * 4 + 3] = 0;
206 }
207 else {
208 buffer[index] = 0;
209 }
210 }
211 }
212}
213
214static int load_tex(Paint *paint, Brush *br, ViewContext *vc, float zoom, bool col, bool primary)
215{
216 bool init;
218
219 MTex *mtex = (primary) ? &br->mtex : &br->mask_mtex;
221 uchar *buffer = nullptr;
222
223 int size;
224 bool refresh;
228 target = (primary) ? paint->runtime->primary_snap.get() : paint->runtime->secondary_snap.get();
229
230 refresh = !target->overlay_texture || (invalid != bke::paint::eOverlayControlFlags{}) ||
231 !same_tex_snap(target, mtex, vc, col, zoom);
232
233 init = (target->overlay_texture != nullptr);
234
235 if (refresh) {
236 ImagePool *pool = nullptr;
237 /* Stencil is rotated later. */
238 const float rotation = (mtex->brush_map_mode != MTEX_MAP_MODE_STENCIL) ? -mtex->rot : 0.0f;
239 const float radius = BKE_brush_radius_get(paint, br) * zoom;
240
241 make_tex_snap(target, vc, zoom);
242
243 if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
244 int s = BKE_brush_radius_get(paint, br);
245 int r = 1;
246
247 for (s >>= 1; s > 0; s >>= 1) {
248 r++;
249 }
250
251 size = (1 << r);
252
253 size = std::max(size, 256);
254 size = std::max(size, target->old_size);
255 }
256 else {
257 size = 512;
258 }
259
260 if (target->old_size != size || target->old_col != col) {
261 if (target->overlay_texture) {
263 target->overlay_texture = nullptr;
264 }
265 init = false;
266
267 target->old_size = size;
268 target->old_col = col;
269 }
270 if (col) {
271 buffer = MEM_new_array_uninitialized<uchar>(size * size * 4, "load_tex");
272 }
273 else {
274 buffer = MEM_new_array_uninitialized<uchar>(size * size, "load_tex");
275 }
276
277 pool = BKE_image_pool_new();
278
279 if (mtex->tex && mtex->tex->nodetree) {
280 /* Has internal flag to detect it only does it once. */
282 }
283
285 data.br = br;
286 data.vc = vc;
287 data.mtex = mtex;
288 data.buffer = buffer;
289 data.col = col;
290 data.pool = pool;
291 data.size = size;
292 data.rotation = rotation;
293 data.radius = radius;
294
295 TaskParallelSettings settings;
297 BLI_task_parallel_range(0, size, &data, load_tex_task_cb_ex, &settings);
298
299 if (mtex->tex && mtex->tex->nodetree) {
301 }
302
303 if (pool) {
305 }
306
307 if (!target->overlay_texture) {
308 gpu::TextureFormat format = col ? gpu::TextureFormat::UNORM_8_8_8_8 :
309 gpu::TextureFormat::UNORM_8;
312 "paint_cursor_overlay", size, size, 1, format, usage, nullptr);
314
315 if (!col) {
317 }
318 }
319
320 if (init) {
322 }
323
324 if (buffer) {
325 MEM_delete(buffer);
326 }
327 }
328 else {
329 size = target->old_size;
330 }
331
332 reset_overlay_flag(*paint, invalid);
333
334 return 1;
335}
336
337static void load_tex_cursor_task_cb(void *__restrict userdata,
338 const int j,
339 const TaskParallelTLS *__restrict /*tls*/)
340{
341 LoadTexData *data = static_cast<LoadTexData *>(userdata);
342 Brush *br = data->br;
343
344 uchar *buffer = data->buffer;
345
346 const int size = data->size;
347
348 for (int i = 0; i < size; i++) {
349 /* Largely duplicated from tex_strength. */
350
351 const int index = j * size + i;
352 const float x = ((float(i) / size) - 0.5f) * 2.0f;
353 const float y = ((float(j) / size) - 0.5f) * 2.0f;
354 const float len = sqrtf(x * x + y * y);
355
356 if (len <= 1.0f) {
357
358 /* Falloff curve. */
359 float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f);
360
361 buffer[index] = uchar(255 * avg);
362 }
363 else {
364 buffer[index] = 0;
365 }
366 }
367}
368
369static int load_tex_cursor(Paint *paint, Brush *br, float zoom)
370{
371 bool init;
372
374 uchar *buffer = nullptr;
375
376 int size;
377 const bool refresh = !paint->runtime->cursor_snap->overlay_texture ||
378 (flag_is_set(overlay_flags,
380 paint->runtime->cursor_snap->zoom != zoom ||
381 paint->runtime->cursor_snap->curve_preset !=
383
384 init = (paint->runtime->cursor_snap->overlay_texture != nullptr);
385
386 if (refresh) {
387 int s, r;
388
389 paint->runtime->cursor_snap->zoom = zoom;
390
392 r = 1;
393
394 for (s >>= 1; s > 0; s >>= 1) {
395 r++;
396 }
397
398 size = (1 << r);
399
400 size = std::max(size, 256);
401 size = std::max(size, paint->runtime->cursor_snap->size);
402
403 if (paint->runtime->cursor_snap->size != size) {
404 if (paint->runtime->cursor_snap->overlay_texture) {
405 GPU_texture_free(paint->runtime->cursor_snap->overlay_texture);
406 paint->runtime->cursor_snap->overlay_texture = nullptr;
407 }
408
409 init = false;
410
411 paint->runtime->cursor_snap->size = size;
412 }
413 buffer = MEM_new_array_uninitialized<uchar>(size * size, "load_tex");
414
416
418 data.br = br;
419 data.buffer = buffer;
420 data.size = size;
421
422 TaskParallelSettings settings;
425
426 if (!paint->runtime->cursor_snap->overlay_texture) {
428 paint->runtime->cursor_snap->overlay_texture = GPU_texture_create_2d(
429 "cursor_snap_overaly", size, size, 1, gpu::TextureFormat::UNORM_8, usage, nullptr);
430 GPU_texture_update(paint->runtime->cursor_snap->overlay_texture, GPU_DATA_UBYTE, buffer);
431
432 GPU_texture_swizzle_set(paint->runtime->cursor_snap->overlay_texture, "rrrr");
433 }
434
435 if (init) {
436 GPU_texture_update(paint->runtime->cursor_snap->overlay_texture, GPU_DATA_UBYTE, buffer);
437 }
438
439 if (buffer) {
440 MEM_delete(buffer);
441 }
442 }
443 else {
444 size = paint->runtime->cursor_snap->size;
445 }
446
447 paint->runtime->cursor_snap->curve_preset = br->curve_distance_falloff_preset;
449
450 return 1;
451}
452
453/* Draw an overlay that shows what effect the brush's texture will
454 * have on brush strength. */
456 Brush *brush,
457 ViewContext *vc,
458 int x,
459 int y,
460 float zoom,
461 const PaintMode mode,
462 bool col,
463 bool primary)
464{
465 rctf quad;
466 /* Check for overlay mode. */
467
468 MTex *mtex = (primary) ? &brush->mtex : &brush->mask_mtex;
469 bool valid = ((primary) ? (brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) != 0 :
470 (brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0);
471 int overlay_alpha = (primary) ? brush->texture_overlay_alpha : brush->mask_overlay_alpha;
472
473 if (mode == PaintMode::Texture3D) {
474 if (primary && brush->image_brush_type != IMAGE_PAINT_BRUSH_TYPE_DRAW) {
475 /* All non-draw tools don't use the primary texture (clone, smear, soften.. etc). */
476 return false;
477 }
478 }
479
480 if (!(mtex->tex) ||
483 {
484 return false;
485 }
486
487 bke::PaintRuntime *paint_runtime = paint->runtime;
488 if (load_tex(paint, brush, vc, zoom, col, primary)) {
489 GPU_color_mask(true, true, true, true);
491
492 if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
494
495 float center[2] = {
496 paint_runtime->draw_anchored ? paint_runtime->anchored_initial_mouse[0] : x,
497 paint_runtime->draw_anchored ? paint_runtime->anchored_initial_mouse[1] : y,
498 };
499
500 /* Brush rotation. */
503 RAD2DEGF(primary ? paint_runtime->brush_rotation : paint_runtime->brush_rotation_sec));
504 GPU_matrix_translate_2f(-center[0], -center[1]);
505
506 /* Scale based on tablet pressure. */
507 if (primary && paint_runtime->stroke_active && BKE_brush_use_size_pressure(brush)) {
508 const float scale = paint_runtime->size_pressure_value;
511 GPU_matrix_translate_2f(-center[0], -center[1]);
512 }
513
514 if (paint_runtime->draw_anchored) {
515 quad.xmin = center[0] - paint_runtime->anchored_size;
516 quad.ymin = center[1] - paint_runtime->anchored_size;
517 quad.xmax = center[0] + paint_runtime->anchored_size;
518 quad.ymax = center[1] + paint_runtime->anchored_size;
519 }
520 else {
521 const int radius = BKE_brush_radius_get(paint, brush) * zoom;
522 quad.xmin = center[0] - radius;
523 quad.ymin = center[1] - radius;
524 quad.xmax = center[0] + radius;
525 quad.ymax = center[1] + radius;
526 }
527 }
528 else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
529 quad.xmin = 0;
530 quad.ymin = 0;
531 quad.xmax = BLI_rcti_size_x(&vc->region->winrct);
532 quad.ymax = BLI_rcti_size_y(&vc->region->winrct);
533 }
534 /* Stencil code goes here. */
535 else {
536 if (primary) {
537 quad.xmin = -brush->stencil_dimension[0];
538 quad.ymin = -brush->stencil_dimension[1];
539 quad.xmax = brush->stencil_dimension[0];
540 quad.ymax = brush->stencil_dimension[1];
541 }
542 else {
543 quad.xmin = -brush->mask_stencil_dimension[0];
544 quad.ymin = -brush->mask_stencil_dimension[1];
545 quad.xmax = brush->mask_stencil_dimension[0];
546 quad.ymax = brush->mask_stencil_dimension[1];
547 }
549 if (primary) {
550 GPU_matrix_translate_2fv(brush->stencil_pos);
551 }
552 else {
553 GPU_matrix_translate_2fv(brush->mask_stencil_pos);
554 }
556 }
557
558 /* Set quad color. Colored overlay does not get blending. */
559 GPUVertFormat *format = immVertexFormat();
560 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
561 uint texCoord = GPU_vertformat_attr_add(format, "texCoord", gpu::VertAttrType::SFLOAT_32_32);
562
563 /* Premultiplied alpha blending. */
565
567
568 float final_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
569 if (!col) {
570 copy_v3_v3(final_color, U.sculpt_paint_overlay_col);
571 }
572 mul_v4_fl(final_color, overlay_alpha * 0.01f);
573 immUniformColor4fv(final_color);
574
575 gpu::Texture *texture = (primary) ? paint->runtime->primary_snap->overlay_texture :
576 paint->runtime->secondary_snap->overlay_texture;
577
582 "image", texture, {GPU_SAMPLER_FILTERING_LINEAR, extend_mode, extend_mode});
583
584 /* Draw textured quad. */
586 immAttr2f(texCoord, 0.0f, 0.0f);
587 immVertex2f(pos, quad.xmin, quad.ymin);
588 immAttr2f(texCoord, 1.0f, 0.0f);
589 immVertex2f(pos, quad.xmax, quad.ymin);
590 immAttr2f(texCoord, 1.0f, 1.0f);
591 immVertex2f(pos, quad.xmax, quad.ymax);
592 immAttr2f(texCoord, 0.0f, 1.0f);
593 immVertex2f(pos, quad.xmin, quad.ymax);
594 immEnd();
595
597
599
602 }
603 }
604 return true;
605}
606
607/* Draw an overlay that shows what effect the brush's texture will
608 * have on brush strength. */
609static bool paint_draw_cursor_overlay(Paint *paint, Brush *brush, int x, int y, float zoom)
610{
611 rctf quad;
612 /* Check for overlay mode. */
613
614 if (!(brush->overlay_flags & BRUSH_OVERLAY_CURSOR)) {
615 return false;
616 }
617
618 if (load_tex_cursor(paint, brush, zoom)) {
619 bool do_pop = false;
620 float center[2];
621
622 GPU_color_mask(true, true, true, true);
624
625 bke::PaintRuntime *paint_runtime = paint->runtime;
626 if (paint_runtime->draw_anchored) {
627 copy_v2_v2(center, paint_runtime->anchored_initial_mouse);
628 quad.xmin = paint_runtime->anchored_initial_mouse[0] - paint_runtime->anchored_size;
629 quad.ymin = paint_runtime->anchored_initial_mouse[1] - paint_runtime->anchored_size;
630 quad.xmax = paint_runtime->anchored_initial_mouse[0] + paint_runtime->anchored_size;
631 quad.ymax = paint_runtime->anchored_initial_mouse[1] + paint_runtime->anchored_size;
632 }
633 else {
634 const int radius = BKE_brush_radius_get(paint, brush) * zoom;
635 center[0] = x;
636 center[1] = y;
637
638 quad.xmin = x - radius;
639 quad.ymin = y - radius;
640 quad.xmax = x + radius;
641 quad.ymax = y + radius;
642 }
643
644 /* Scale based on tablet pressure. */
645 if (paint_runtime->stroke_active && BKE_brush_use_size_pressure(brush)) {
646 do_pop = true;
650 GPU_matrix_translate_2f(-center[0], -center[1]);
651 }
652
653 GPUVertFormat *format = immVertexFormat();
654 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
655 uint texCoord = GPU_vertformat_attr_add(format, "texCoord", gpu::VertAttrType::SFLOAT_32_32);
656
658
660
661 float final_color[4] = {UNPACK3(U.sculpt_paint_overlay_col), 1.0f};
662 mul_v4_fl(final_color, brush->cursor_overlay_alpha * 0.01f);
663 immUniformColor4fv(final_color);
664
665 /* Draw textured quad. */
666 immBindTextureSampler("image",
667 paint->runtime->cursor_snap->overlay_texture,
668 {GPU_SAMPLER_FILTERING_LINEAR,
669 GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER,
670 GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER});
671
673 immAttr2f(texCoord, 0.0f, 0.0f);
674 immVertex2f(pos, quad.xmin, quad.ymin);
675 immAttr2f(texCoord, 1.0f, 0.0f);
676 immVertex2f(pos, quad.xmax, quad.ymin);
677 immAttr2f(texCoord, 1.0f, 1.0f);
678 immVertex2f(pos, quad.xmax, quad.ymax);
679 immAttr2f(texCoord, 0.0f, 1.0f);
680 immVertex2f(pos, quad.xmin, quad.ymax);
681 immEnd();
682
683 GPU_texture_unbind(paint->runtime->cursor_snap->overlay_texture);
684
686
687 if (do_pop) {
689 }
690 }
691 return true;
692}
693
695 Paint *paint, Brush *brush, ViewContext *vc, int x, int y, float zoom, PaintMode mode)
696{
697 /* Color means that primary brush texture is colored and
698 * secondary is used for alpha/mask control. */
700
701 bool alpha_overlay_active = false;
702
704 GPUBlend blend_state = GPU_blend_get();
705 GPUDepthTest depth_test = GPU_depth_test_get();
706
707 /* Translate to region. */
710 x -= vc->region->winrct.xmin;
711 y -= vc->region->winrct.ymin;
712
713 /* Colored overlay should be drawn separately. */
714 if (col) {
715 if (!flag_is_set(flags, bke::paint::eOverlayControlFlags::OverridePrimary)) {
716 alpha_overlay_active = paint_draw_tex_overlay(
717 paint, brush, vc, x, y, zoom, mode, true, true);
718 }
720 alpha_overlay_active = paint_draw_tex_overlay(
721 paint, brush, vc, x, y, zoom, mode, false, false);
722 }
723 if (!flag_is_set(flags, bke::paint::eOverlayControlFlags::OverrideCursor)) {
724 alpha_overlay_active = paint_draw_cursor_overlay(paint, brush, x, y, zoom);
725 }
726 }
727 else {
728 if (!flag_is_set(flags, bke::paint::eOverlayControlFlags::OverridePrimary) &&
729 (mode != PaintMode::Weight))
730 {
731 alpha_overlay_active = paint_draw_tex_overlay(
732 paint, brush, vc, x, y, zoom, mode, false, true);
733 }
734 if (!flag_is_set(flags, bke::paint::eOverlayControlFlags::OverrideCursor)) {
735 alpha_overlay_active = paint_draw_cursor_overlay(paint, brush, x, y, zoom);
736 }
737 }
738
740 GPU_blend(blend_state);
741 GPU_depth_test(depth_test);
742
743 return alpha_overlay_active;
744}
745
747 const float sel_col[4],
748 const float pivot_col[4],
749 float *co,
750 float width,
751 bool selected)
752{
753 immUniformColor4fv(selected ? sel_col : pivot_col);
754
755 GPU_line_width(3.0f);
756
757 float w = width / 2.0f;
758 const float tri[3][2] = {
759 {co[0], co[1] + w},
760 {co[0] - w, co[1] - w},
761 {co[0] + w, co[1] - w},
762 };
763
765 immVertex2fv(pos, tri[0]);
766 immVertex2fv(pos, tri[1]);
767 immVertex2fv(pos, tri[2]);
768 immEnd();
769
770 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
771 GPU_line_width(1.0f);
772
774 immVertex2fv(pos, tri[0]);
775 immVertex2fv(pos, tri[1]);
776 immVertex2fv(pos, tri[2]);
777 immEnd();
778}
779
781 const float sel_col[4],
782 const float handle_col[4],
783 const float *co,
784 float width,
785 bool selected)
786{
787 immUniformColor4fv(selected ? sel_col : handle_col);
788
789 GPU_line_width(3.0f);
790
791 float w = width / 2.0f;
792 float minx = co[0] - w;
793 float miny = co[1] - w;
794 float maxx = co[0] + w;
795 float maxy = co[1] + w;
796
797 imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
798
799 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
800 GPU_line_width(1.0f);
801
802 imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
803}
804
805BLI_INLINE void draw_bezier_handle_lines(uint pos, const float sel_col[4], BezTriple *bez)
806{
807 immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
808 GPU_line_width(3.0f);
809
811 immVertex2fv(pos, bez->vec[0]);
812 immVertex2fv(pos, bez->vec[1]);
813 immVertex2fv(pos, bez->vec[2]);
814 immEnd();
815
816 GPU_line_width(1.0f);
817
818 if (bez->f1 || bez->f2) {
819 immUniformColor4fv(sel_col);
820 }
821 else {
822 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
823 }
825 immVertex2fv(pos, bez->vec[0]);
826 immVertex2fv(pos, bez->vec[1]);
827 immEnd();
828
829 if (bez->f3 || bez->f2) {
830 immUniformColor4fv(sel_col);
831 }
832 else {
833 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
834 }
836 immVertex2fv(pos, bez->vec[1]);
837 immVertex2fv(pos, bez->vec[2]);
838 immEnd();
839}
840
842{
846
847 if (brush->paint_curve && brush->paint_curve->points) {
848 PaintCurve *pc = brush->paint_curve;
849 PaintCurvePoint *cp = pc->points;
850
851 GPU_line_smooth(true);
853
854 /* Draw the bezier handles and the curve segment between the current and next point. */
855 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
856
858
859 float selec_col[4], handle_col[4], pivot_col[4];
863
864 for (int i = 0; i < pc->tot_points - 1; i++, cp++) {
865 int j;
866 PaintCurvePoint *cp_next = cp + 1;
867 float data[(PAINT_CURVE_NUM_SEGMENTS + 1) * 2];
868 /* Use color coding to distinguish handles vs curve segments. */
869 draw_bezier_handle_lines(pos, selec_col, &cp->bez);
870 draw_tri_point(pos, selec_col, pivot_col, &cp->bez.vec[1][0], 10.0f, cp->bez.f2);
872 pos, selec_col, handle_col, &cp->bez.vec[0][0], 8.0f, cp->bez.f1 || cp->bez.f2);
874 pos, selec_col, handle_col, &cp->bez.vec[2][0], 8.0f, cp->bez.f3 || cp->bez.f2);
875
876 for (j = 0; j < 2; j++) {
878 cp->bez.vec[2][j],
879 cp_next->bez.vec[0][j],
880 cp_next->bez.vec[1][j],
881 data + j,
883 sizeof(float[2]));
884 }
885
886 float (*v)[2] = reinterpret_cast<float (*)[2]>(data);
887
888 immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
889 GPU_line_width(3.0f);
891 for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
892 immVertex2fv(pos, v[j]);
893 }
894 immEnd();
895
896 immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f);
897 GPU_line_width(1.0f);
899 for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
900 immVertex2fv(pos, v[j]);
901 }
902 immEnd();
903 }
904
905 /* Draw last line segment. */
906 draw_bezier_handle_lines(pos, selec_col, &cp->bez);
907 draw_tri_point(pos, selec_col, pivot_col, &cp->bez.vec[1][0], 10.0f, cp->bez.f2);
909 pos, selec_col, handle_col, &cp->bez.vec[0][0], 8.0f, cp->bez.f1 || cp->bez.f2);
911 pos, selec_col, handle_col, &cp->bez.vec[2][0], 8.0f, cp->bez.f3 || cp->bez.f2);
912
914 GPU_line_smooth(false);
915
917 }
919}
920
921static bool paint_use_2d_cursor(PaintMode mode, const Brush &brush)
922{
923 switch (mode) {
927 return false;
929 if (!USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint)) {
930 return true;
931 }
939 return true;
942 }
943 return true;
944}
945
947 const int2 &xy,
948 const float2 &tilt,
949 PaintCursorContext &pcontext)
950{
952 ARegion *region = CTX_wm_region(C);
953 if (region && region->regiontype != RGN_TYPE_WINDOW) {
954 return false;
955 }
956
957 pcontext.region = region;
958 pcontext.wm = CTX_wm_manager(C);
959 pcontext.win = CTX_wm_window(C);
960 pcontext.screen = CTX_wm_screen(C);
962 pcontext.scene = CTX_data_scene(C);
963 pcontext.object = CTX_data_active_object(C);
965 if (pcontext.paint == nullptr) {
966 return false;
967 }
968 pcontext.ups = &pcontext.paint->unified_paint_settings;
969 pcontext.brush = BKE_paint_brush(pcontext.paint);
970 if (pcontext.brush == nullptr) {
971 return false;
972 }
974 if (pcontext.mode == PaintMode::Sculpt) {
975 pcontext.sd = CTX_data_tool_settings(C)->sculpt;
976 }
977
978 if (ELEM(pcontext.mode,
983 {
984 pcontext.base = CTX_data_active_base(C);
985 }
986
987 pcontext.vc = ED_view3d_viewcontext_init(C, pcontext.depsgraph);
988
989 if (pcontext.brush->stroke_method == BRUSH_STROKE_CURVE) {
991 }
992 else if (paint_use_2d_cursor(pcontext.mode, *pcontext.brush)) {
994 }
995 else {
997 }
998
999 pcontext.mval = xy;
1000 pcontext.translation = {float(xy[0]), float(xy[1])};
1001 pcontext.tilt = tilt;
1002
1003 float zoomx, zoomy;
1004 get_imapaint_zoom(C, &zoomx, &zoomy);
1005 pcontext.zoomx = max_ff(zoomx, zoomy);
1006 pcontext.final_radius = (BKE_brush_radius_get(pcontext.paint, pcontext.brush) * zoomx);
1007
1008 const bke::PaintRuntime &paint_runtime = *pcontext.paint->runtime;
1009 /* There is currently no way to check if the direction is inverted before starting the stroke,
1010 * so this does not reflect the state of the brush in the UI. */
1011 if ((pcontext.brush->flag & BRUSH_DIR_IN) &&
1013 {
1014 pcontext.outline_col = float3(pcontext.brush->sub_col);
1015 }
1016 else {
1017 pcontext.outline_col = float3(pcontext.brush->add_col);
1018 }
1019 pcontext.outline_alpha = pcontext.brush->add_col[3];
1020
1021 Object *active_object = pcontext.vc.obact;
1022 pcontext.ss = active_object ? active_object->runtime->sculpt_session : nullptr;
1023
1024 if (pcontext.ss && pcontext.ss->draw_faded_cursor) {
1025 pcontext.outline_alpha = 0.3f;
1026 pcontext.outline_col = float3(0.8f);
1027 }
1028
1029 const ScrArea *area = CTX_wm_area(C);
1030 pcontext.is_brush_active = paint_brush_tool_poll(area, region, pcontext.paint, pcontext.object);
1031 if (!pcontext.is_brush_active) {
1032 /* Use a default color for tools that are not brushes. */
1033 pcontext.outline_alpha = 0.8f;
1034 pcontext.outline_col = float3(0.8f);
1035 }
1036
1037 pcontext.is_stroke_active = paint_runtime.stroke_active;
1038
1039 return true;
1040}
1041
1043{
1044 if (pcontext.win->grabcursor != 0 || pcontext.win->modalcursor != 0) {
1045 /* Don't set the cursor while it's grabbed, since this will show the cursor when interacting
1046 * with the UI (dragging a number button for example), see: #102792.
1047 * And don't overwrite a modal cursor, allowing modal operators to set a cursor temporarily. */
1048 return;
1049 }
1050
1051 /* Don't set the cursor when a temporary popup is opened (e.g. a context menu, pie menu or
1052 * dialog), see: #137386. */
1053 if (!pcontext.screen->regionbase.is_empty() &&
1055 {
1056 return;
1057 }
1058
1060 WM_cursor_set(pcontext.win, WM_CURSOR_DOT);
1061 }
1062 else {
1063 /* Don't use paint cursor when overlapping with the size circle. */
1064 const int brush_size = BKE_brush_size_get(pcontext.paint, pcontext.brush);
1065 const bool small = brush_size < 28 && brush_size > 12;
1066 WM_cursor_set(pcontext.win, small ? WM_CURSOR_DOT : WM_CURSOR_PAINT);
1067 }
1068}
1069
1071{
1073 const bke::PaintRuntime *paint_runtime = pcontext.paint->runtime;
1074
1075 /* Draw brush outline. */
1076 if (paint_runtime->stroke_active && BKE_brush_use_size_pressure(pcontext.brush)) {
1078 pcontext.translation[0],
1079 pcontext.translation[1],
1080 pcontext.final_radius * paint_runtime->size_pressure_value,
1081 40);
1082 /* Outer at half alpha. */
1083 immUniformColor3fvAlpha(pcontext.outline_col, pcontext.outline_alpha * 0.5f);
1084 }
1085
1086 GPU_line_width(1.0f);
1088 pcontext.pos, pcontext.translation[0], pcontext.translation[1], pcontext.final_radius, 40);
1089}
1090
1092{
1094 switch (pcontext.mode) {
1095 case PaintMode::GPencil:
1097 grease_pencil_cursor_draw(pcontext);
1098 break;
1099 default:
1101 }
1102}
1103
1105{
1107 GPU_line_width(1.0f);
1110 pcontext.pos, pcontext.translation[0], pcontext.translation[1], pcontext.final_radius, 40);
1111}
1112
1114{
1115 BLI_assert(ELEM(pcontext.mode,
1120 /* These paint tools are not using the SculptSession, so they need to use the default 2D brush
1121 * cursor in the 3D view. */
1122 if (!USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint) && pcontext.mode == PaintMode::Texture3D) {
1124 return;
1125 }
1126
1127 BLI_assert(pcontext.ss);
1128
1130
1131 if (pcontext.is_stroke_active) {
1132 mesh_cursor_active_draw(pcontext);
1133 }
1134 else {
1135 const Brush &brush = *pcontext.brush;
1136 /* 2D falloff is better represented with the default 2D cursor,
1137 * there is no need to draw anything else. */
1138 if (brush.falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
1140 return;
1141 }
1142 if (pcontext.alpha_overlay_drawn) {
1144 return;
1145 }
1146
1147 mesh_cursor_inactive_draw(pcontext);
1148 }
1149}
1150
1152{
1153 const ViewContext *vc = &pcontext.vc;
1154 return vc->rv3d && (vc->rv3d->rflag & RV3D_NAVIGATING);
1155}
1156
1158{
1159 if (pcontext.paint->flags & PAINT_SHOW_BRUSH) {
1162 {
1163 return false;
1164 }
1165 return true;
1166 }
1167 return false;
1168}
1169
1171{
1173 /* Don't calculate rake angles while a stroke is active because the rake variables are global
1174 * and we may get interference with the stroke itself.
1175 * For line strokes, such interference is visible. */
1176
1177 const bke::PaintRuntime *paint_runtime = pcontext.paint->runtime;
1178
1179 ARegion *region = pcontext.vc.region;
1180 float2 mouse = {pcontext.translation.x - region->winrct.xmin,
1181 pcontext.translation.y - region->winrct.ymin};
1182 if (!paint_runtime->stroke_active) {
1184 *pcontext.paint, *pcontext.brush, mouse, pcontext.mode, false, false);
1185 }
1186}
1187
1189{
1191 pcontext.alpha_overlay_drawn = pcontext.is_brush_active &&
1193 pcontext.brush,
1194 &pcontext.vc,
1195 pcontext.mval.x,
1196 pcontext.mval.y,
1197 pcontext.zoomx,
1198 pcontext.mode);
1199}
1200
1202{
1203 bke::PaintRuntime *paint_runtime = pcontext.paint->runtime;
1204 if (paint_runtime->draw_anchored) {
1205 pcontext.final_radius = paint_runtime->anchored_size;
1206 pcontext.translation = {
1207 paint_runtime->anchored_initial_mouse[0] + pcontext.region->winrct.xmin,
1208 paint_runtime->anchored_initial_mouse[1] + pcontext.region->winrct.ymin};
1209 }
1210}
1211
1213{
1214 GPU_line_width(2.0f);
1216 GPU_line_smooth(true);
1217 pcontext.pos = GPU_vertformat_attr_add(
1218 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
1220}
1221
1223{
1224 GPU_line_width(2.0f);
1226 GPU_line_smooth(true);
1227 pcontext.pos = GPU_vertformat_attr_add(
1228 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
1230}
1231
1238
1239static void paint_draw_cursor(bContext *C, const int2 &xy, const float2 &tilt, void * /*unused*/)
1240{
1242 PaintCursorContext pcontext;
1243 if (!paint_cursor_context_init(C, xy, tilt, pcontext)) {
1244 return;
1245 }
1246
1247 if (!paint_cursor_is_brush_cursor_enabled(pcontext)) {
1248 /* For Grease Pencil draw mode, we want to we only render a small mouse cursor (dot) if the
1249 * paint cursor is disabled so that the default mouse cursor doesn't get in the way of tablet
1250 * users. See #130089. But don't overwrite a modal cursor, allowing modal operators to set one
1251 * temporarily. */
1252 if (pcontext.mode == PaintMode::GPencil && pcontext.win->modalcursor == 0) {
1253 WM_cursor_set(pcontext.win, WM_CURSOR_DOT);
1254 }
1255 return;
1256 }
1257 if (paint_cursor_is_3d_view_navigating(pcontext)) {
1258 /* Still draw stencil while navigating. */
1260 return;
1261 }
1262
1263 switch (pcontext.cursor_type) {
1265 paint_draw_curve_cursor(pcontext.brush, &pcontext.vc);
1266 break;
1268 paint_update_mouse_cursor(pcontext);
1269
1273
1277 break;
1279 paint_update_mouse_cursor(pcontext);
1280
1284
1288 break;
1289 default:
1291 }
1292}
1293
1294} // namespace ed::sculpt_paint
1295
1296/* Public API */
1297
1299{
1300 if (paint && paint->runtime && !paint->runtime->paint_cursor) {
1301 paint->runtime->paint_cursor = WM_paint_cursor_activate(
1303 }
1304
1305 if (paint) {
1306 /* Invalidate the paint cursors. */
1308 }
1309}
1310
1311} // namespace blender
#define RAD2DEGF(_rad)
Object is a sort of wrapper for general info.
#define RGN_TYPE_ANY
#define SPACE_TYPE_ANY
#define USER_EXPERIMENTAL_TEST(userdef, member)
Read Blender memory allocation and freeing.
#define PRF_scope(category)
#define C
Definition RandGen.cpp:29
#define CLAMP(a, b, c)
#define BLI_assert_unreachable()
#define BLI_INLINE
#define UNPACK3(a)
#define ELEM(...)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
bool supports_secondary_cursor_color(const Brush &brush)
Definition brush.cc:2028
bool implements_3d_texture_paint(const Brush &brush)
Definition brush.cc:1850
void invalidate_overlay_all(Scene &scene)
eOverlayControlFlags get_overlay_flags(const Paint &paint)
void mesh_cursor_inactive_draw(PaintCursorContext &pcontext)
static void paint_draw_2D_view_brush_cursor(PaintCursorContext &pcontext)
static void load_tex_cursor_task_cb(void *__restrict userdata, const int j, const TaskParallelTLS *__restrict)
static void load_tex_task_cb_ex(void *__restrict userdata, const int j, const TaskParallelTLS *__restrict tls)
static void paint_update_mouse_cursor(PaintCursorContext &pcontext)
static bool paint_draw_cursor_overlay(Paint *paint, Brush *brush, int x, int y, float zoom)
static void paint_cursor_draw_3D_view_brush_cursor(PaintCursorContext &pcontext)
static int load_tex(Paint *paint, Brush *br, ViewContext *vc, float zoom, bool col, bool primary)
static void paint_cursor_restore_drawing_state()
BLI_INLINE void draw_bezier_handle_lines(uint pos, const float sel_col[4], BezTriple *bez)
static void paint_cursor_update_anchored_location(PaintCursorContext &pcontext)
void grease_pencil_cursor_draw(PaintCursorContext &pcontext)
static void paint_cursor_update_rake_rotation(PaintCursorContext &pcontext)
static bool paint_cursor_is_3d_view_navigating(const PaintCursorContext &pcontext)
void mesh_cursor_active_draw(PaintCursorContext &pcontext)
BLI_INLINE void draw_tri_point(uint pos, const float sel_col[4], const float pivot_col[4], float *co, float width, bool selected)
BLI_INLINE void draw_rect_point(uint pos, const float sel_col[4], const float handle_col[4], const float *co, float width, bool selected)
static void paint_cursor_setup_3D_drawing(PaintCursorContext &pcontext)
static void paint_cursor_check_and_draw_alpha_overlays(PaintCursorContext &pcontext)
static bool paint_cursor_is_brush_cursor_enabled(const PaintCursorContext &pcontext)
static void paint_cursor_setup_2D_drawing(PaintCursorContext &pcontext)
static void paint_draw_cursor(bContext *C, const int2 &xy, const float2 &tilt, void *)
static bool paint_draw_alpha_overlay(Paint *paint, Brush *brush, ViewContext *vc, int x, int y, float zoom, PaintMode mode)
static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
void mesh_cursor_update_and_init(PaintCursorContext &pcontext)
static int load_tex_cursor(Paint *paint, Brush *br, float zoom)
static void make_tex_snap(bke::paint::TexSnapshot *snap, ViewContext *vc, float zoom)
static bool paint_use_2d_cursor(PaintMode mode, const Brush &brush)
static int same_tex_snap(bke::paint::TexSnapshot *snap, MTex *mtex, ViewContext *vc, bool col, float zoom)
static void paint_draw_legacy_3D_view_brush_cursor(PaintCursorContext &pcontext)
static bool paint_cursor_context_init(bContext *C, const int2 &xy, const float2 &tilt, PaintCursorContext &pcontext)
static void paint_draw_2D_view_brush_cursor_default(PaintCursorContext &pcontext)
bool paint_brush_tool_poll(bContext *C)
static bool paint_draw_tex_overlay(Paint *paint, Brush *brush, ViewContext *vc, int x, int y, float zoom, const PaintMode mode, bool col, bool primary)
void get_color_type_4fv(int colorid, int spacetype, float col[4])
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
struct bNodeTreeExec * ntreeTexBeginExecTree(struct bNodeTree *ntree)
ScrArea * CTX_wm_area(const bContext *C)
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void immEnd()
void GPU_matrix_scale_1f(float factor)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BKE_paint_calculate_rake_rotation(Paint &paint, const Brush &brush, const float mouse_pos[2], PaintMode paint_mode, bool in_stroke, bool is_first_dab)
GPUDepthTest GPU_depth_test_get()
Definition gpu_state.cc:229
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
GPUVertFormat * immVertexFormat()
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1366
@ PAINT_FALLOFF_SHAPE_TUBE
void immBegin(GPUPrimType, uint vertex_len)
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:80
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
@ GPU_SAMPLER_FILTERING_LINEAR
wmWindow * CTX_wm_window(const bContext *C)
@ TH_VERTEX_SELECT
@ TH_GIZMO_SECONDARY
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
void GPU_matrix_rotate_2d(float deg)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void immUniformColor4fv(const float rgba[4])
void immAttr2f(uint attr_id, float x, float y)
Base * CTX_data_active_base(const bContext *C)
void immUnbindProgram()
void ED_paint_cursor_start(Paint *paint, bool(*poll)(bContext *C))
void GPU_line_width(float width)
Definition gpu_state.cc:151
void GPU_matrix_scale_2f(float x, float y)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:91
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
void BKE_curvemapping_init(CurveMapping *cumap)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
@ GPU_DEPTH_NONE
Definition GPU_state.hh:132
void immVertex2f(uint attr_id, float x, float y)
unsigned char uchar
Definition BKE_text.h:58
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
BMesh const char void * data
wmWindowManager * CTX_wm_manager(const bContext *C)
void GPU_texture_swizzle_set(gpu::Texture *texture, const char swizzle[4])
void GPU_color_mask(bool r, bool g, bool b, bool a)
Definition gpu_state.cc:95
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_FILL
void immUniformColor4f(float r, float g, float b, float a)
void ntreeTexEndExecTree(struct bNodeTreeExec *exec)
int BKE_brush_size_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1356
MINLINE void clamp_v4(float vec[4], float min, float max)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool paint_get_tex_pixel(const MTex *mtex, float u, float v, ImagePool *pool, int thread, float *r_intensity, float r_rgba[4])
int BLI_task_parallel_thread_id(const TaskParallelTLS *tls)
void BKE_image_pool_free(ImagePool *pool)
void GPU_matrix_translate_2f(float x, float y)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, wmPaintCursorPoll poll, wmPaintCursorDraw draw, void *customdata)
void immBindTextureSampler(const char *name, gpu::Texture *tex, GPUSamplerState state)
bool BKE_brush_use_size_pressure(const Brush *brush)
Definition brush.cc:1380
float BKE_brush_curve_strength_clamped(const Brush *br, float p, float len)
Definition brush.cc:1751
@ WM_CURSOR_PAINT
Definition wm_cursors.hh:29
@ WM_CURSOR_DOT
Definition wm_cursors.hh:30
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
GPUBlend GPU_blend_get()
Definition gpu_state.cc:211
Paint * BKE_paint_get_active_from_context(const bContext *C)
MINLINE float max_ff(float a, float b)
void GPU_texture_free(gpu::Texture *texture)
Brush * BKE_paint_brush(Paint *paint)
void GPU_texture_unbind(gpu::Texture *texture)
void GPU_matrix_translate_2fv(const float vec[2])
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
void WM_cursor_set(wmWindow *win, int curs)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
MINLINE void mul_v4_fl(float r[4], float f)
VecBase< float, 3 > float3
@ BRUSH_OVERLAY_SECONDARY
@ BRUSH_OVERLAY_PRIMARY
ImBuf * BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
void immVertex2fv(uint attr_id, const float data[2])
void GPU_matrix_pop()
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
Definition curve.cc:1696
void immUniformColor3fvAlpha(const float rgb[3], float a)
ARegion * BKE_screen_find_region_type(const bScreen *screen, int region_type) ATTR_NONNULL(1)
Definition screen.cc:1069
void GPU_depth_test(GPUDepthTest test)
Definition gpu_state.cc:70
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_matrix_push()
ocio::ColorSpace ColorSpace
Definition BLF_api.hh:42
vector snap(vector a, vector b)
Definition node_math.h:147
#define PAINT_CURVE_NUM_SEGMENTS
#define sqrtf
#define sinf
#define cosf
#define atan2f
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eRegion_Type regiontype
eBezTriple_Flag f2
eBezTriple_Flag f3
eBezTriple_Flag f1
eBrushImagePaintType image_brush_type
struct MTex mask_mtex
eBrushCurvePreset curve_distance_falloff_preset
struct CurveMapping * curve_distance_falloff
eBrushStrokeType stroke_method
const ColorSpace * colorspace
ImBufByteBuffer byte_buffer
const float * float_data() const
eMTex_BrushMapMode brush_map_mode
bke::ObjectRuntime * runtime
PaintCurvePoint * points
struct UnifiedPaintSettings unified_paint_settings
bke::PaintRuntime * runtime
eRegionView3D_Flag rflag
struct ImageUser iuser
struct Image * ima
struct bNodeTree * nodetree
RegionView3D * rv3d
Definition ED_view3d.hh:86
bke::bNodeTreeRuntime * runtime
ListBaseT< ARegion > regionbase