Blender V5.3
paint_image_ops_paint.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 "DNA_brush_types.h"
11#include "DNA_scene_types.h"
12#include "DNA_space_types.h"
14
16#include "BLI_math_color_c.hh"
17#include "BLI_math_matrix.hh"
18#include "BLI_math_vector_c.hh"
19
20#include "BKE_brush.hh"
21#include "BKE_colortools.hh"
22#include "BKE_context.hh"
23#include "BKE_global.hh"
24#include "BKE_layer.hh"
25#include "BKE_object_types.hh"
26#include "BKE_paint.hh"
27#include "BKE_paint_types.hh"
28#include "BKE_undo_system.hh"
29
30#include "ED_image.hh"
31#include "ED_paint.hh"
32#include "ED_screen.hh"
33#include "ED_view3d.hh"
34
35#include "GPU_immediate.hh"
36#include "GPU_state.hh"
37
38#include "MEM_guardedalloc.h"
39
40#include "RNA_access.hh"
41#include "RNA_define.hh"
42
43#include "WM_api.hh"
44#include "WM_types.hh"
45
46#include "image_paint_intern.hh"
47#include "mesh_paint.hh"
48#include "sculpt_automask.hh"
49#include "sculpt_intern.hh"
50
51#include "../paint_intern.hh"
52
53namespace blender {
54
56
57/* TODO: Remove this usage in favor of the `PaintStroke` information */
59 float prev_mouse[2] = {0.0f, 0.0f};
60 float start_mouse[2] = {0.0f, 0.0f};
61};
62
64 const int2 &xy,
65 const float2 & /*tilt*/,
66 void *customdata)
67{
68 PaintGradientData *gradient_data = static_cast<PaintGradientData *>(customdata);
69
70 if (gradient_data) {
71 GPU_line_smooth(true);
73
75 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
76
77 ARegion *region = CTX_wm_region(C);
78
80
81 GPU_line_width(4.0);
82 immUniformColor4ub(0, 0, 0, 255);
83
85 immVertex2fv(pos, float2(xy));
86 immVertex2f(pos,
87 gradient_data->start_mouse[0] + region->winrct.xmin,
88 gradient_data->start_mouse[1] + region->winrct.ymin);
89 immEnd();
90
91 GPU_line_width(2.0);
92 immUniformColor4ub(255, 255, 255, 255);
93
95 immVertex2fv(pos, float2(xy));
96 immVertex2f(pos,
97 gradient_data->start_mouse[0] + region->winrct.xmin,
98 gradient_data->start_mouse[1] + region->winrct.ymin);
99 immEnd();
100
102
104 GPU_line_smooth(false);
105 }
106}
107
109 public:
111
112 private:
113 void *stroke_handle_ = nullptr;
114 wmPaintCursor *cursor_ = nullptr;
115
116 public:
118 : PaintStroke(C, op, event, PaintMode::Texture2D)
119 {
120 }
121
122 std::optional<float3> get_location(float2 mouse, bool force_original) override;
123 bool test_start(wmOperator *op, float2 mouse) override;
124 void update_step(wmOperator *op, const StrokeStep &stroke_step) override;
125 void redraw(bool final) override;
126 bool test_cancel() override;
127 void done(bool is_cancel, bool stroke_started) override;
128};
129
131{
133 bke::PaintRuntime *paint_runtime = paint->runtime;
135
136 float alphafac = (brush->flag & BRUSH_ACCUMULATE) ? paint_runtime->overlap_factor : 1.0f;
137
138 /* initial brush values. Maybe it should be considered moving these to stroke system */
139 float startalpha = BKE_brush_alpha_get(paint, brush);
140
141 float distance = this->stroke_distance();
142 int eraser = RNA_boolean_get(op->ptr, "pen_flip");
143
144 float mouse[2];
145 copy_v2_v2(mouse, stroke_step.mouse);
146 float pressure = stroke_step.pressure;
147 float size = stroke_step.size;
148
149 /* stroking with fill tool only acts on stroke end */
151 copy_v2_v2(this->gradient_data.prev_mouse, mouse);
152 return;
153 }
154
156 pressure = BKE_curvemapping_evaluateF(brush->curve_strength, 0, pressure);
157 BKE_brush_alpha_set(paint, brush, max_ff(0.0f, startalpha * pressure * alphafac));
158 }
159 else {
160 BKE_brush_alpha_set(paint, brush, max_ff(0.0f, startalpha * alphafac));
161 }
162
166 }
167
169 stroke_handle_, this->gradient_data.prev_mouse, mouse, eraser, pressure, distance, size);
170
171 copy_v2_v2(this->gradient_data.prev_mouse, mouse);
172
173 /* restore brush values */
174 BKE_brush_alpha_set(paint, brush, startalpha);
175}
176
178{
179 paint_2d_redraw(evil_C, stroke_handle_, final);
180}
181
182void ImagePaintStroke::done(const bool is_cancel, const bool /*stroke_started*/)
183{
185 ToolSettings *toolsettings = scene->toolsettings;
186
188 Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint);
189
190 if (stroke_handle_ == nullptr) {
192 return;
193 }
194
195 toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
196
200 brush,
202 this->gradient_data.prev_mouse,
203 stroke_handle_);
204 }
205 else {
206 float color[3];
207 if (this->stroke_inverted()) {
209 }
210 else {
212 }
214 color,
215 brush,
217 this->gradient_data.prev_mouse,
218 stroke_handle_);
219 }
220 }
221 paint_2d_stroke_done(stroke_handle_, cursor_);
222
223 if (!is_cancel) {
225 }
226}
227std::optional<float3> ImagePaintStroke::get_location(const float2 /*mouse*/,
228 bool /*force_original*/)
229{
230 return std::nullopt;
231}
232
234{
235 return true;
236}
237
239{
241
242 const Main *bmain = CTX_data_main(evil_C);
244 ToolSettings *settings = scene->toolsettings;
245
246 ViewLayer *view_layer = CTX_data_view_layer(evil_C);
247 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
248
250
252 auto mode = BrushStrokeMode(RNA_enum_get(op->ptr, "mode"));
253
254 copy_v2_v2(this->gradient_data.prev_mouse, mouse);
256
257 stroke_handle_ = paint_2d_new_stroke(evil_C, op, mode);
258 if (stroke_handle_ == nullptr) {
259 return false;
260 }
261
264 {
269 &this->gradient_data);
270 }
271
272 settings->imapaint.flag |= IMAGEPAINT_DRAWING;
274
278
279 return true;
280}
281
283 public:
285
286 private:
287 void *stroke_handle_ = nullptr;
288 wmPaintCursor *cursor_ = nullptr;
289
290 public:
292 : PaintStroke(C, op, event, PaintMode::Texture3D)
293 {
294 }
295
296 std::optional<float3> get_location(float2 mouse, bool force_original) override;
297 bool test_start(wmOperator *op, float2 mouse) override;
298 void update_step(wmOperator *op, const StrokeStep &stroke_step) override;
299 void redraw(bool final) override;
300 bool test_cancel() override;
301 void done(bool is_cancel, bool stroke_started) override;
302};
303
305{
307 bke::PaintRuntime *paint_runtime = paint->runtime;
309
310 float alphafac = (brush->flag & BRUSH_ACCUMULATE) ? paint_runtime->overlap_factor : 1.0f;
311
312 /* initial brush values. Maybe it should be considered moving these to stroke system */
313 float startalpha = BKE_brush_alpha_get(paint, brush);
314
315 float distance = this->stroke_distance();
316 int eraser = RNA_boolean_get(op->ptr, "pen_flip");
317
318 float mouse[2];
319 copy_v2_v2(mouse, stroke_step.mouse);
320 float pressure = stroke_step.pressure;
321 float size = stroke_step.size;
322
323 /* stroking with fill tool only acts on stroke end */
325 copy_v2_v2(this->gradient_data.prev_mouse, mouse);
326 return;
327 }
328
330 pressure = BKE_curvemapping_evaluateF(brush->curve_strength, 0, pressure);
331 BKE_brush_alpha_set(paint, brush, max_ff(0.0f, startalpha * pressure * alphafac));
332 }
333 else {
334 BKE_brush_alpha_set(paint, brush, max_ff(0.0f, startalpha * alphafac));
335 }
336
340 }
341
343 stroke_handle_,
345 mouse,
346 eraser,
347 pressure,
348 distance,
349 size);
350
351 copy_v2_v2(this->gradient_data.prev_mouse, mouse);
352
353 /* restore brush values */
354 BKE_brush_alpha_set(paint, brush, startalpha);
355}
356
358{
359 paint_proj_redraw(evil_C, stroke_handle_, final);
360}
361
362void TexturePaintStroke::done(const bool is_cancel, const bool /*stroke_started*/)
363{
365 ToolSettings *toolsettings = scene->toolsettings;
366
368 Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint);
369
370 if (stroke_handle_ == nullptr) {
372 return;
373 }
374
375 toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
376
379 stroke_handle_,
382 this->stroke_flipped(),
383 1.0,
384 0.0,
386 /* two redraws, one for GPU update, one for notification */
387 paint_proj_redraw(evil_C, stroke_handle_, false);
388 paint_proj_redraw(evil_C, stroke_handle_, true);
389 }
390 paint_proj_stroke_done(stroke_handle_, cursor_);
391
392 if (!is_cancel) {
394 }
395}
396std::optional<float3> TexturePaintStroke::get_location(const float2 /*mouse*/,
397 bool /*force_original*/)
398{
399 /* TODO: This value is a dummy value and not actually used by the rest of the stroke system,
400 * this could be replaced with std::nullopt, but that requires further refactoring. */
401 return float3(0.0f, 0.0f, 0.0f);
402}
403
405{
406 return true;
407}
408
410{
412
413 const Main *bmain = CTX_data_main(evil_C);
415 ToolSettings *settings = scene->toolsettings;
416
417 ViewLayer *view_layer = CTX_data_view_layer(evil_C);
418 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
420
422
423 bool uvs, mat, tex, stencil;
424 if (!ED_paint_proj_mesh_data_check(*scene, *ob, &uvs, &mat, &tex, &stencil)) {
425 ED_paint_data_warning(op->reports, uvs, mat, tex, stencil);
427 return false;
428 }
429
431 auto mode = BrushStrokeMode(RNA_enum_get(op->ptr, "mode"));
432 auto brush_switch_mode = BrushSwitchMode(RNA_enum_get(op->ptr, "brush_toggle"));
433
434 copy_v2_v2(this->gradient_data.prev_mouse, mouse);
436
437 /* initialize from context */
438
439 stroke_handle_ = paint_proj_new_stroke(evil_C, ob, mouse, mode, brush_switch_mode);
440 if (stroke_handle_ == nullptr) {
441 return false;
442 }
443
446 {
451 &this->gradient_data);
452 }
453
454 settings->imapaint.flag |= IMAGEPAINT_DRAWING;
456
460
461 return true;
462}
463
465 std::unique_ptr<ImageData> image_data;
466 std::unique_ptr<ImageData> mask_data;
467};
468
472
474 : PaintStroke(C, op, event, PaintMode::Texture3D)
475 {
477 ToolSettings *tool_settings = CTX_data_tool_settings(C);
478 settings_ = &tool_settings->imapaint;
479
480 if (!G.background) {
482 }
483
486
488
489 if (!ss.cache) {
490 ss.cache = MEM_new<StrokeCache>(__func__);
491 const BrushStrokeMode stroke_mode = BrushStrokeMode(RNA_enum_get(op->ptr, "mode"));
492 const bool pen_flip = RNA_boolean_get(op->ptr, "pen_flip");
493
494 StrokeToggleSettings toggle_settings;
495
496 toggle_settings.invert = stroke_mode == BrushStrokeMode::Invert || pen_flip;
497
499 toggle_settings.invert = toggle_settings.invert ^
500 ((tool_settings->imapaint.flag &
502 }
503
504 ss.cache->toggle_settings = toggle_settings;
505
506 /* TODO: Further toggle support */
507 }
508
511
513 }
514
515 std::optional<float3> get_location(float2 mouse, bool force_original) override;
516 bool test_start(wmOperator *op, float2 mouse) override;
517 void update_step(wmOperator *op, const StrokeStep &stroke_step) override;
518 void redraw(bool final) override;
519 bool test_cancel() override;
520 void done(bool is_cancel, bool stroke_started) override;
521};
522
524 bool force_original)
525{
527 *this->depsgraph, this->vc, *this->paint, this->brush, mouse, force_original);
528}
530{
532 *this->depsgraph, this->vc, *this->paint, this->brush, mouse, false))
533 {
534 return false;
535 }
536
537 SculptSession &ss = *this->object->runtime->sculpt_session;
538 StrokeCache &cache = *ss.cache;
539 stroke_cache_common_init(this->vc, *this->paint, *this->brush, *this->object, mouse);
540 cache.accum = true;
541
542 std::unique_ptr<TexturePaintData> texture_paint_data = std::make_unique<TexturePaintData>();
543 texture_paint_data->image_data = ImageData::init_active_image(*this->object, *settings_);
544 texture_paint_data->mask_data = ImageData::init_mask_image(*settings_);
545 if (!texture_paint_data->image_data ||
546 (this->brush && this->brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_MASK &&
547 !texture_paint_data->mask_data))
548 {
549 BLI_assert(0);
550 return false;
551 }
552 mode_data_ = std::move(texture_paint_data);
553
558 }
559
560 cursor_geometry_info_update(*this->depsgraph, *paint, nullptr, this->vc, base_, mouse, false);
561
563
564 return true;
565};
566
567static void stroke_cache_update(ViewContext & /*vc*/,
568 Paint &paint,
569 Object &object,
570 const PaintStroke::StrokeStep &stroke_step)
571{
572 bke::PaintRuntime &paint_runtime = *paint.runtime;
573 SculptSession &ss = *object.runtime->sculpt_session;
574 StrokeCache &cache = *ss.cache;
576
578 brush.stroke_method != BRUSH_STROKE_ANCHORED)
579 {
580 cache.location = stroke_step.location;
581 }
582
583 cache.mouse = stroke_step.mouse;
584 cache.mouse_event = stroke_step.mouse_event;
585
587 cache.pressure = stroke_step.pressure;
588 }
589
590 cache.tilt = stroke_step.tilt;
591
594
597 }
598 }
599
602 {
603 const float pressure_eval = BKE_curvemapping_evaluateF(brush.curve_size, 0, cache.pressure);
604 cache.radius = cache.initial_radius * pressure_eval;
605 }
606 else if (brush.stroke_method == BRUSH_STROKE_ANCHORED) {
608 *cache.vc, cache.location, paint_runtime.pixel_radius);
609 }
610 else {
611 cache.radius = cache.initial_radius;
612 }
613 cache.radius_squared = cache.radius * cache.radius;
614
615 cache.hardness = brush.hardness;
616 /* TODO: Extend the brush "capabilities" checks to handle multi-mode */
617 if (brush.flag & BRUSH_HARDNESS_PRESSURE) {
618 cache.hardness *= BKE_curvemapping_evaluateF(brush.curve_hardness, 0, cache.pressure);
619 }
620
621 /* TODO: Brush delta */
622}
623
624static void do_brush_action(const Depsgraph &depsgraph,
625 const Scene &scene,
626 const Brush &brush,
627 Object &ob,
628 PaintModeData *paint_mode_data)
629{
631 /* TODO: Dynamic brush name */
632 ImagePaintSettings &image_paint_settings = scene.toolsettings->imapaint;
633 TexturePaintData *mode_data = static_cast<TexturePaintData *>(paint_mode_data);
635 IndexMaskMemory memory;
636
637 const bool is_mask_brush = brush.image_brush_type == IMAGE_PAINT_BRUSH_TYPE_MASK;
638 Image *image = is_mask_brush ? mode_data->mask_data->image : mode_data->image_data->image;
639 ImageUser image_user = is_mask_brush ? mode_data->mask_data->image_user_get() :
640 mode_data->image_data->image_user_get();
641
642 bke::pbvh::build_pixels(depsgraph, ob, *image, image_user);
643
644 const IndexMask node_mask = gather_brush_nodes(ob, brush, memory, node_fully_masked_or_hidden);
645
646 /* Only act if some verts are inside the brush area. */
647 if (node_mask.is_empty()) {
648 return;
649 }
650
651/* TODO: Automasking support */
652#if 0
653 if (auto_mask::is_enabled(image_paint_settings.paint, ob, &brush)) {
654 auto_mask::Cache &cache = auto_mask::stroke_cache_ensure(depsgraph, image_paint_settings.paint,
656 cache.calc_cavity_factor(depsgraph, ob, node_mask);
657 }
658 }
659#endif
660
661 /* TODO: Sculpt normal */
662 /* TODO: Brush local mat */
663 /* TODO: Cube tip */
664
665 /* Main brush action */
666 switch (brush.image_brush_type) {
669 depsgraph, image_paint_settings.paint, brush, ob, *mode_data->image_data, node_mask);
670 break;
673 depsgraph, image_paint_settings.paint, brush, ob, *mode_data->mask_data, node_mask);
674 break;
675 default:
676 /* TODO: Implement the rest of them... */
677 BLI_assert(0);
678 break;
679 }
680
681 /* Update average stroke position. */
682 const float3 world_location = math::project_point(ob.object_to_world(), ss.cache->location);
683
684 bke::paint::stroke_track_location(image_paint_settings.paint, world_location);
685}
686
688{
689 Object &object = *this->object;
690 SculptSession &ss = *object.runtime->sculpt_session;
691 StrokeCache &cache = *ss.cache;
692 TexturePaintData &mode_data = *static_cast<TexturePaintData *>(mode_data_.get());
693
694 cache.stroke_distance = this->stroke_distance();
695 stroke_cache_update(this->vc, *this->paint, object, step);
696
697 /* TODO: 'restore' support */
698
699 const bke::PaintRuntime &paint_runtime = *this->paint->runtime;
700 const float overlap = paint_runtime.overlap_factor;
701 const float pressure = BKE_brush_use_alpha_pressure(brush) ?
703 1.0f;
704 /* TODO: Remove hardcoded square pressure, this should be controlled by the user. */
705 cache.base_brush_strength = pressure * pressure * overlap;
706
708 *this->depsgraph, *this->scene, *this->paint, object, do_brush_action, &mode_data);
709 cache.first_time = false;
710
711 if (this->vc.rv3d) {
712 /* Mark for faster 3D viewport redraws. */
713 this->vc.rv3d->rflag |= RV3D_PAINTING;
714 }
716}
719{
720 return true;
721}
722void ExperimentalTexturePaintStroke::done(bool is_cancel, bool stroke_started)
723{
724 Object &ob = *this->object;
726
728
729 if (!ss.cache) {
730 return;
731 }
732
733 if (this->vc.rv3d) {
734 this->vc.rv3d->rflag &= ~RV3D_PAINTING;
735 }
736
737 MEM_delete(ss.cache);
738 ss.cache = nullptr;
739
740 if (!is_cancel && stroke_started) {
742 }
743
744 if (stroke_started) {
745 TexturePaintData *mode_data = static_cast<TexturePaintData *>(mode_data_.get());
746 const bool is_mask_brush = this->brush &&
748 Image *image = is_mask_brush ? mode_data->mask_data->image : mode_data->image_data->image;
749
752
754 }
755}
756
758{
759 if (CTX_wm_region_view3d(C)) {
760 auto switch_mode = BrushSwitchMode(RNA_enum_get(op->ptr, "brush_toggle"));
761
764 if (USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint) &&
766 {
767 return MEM_new<ExperimentalTexturePaintStroke>(__func__, C, op, event);
768 }
769 return MEM_new<TexturePaintStroke>(__func__, C, op, event);
770 }
771 return MEM_new<ImagePaintStroke>(__func__, C, op, event);
772}
773
775{
776 if (CTX_wm_region_view3d(C)) {
777 auto switch_mode = BrushSwitchMode(RNA_enum_get(op->ptr, "brush_toggle"));
778
781 if (USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint) &&
783 {
784 return static_cast<ExperimentalTexturePaintStroke *>(op->customdata);
785 }
786 return static_cast<TexturePaintStroke *>(op->customdata);
787 }
788 return static_cast<ImagePaintStroke *>(op->customdata);
789}
790
792{
793 if (CTX_wm_region_view3d(C)) {
794 auto switch_mode = BrushSwitchMode(RNA_enum_get(op->ptr, "brush_toggle"));
795
798 if (USER_EXPERIMENTAL_TEST(&U, use_3d_texture_paint) &&
800 {
801 return true;
802 }
803 }
804 return false;
805}
806
808{
809 const Main &bmain = *CTX_data_main(C);
810 Scene &scene = *CTX_data_scene(C);
811 ViewLayer *view_layer = CTX_data_view_layer(C);
812 BKE_view_layer_synced_ensure(bmain, &scene, view_layer);
813 Object &ob = *BKE_view_layer_active_object_get(view_layer);
814
815 bool uvs, mat, tex, stencil;
816 if (!ED_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, &stencil)) {
817 ED_paint_data_warning(op->reports, uvs, mat, tex, stencil);
819 return false;
820 }
821 return true;
822}
823
825{
827 if (!check_preconditions(C, op)) {
828 return OPERATOR_CANCELLED;
829 }
830 }
831 PaintStroke *stroke = create_paint_stroke(C, op, event);
832
833 op->customdata = stroke;
834
835 const wmOperatorStatus retval = op->type->modal(C, op, event);
836 OPERATOR_RETVAL_CHECK(retval);
837
838 if (retval == OPERATOR_FINISHED) {
839 stroke = get_paint_stroke(C, op);
840 if (stroke) {
841 stroke->finish(C);
842 MEM_delete(stroke);
843 }
844 return OPERATOR_FINISHED;
845 }
846 /* add modal handler */
848
850
852}
853
855{
857 if (!check_preconditions(C, op)) {
858 return OPERATOR_CANCELLED;
859 }
860 }
861
862 PaintStroke *stroke = create_paint_stroke(C, op, nullptr);
863 op->customdata = stroke;
864
865 wmOperatorStatus ret_val = stroke->exec(C, op);
866
867 MEM_delete(stroke);
868
869 return ret_val;
870}
871
873{
874 PaintStroke *stroke = get_paint_stroke(C, op);
875 const wmOperatorStatus retval = stroke->modal(C, op, event);
876
878 MEM_delete(stroke);
879 op->customdata = nullptr;
880 }
881
882 return retval;
883}
884
886{
887 PaintStroke *stroke = get_paint_stroke(C, op);
889 if (ustack->step_init) {
890 /* If the user cancels a stroke when none actually started, there is nothing to undo from. */
892 }
893
894 stroke->cancel(C);
895}
896} // namespace ed::sculpt_paint::image::ops::paint
897
899{
901
902 /* identifiers */
903 ot->name = "Image Paint";
904 ot->idname = "PAINT_OT_image_paint";
905 ot->description = "Paint a stroke into the image";
906
907 /* API callbacks. */
908 ot->invoke = paint_invoke;
909 ot->modal = paint_modal;
910 ot->exec = paint_exec;
912 ot->cancel = paint_cancel;
913
914 /* flags */
915 ot->flag = OPTYPE_BLOCKING;
916
919 ot->srna,
920 "override_location",
921 false,
922 "Override Location",
923 "Override the given \"location\" array by recalculating object space positions from the "
924 "provided \"mouse_event\" positions");
925}
926
927} // namespace blender
#define final(a, b, c)
Definition BLI_hash_c.hh:21
#define RGN_TYPE_ANY
#define SPACE_TYPE_ANY
#define USER_EXPERIMENTAL_TEST(userdef, member)
#define OPERATOR_RETVAL_CHECK(ret)
Read Blender memory allocation and freeing.
#define PRF_scope(category)
#define C
Definition RandGen.cpp:29
#define ND_DRAW
Definition WM_types.hh:502
#define NC_SCENE
Definition WM_types.hh:391
#define ND_TOOLSETTINGS
Definition WM_types.hh:468
#define NC_IMAGE
Definition WM_types.hh:397
#define NA_PAINTING
Definition WM_types.hh:641
#define NC_OBJECT
Definition WM_types.hh:392
#define ELEM(...)
float distance(float, float) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
bool implements_3d_texture_paint(const Brush &brush)
Definition brush.cc:1850
void stroke_track_location(Paint &paint, float3 location)
void build_pixels(const Depsgraph &depsgraph, Object &object, Image &image, const ImageUser &image_user)
Cache & stroke_cache_ensure(const Depsgraph &depsgraph, const Paint &paint, const Brush *brush, Object &ob)
bool is_enabled(const Paint &paint, const Object &object, const Brush *br)
static void gradient_draw_line(bContext *C, const int2 &xy, const float2 &, void *customdata)
static wmOperatorStatus paint_exec(bContext *C, wmOperator *op)
static void stroke_cache_update(ViewContext &, Paint &paint, Object &object, const PaintStroke::StrokeStep &stroke_step)
static wmOperatorStatus paint_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void do_brush_action(const Depsgraph &depsgraph, const Scene &scene, const Brush &brush, Object &ob, PaintModeData *paint_mode_data)
static wmOperatorStatus paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool should_check_before_stroke_creation(bContext *C, wmOperator *op)
static PaintStroke * create_paint_stroke(bContext *C, wmOperator *op, const wmEvent *event)
static PaintStroke * get_paint_stroke(bContext *C, wmOperator *op)
static bool check_preconditions(bContext *C, wmOperator *op)
static void paint_cancel(bContext *C, wmOperator *op)
void do_3d_image_paint_brush(const Depsgraph &depsgraph, const Paint &paint, const Brush &brush, Object &ob, ImageData &image_data, const IndexMask &node_mask)
IndexMask gather_brush_nodes(const Object &ob, const Brush &brush, IndexMaskMemory &memory, FunctionRef< bool(const bke::pbvh::Node &)> node_ignore_fn)
bool node_fully_masked_or_hidden(const bke::pbvh::Node &node)
Definition sculpt.cc:2500
bool stroke_is_first_brush_step_of_symmetry_pass(const StrokeCache &cache)
Definition sculpt.cc:667
bool paint_supports_dynamic_size(const Brush &br, PaintMode mode)
void do_symmetrical_brush_actions_with_tiling_and_feathering(const Depsgraph &depsgraph, const Scene &scene, const Paint &paint, Object &object, const BrushActionFn action_fn, PaintModeData *paint_mode_data)
bool brush_type_is_paint(const int tool)
std::optional< float3 > stroke_get_location_bvh(Depsgraph &depsgraph, ViewContext &vc, const Sculpt &sd, const Brush *brush, const float mval[2], const bool force_original)
Definition sculpt.cc:4855
void stroke_cache_common_init(ViewContext &vc, const Paint &paint, const Brush &brush, Object &object, const float2 mval)
float object_space_radius_get(const ViewContext &vc, const Paint &paint, const Brush &brush, const float3 &location, const float scale_factor)
Definition sculpt.cc:121
std::optional< CursorGeometryInfo > cursor_geometry_info_update(bContext *C, const float2 &mval, const bool use_sampled_normal)
Definition sculpt.cc:4584
VectorT project_point(const MatT &mat, const VectorT &point)
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void ED_image_undo_restore(UndoStep *us)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void PAINT_OT_image_paint(wmOperatorType *ot)
void immEnd()
@ IMAGEPAINT_PROJECT_LAYER_STENCIL_INV
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
@ BRUSH_STROKE_DRAG_DOT
@ BRUSH_STROKE_ANCHORED
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 immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void ED_image_undo_push_end()
void * paint_2d_new_stroke(bContext *C, wmOperator *op, const BrushStrokeMode mode)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode)
GPUVertFormat * immVertexFormat()
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1366
void immBegin(GPUPrimType, uint vertex_len)
void ED_paint_brush_type_update_sticky_shading_color(bContext *C, Object *ob)
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:80
void view3d_operator_needs_gpu(const bContext *C)
void * paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], const BrushStrokeMode mode, const BrushSwitchMode brush_switch_mode)
void paint_2d_stroke_done(void *ps, wmPaintCursor *cursor)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
Base * CTX_data_active_base(const bContext *C)
void immUnbindProgram()
bool BKE_brush_use_alpha_pressure(const Brush *brush)
Definition brush.cc:1385
ViewLayer * CTX_data_view_layer(const bContext *C)
void GPU_line_width(float width)
Definition gpu_state.cc:151
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final)
Global G
Definition blender.cc:57
void BKE_brush_unprojected_size_set(Paint *paint, Brush *brush, float unprojected_size)
Definition brush.cc:1390
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void BKE_curvemapping_init(CurveMapping *cumap)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void immVertex2f(uint attr_id, float x, float y)
void DEG_id_tag_update(ID *id, unsigned int flags)
wmWindowManager * CTX_wm_manager(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void paint_2d_redraw(const bContext *C, void *ps, bool final)
void paint_2d_gradient_fill(const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_FILL
@ IMAGE_PAINT_BRUSH_TYPE_MASK
void paint_proj_stroke(const bContext *C, void *ps_handle_p, const float prev_pos[2], const float pos[2], const bool eraser, float pressure, float distance, float size)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
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)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool BKE_brush_use_locked_size(const Paint *paint, const Brush *brush)
Definition brush.cc:1371
void paint_brush_exit_tex(Brush *brush)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, wmPaintCursorPoll poll, wmPaintCursorDraw draw, void *customdata)
@ BRUSH_AUTOMASKING_CAVITY_ALL
void paint_stroke_operator_properties(wmOperatorType *ot)
bool BKE_brush_use_size_pressure(const Brush *brush)
Definition brush.cc:1380
const Brush * BKE_paint_brush_for_read(const Paint *paint)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
Main * CTX_data_main(const bContext *C)
void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], const bool eraser, float pressure, float distance, float base_size)
Paint * BKE_paint_get_active_from_context(const bContext *C)
MINLINE float max_ff(float a, float b)
float paint_calc_object_space_radius(const ViewContext &vc, const float3 &center, float pixel_radius)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
bool ED_image_tools_paint_poll(bContext *C)
void BKE_sculptsession_update_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
Brush * BKE_paint_brush(Paint *paint)
@ BRUSH_HARDNESS_PRESSURE
void ED_paint_data_warning(ReportList *reports, bool has_uvs, bool has_mat, bool has_tex, bool has_stencil)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1253
void paint_proj_stroke_done(void *ps_handle_p, wmPaintCursor *cursor)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void immVertex2fv(uint attr_id, const float data[2])
void BKE_brush_alpha_set(Paint *paint, Brush *brush, float alpha)
Definition brush.cc:1441
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
View3D * CTX_wm_view3d(const bContext *C)
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1454
void paint_brush_init_tex(Brush *brush)
float3 BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1297
struct CurveMapping * curve_rand_value
struct CurveMapping * curve_rand_saturation
eBrushImagePaintType image_brush_type
eBrushSculptType sculpt_brush_type
struct CurveMapping * curve_rand_hue
struct CurveMapping * curve_strength
eBrushStrokeType stroke_method
bke::ObjectRuntime * runtime
bke::PaintRuntime * runtime
eRegionView3D_Flag rflag
struct ToolSettings * toolsettings
ed::sculpt_paint::StrokeCache * cache
Definition BKE_paint.hh:409
struct ImagePaintSettings imapaint
RegionView3D * rv3d
Definition ED_view3d.hh:86
wmOperatorStatus modal(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus exec(bContext *C, wmOperator *op)
std::unique_ptr< PaintModeData > mode_data_
void calc_cavity_factor(const Depsgraph &depsgraph, const Object &object, const IndexMask &node_mask)
static std::unique_ptr< ImageData > init_active_image(Object &ob, ImagePaintSettings &settings)
static std::unique_ptr< ImageData > init_mask_image(ImagePaintSettings &settings)
void update_step(wmOperator *op, const StrokeStep &stroke_step) override
ExperimentalTexturePaintStroke(bContext *C, wmOperator *op, const wmEvent *event)
std::optional< float3 > get_location(float2 mouse, bool force_original) override
ImagePaintStroke(bContext *C, wmOperator *op, const wmEvent *event)
std::optional< float3 > get_location(float2 mouse, bool force_original) override
void done(bool is_cancel, bool stroke_started) override
void update_step(wmOperator *op, const StrokeStep &stroke_step) override
void done(bool is_cancel, bool stroke_started) override
TexturePaintStroke(bContext *C, wmOperator *op, const wmEvent *event)
void update_step(wmOperator *op, const StrokeStep &stroke_step) override
std::optional< float3 > get_location(float2 mouse, bool force_original) override
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
bke::WindowManagerRuntime * runtime