Blender V5.3
paint_image.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#include <cfloat>
11#include <cmath>
12#include <cstdio>
13#include <cstring>
14
15#include "DNA_space_types.h"
16#include "MEM_guardedalloc.h"
17
18#include "BLI_listbase.hh"
19#include "BLI_math_color_c.hh"
20#include "BLI_math_vector.hh"
21#include "BLI_rand.hh"
22#include "BLI_string.hh"
23#include "BLI_utildefines.hh"
24
25#include "IMB_imbuf.hh"
26#include "IMB_imbuf_types.hh"
27#include "IMB_partial_update.hh"
28
29#include "DNA_brush_types.h"
30#include "DNA_material_types.h"
31#include "DNA_mesh_types.h"
32#include "DNA_node_types.h"
33#include "DNA_object_types.h"
34#include "DNA_scene_types.h"
35
36#include "BKE_brush.hh"
37#include "BKE_colorband.hh"
38#include "BKE_context.hh"
39#include "BKE_image.hh"
40#include "BKE_image_gpu.hh"
41#include "BKE_library.hh"
42#include "BKE_main.hh"
43#include "BKE_material.hh"
44#include "BKE_mesh.hh"
45#include "BKE_node_runtime.hh"
46#include "BKE_object.hh"
47#include "BKE_paint.hh"
48#include "BKE_paint_types.hh"
49#include "BKE_scene.hh"
50
51#include "NOD_texture.h"
52
53#include "DEG_depsgraph.hh"
55
56#include "UI_view2d.hh"
57
58#include "ED_grease_pencil.hh"
59#include "ED_image.hh"
60#include "ED_object.hh"
61#include "ED_paint.hh"
62#include "ED_screen.hh"
63
64#include "WM_api.hh"
65#include "WM_message.hh"
66#include "WM_toolsystem.hh"
67#include "WM_types.hh"
68
69#include "RNA_access.hh"
70#include "RNA_define.hh"
71
73
74#include "mesh_paint.hh"
75
76#include "../paint_intern.hh"
77
78namespace blender {
79
80/* -------------------------------------------------------------------- */
83
90
95
100
101/* Image paint Partial Redraw & Dirty Region. */
102
107
109 ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
110{
111 int srcx = 0, srcy = 0;
112
113 IMB_rectclip(ibuf, nullptr, &x, &y, &srcx, &srcy, &w, &h);
114
115 *tw = ((x + w - 1) >> ED_IMAGE_UNDO_TILE_BITS);
116 *th = ((y + h - 1) >> ED_IMAGE_UNDO_TILE_BITS);
117 *tx = (x >> ED_IMAGE_UNDO_TILE_BITS);
118 *ty = (y >> ED_IMAGE_UNDO_TILE_BITS);
119}
120
122 Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h)
123{
124 int tilex, tiley, tilew, tileh, tx, ty;
125 int srcx = 0, srcy = 0;
126
127 IMB_rectclip(ibuf, nullptr, &x, &y, &srcx, &srcy, &w, &h);
128
129 if (w == 0 || h == 0) {
130 return;
131 }
132
133 rcti rect_to_merge;
134 BLI_rcti_init(&rect_to_merge, x, x + w, y, y + h);
136
137 imapaint_region_tiles(ibuf, x, y, w, h, &tilex, &tiley, &tilew, &tileh);
138
140
141 for (ty = tiley; ty <= tileh; ty++) {
142 for (tx = tilex; tx <= tilew; tx++) {
143 ED_image_paint_tile_push(undo_tiles, ima, ibuf, iuser, tx, ty, nullptr, nullptr);
144 }
145 }
146
147 IMB_mark_dirty(ibuf);
148}
149
151{
152 if (ibuf == nullptr || BLI_rcti_is_empty(&imapaintpartial.dirty_region)) {
153 return;
154 }
155
156 /* When buffer is partial updated the planes should be set to a larger value than 8. This will
157 * make sure that partial updating is working but uses more GPU memory as the gpu texture will
158 * have 4 channels. When so the whole texture needs to be re-uploaded to the GPU using the new
159 * texture format. */
160 if (ibuf->color_mode == ImColorMode::BW) {
163 return;
164 }
165
167}
168
170
171/* -------------------------------------------------------------------- */
174
176{
177 int i, j;
178 BlurKernel *kernel = MEM_new<BlurKernel>("BlurKernel");
179
180 float radius;
181 int side;
182 eBlurKernelType type = static_cast<eBlurKernelType>(br->blur_mode);
183
184 if (proj) {
185 radius = 0.5f;
186
187 side = kernel->side = 2;
188 kernel->side_squared = kernel->side * kernel->side;
189 kernel->wdata = MEM_new_array_uninitialized<float>(kernel->side_squared, "blur kernel data");
190 kernel->pixel_len = radius;
191 }
192 else {
193 if (br->blur_kernel_radius <= 0) {
194 br->blur_kernel_radius = 1;
195 }
196
197 radius = br->blur_kernel_radius;
198
199 side = kernel->side = radius * 2 + 1;
200 kernel->side_squared = kernel->side * kernel->side;
201 kernel->wdata = MEM_new_array_uninitialized<float>(kernel->side_squared, "blur kernel data");
202 kernel->pixel_len = br->blur_kernel_radius;
203 }
204
205 switch (type) {
206 case KERNEL_BOX:
207 for (i = 0; i < kernel->side_squared; i++) {
208 kernel->wdata[i] = 1.0;
209 }
210 break;
211
212 case KERNEL_GAUSSIAN: {
213 /* at 3.0 standard deviations distance, kernel is about zero */
214 float standard_dev = radius / 3.0f;
215
216 /* make the necessary adjustment to the value for use in the normal distribution formula */
217 standard_dev = -standard_dev * standard_dev * 2;
218
219 for (i = 0; i < side; i++) {
220 for (j = 0; j < side; j++) {
221 float idist = radius - i;
222 float jdist = radius - j;
223 float value = exp((idist * idist + jdist * jdist) / standard_dev);
224
225 kernel->wdata[i + j * side] = value;
226 }
227 }
228
229 break;
230 }
231
232 default:
233 printf("unidentified kernel type, aborting\n");
235 MEM_delete(kernel);
236 return nullptr;
237 }
238
239 return kernel;
240}
241
243{
244 if (kernel->wdata) {
245 MEM_delete(kernel->wdata);
246 }
247}
248
250
251/* -------------------------------------------------------------------- */
254
256{
257 Scene *scene = CTX_data_scene(C);
258 ToolSettings *settings = scene->toolsettings;
259
260 return BKE_paint_brush(&settings->imapaint.paint);
261}
262
263static bool image_paint_poll_ex(bContext *C, bool check_tool)
264{
265 if (!image_paint_brush(C)) {
266 return false;
267 }
268
269 if (SpaceImage *sima = CTX_wm_space_image(C)) {
270 if (sima->image != nullptr &&
271 (!ID_IS_EDITABLE(sima->image) || ID_IS_OVERRIDE_LIBRARY(sima->image)))
272 {
273 return false;
274 }
275 if (sima->mode == SI_MODE_PAINT) {
276 const ARegion *region = CTX_wm_region(C);
277 if (region->regiontype == RGN_TYPE_WINDOW) {
278 if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) {
279 return true;
280 }
281 }
282 }
283 }
284 else {
286 if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
287 if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) {
288 return true;
289 }
290 }
291 }
292
293 return false;
294}
295
297{
298 return image_paint_poll_ex(C, true);
299}
300
302{
303 return image_paint_poll_ex(C, false);
304}
305
307{
308 const Scene *scene = CTX_data_scene(C);
309 const ToolSettings *settings = scene->toolsettings;
310 const ImagePaintSettings &image_paint_settings = settings->imapaint;
312
314 if (brush && (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_CLONE)) {
315 if (image_paint_settings.clone) {
316 return true;
317 }
318 }
319 }
320
321 return false;
322}
323
325
326/* -------------------------------------------------------------------- */
329
331{
332 return ((ELEM(brush->stroke_method,
336 ELEM(brush->image_brush_type,
339 (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_FILL) ||
340 (brush->flag & BRUSH_USE_GRADIENT) ||
342 (brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode,
346 false :
347 true);
348}
349
351 Brush *br,
352 std::optional<float3> &initial_hsv_jitter,
353 bool invert,
354 float distance,
355 float pressure,
356 float r_color[3])
357{
358 if (invert) {
360 }
361 else {
362 const std::optional<BrushColorJitterSettings> color_jitter_settings =
364 if (br->flag & BRUSH_USE_GRADIENT) {
365 float color_gr[4];
366 switch (br->gradient_stroke_mode) {
368 BKE_colorband_evaluate(br->gradient, pressure, color_gr);
369 break;
371 float coord = fmod(distance / br->gradient_spacing, 1.0);
372 BKE_colorband_evaluate(br->gradient, coord, color_gr);
373 break;
374 }
377 break;
378 }
379 }
380 copy_v3_v3(r_color, color_gr);
381 }
382 else if (color_jitter_settings) {
383 /* Perform color jitter with sRGB transfer function. This is inconsistent with other
384 * paint modes which do it in linear space. But arguably it's better to do it in the
385 * more perceptually uniform color space. */
389 *color_jitter_settings, *initial_hsv_jitter, distance, pressure, color);
391 }
392 else {
393 copy_v3_v3(r_color, BKE_brush_color_get(paint, br));
394 }
395 }
396}
397
399{
400 /* init mtex nodes */
401 if (brush) {
402 MTex *mtex = &brush->mtex;
403 if (mtex->tex && mtex->tex->nodetree) {
404 /* has internal flag to detect it only does it once */
406 }
407 mtex = &brush->mask_mtex;
408 if (mtex->tex && mtex->tex->nodetree) {
410 }
411 }
412}
413
415{
416 if (brush) {
417 MTex *mtex = &brush->mtex;
418 if (mtex->tex && mtex->tex->nodetree) {
420 }
421 mtex = &brush->mask_mtex;
422 if (mtex->tex && mtex->tex->nodetree) {
424 }
425 }
426}
427
428bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
429{
430 ScrArea *area = CTX_wm_area(C);
431 if (area && area->spacetype == SPACE_IMAGE) {
432 SpaceImage *sima = area->spacedata.first_as<SpaceImage>();
433 if (sima->mode == SI_MODE_PAINT) {
434 ARegion *region = CTX_wm_region(C);
435 ED_space_image_get_zoom(sima, region, zoomx, zoomy);
436 return true;
437 }
438 }
439
440 *zoomx = *zoomy = 1;
441
442 return false;
443}
444
446
447/* -------------------------------------------------------------------- */
450
451static void toggle_paint_cursor(Scene &scene, bool enable)
452{
453 ToolSettings *settings = scene.toolsettings;
454 Paint &p = settings->imapaint.paint;
455
456 if (p.runtime->paint_cursor && !enable) {
458 p.runtime->paint_cursor = nullptr;
460 }
461 else if (enable) {
463 }
464}
465
467{
468 ToolSettings *settings = scene->toolsettings;
469 ImagePaintSettings *imapaint = &settings->imapaint;
470 bool enabled = false;
471
472 for (wmWindow &win : wm->windows) {
473 bScreen *screen = WM_window_get_active_screen(&win);
474
475 for (ScrArea &area : screen->areabase) {
476 if (area.spacetype == SPACE_IMAGE) {
477 if ((area.spacedata.first_as<SpaceImage>())->mode == SI_MODE_PAINT) {
478 enabled = true;
479 }
480 }
481 }
482 }
483
484 if (enabled) {
486
488 }
489 else {
491 }
492}
493
495
496/* -------------------------------------------------------------------- */
499
500struct GrabClone {
501 float startoffset[2];
503};
504
506{
507 const Scene *scene = CTX_data_scene(C);
508 ToolSettings *settings = scene->toolsettings;
509 ImagePaintSettings &image_paint_settings = settings->imapaint;
510 float delta[2];
511
512 RNA_float_get_array(op->ptr, "delta", delta);
513 add_v2_v2(image_paint_settings.clone_offset, delta);
515}
516
523
525{
526 const Scene *scene = CTX_data_scene(C);
527 const ToolSettings *settings = scene->toolsettings;
528 const ImagePaintSettings &image_paint_settings = settings->imapaint;
529 GrabClone *cmv;
530
531 cmv = MEM_new_zeroed<GrabClone>("GrabClone");
532 copy_v2_v2(cmv->startoffset, image_paint_settings.clone_offset);
533 cmv->startx = event->xy[0];
534 cmv->starty = event->xy[1];
535 op->customdata = cmv;
536
538
540}
541
543{
544 const Scene *scene = CTX_data_scene(C);
545 ToolSettings *settings = scene->toolsettings;
546 ImagePaintSettings &image_paint_settings = settings->imapaint;
547 ARegion *region = CTX_wm_region(C);
548 GrabClone *cmv = static_cast<GrabClone *>(op->customdata);
549 float startfx, startfy, fx, fy, delta[2];
550 int xmin = region->winrct.xmin, ymin = region->winrct.ymin;
551
552 switch (event->type) {
553 case LEFTMOUSE:
554 case MIDDLEMOUSE:
555 case RIGHTMOUSE: /* XXX hardcoded */
556 MEM_delete(cmv);
557 return OPERATOR_FINISHED;
558 case MOUSEMOVE:
559 /* mouse moved, so move the clone image */
561 &region->v2d, cmv->startx - xmin, cmv->starty - ymin, &startfx, &startfy);
562 ui::view2d_region_to_view(&region->v2d, event->xy[0] - xmin, event->xy[1] - ymin, &fx, &fy);
563
564 delta[0] = fx - startfx;
565 delta[1] = fy - startfy;
566 RNA_float_set_array(op->ptr, "delta", delta);
567
568 copy_v2_v2(image_paint_settings.clone_offset, cmv->startoffset);
569
570 grab_clone_apply(C, op);
571 break;
572 default: {
573 break;
574 }
575 }
576
578}
579
580static void grab_clone_cancel(bContext * /*C*/, wmOperator *op)
581{
582 GrabClone *cmv = static_cast<GrabClone *>(op->customdata);
583 MEM_delete(cmv);
584}
585
587{
588 /* identifiers */
589 ot->name = "Grab Clone";
590 ot->idname = "PAINT_OT_grab_clone";
591 ot->description = "Move the clone source image";
592
593 /* API callbacks. */
594 ot->exec = grab_clone_exec;
599
600 /* flags */
602
603 /* properties */
605 "delta",
606 2,
607 nullptr,
608 -FLT_MAX,
609 FLT_MAX,
610 "Delta",
611 "Delta offset of clone image in 0.0 to 1.0 coordinates",
612 -1.0f,
613 1.0f);
614}
615
617
618/* -------------------------------------------------------------------- */
621
623 Scene &scene,
624 Depsgraph &depsgraph,
625 Object &ob)
626{
627 Image *ima = nullptr;
628 ImagePaintSettings &imapaint = scene.toolsettings->imapaint;
629
630 /* This has to stay here to regenerate the texture paint
631 * cache in case we are loading a file */
633
634 ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
635
636 /* entering paint mode also sets image to editors */
637 if (imapaint.mode == IMAGEPAINT_MODE_MATERIAL) {
638 /* set the current material active paint slot on image editor */
640
641 if (ma && ma->texpaintslot) {
642 ima = ma->texpaintslot[ma->paint_active_slot].ima;
643 }
644 }
645 else if (imapaint.mode == IMAGEPAINT_MODE_IMAGE) {
646 ima = imapaint.canvas;
647 }
648
649 if (ima) {
650 ED_space_image_sync(&bmain, ima, false);
651 }
652
653 if (USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint)) {
655 }
656 else {
658 BKE_paint_init(&bmain, &scene, PaintMode::Texture3D);
659 BKE_paint_brushes_validate(&bmain, &imapaint.paint);
660 toggle_paint_cursor(scene, true);
661
663 BLI_assert(mesh != nullptr);
665
666 /* Ensure we have evaluated data for bounding box. */
667 BKE_scene_graph_evaluated_ensure(&depsgraph, &bmain);
668
669 /* Set pivot to bounding box center. */
670 Object *ob_eval = DEG_get_evaluated(&depsgraph, &ob);
671 paint_init_pivot(ob_eval ? ob_eval : &ob, &scene, &imapaint.paint);
672 }
673
675}
676
678{
679 Main &bmain = *CTX_data_main(C);
681 Scene &scene = *CTX_data_scene(C);
682 Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
683
684 ED_object_texture_paint_mode_enter_ex(bmain, scene, depsgraph, ob);
685}
686
688{
689 if (USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint)) {
691 }
692 else {
694
695 toggle_paint_cursor(scene, false);
696 }
697
699 BLI_assert(mesh != nullptr);
702}
703
711
713{
715 if (ob == nullptr || ob->type != OB_MESH) {
716 return false;
717 }
718 if (ob->data == nullptr || !ID_IS_EDITABLE(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) {
719 return false;
720 }
721
722 return true;
723}
724
726{
727 using namespace blender::ed;
729 Main &bmain = *CTX_data_main(C);
730 Scene &scene = *CTX_data_scene(C);
732 const int mode_flag = OB_MODE_TEXTURE_PAINT;
733 const bool is_mode_set = (ob.mode & mode_flag) != 0;
734
735 if (!is_mode_set) {
736 if (!object::mode_compat_set(C, &ob, eObjectMode(mode_flag), op->reports)) {
737 return OPERATOR_CANCELLED;
738 }
739 }
740
741 if (ob.mode & mode_flag) {
742 ED_object_texture_paint_mode_exit_ex(bmain, scene, ob);
743 }
744 else {
745 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
746 ED_object_texture_paint_mode_enter_ex(bmain, scene, *depsgraph, ob);
747 }
748
749 WM_msg_publish_rna_prop(mbus, &ob.id, &ob, Object, mode);
750
752
753 return OPERATOR_FINISHED;
754}
755
757{
758 /* identifiers */
759 ot->name = "Texture Paint Mode";
760 ot->idname = "PAINT_OT_texture_paint_toggle";
761 ot->description = "Toggle texture paint mode in 3D view";
762
763 /* API callbacks. */
766
767 /* flags */
769}
770
772
773/* -------------------------------------------------------------------- */
776
778{
781
783 UnifiedPaintSettings &ups = paint->unified_paint_settings;
786 }
787 else if (br) {
791 }
792 else {
793 return OPERATOR_CANCELLED;
794 }
795
797
798 return OPERATOR_FINISHED;
799}
800
802{
806 return true;
807 }
808 }
809 else {
811 if (ob != nullptr) {
813 return true;
814 }
817 {
818 return true;
819 }
820 }
821 }
822 return false;
823}
824
826{
827 /* identifiers */
828 ot->name = "Swap Colors";
829 ot->idname = "PAINT_OT_brush_colors_flip";
830 ot->description = "Swap primary and secondary brush colors";
831
832 /* API callbacks. */
835
836 /* flags */
837 ot->flag = OPTYPE_REGISTER;
838}
839
841
842/* -------------------------------------------------------------------- */
845
846void ED_imapaint_bucket_fill(bContext *C, float const color[3], wmOperator *op, const int mouse[2])
847{
849
850 if (sima && sima->image) {
851 Image *ima = sima->image;
852
854
855 const float mouse_init[2] = {float(mouse[0]), float(mouse[1])};
856 paint_2d_bucket_fill(C, color, nullptr, mouse_init, nullptr, nullptr);
857
859
860 DEG_id_tag_update(&ima->id, 0);
861 }
862}
863
865{
868 return true;
869 }
870 }
871
872 return false;
873}
874
880
889
894
899
904
906
907} // namespace blender
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object is a sort of wrapper for general info.
#define IMAGEPAINT_MODE_IMAGE
#define IMAGEPAINT_MODE_MATERIAL
#define USER_EXPERIMENTAL_TEST(userdef, member)
#define ED_IMAGE_UNDO_TILE_BITS
Definition ED_paint.hh:115
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NC_BRUSH
Definition WM_types.hh:398
#define ND_MODE
Definition WM_types.hh:464
#define NC_SCENE
Definition WM_types.hh:391
#define NA_EDITED
Definition WM_types.hh:634
#define ELEM(...)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
static RandomNumberGenerator from_random_seed()
Definition rand.cc:288
#define FLT_MAX
#define exp
float distance(float, float) RET
float2x2 invert(float2x2 mat)
ccl_device_inline float2 fmod(const float2 a, const float b)
void cursor_reinitialize_textures(Paint &paint)
bool grease_pencil_vertex_painting_poll(bContext *C)
bool grease_pencil_painting_poll(bContext *C)
bool mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports)
void mode_exit_generic(Scene &scene, Object &ob, const eObjectMode mode_flag)
void mode_enter_generic(Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob, const eObjectMode mode_flag)
Definition mesh_paint.cc:76
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
struct bNodeTreeExec * ntreeTexBeginExecTree(struct bNodeTree *ntree)
ScrArea * CTX_wm_area(const bContext *C)
static bool texture_paint_object_toggle_poll(bContext *C)
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
static ImagePaintPartialRedraw imapaintpartial
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ BRUSH_STROKE_DRAG_DOT
@ BRUSH_STROKE_ANCHORED
@ BRUSH_STROKE_AIRBRUSH
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void ED_imapaint_clear_partial_redraw()
void paint_2d_bucket_fill(const bContext *C, const float color[3], Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
void ED_space_image_sync(Main *bmain, Image *image, bool ignore_render_viewer)
Definition image_edit.cc:79
void ED_image_undo_push_end()
@ BRUSH_GRADIENT_SPACING_CLAMP
@ BRUSH_GRADIENT_SPACING_REPEAT
@ BRUSH_GRADIENT_PRESSURE
void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
bool image_texture_paint_poll(bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
Material * BKE_object_material_get(Object *ob, short act)
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode)
static wmOperatorStatus brush_colors_flip_exec(bContext *C, wmOperator *)
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
bool mask_paint_poll(bContext *C)
static bool image_paint_poll_ex(bContext *C, bool check_tool)
void IMB_mark_dirty(ImBuf *ibuf)
void BLI_rcti_init_minmax(struct rcti *rect)
Definition rct.cc:488
static void toggle_paint_cursor(Scene &scene, bool enable)
void imapaint_image_update(ImBuf *ibuf)
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
Definition colorband.cc:399
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
PaintTileMap * ED_image_paint_tile_map_get()
void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain)
Definition scene.cc:2872
void ED_paint_cursor_start(Paint *paint, bool(*poll)(bContext *C))
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void BKE_brush_tag_unsaved_changes(Brush *brush)
Definition brush.cc:843
void ED_object_texture_paint_mode_enter_ex(Main &bmain, Scene &scene, Depsgraph &depsgraph, Object &ob)
static wmOperatorStatus texture_paint_toggle_exec(bContext *C, wmOperator *op)
bool vert_paint_poll(bContext *C)
static Brush * image_paint_brush(bContext *C)
static wmOperatorStatus grab_clone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_grab_clone(wmOperatorType *ot)
static bool image_paint_2d_clone_poll(bContext *C)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
MINLINE void add_v2_v2(float r[2], const float a[2])
void paint_brush_color_get(const Paint *paint, Brush *br, std::optional< float3 > &initial_hsv_jitter, bool invert, float distance, float pressure, float r_color[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
MINLINE void swap_v3_v3(float a[3], float b[3])
@ OB_MODE_TEXTURE_PAINT
Mesh * BKE_mesh_from_object(Object *ob)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void ED_object_texture_paint_mode_exit_ex(Main &bmain, Scene &scene, Object &ob)
bool BKE_paint_select_elem_test(const Object *ob)
void ED_object_texture_paint_mode_exit(bContext *C)
float3 BKE_paint_seed_hsv_jitter()
void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, bool ensure_brushes=true)
void WM_toolsystem_update_from_context_view3d(bContext *C)
@ IMAGE_PAINT_BRUSH_TYPE_SOFTEN
@ IMAGE_PAINT_BRUSH_TYPE_SMEAR
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_FILL
@ IMAGE_PAINT_BRUSH_TYPE_CLONE
void ntreeTexEndExecTree(struct bNodeTreeExec *exec)
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
Definition rectop.cc:511
bool ED_paint_proj_mesh_data_check(Scene &scene, Object &ob, bool *r_has_uvs, bool *r_has_mat, bool *r_has_tex, bool *r_has_stencil)
void IMB_partial_update_mark_region(ImBuf *ibuf, const rcti &region)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
void IMB_partial_update_mark_full(ImBuf *ibuf)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
bool BKE_paint_select_face_test(const Object *ob)
void BKE_brush_color_sync_legacy(Brush *brush)
Definition brush.cc:1319
bool BLI_rcti_is_empty(const struct rcti *rect)
void paint_brush_exit_tex(Brush *brush)
void ED_imapaint_bucket_fill(bContext *C, const float color[3], wmOperator *op, const int mouse[2])
bool paint_use_opacity_masking(const Paint *paint, const Brush *brush)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void imapaint_region_tiles(ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
static bool texture_paint_object_poll(bContext *C)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:428
void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h)
static bool brush_colors_flip_poll(bContext *C)
SpaceImage * CTX_wm_space_image(const bContext *C)
static void grab_clone_cancel(bContext *, wmOperator *op)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void PAINT_OT_brush_colors_flip(wmOperatorType *ot)
Main * CTX_data_main(const bContext *C)
const ImBuf * ED_image_paint_tile_push(PaintTileMap *paint_tile_map, Image *image, ImBuf *ibuf, ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid)
bool WM_toolsystem_active_tool_is_brush(const bContext *C)
void ED_object_texture_paint_mode_enter(bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
void paint_init_pivot(Object *ob, Scene *scene, Paint *paint)
ImagePaintPartialRedraw * get_imapaintpartial()
void paint_delete_blur_kernel(BlurKernel *kernel)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
bool ED_image_tools_paint_poll(bContext *C)
std::optional< BrushColorJitterSettings > BKE_brush_color_jitter_get_settings(const Paint *paint, const Brush *brush)
Definition brush.cc:1262
void ED_space_image_get_zoom(SpaceImage *sima, const ARegion *region, float *r_zoomx, float *r_zoomy)
static void grab_clone_apply(bContext *C, wmOperator *op)
Brush * BKE_paint_brush(Paint *paint)
void BKE_texpaint_slots_refresh_object(Scene *scene, Object *ob)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1253
bool facemask_paint_poll(bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene)
VecBase< float, 3 > float3
bool BKE_paint_select_vert_test(const Object *ob)
void BKE_paint_brushes_validate(Main *bmain, Paint *paint)
float3 BKE_paint_randomize_color(const BrushColorJitterSettings &color_jitter, const float3 &initial_hsv_jitter, const float distance, const float pressure, const float3 &color)
bScreen * WM_window_get_active_screen(const wmWindow *win)
Object * CTX_data_active_object(const bContext *C)
void set_imapaintpartial(ImagePaintPartialRedraw *ippr)
ARegion * CTX_wm_region(const bContext *C)
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
bool image_paint_poll_ignore_tool(bContext *C)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void paint_brush_init_tex(Brush *brush)
static wmOperatorStatus grab_clone_modal(bContext *C, wmOperator *op, const wmEvent *event)
bool WM_paint_cursor_end(wmPaintCursor *handle)
bool BKE_brush_use_unified_color(const Paint *paint, const Brush *brush)
Definition brush.cc:1242
static wmOperatorStatus grab_clone_exec(bContext *C, wmOperator *op)
float3 BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1297
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eRegion_Type regiontype
struct ColorBand * gradient
eBrushImagePaintType image_brush_type
float secondary_color[3]
eBlurKernelType blur_mode
eBrushGradientSourceStroke gradient_stroke_mode
ImColorMode color_mode
bke::PaintRuntime * runtime
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
eSpaceImage_Mode mode
struct bNodeTree * nodetree
struct ImagePaintSettings imapaint
bke::bNodeTreeRuntime * runtime
ListBaseT< struct ScrArea > areabase
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports
struct wmOperatorType * type
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)