Blender  V3.3
paint_image_ops_paint.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
9 #include "DNA_brush_types.h"
10 #include "DNA_color_types.h"
11 #include "DNA_scene_types.h"
12 #include "DNA_space_types.h"
13 
14 #include "BKE_brush.h"
15 #include "BKE_context.h"
16 #include "BKE_paint.h"
17 #include "BKE_undo_system.h"
18 
19 #include "DEG_depsgraph.h"
20 
21 #include "ED_paint.h"
22 #include "ED_view3d.h"
23 
24 #include "GPU_immediate.h"
25 #include "GPU_state.h"
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "RNA_access.h"
30 #include "RNA_define.h"
31 
32 #include "WM_api.h"
33 #include "WM_message.h"
34 #include "WM_toolsystem.h"
35 #include "WM_types.h"
36 
37 #include "ED_image.h"
38 
39 #include "paint_intern.h"
40 
42 
48  public:
49  virtual ~AbstractPaintMode() = default;
50  virtual void *paint_new_stroke(
51  bContext *C, wmOperator *op, Object *ob, const float mouse[2], int mode) = 0;
52  virtual void paint_stroke(bContext *C,
53  void *stroke_handle,
54  float prev_mouse[2],
55  float mouse[2],
56  int eraser,
57  float pressure,
58  float distance,
59  float size) = 0;
60 
61  virtual void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final) = 0;
62  virtual void paint_stroke_done(void *stroke_handle) = 0;
63  virtual void paint_gradient_fill(const bContext *C,
64  const Scene *scene,
65  Brush *brush,
66  struct PaintStroke *stroke,
67  void *stroke_handle,
68  float mouse_start[2],
69  float mouse_end[2]) = 0;
70  virtual void paint_bucket_fill(const bContext *C,
71  const Scene *scene,
72  Brush *brush,
73  struct PaintStroke *stroke,
74  void *stroke_handle,
75  float mouse_start[2],
76  float mouse_end[2]) = 0;
77 };
78 
80  public:
82  wmOperator *op,
83  Object *UNUSED(ob),
84  const float UNUSED(mouse[2]),
85  int mode) override
86  {
87  return paint_2d_new_stroke(C, op, mode);
88  }
89 
91  void *stroke_handle,
92  float prev_mouse[2],
93  float mouse[2],
94  int eraser,
95  float pressure,
96  float distance,
97  float size) override
98  {
99  paint_2d_stroke(stroke_handle, prev_mouse, mouse, eraser, pressure, distance, size);
100  }
101 
102  void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final) override
103  {
104  paint_2d_redraw(C, stroke_handle, final);
105  }
106 
107  void paint_stroke_done(void *stroke_handle) override
108  {
109  paint_2d_stroke_done(stroke_handle);
110  }
111 
113  const Scene *UNUSED(scene),
114  Brush *brush,
115  struct PaintStroke *UNUSED(stroke),
116  void *stroke_handle,
117  float mouse_start[2],
118  float mouse_end[2]) override
119  {
120  paint_2d_gradient_fill(C, brush, mouse_start, mouse_end, stroke_handle);
121  }
122 
124  const Scene *scene,
125  Brush *brush,
126  struct PaintStroke *stroke,
127  void *stroke_handle,
128  float mouse_start[2],
129  float mouse_end[2]) override
130  {
131  float color[3];
132  if (paint_stroke_inverted(stroke)) {
134  }
135  else {
137  }
138  paint_2d_bucket_fill(C, color, brush, mouse_start, mouse_end, stroke_handle);
139  }
140 };
141 
143  public:
145  bContext *C, wmOperator *UNUSED(op), Object *ob, const float mouse[2], int mode) override
146  {
147  return paint_proj_new_stroke(C, ob, mouse, mode);
148  }
149 
151  void *stroke_handle,
152  float prev_mouse[2],
153  float mouse[2],
154  int eraser,
155  float pressure,
156  float distance,
157  float size) override
158  {
159  paint_proj_stroke(C, stroke_handle, prev_mouse, mouse, eraser, pressure, distance, size);
160  };
161 
162  void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final) override
163  {
164  paint_proj_redraw(C, stroke_handle, final);
165  }
166 
167  void paint_stroke_done(void *stroke_handle) override
168  {
169  paint_proj_stroke_done(stroke_handle);
170  }
171 
173  const Scene *scene,
174  Brush *brush,
175  struct PaintStroke *stroke,
176  void *stroke_handle,
177  float mouse_start[2],
178  float mouse_end[2]) override
179  {
180  paint_fill(C, scene, brush, stroke, stroke_handle, mouse_start, mouse_end);
181  }
182 
184  const Scene *scene,
185  Brush *brush,
186  struct PaintStroke *stroke,
187  void *stroke_handle,
188  float mouse_start[2],
189  float mouse_end[2]) override
190  {
191  paint_fill(C, scene, brush, stroke, stroke_handle, mouse_start, mouse_end);
192  }
193 
194  private:
195  void paint_fill(const bContext *C,
196  const Scene *scene,
197  Brush *brush,
198  struct PaintStroke *stroke,
199  void *stroke_handle,
200  float mouse_start[2],
201  float mouse_end[2])
202  {
204  stroke_handle,
205  mouse_start,
206  mouse_end,
207  paint_stroke_flipped(stroke),
208  1.0,
209  0.0,
210  BKE_brush_size_get(scene, brush));
211  /* two redraws, one for GPU update, one for notification */
212  paint_proj_redraw(C, stroke_handle, false);
213  paint_proj_redraw(C, stroke_handle, true);
214  }
215 };
216 
219 
220  void *stroke_handle = nullptr;
221 
222  float prevmouse[2] = {0.0f, 0.0f};
223  float startmouse[2] = {0.0f, 0.0f};
224  double starttime = 0.0;
225 
226  wmPaintCursor *cursor = nullptr;
227  ViewContext vc = {nullptr};
228 
229  PaintOperation() = default;
231  {
232  MEM_delete(mode);
233  mode = nullptr;
234 
235  if (cursor) {
237  cursor = nullptr;
238  }
239  }
240 };
241 
242 static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customdata)
243 {
244  PaintOperation *pop = (PaintOperation *)customdata;
245 
246  if (pop) {
247  GPU_line_smooth(true);
249 
252 
253  ARegion *region = pop->vc.region;
254 
256 
257  GPU_line_width(4.0);
258  immUniformColor4ub(0, 0, 0, 255);
259 
261  immVertex2i(pos, x, y);
262  immVertex2i(
263  pos, pop->startmouse[0] + region->winrct.xmin, pop->startmouse[1] + region->winrct.ymin);
264  immEnd();
265 
266  GPU_line_width(2.0);
267  immUniformColor4ub(255, 255, 255, 255);
268 
270  immVertex2i(pos, x, y);
271  immVertex2i(
272  pos, pop->startmouse[0] + region->winrct.xmin, pop->startmouse[1] + region->winrct.ymin);
273  immEnd();
274 
276 
278  GPU_line_smooth(false);
279  }
280 }
281 
282 static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const float mouse[2])
283 {
286  ToolSettings *settings = scene->toolsettings;
287  PaintOperation *pop = MEM_new<PaintOperation>("PaintOperation"); /* caller frees */
288  Brush *brush = BKE_paint_brush(&settings->imapaint.paint);
289  int mode = RNA_enum_get(op->ptr, "mode");
291 
292  copy_v2_v2(pop->prevmouse, mouse);
293  copy_v2_v2(pop->startmouse, mouse);
294 
295  ViewLayer *view_layer = CTX_data_view_layer(C);
296  Object *ob = OBACT(view_layer);
297 
298  /* initialize from context */
299  if (CTX_wm_region_view3d(C)) {
300  bool uvs, mat, tex, stencil;
301  if (!ED_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, &stencil)) {
302  ED_paint_data_warning(op->reports, uvs, mat, tex, stencil);
303  MEM_delete(pop);
305  return nullptr;
306  }
307  pop->mode = MEM_new<ProjectionPaintMode>("ProjectionPaintMode");
308  }
309  else {
310  pop->mode = MEM_new<ImagePaintMode>("ImagePaintMode");
311  }
312 
313  pop->stroke_handle = pop->mode->paint_new_stroke(C, op, ob, mouse, mode);
314  if (!pop->stroke_handle) {
315  MEM_delete(pop);
316  return nullptr;
317  }
318 
319  if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) {
322  }
323 
324  settings->imapaint.flag |= IMAGEPAINT_DRAWING;
326 
327  return pop;
328 }
329 
331  wmOperator *UNUSED(op),
332  struct PaintStroke *stroke,
333  PointerRNA *itemptr)
334 {
335  PaintOperation *pop = static_cast<PaintOperation *>(paint_stroke_mode_data(stroke));
337  ToolSettings *toolsettings = CTX_data_tool_settings(C);
338  UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
339  Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint);
340 
341  float alphafac = (brush->flag & BRUSH_ACCUMULATE) ? ups->overlap_factor : 1.0f;
342 
343  /* initial brush values. Maybe it should be considered moving these to stroke system */
344  float startalpha = BKE_brush_alpha_get(scene, brush);
345 
346  float mouse[2];
347  float pressure;
348  float size;
349  float distance = paint_stroke_distance_get(stroke);
350  int eraser;
351 
352  RNA_float_get_array(itemptr, "mouse", mouse);
353  pressure = RNA_float_get(itemptr, "pressure");
354  eraser = RNA_boolean_get(itemptr, "pen_flip");
355  size = RNA_float_get(itemptr, "size");
356 
357  /* stroking with fill tool only acts on stroke end */
358  if (brush->imagepaint_tool == PAINT_TOOL_FILL) {
359  copy_v2_v2(pop->prevmouse, mouse);
360  return;
361  }
362 
363  if (BKE_brush_use_alpha_pressure(brush)) {
364  BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * pressure * alphafac));
365  }
366  else {
367  BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * alphafac));
368  }
369 
370  if ((brush->flag & BRUSH_DRAG_DOT) || (brush->flag & BRUSH_ANCHORED)) {
371  UndoStack *ustack = CTX_wm_manager(C)->undo_stack;
373  }
374 
375  pop->mode->paint_stroke(
376  C, pop->stroke_handle, pop->prevmouse, mouse, eraser, pressure, distance, size);
377 
378  copy_v2_v2(pop->prevmouse, mouse);
379 
380  /* restore brush values */
381  BKE_brush_alpha_set(scene, brush, startalpha);
382 }
383 
384 static void paint_stroke_redraw(const bContext *C, struct PaintStroke *stroke, bool final)
385 {
386  PaintOperation *pop = static_cast<PaintOperation *>(paint_stroke_mode_data(stroke));
387  pop->mode->paint_stroke_redraw(C, pop->stroke_handle, final);
388 }
389 
390 static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
391 {
393  ToolSettings *toolsettings = scene->toolsettings;
394  PaintOperation *pop = static_cast<PaintOperation *>(paint_stroke_mode_data(stroke));
395  Brush *brush = BKE_paint_brush(&toolsettings->imapaint.paint);
396 
397  toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
398 
399  if (brush->imagepaint_tool == PAINT_TOOL_FILL) {
400  if (brush->flag & BRUSH_USE_GRADIENT) {
402  C, scene, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse);
403  }
404  else {
405  pop->mode->paint_bucket_fill(
406  C, scene, brush, stroke, pop->stroke_handle, pop->startmouse, pop->prevmouse);
407  }
408  }
410  pop->stroke_handle = nullptr;
411 
413 
414 /* duplicate warning, see texpaint_init */
415 #if 0
416  if (pop->s.warnmultifile) {
417  BKE_reportf(op->reports,
418  RPT_WARNING,
419  "Image requires 4 color channels to paint: %s",
420  pop->s.warnmultifile);
421  }
422  if (pop->s.warnpackedfile) {
423  BKE_reportf(op->reports,
424  RPT_WARNING,
425  "Packed MultiLayer files cannot be painted: %s",
426  pop->s.warnpackedfile);
427  }
428 #endif
429  MEM_delete(pop);
430 }
431 
432 static bool paint_stroke_test_start(bContext *C, wmOperator *op, const float mouse[2])
433 {
434  PaintOperation *pop;
435 
436  /* TODO: Should avoid putting this here. Instead, last position should be requested
437  * from stroke system. */
438 
439  if (!(pop = texture_paint_init(C, op, mouse))) {
440  return false;
441  }
442 
443  paint_stroke_set_mode_data(static_cast<PaintStroke *>(op->customdata), pop);
444 
445  return true;
446 }
447 
448 static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
449 {
450  int retval;
451 
453  op,
454  nullptr,
459  event->type);
460 
461  if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
462  paint_stroke_free(C, op, static_cast<PaintStroke *>(op->customdata));
463  return OPERATOR_FINISHED;
464  }
465  /* add modal handler */
467 
468  OPERATOR_RETVAL_CHECK(retval);
470 
471  return OPERATOR_RUNNING_MODAL;
472 }
473 
474 static int paint_exec(bContext *C, wmOperator *op)
475 {
476  PropertyRNA *strokeprop;
477  PointerRNA firstpoint;
478  float mouse[2];
479 
480  strokeprop = RNA_struct_find_property(op->ptr, "stroke");
481 
482  if (!RNA_property_collection_lookup_int(op->ptr, strokeprop, 0, &firstpoint)) {
483  return OPERATOR_CANCELLED;
484  }
485 
486  RNA_float_get_array(&firstpoint, "mouse", mouse);
487 
489  op,
490  nullptr,
495  0);
496  /* frees op->customdata */
497  return paint_stroke_exec(C, op, static_cast<PaintStroke *>(op->customdata));
498 }
499 
500 static int paint_modal(bContext *C, wmOperator *op, const wmEvent *event)
501 {
502  return paint_stroke_modal(C, op, event, reinterpret_cast<PaintStroke **>(&op->customdata));
503 }
504 
505 static void paint_cancel(bContext *C, wmOperator *op)
506 {
507  paint_stroke_cancel(C, op, static_cast<PaintStroke *>(op->customdata));
508 }
509 } // namespace blender::ed::sculpt_paint::image::ops::paint
510 
511 extern "C" {
513 {
515 
516  /* identifiers */
517  ot->name = "Image Paint";
518  ot->idname = "PAINT_OT_image_paint";
519  ot->description = "Paint a stroke into the image";
520 
521  /* api callbacks */
523  ot->modal = paint_modal;
524  ot->exec = paint_exec;
527 
528  /* flags */
530 
532 }
533 }
void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float alpha)
Definition: brush.cc:2313
const float * BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush)
Definition: brush.cc:2216
float BKE_brush_alpha_get(const struct Scene *scene, const struct Brush *brush)
const float * BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush)
Definition: brush.cc:2210
int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush)
bool BKE_brush_use_alpha_pressure(const struct Brush *brush)
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
Definition: context.c:1282
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
Definition: context.c:793
struct Brush * BKE_paint_brush(struct Paint *paint)
Definition: paint.c:607
@ PAINT_MODE_TEXTURE_2D
Definition: BKE_paint.h:75
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert(a)
Definition: BLI_assert.h:46
MINLINE float max_ff(float a, float b)
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED(x)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
@ BRUSH_DRAG_DOT
@ BRUSH_ACCUMULATE
@ BRUSH_ANCHORED
@ BRUSH_USE_GRADIENT
@ PAINT_TOOL_FILL
#define OBACT(_view_layer)
#define IMAGEPAINT_DRAWING
#define RGN_TYPE_ANY
#define SPACE_TYPE_ANY
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
#define OPERATOR_RETVAL_CHECK(ret)
bool ED_image_tools_paint_poll(struct bContext *C)
Definition: paint_image.cc:291
void ED_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil)
void ED_image_undo_push_begin(const char *name, int paint_mode)
Definition: image_undo.cc:1095
void ED_image_undo_restore(struct UndoStep *us)
Definition: image_undo.cc:1077
void ED_image_undo_push_end(void)
Definition: image_undo.cc:1133
bool ED_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immVertex2i(uint attr_id, int x, int y)
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
GPUVertFormat * immVertexFormat(void)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:201
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
void GPU_line_width(float width)
Definition: gpu_state.cc:158
void GPU_line_smooth(bool enable)
Definition: gpu_state.cc:75
@ GPU_FETCH_INT_TO_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_I32
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#define C
Definition: RandGen.cpp:25
@ OPTYPE_BLOCKING
Definition: WM_types.h:150
#define NC_SCENE
Definition: WM_types.h:328
#define ND_TOOLSETTINGS
Definition: WM_types.h:397
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
virtual void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final)=0
virtual void paint_gradient_fill(const bContext *C, const Scene *scene, Brush *brush, struct PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2])=0
virtual void paint_stroke(bContext *C, void *stroke_handle, float prev_mouse[2], float mouse[2], int eraser, float pressure, float distance, float size)=0
virtual void paint_bucket_fill(const bContext *C, const Scene *scene, Brush *brush, struct PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2])=0
virtual void * paint_new_stroke(bContext *C, wmOperator *op, Object *ob, const float mouse[2], int mode)=0
void paint_gradient_fill(const bContext *C, const Scene *UNUSED(scene), Brush *brush, struct PaintStroke *UNUSED(stroke), void *stroke_handle, float mouse_start[2], float mouse_end[2]) override
void paint_bucket_fill(const bContext *C, const Scene *scene, Brush *brush, struct PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2]) override
void * paint_new_stroke(bContext *C, wmOperator *op, Object *UNUSED(ob), const float UNUSED(mouse[2]), int mode) override
void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final) override
void paint_stroke(bContext *UNUSED(C), void *stroke_handle, float prev_mouse[2], float mouse[2], int eraser, float pressure, float distance, float size) override
void paint_gradient_fill(const bContext *C, const Scene *scene, Brush *brush, struct PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2]) override
void paint_stroke_redraw(const bContext *C, void *stroke_handle, bool final) override
void * paint_new_stroke(bContext *C, wmOperator *UNUSED(op), Object *ob, const float mouse[2], int mode) override
void paint_stroke(bContext *C, void *stroke_handle, float prev_mouse[2], float mouse[2], int eraser, float pressure, float distance, float size) override
void paint_bucket_fill(const bContext *C, const Scene *scene, Brush *brush, struct PaintStroke *stroke, void *stroke_handle, float mouse_start[2], float mouse_end[2]) override
Scene scene
const Depsgraph * depsgraph
uint pos
format
Definition: logImageCore.h:38
static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customdata)
static bool paint_stroke_test_start(bContext *C, wmOperator *op, const float mouse[2])
static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
static void paint_stroke_update_step(bContext *C, wmOperator *UNUSED(op), struct PaintStroke *stroke, PointerRNA *itemptr)
static int paint_exec(bContext *C, wmOperator *op)
static PaintOperation * texture_paint_init(bContext *C, wmOperator *op, const float mouse[2])
static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void paint_cancel(bContext *C, wmOperator *op)
static void paint_stroke_redraw(const bContext *C, struct PaintStroke *stroke, bool final)
static int paint_modal(bContext *C, wmOperator *op, const wmEvent *event)
T distance(const T &a, const T &b)
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 paint_2d_gradient_fill(const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
void paint_2d_stroke_done(void *ps)
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)
void * paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
void paint_2d_redraw(const bContext *C, void *ps, bool final)
void PAINT_OT_image_paint(wmOperatorType *ot)
void * paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int mode)
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)
void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final)
void paint_proj_stroke_done(void *ps_handle_p)
void paint_stroke_cancel(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke)
bool paint_stroke_flipped(struct PaintStroke *stroke)
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event, struct PaintStroke **stroke_p)
int paint_stroke_exec(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke)
struct PaintStroke * paint_stroke_new(struct bContext *C, struct wmOperator *op, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, StrokeRedraw redraw, StrokeDone done, int event_type)
Definition: paint_stroke.c:874
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data)
void paint_stroke_free(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke)
void * paint_stroke_mode_data(struct PaintStroke *stroke)
bool paint_stroke_inverted(struct PaintStroke *stroke)
void paint_stroke_operator_properties(struct wmOperatorType *ot)
Definition: paint_utils.c:188
float paint_stroke_distance_get(struct PaintStroke *stroke)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
Definition: rna_access.c:4097
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
char imagepaint_tool
struct ToolSettings * toolsettings
struct ImagePaintSettings imapaint
struct UnifiedPaintSettings unified_paint_settings
struct UndoStep * step_init
struct ARegion * region
Definition: ED_view3d.h:69
int ymin
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
short type
Definition: WM_types.h:678
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:935
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:927
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct ReportList * reports
struct wmOperatorType * type
struct PointerRNA * ptr
struct UndoStack * undo_stack
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479
bool WM_paint_cursor_end(wmPaintCursor *handle)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)