Blender  V3.3
paint_ops.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "MEM_guardedalloc.h"
8 
9 #include "BLI_listbase.h"
10 #include "BLI_math_vector.h"
11 #include "BLI_string.h"
12 #include "BLI_utildefines.h"
13 #include <stdlib.h>
14 
15 #include "IMB_imbuf.h"
16 #include "IMB_imbuf_types.h"
17 
18 #include "DNA_brush_types.h"
19 #include "DNA_customdata_types.h"
20 #include "DNA_object_types.h"
21 #include "DNA_scene_types.h"
22 
23 #include "BKE_brush.h"
24 #include "BKE_context.h"
25 #include "BKE_image.h"
26 #include "BKE_lib_id.h"
27 #include "BKE_main.h"
28 #include "BKE_paint.h"
29 #include "BKE_report.h"
30 
31 #include "ED_image.h"
32 #include "ED_paint.h"
33 #include "ED_screen.h"
34 
35 #include "WM_api.h"
36 #include "WM_toolsystem.h"
37 #include "WM_types.h"
38 
39 #include "RNA_access.h"
40 #include "RNA_define.h"
41 
42 #include "curves_sculpt_intern.h"
43 #include "paint_intern.h"
44 #include "sculpt_intern.h"
45 
46 #include <stddef.h>
47 #include <string.h>
48 
49 /* Brush operators */
51 {
52  // int type = RNA_enum_get(op->ptr, "type");
54  Brush *br = BKE_paint_brush(paint);
55  Main *bmain = CTX_data_main(C);
57 
58  if (br) {
59  br = (Brush *)BKE_id_copy(bmain, &br->id);
60  }
61  else {
62  br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paintmode(mode));
63  }
64  id_us_min(&br->id); /* fake user only */
65 
66  BKE_paint_brush_set(paint, br);
67 
68  return OPERATOR_FINISHED;
69 }
70 
72 {
73  /* identifiers */
74  ot->name = "Add Brush";
75  ot->description = "Add brush by mode type";
76  ot->idname = "BRUSH_OT_add";
77 
78  /* api callbacks */
80 
81  /* flags */
83 }
84 
86  enum eContextObjectMode mode)
87 {
88  switch (mode) {
90  if (STREQ(tool->runtime->data_block, "DRAW")) {
92  }
93  if (STREQ(tool->runtime->data_block, "FILL")) {
95  }
96  if (STREQ(tool->runtime->data_block, "ERASE")) {
98  }
99  if (STREQ(tool->runtime->data_block, "TINT")) {
100  return GP_BRUSH_PRESET_TINT;
101  }
102  break;
103  }
105  if (STREQ(tool->runtime->data_block, "SMOOTH")) {
107  }
108  if (STREQ(tool->runtime->data_block, "STRENGTH")) {
110  }
111  if (STREQ(tool->runtime->data_block, "THICKNESS")) {
113  }
114  if (STREQ(tool->runtime->data_block, "GRAB")) {
116  }
117  if (STREQ(tool->runtime->data_block, "PUSH")) {
119  }
120  if (STREQ(tool->runtime->data_block, "TWIST")) {
122  }
123  if (STREQ(tool->runtime->data_block, "PINCH")) {
125  }
126  if (STREQ(tool->runtime->data_block, "RANDOMIZE")) {
128  }
129  if (STREQ(tool->runtime->data_block, "CLONE")) {
131  }
132  break;
133  }
136  }
138  if (STREQ(tool->runtime->data_block, "DRAW")) {
140  }
141  if (STREQ(tool->runtime->data_block, "BLUR")) {
143  }
144  if (STREQ(tool->runtime->data_block, "AVERAGE")) {
146  }
147  if (STREQ(tool->runtime->data_block, "SMEAR")) {
149  }
150  if (STREQ(tool->runtime->data_block, "REPLACE")) {
152  }
153  break;
154  }
155  default:
157  }
159 }
160 
162 {
164  Brush *br = BKE_paint_brush(paint);
165  Main *bmain = CTX_data_main(C);
166 
167  if (br) {
168  br = (Brush *)BKE_id_copy(bmain, &br->id);
169  }
170  else {
171  /* Get the active tool to determine what type of brush is active. */
172  bScreen *screen = CTX_wm_screen(C);
173  if (screen == NULL) {
174  return OPERATOR_CANCELLED;
175  }
176 
177  bToolRef *tool = NULL;
178  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
179  if (area->spacetype == SPACE_VIEW3D) {
180  /* Check the current tool is a brush. */
181  bToolRef *tref = area->runtime.tool;
182  if (tref && tref->runtime && tref->runtime->data_block[0]) {
183  tool = tref;
184  break;
185  }
186  }
187  }
188 
189  if (tool == NULL) {
190  return OPERATOR_CANCELLED;
191  }
192 
193  /* Get Brush mode base on context mode. */
194  const enum eContextObjectMode mode = CTX_data_mode_enum(C);
196  switch (mode) {
198  obmode = OB_MODE_PAINT_GPENCIL;
199  break;
201  obmode = OB_MODE_SCULPT_GPENCIL;
202  break;
204  obmode = OB_MODE_WEIGHT_GPENCIL;
205  break;
207  obmode = OB_MODE_VERTEX_GPENCIL;
208  break;
209  default:
210  return OPERATOR_CANCELLED;
211  break;
212  }
213 
214  /* Get brush preset using the actual tool. */
216 
217  /* Capitalize Brush name first letter using the tool name. */
218  char name[64];
219  BLI_strncpy(name, tool->runtime->data_block, sizeof(name));
220  BLI_str_tolower_ascii(name, sizeof(name));
221  name[0] = BLI_toupper_ascii(name[0]);
222 
223  /* Create the brush and assign default values. */
224  br = BKE_brush_add(bmain, name, obmode);
225  if (br) {
227  BKE_gpencil_brush_preset_set(bmain, br, preset);
228  }
229  }
230 
231  if (br) {
232  id_us_min(&br->id); /* fake user only */
233  BKE_paint_brush_set(paint, br);
234  }
235 
236  return OPERATOR_FINISHED;
237 }
238 
240 {
241  /* identifiers */
242  ot->name = "Add Drawing Brush";
243  ot->description = "Add brush for Grease Pencil";
244  ot->idname = "BRUSH_OT_add_gpencil";
245 
246  /* api callbacks */
248 
249  /* flags */
251 }
252 
254 {
257  Brush *brush = BKE_paint_brush(paint);
258  const bool is_gpencil = (brush && brush->gpencil_settings != NULL);
259  // Object *ob = CTX_data_active_object(C);
260  float scalar = RNA_float_get(op->ptr, "scalar");
261 
262  if (brush) {
263  /* pixel radius */
264  {
265  const int old_size = (!is_gpencil) ? BKE_brush_size_get(scene, brush) : brush->size;
266  int size = (int)(scalar * old_size);
267 
268  if (abs(old_size - size) < U.pixelsize) {
269  if (scalar > 1) {
270  size += U.pixelsize;
271  }
272  else if (scalar < 1) {
273  size -= U.pixelsize;
274  }
275  }
276  /* Grease Pencil does not use unified size. */
277  if (is_gpencil) {
278  brush->size = max_ii(size, 1);
280  return OPERATOR_FINISHED;
281  }
282 
283  BKE_brush_size_set(scene, brush, size);
284  }
285 
286  /* unprojected radius */
287  {
288  float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush);
289 
290  if (unprojected_radius < 0.001f) { /* XXX magic number */
291  unprojected_radius = 0.001f;
292  }
293 
294  BKE_brush_unprojected_radius_set(scene, brush, unprojected_radius);
295  }
296 
298  }
299 
300  return OPERATOR_FINISHED;
301 }
302 
304 {
305  /* identifiers */
306  ot->name = "Scale Sculpt/Paint Brush Size";
307  ot->description = "Change brush size by a scalar";
308  ot->idname = "BRUSH_OT_scale_size";
309 
310  /* api callbacks */
312 
313  /* flags */
314  ot->flag = 0;
315 
316  RNA_def_float(ot->srna, "scalar", 1, 0, 2, "Scalar", "Factor to scale brush size by", 0, 2);
317 }
318 
319 /* Palette operators */
320 
322 {
324  Main *bmain = CTX_data_main(C);
325  Palette *palette;
326 
327  palette = BKE_palette_add(bmain, "Palette");
328 
329  BKE_paint_palette_set(paint, palette);
330 
331  return OPERATOR_FINISHED;
332 }
333 
335 {
336  /* identifiers */
337  ot->name = "Add New Palette";
338  ot->description = "Add new palette";
339  ot->idname = "PALETTE_OT_new";
340 
341  /* api callbacks */
343 
344  /* flags */
346 }
347 
348 static bool palette_poll(bContext *C)
349 {
351 
352  if (paint && paint->palette != NULL && !ID_IS_LINKED(paint->palette) &&
353  !ID_IS_OVERRIDE_LIBRARY(paint->palette)) {
354  return true;
355  }
356 
357  return false;
358 }
359 
361 {
365  Palette *palette = paint->palette;
367 
368  color = BKE_palette_color_add(palette);
369  palette->active_color = BLI_listbase_count(&palette->colors) - 1;
370 
371  if (paint->brush) {
372  const Brush *brush = paint->brush;
373  if (ELEM(mode,
378  copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
379  color->value = 0.0;
380  }
381  else if (mode == PAINT_MODE_WEIGHT) {
382  zero_v3(color->rgb);
383  color->value = brush->weight;
384  }
385  }
386 
387  return OPERATOR_FINISHED;
388 }
389 
391 {
392  /* identifiers */
393  ot->name = "New Palette Color";
394  ot->description = "Add new color to active palette";
395  ot->idname = "PALETTE_OT_color_add";
396 
397  /* api callbacks */
399  ot->poll = palette_poll;
400  /* flags */
402 }
403 
405 {
407  Palette *palette = paint->palette;
408  PaletteColor *color = BLI_findlink(&palette->colors, palette->active_color);
409 
410  if (color) {
412  }
413 
414  return OPERATOR_FINISHED;
415 }
416 
418 {
419  /* identifiers */
420  ot->name = "Delete Palette Color";
421  ot->description = "Remove active color from palette";
422  ot->idname = "PALETTE_OT_color_delete";
423 
424  /* api callbacks */
426  ot->poll = palette_poll;
427  /* flags */
429 }
430 
431 /* --- Extract Palette from Image. */
433 {
435  if ((sl != NULL) && (sl->spacetype == SPACE_IMAGE)) {
437  Image *image = sima->image;
438  ImageUser iuser = sima->iuser;
439  return BKE_image_has_ibuf(image, &iuser);
440  }
441 
442  return false;
443 }
444 
446 {
447  const int threshold = RNA_int_get(op->ptr, "threshold");
448 
449  Main *bmain = CTX_data_main(C);
450  bool done = false;
451 
453  Image *image = sima->image;
454  ImageUser iuser = sima->iuser;
455  void *lock;
456  ImBuf *ibuf;
457  GHash *color_table = BLI_ghash_int_new(__func__);
458 
459  ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
460 
461  if (ibuf && ibuf->rect) {
462  /* Extract all colors. */
463  const int range = (int)pow(10.0f, threshold);
464  for (int row = 0; row < ibuf->y; row++) {
465  for (int col = 0; col < ibuf->x; col++) {
466  float color[4];
467  IMB_sampleImageAtLocation(ibuf, (float)col, (float)row, false, color);
468  for (int i = 0; i < 3; i++) {
469  color[i] = truncf(color[i] * range) / range;
470  }
471 
472  uint key = rgb_to_cpack(color[0], color[1], color[2]);
473  if (!BLI_ghash_haskey(color_table, POINTER_FROM_INT(key))) {
474  BLI_ghash_insert(color_table, POINTER_FROM_INT(key), POINTER_FROM_INT(key));
475  }
476  }
477  }
478 
479  done = BKE_palette_from_hash(bmain, color_table, image->id.name + 2, false);
480  }
481 
482  /* Free memory. */
483  BLI_ghash_free(color_table, NULL, NULL);
485 
486  if (done) {
487  BKE_reportf(op->reports, RPT_INFO, "Palette created");
488  }
489 
490  return OPERATOR_FINISHED;
491 }
492 
494 {
495  PropertyRNA *prop;
496 
497  /* identifiers */
498  ot->name = "Extract Palette from Image";
499  ot->idname = "PALETTE_OT_extract_from_image";
500  ot->description = "Extract all colors used in Image and create a Palette";
501 
502  /* api callbacks */
505 
506  /* flags */
508 
509  /* properties */
510  prop = RNA_def_int(ot->srna, "threshold", 1, 1, 1, "Threshold", "", 1, 1);
512 }
513 
514 /* Sort Palette color by Hue and Saturation. */
516 {
517  const int type = RNA_enum_get(op->ptr, "type");
518 
520  Palette *palette = paint->palette;
521 
522  if (palette == NULL) {
523  return OPERATOR_CANCELLED;
524  }
525 
526  tPaletteColorHSV *color_array = NULL;
527  tPaletteColorHSV *col_elm = NULL;
528 
529  const int totcol = BLI_listbase_count(&palette->colors);
530 
531  if (totcol > 0) {
532  color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__);
533  /* Put all colors in an array. */
534  int t = 0;
535  LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) {
536  float h, s, v;
537  rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &v);
538  col_elm = &color_array[t];
539  copy_v3_v3(col_elm->rgb, color->rgb);
540  col_elm->value = color->value;
541  col_elm->h = h;
542  col_elm->s = s;
543  col_elm->v = v;
544  t++;
545  }
546  /* Sort */
547  if (type == 1) {
548  BKE_palette_sort_hsv(color_array, totcol);
549  }
550  else if (type == 2) {
551  BKE_palette_sort_svh(color_array, totcol);
552  }
553  else if (type == 3) {
554  BKE_palette_sort_vhs(color_array, totcol);
555  }
556  else {
557  BKE_palette_sort_luminance(color_array, totcol);
558  }
559 
560  /* Clear old color swatches. */
561  PaletteColor *color_next = NULL;
562  for (PaletteColor *color = palette->colors.first; color; color = color_next) {
563  color_next = color->next;
565  }
566 
567  /* Recreate swatches sorted. */
568  for (int i = 0; i < totcol; i++) {
569  col_elm = &color_array[i];
570  PaletteColor *palcol = BKE_palette_color_add(palette);
571  if (palcol) {
572  copy_v3_v3(palcol->rgb, col_elm->rgb);
573  }
574  }
575  }
576 
577  /* Free memory. */
578  if (totcol > 0) {
579  MEM_SAFE_FREE(color_array);
580  }
581 
583 
584  return OPERATOR_FINISHED;
585 }
586 
588 {
589  static const EnumPropertyItem sort_type[] = {
590  {1, "HSV", 0, "Hue, Saturation, Value", ""},
591  {2, "SVH", 0, "Saturation, Value, Hue", ""},
592  {3, "VHS", 0, "Value, Hue, Saturation", ""},
593  {4, "LUMINANCE", 0, "Luminance", ""},
594  {0, NULL, 0, NULL, NULL},
595  };
596 
597  /* identifiers */
598  ot->name = "Sort Palette";
599  ot->idname = "PALETTE_OT_sort";
600  ot->description = "Sort Palette Colors";
601 
602  /* api callbacks */
604  ot->poll = palette_poll;
605 
606  /* flags */
608 
609  ot->prop = RNA_def_enum(ot->srna, "type", sort_type, 1, "Type", "");
610 }
611 
612 /* Move colors in palette. */
614 {
616  Palette *palette = paint->palette;
617  PaletteColor *palcolor = BLI_findlink(&palette->colors, palette->active_color);
618 
619  if (palcolor == NULL) {
620  return OPERATOR_CANCELLED;
621  }
622 
623  const int direction = RNA_enum_get(op->ptr, "type");
624 
625  BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
626  if (BLI_listbase_link_move(&palette->colors, palcolor, direction)) {
627  palette->active_color += direction;
629  }
630 
631  return OPERATOR_FINISHED;
632 }
633 
635 {
636  static const EnumPropertyItem slot_move[] = {
637  {-1, "UP", 0, "Up", ""},
638  {1, "DOWN", 0, "Down", ""},
639  {0, NULL, 0, NULL, NULL},
640  };
641 
642  /* identifiers */
643  ot->name = "Move Palette Color";
644  ot->idname = "PALETTE_OT_color_move";
645  ot->description = "Move the active Color up/down in the list";
646 
647  /* api callbacks */
649  ot->poll = palette_poll;
650 
651  /* flags */
653 
654  ot->prop = RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
655 }
656 
657 /* Join Palette swatches. */
659 {
660  Main *bmain = CTX_data_main(C);
662  Palette *palette = paint->palette;
663  Palette *palette_join = NULL;
664  bool done = false;
665 
666  char name[MAX_ID_NAME - 2];
667  RNA_string_get(op->ptr, "palette", name);
668 
669  if ((palette == NULL) || (name[0] == '\0')) {
670  return OPERATOR_CANCELLED;
671  }
672 
673  palette_join = (Palette *)BKE_libblock_find_name(bmain, ID_PAL, name);
674  if (palette_join == NULL) {
675  return OPERATOR_CANCELLED;
676  }
677 
678  const int totcol = BLI_listbase_count(&palette_join->colors);
679 
680  if (totcol > 0) {
681  LISTBASE_FOREACH (PaletteColor *, color, &palette_join->colors) {
682  PaletteColor *palcol = BKE_palette_color_add(palette);
683  if (palcol) {
684  copy_v3_v3(palcol->rgb, color->rgb);
685  palcol->value = color->value;
686  done = true;
687  }
688  }
689  }
690 
691  if (done) {
692  /* Clear old color swatches. */
693  PaletteColor *color_next = NULL;
694  for (PaletteColor *color = palette_join->colors.first; color; color = color_next) {
695  color_next = color->next;
696  BKE_palette_color_remove(palette_join, color);
697  }
698 
699  /* Notifier. */
701  }
702 
703  return OPERATOR_FINISHED;
704 }
705 
707 {
708  /* identifiers */
709  ot->name = "Join Palette Swatches";
710  ot->idname = "PALETTE_OT_join";
711  ot->description = "Join Palette Swatches";
712 
713  /* api callbacks */
715  ot->poll = palette_poll;
716 
717  /* flags */
719 
720  /* properties */
721  RNA_def_string(ot->srna, "palette", NULL, MAX_ID_NAME - 2, "Palette", "Name of the Palette");
722 }
723 
725 {
727  Brush *brush = BKE_paint_brush(paint);
729 
730  if (!ob || !brush) {
731  return OPERATOR_CANCELLED;
732  }
733 
734  /* TODO: other modes */
735  if (ob->mode & OB_MODE_SCULPT) {
736  BKE_brush_sculpt_reset(brush);
737  }
738  else {
739  return OPERATOR_CANCELLED;
740  }
742 
743  return OPERATOR_FINISHED;
744 }
745 
747 {
748  /* identifiers */
749  ot->name = "Reset Brush";
750  ot->description = "Return brush to defaults based on current tool";
751  ot->idname = "BRUSH_OT_reset";
752 
753  /* api callbacks */
755 
756  /* flags */
758 }
759 
760 static int brush_tool(const Brush *brush, size_t tool_offset)
761 {
762  return *(((char *)brush) + tool_offset);
763 }
764 
765 static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool)
766 {
767  *(((char *)brush) + tool_offset) = tool;
768 }
769 
770 static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)
771 {
772  Brush *brush, *first_brush;
773 
774  if (!brush_orig && !(brush_orig = bmain->brushes.first)) {
775  return NULL;
776  }
777 
778  if (brush_tool(brush_orig, paint->runtime.tool_offset) != tool) {
779  /* If current brush's tool is different from what we need,
780  * start cycling from the beginning of the list.
781  * Such logic will activate the same exact brush not relating from
782  * which tool user requests other tool.
783  */
784 
785  /* Try to tool-slot first. */
786  first_brush = BKE_paint_toolslots_brush_get(paint, tool);
787  if (first_brush == NULL) {
788  first_brush = bmain->brushes.first;
789  }
790  }
791  else {
792  /* If user wants to switch to brush with the same tool as
793  * currently active brush do a cycling via all possible
794  * brushes with requested tool.
795  */
796  first_brush = brush_orig->id.next ? brush_orig->id.next : bmain->brushes.first;
797  }
798 
799  /* get the next brush with the active tool */
800  brush = first_brush;
801  do {
802  if ((brush->ob_mode & paint->runtime.ob_mode) &&
803  (brush_tool(brush, paint->runtime.tool_offset) == tool)) {
804  return brush;
805  }
806 
807  brush = brush->id.next ? brush->id.next : bmain->brushes.first;
808  } while (brush != first_brush);
809 
810  return NULL;
811 }
812 
813 static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)
814 {
815  if (!brush_orig || brush_tool(brush_orig, paint->runtime.tool_offset) != tool) {
816  Brush *br;
817  /* if the current brush is not using the desired tool, look
818  * for one that is */
819  br = brush_tool_cycle(bmain, paint, brush_orig, tool);
820  /* store the previously-selected brush */
821  if (br) {
822  br->toggle_brush = brush_orig;
823  }
824 
825  return br;
826  }
827  if (brush_orig->toggle_brush) {
828  /* if current brush is using the desired tool, try to toggle
829  * back to the previously selected brush. */
830  return brush_orig->toggle_brush;
831  }
832  return NULL;
833 }
834 
836  Main *bmain,
837  Paint *paint,
838  const int tool,
839  const char *tool_name,
840  const bool create_missing,
841  const bool toggle)
842 {
843  Brush *brush, *brush_orig = BKE_paint_brush(paint);
844 
845  if (toggle) {
846  brush = brush_tool_toggle(bmain, paint, brush_orig, tool);
847  }
848  else {
849  brush = brush_tool_cycle(bmain, paint, brush_orig, tool);
850  }
851 
852  if (((brush == NULL) && create_missing) &&
853  ((brush_orig == NULL) || brush_tool(brush_orig, paint->runtime.tool_offset) != tool)) {
854  brush = BKE_brush_add(bmain, tool_name, paint->runtime.ob_mode);
855  id_us_min(&brush->id); /* fake user only */
856  brush_tool_set(brush, paint->runtime.tool_offset, tool);
857  brush->toggle_brush = brush_orig;
858  }
859 
860  if (brush) {
861  BKE_paint_brush_set(paint, brush);
863 
865 
866  /* Tool System
867  * This is needed for when there is a non-sculpt tool active (transform for e.g.).
868  * In case we are toggling (and the brush changed to the toggle_brush), we need to get the
869  * tool_name again. */
870  int tool_result = brush_tool(brush, paint->runtime.tool_offset);
872  const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
873  RNA_enum_name_from_value(items, tool_result, &tool_name);
874 
875  char tool_id[MAX_NAME];
876  SNPRINTF(tool_id, "builtin_brush.%s", tool_name);
877  WM_toolsystem_ref_set_by_id(C, tool_id);
878 
879  return true;
880  }
881  return false;
882 }
883 
894 };
895 
897 {
898  Main *bmain = CTX_data_main(C);
900  const bool create_missing = RNA_boolean_get(op->ptr, "create_missing");
901  const bool toggle = RNA_boolean_get(op->ptr, "toggle");
902  const char *tool_name = "Brush";
903  int tool = 0;
904 
905  ePaintMode paint_mode = PAINT_MODE_INVALID;
906  for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
907  paint_mode = brush_select_paint_modes[i];
908  const char *op_prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
909  PropertyRNA *prop = RNA_struct_find_property(op->ptr, op_prop_id);
910  if (RNA_property_is_set(op->ptr, prop)) {
911  tool = RNA_property_enum_get(op->ptr, prop);
912  break;
913  }
914  }
915 
916  if (paint_mode == PAINT_MODE_INVALID) {
917  return OPERATOR_CANCELLED;
918  }
919 
920  Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
921  if (paint == NULL) {
922  return OPERATOR_CANCELLED;
923  }
924  const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
925  RNA_enum_name_from_value(items, tool, &tool_name);
926 
927  if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) {
928  return OPERATOR_FINISHED;
929  }
930  return OPERATOR_CANCELLED;
931 }
932 
934 {
935  PropertyRNA *prop;
936 
937  /* identifiers */
938  ot->name = "Brush Select";
939  ot->description = "Select a paint mode's brush by tool type";
940  ot->idname = "PAINT_OT_brush_select";
941 
942  /* api callbacks */
944 
945  /* flags */
946  ot->flag = 0;
947 
948  /* props */
949  /* All properties are hidden, so as not to show the redo panel. */
950  for (int i = 0; i < ARRAY_SIZE(brush_select_paint_modes); i++) {
951  const ePaintMode paint_mode = brush_select_paint_modes[i];
952  const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
953  prop = RNA_def_enum(
954  ot->srna, prop_id, BKE_paint_get_tool_enum_from_paintmode(paint_mode), 0, prop_id, "");
956  }
957 
958  prop = RNA_def_boolean(
959  ot->srna, "toggle", 0, "Toggle", "Toggle between two brushes rather than cycling");
961  prop = RNA_def_boolean(ot->srna,
962  "create_missing",
963  0,
964  "Create Missing",
965  "If the requested brush type does not exist, create a new brush");
967 }
968 
969 /***** Stencil Control *****/
970 
971 typedef enum {
976 
977 typedef enum {
981 
982 typedef enum {
986 
987 typedef struct {
988  float init_mouse[2];
989  float init_spos[2];
990  float init_sdim[2];
991  float init_rot;
992  float init_angle;
993  float lenorig;
994  float area_size[2];
998  int mask;
1000  float *dim_target;
1001  float *rot_target;
1002  float *pos_target;
1005 
1007 {
1008  Brush *br = scd->br;
1009  float mdiff[2];
1010  if (scd->mask) {
1013  scd->init_rot = br->mask_mtex.rot;
1014 
1016  scd->rot_target = &br->mask_mtex.rot;
1017  scd->pos_target = br->mask_stencil_pos;
1018 
1019  sub_v2_v2v2(mdiff, scd->init_mouse, br->mask_stencil_pos);
1020  }
1021  else {
1023  copy_v2_v2(scd->init_spos, br->stencil_pos);
1024  scd->init_rot = br->mtex.rot;
1025 
1026  scd->dim_target = br->stencil_dimension;
1027  scd->rot_target = &br->mtex.rot;
1028  scd->pos_target = br->stencil_pos;
1029 
1030  sub_v2_v2v2(mdiff, scd->init_mouse, br->stencil_pos);
1031  }
1032 
1033  scd->lenorig = len_v2(mdiff);
1034 
1035  scd->init_angle = atan2f(mdiff[1], mdiff[0]);
1036 }
1037 
1038 static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1039 {
1041  Brush *br = BKE_paint_brush(paint);
1042  const float mvalf[2] = {event->mval[0], event->mval[1]};
1043  ARegion *region = CTX_wm_region(C);
1044  StencilControlData *scd;
1045  int mask = RNA_enum_get(op->ptr, "texmode");
1046 
1047  if (mask) {
1049  return OPERATOR_CANCELLED;
1050  }
1051  }
1052  else {
1054  return OPERATOR_CANCELLED;
1055  }
1056  }
1057 
1058  scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control");
1059  scd->mask = mask;
1060  scd->br = br;
1061 
1062  copy_v2_v2(scd->init_mouse, mvalf);
1063 
1064  stencil_set_target(scd);
1065 
1066  scd->mode = RNA_enum_get(op->ptr, "mode");
1068  scd->area_size[0] = region->winx;
1069  scd->area_size[1] = region->winy;
1070 
1071  op->customdata = scd;
1073 
1074  return OPERATOR_RUNNING_MODAL;
1075 }
1076 
1078 {
1079  copy_v2_v2(scd->dim_target, scd->init_sdim);
1080  copy_v2_v2(scd->pos_target, scd->init_spos);
1081  *scd->rot_target = scd->init_rot;
1082 }
1083 
1085 {
1086  StencilControlData *scd = op->customdata;
1087 
1088  stencil_restore(scd);
1089  MEM_freeN(op->customdata);
1090 }
1091 
1092 static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
1093 {
1094 #define PIXEL_MARGIN 5
1095 
1096  float mdiff[2];
1097  const float mvalf[2] = {mval[0], mval[1]};
1098  switch (scd->mode) {
1099  case STENCIL_TRANSLATE:
1100  sub_v2_v2v2(mdiff, mvalf, scd->init_mouse);
1101  add_v2_v2v2(scd->pos_target, scd->init_spos, mdiff);
1102  CLAMP(scd->pos_target[0],
1103  -scd->dim_target[0] + PIXEL_MARGIN,
1104  scd->area_size[0] + scd->dim_target[0] - PIXEL_MARGIN);
1105 
1106  CLAMP(scd->pos_target[1],
1107  -scd->dim_target[1] + PIXEL_MARGIN,
1108  scd->area_size[1] + scd->dim_target[1] - PIXEL_MARGIN);
1109 
1110  break;
1111  case STENCIL_SCALE: {
1112  float len, factor;
1113  sub_v2_v2v2(mdiff, mvalf, scd->pos_target);
1114  len = len_v2(mdiff);
1115  factor = len / scd->lenorig;
1116  copy_v2_v2(mdiff, scd->init_sdim);
1117  if (scd->constrain_mode != STENCIL_CONSTRAINT_Y) {
1118  mdiff[0] = factor * scd->init_sdim[0];
1119  }
1120  if (scd->constrain_mode != STENCIL_CONSTRAINT_X) {
1121  mdiff[1] = factor * scd->init_sdim[1];
1122  }
1123  clamp_v2(mdiff, 5.0f, 10000.0f);
1124  copy_v2_v2(scd->dim_target, mdiff);
1125  break;
1126  }
1127  case STENCIL_ROTATE: {
1128  float angle;
1129  sub_v2_v2v2(mdiff, mvalf, scd->pos_target);
1130  angle = atan2f(mdiff[1], mdiff[0]);
1131  angle = scd->init_rot + angle - scd->init_angle;
1132  if (angle < 0.0f) {
1133  angle += (float)(2 * M_PI);
1134  }
1135  if (angle > (float)(2 * M_PI)) {
1136  angle -= (float)(2 * M_PI);
1137  }
1138  *scd->rot_target = angle;
1139  break;
1140  }
1141  }
1142 #undef PIXEL_MARGIN
1143 }
1144 
1145 static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
1146 {
1147  StencilControlData *scd = op->customdata;
1148 
1149  if (event->type == scd->launch_event && event->val == KM_RELEASE) {
1150  MEM_freeN(op->customdata);
1152  return OPERATOR_FINISHED;
1153  }
1154 
1155  switch (event->type) {
1156  case MOUSEMOVE:
1157  stencil_control_calculate(scd, event->mval);
1158  break;
1159  case EVT_ESCKEY:
1160  if (event->val == KM_PRESS) {
1163  return OPERATOR_CANCELLED;
1164  }
1165  break;
1166  case EVT_XKEY:
1167  if (event->val == KM_PRESS) {
1168 
1169  if (scd->constrain_mode == STENCIL_CONSTRAINT_X) {
1170  scd->constrain_mode = 0;
1171  }
1172  else {
1174  }
1175 
1176  stencil_control_calculate(scd, event->mval);
1177  }
1178  break;
1179  case EVT_YKEY:
1180  if (event->val == KM_PRESS) {
1181  if (scd->constrain_mode == STENCIL_CONSTRAINT_Y) {
1182  scd->constrain_mode = 0;
1183  }
1184  else {
1186  }
1187 
1188  stencil_control_calculate(scd, event->mval);
1189  }
1190  break;
1191  default:
1192  break;
1193  }
1194 
1196 
1197  return OPERATOR_RUNNING_MODAL;
1198 }
1199 
1201 {
1203 
1204  Paint *paint;
1205  Brush *br;
1206 
1207  if (!paint_supports_texture(mode)) {
1208  return false;
1209  }
1210 
1212  br = BKE_paint_brush(paint);
1213  return (br && (br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL ||
1215 }
1216 
1218 {
1219  static const EnumPropertyItem stencil_control_items[] = {
1220  {STENCIL_TRANSLATE, "TRANSLATION", 0, "Translation", ""},
1221  {STENCIL_SCALE, "SCALE", 0, "Scale", ""},
1222  {STENCIL_ROTATE, "ROTATION", 0, "Rotation", ""},
1223  {0, NULL, 0, NULL, NULL},
1224  };
1225 
1226  static const EnumPropertyItem stencil_texture_items[] = {
1227  {STENCIL_PRIMARY, "PRIMARY", 0, "Primary", ""},
1228  {STENCIL_SECONDARY, "SECONDARY", 0, "Secondary", ""},
1229  {0, NULL, 0, NULL, NULL},
1230  };
1231  /* identifiers */
1232  ot->name = "Stencil Brush Control";
1233  ot->description = "Control the stencil brush";
1234  ot->idname = "BRUSH_OT_stencil_control";
1235 
1236  /* api callbacks */
1241 
1242  /* flags */
1243  ot->flag = 0;
1244 
1245  PropertyRNA *prop;
1246  prop = RNA_def_enum(ot->srna, "mode", stencil_control_items, STENCIL_TRANSLATE, "Tool", "");
1248  prop = RNA_def_enum(ot->srna, "texmode", stencil_texture_items, STENCIL_PRIMARY, "Tool", "");
1250 }
1251 
1253 {
1255  Brush *br = BKE_paint_brush(paint);
1256  bool use_scale = RNA_boolean_get(op->ptr, "use_scale");
1257  bool use_repeat = RNA_boolean_get(op->ptr, "use_repeat");
1258  bool do_mask = RNA_boolean_get(op->ptr, "mask");
1259  Tex *tex = NULL;
1260  MTex *mtex = NULL;
1261  if (br) {
1262  mtex = do_mask ? &br->mask_mtex : &br->mtex;
1263  tex = mtex->tex;
1264  }
1265 
1266  if (tex && tex->type == TEX_IMAGE && tex->ima) {
1267  float aspx, aspy;
1268  Image *ima = tex->ima;
1269  float orig_area, stencil_area, factor;
1270  ED_image_get_uv_aspect(ima, NULL, &aspx, &aspy);
1271 
1272  if (use_scale) {
1273  aspx *= mtex->size[0];
1274  aspy *= mtex->size[1];
1275  }
1276 
1277  if (use_repeat && tex->extend == TEX_REPEAT) {
1278  aspx *= tex->xrepeat;
1279  aspy *= tex->yrepeat;
1280  }
1281 
1282  orig_area = fabsf(aspx * aspy);
1283 
1284  if (do_mask) {
1285  stencil_area = fabsf(br->mask_stencil_dimension[0] * br->mask_stencil_dimension[1]);
1286  }
1287  else {
1288  stencil_area = fabsf(br->stencil_dimension[0] * br->stencil_dimension[1]);
1289  }
1290 
1291  factor = sqrtf(stencil_area / orig_area);
1292 
1293  if (do_mask) {
1294  br->mask_stencil_dimension[0] = fabsf(factor * aspx);
1295  br->mask_stencil_dimension[1] = fabsf(factor * aspy);
1296  }
1297  else {
1298  br->stencil_dimension[0] = fabsf(factor * aspx);
1299  br->stencil_dimension[1] = fabsf(factor * aspy);
1300  }
1301  }
1302 
1304 
1305  return OPERATOR_FINISHED;
1306 }
1307 
1309 {
1310  /* identifiers */
1311  ot->name = "Image Aspect";
1312  ot->description =
1313  "When using an image texture, adjust the stencil size to fit the image aspect ratio";
1314  ot->idname = "BRUSH_OT_stencil_fit_image_aspect";
1315 
1316  /* api callbacks */
1319 
1320  /* flags */
1322 
1323  RNA_def_boolean(ot->srna, "use_repeat", 1, "Use Repeat", "Use repeat mapping values");
1324  RNA_def_boolean(ot->srna, "use_scale", 1, "Use Scale", "Use texture scale values");
1326  ot->srna, "mask", 0, "Modify Mask Stencil", "Modify either the primary or mask stencil");
1327 }
1328 
1330 {
1332  Brush *br = BKE_paint_brush(paint);
1333  bool do_mask = RNA_boolean_get(op->ptr, "mask");
1334 
1335  if (!br) {
1336  return OPERATOR_CANCELLED;
1337  }
1338 
1339  if (do_mask) {
1340  br->mask_stencil_pos[0] = 256;
1341  br->mask_stencil_pos[1] = 256;
1342 
1343  br->mask_stencil_dimension[0] = 256;
1344  br->mask_stencil_dimension[1] = 256;
1345 
1346  br->mask_mtex.rot = 0;
1347  }
1348  else {
1349  br->stencil_pos[0] = 256;
1350  br->stencil_pos[1] = 256;
1351 
1352  br->stencil_dimension[0] = 256;
1353  br->stencil_dimension[1] = 256;
1354 
1355  br->mtex.rot = 0;
1356  }
1357 
1359 
1360  return OPERATOR_FINISHED;
1361 }
1362 
1364 {
1365  /* identifiers */
1366  ot->name = "Reset Transform";
1367  ot->description = "Reset the stencil transformation to the default";
1368  ot->idname = "BRUSH_OT_stencil_reset_transform";
1369 
1370  /* api callbacks */
1373 
1374  /* flags */
1376 
1378  ot->srna, "mask", 0, "Modify Mask Stencil", "Modify either the primary or mask stencil");
1379 }
1380 
1381 /**************************** registration **********************************/
1382 
1384 {
1385  wmOperatorType *ot;
1386  wmOperatorTypeMacro *otmacro;
1387 
1388  ot = WM_operatortype_append_macro("PAINTCURVE_OT_add_point_slide",
1389  "Add Curve Point and Slide",
1390  "Add new curve point and slide it",
1391  OPTYPE_UNDO);
1392  ot->description = "Add new curve point and slide it";
1393  WM_operatortype_macro_define(ot, "PAINTCURVE_OT_add_point");
1394  otmacro = WM_operatortype_macro_define(ot, "PAINTCURVE_OT_slide");
1395  RNA_boolean_set(otmacro->ptr, "align", true);
1396  RNA_boolean_set(otmacro->ptr, "select", false);
1397 }
1398 
1400 {
1401  /* palette */
1405 
1410 
1411  /* paint curve */
1419 
1420  /* brush */
1429 
1430  /* NOTE: particle uses a different system, can be added with existing operators in `wm.py`. */
1432 
1433  /* image */
1443 
1444  /* weight */
1452 
1453  /* uv */
1455 
1456  /* vertex selection */
1460 
1461  /* vertex */
1466 
1472 
1473  /* face-select */
1478 
1480 
1481  /* partial visibility */
1483 
1484  /* paint masking */
1489 }
1490 
1492 {
1493  wmKeyMap *keymap;
1494 
1495  keymap = WM_keymap_ensure(keyconf, "Paint Curve", 0, 0);
1496  keymap->poll = paint_curve_poll;
1497 
1498  /* Sculpt mode */
1499  keymap = WM_keymap_ensure(keyconf, "Sculpt", 0, 0);
1500  keymap->poll = SCULPT_mode_poll;
1501 
1502  /* Vertex Paint mode */
1503  keymap = WM_keymap_ensure(keyconf, "Vertex Paint", 0, 0);
1504  keymap->poll = vertex_paint_mode_poll;
1505 
1506  /* Weight Paint mode */
1507  keymap = WM_keymap_ensure(keyconf, "Weight Paint", 0, 0);
1508  keymap->poll = weight_paint_mode_poll;
1509 
1510  /* Weight paint's Vertex Selection Mode. */
1511  keymap = WM_keymap_ensure(keyconf, "Paint Vertex Selection (Weight, Vertex)", 0, 0);
1512  keymap->poll = vert_paint_poll;
1513 
1514  /* Image/Texture Paint mode */
1515  keymap = WM_keymap_ensure(keyconf, "Image Paint", 0, 0);
1516  keymap->poll = image_texture_paint_poll;
1517 
1518  /* face-mask mode */
1519  keymap = WM_keymap_ensure(keyconf, "Paint Face Mask (Weight, Vertex, Texture)", 0, 0);
1520  keymap->poll = facemask_paint_poll;
1521 
1522  /* paint stroke */
1523  keymap = paint_stroke_modal_keymap(keyconf);
1524  WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke");
1525 
1526  /* Curves Sculpt mode. */
1527  keymap = WM_keymap_ensure(keyconf, "Sculpt Curves", 0, 0);
1528  keymap->poll = CURVES_SCULPT_mode_poll;
1529 
1530  /* sculpt expand. */
1531  sculpt_expand_modal_keymap(keyconf);
1532 }
typedef float(TangentPoint)[2]
struct Brush * BKE_brush_add(struct Main *bmain, const char *name, eObjectMode ob_mode)
Definition: brush.cc:496
void BKE_brush_size_set(struct Scene *scene, struct Brush *brush, int size)
Definition: brush.cc:2234
void BKE_brush_init_gpencil_settings(struct Brush *brush)
Definition: brush.cc:509
void BKE_gpencil_brush_preset_set(struct Main *bmain, struct Brush *brush, short type)
Definition: brush.cc:669
const float * BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush)
Definition: brush.cc:2210
void BKE_brush_sculpt_reset(struct Brush *brush)
Definition: brush.cc:1683
int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush)
float BKE_brush_unprojected_radius_get(const struct Scene *scene, const struct Brush *brush)
void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float unprojected_radius)
Definition: brush.cc:2294
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
eContextObjectMode
Definition: BKE_context.h:103
@ CTX_MODE_WEIGHT_GPENCIL
Definition: BKE_context.h:122
@ CTX_MODE_VERTEX_GPENCIL
Definition: BKE_context.h:123
@ CTX_MODE_SCULPT_GPENCIL
Definition: BKE_context.h:121
@ CTX_MODE_PAINT_GPENCIL
Definition: BKE_context.h:119
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1353
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:733
struct SpaceLink * CTX_wm_space_data(const bContext *C)
Definition: context.c:743
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:824
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
Definition: context.c:1228
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
bool BKE_image_has_ibuf(struct Image *ima, struct ImageUser *iuser)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void id_us_min(struct ID *id)
Definition: lib_id.c:313
struct ID * BKE_libblock_find_name(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: lib_id.c:1297
void BKE_palette_sort_vhs(struct tPaletteColorHSV *color_array, int totcol)
Definition: paint.c:906
eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode)
Definition: paint.c:1022
void BKE_paint_brush_set(struct Paint *paint, struct Brush *br)
Definition: paint.c:617
struct Palette * BKE_palette_add(struct Main *bmain, const char *name)
Definition: paint.c:764
void BKE_palette_sort_svh(struct tPaletteColorHSV *color_array, int totcol)
Definition: paint.c:900
struct Paint * BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode)
Definition: paint.c:345
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C)
struct Brush * BKE_paint_toolslots_brush_get(struct Paint *paint, int slot_index)
struct Brush * BKE_paint_brush(struct Paint *paint)
Definition: paint.c:607
void BKE_paint_palette_set(struct Paint *p, struct Palette *palette)
Definition: paint.c:719
void BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color)
Definition: paint.c:742
void BKE_palette_sort_hsv(struct tPaletteColorHSV *color_array, int totcol)
Definition: paint.c:894
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
const struct EnumPropertyItem * BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
Definition: paint.c:382
void BKE_paint_invalidate_overlay_all(void)
Definition: paint.c:260
ePaintMode
Definition: BKE_paint.h:67
@ PAINT_MODE_INVALID
Definition: BKE_paint.h:86
@ PAINT_MODE_SCULPT_CURVES
Definition: BKE_paint.h:83
@ PAINT_MODE_GPENCIL
Definition: BKE_paint.h:77
@ PAINT_MODE_VERTEX_GPENCIL
Definition: BKE_paint.h:79
@ PAINT_MODE_TEXTURE_3D
Definition: BKE_paint.h:73
@ PAINT_MODE_WEIGHT_GPENCIL
Definition: BKE_paint.h:81
@ PAINT_MODE_SCULPT
Definition: BKE_paint.h:68
@ PAINT_MODE_SCULPT_GPENCIL
Definition: BKE_paint.h:80
@ PAINT_MODE_WEIGHT
Definition: BKE_paint.h:71
@ PAINT_MODE_TEXTURE_2D
Definition: BKE_paint.h:75
@ PAINT_MODE_VERTEX
Definition: BKE_paint.h:70
const char * BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
Definition: paint.c:412
struct PaletteColor * BKE_palette_color_add(struct Palette *palette)
Definition: paint.c:770
void BKE_palette_sort_luminance(struct tPaletteColorHSV *color_array, int totcol)
Definition: paint.c:912
bool BKE_palette_from_hash(struct Main *bmain, struct GHash *color_table, const char *name, bool linear)
Definition: paint.c:918
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert(a)
Definition: BLI_assert.h:46
bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:822
GHash * BLI_ghash_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Definition: listbase.c:405
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
#define M_PI
Definition: BLI_math_base.h:20
unsigned int rgb_to_cpack(float r, float g, float b)
Definition: math_color.c:348
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
Definition: math_color.c:208
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void clamp_v2(float vec[2], float min, float max)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
#define SNPRINTF(dst, format,...)
Definition: BLI_string.h:485
void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL()
Definition: string.c:927
char BLI_toupper_ascii(const char c)
Definition: string.c:922
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
unsigned int uint
Definition: BLI_sys_types.h:67
#define ARRAY_SIZE(arr)
#define POINTER_FROM_INT(i)
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:566
#define MAX_ID_NAME
Definition: DNA_ID.h:337
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:588
@ ID_PAL
Definition: DNA_ID_enums.h:76
eGPBrush_Presets
@ GP_BRUSH_PRESET_TWIST_STROKE
@ GP_BRUSH_PRESET_PUSH_STROKE
@ GP_BRUSH_PRESET_VERTEX_AVERAGE
@ GP_BRUSH_PRESET_PENCIL
@ GP_BRUSH_PRESET_DRAW_WEIGHT
@ GP_BRUSH_PRESET_VERTEX_BLUR
@ GP_BRUSH_PRESET_FILL_AREA
@ GP_BRUSH_PRESET_VERTEX_DRAW
@ GP_BRUSH_PRESET_VERTEX_REPLACE
@ GP_BRUSH_PRESET_SMOOTH_STROKE
@ GP_BRUSH_PRESET_GRAB_STROKE
@ GP_BRUSH_PRESET_TINT
@ GP_BRUSH_PRESET_CLONE_STROKE
@ GP_BRUSH_PRESET_ERASER_SOFT
@ GP_BRUSH_PRESET_THICKNESS_STROKE
@ GP_BRUSH_PRESET_STRENGTH_STROKE
@ GP_BRUSH_PRESET_UNKNOWN
@ GP_BRUSH_PRESET_RANDOMIZE_STROKE
@ GP_BRUSH_PRESET_VERTEX_SMEAR
@ GP_BRUSH_PRESET_PINCH_STROKE
#define MAX_NAME
Definition: DNA_defs.h:48
eObjectMode
@ OB_MODE_VERTEX_GPENCIL
@ OB_MODE_WEIGHT_GPENCIL
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_GPENCIL
@ OB_MODE_PAINT_GPENCIL
Object is a sort of wrapper for general info.
@ SPACE_IMAGE
@ SPACE_VIEW3D
#define TEX_REPEAT
#define MTEX_MAP_MODE_STENCIL
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *r_aspx, float *r_aspy)
Definition: image_edit.c:282
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:655
_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 type
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
void IMB_sampleImageAtLocation(struct ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4])
Definition: imageprocess.c:484
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block TEX_IMAGE
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
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_HIDDEN
Definition: RNA_types.h:216
#define C
Definition: RandGen.cpp:25
@ KM_PRESS
Definition: WM_types.h:267
@ KM_RELEASE
Definition: WM_types.h:268
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_WINDOW
Definition: WM_types.h:325
#define NC_BRUSH
Definition: WM_types.h:335
#define NA_EDITED
Definition: WM_types.h:523
volatile int lock
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
bool CURVES_SCULPT_mode_poll(struct bContext *C)
Scene scene
int len
Definition: draw_manager.c:108
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
uint col
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:32
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
ccl_device_inline float3 pow(float3 v, float e)
Definition: math_float3.h:533
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
#define atan2f(x, y)
Definition: metal/compat.h:227
#define fabsf(x)
Definition: metal/compat.h:219
#define sqrtf(x)
Definition: metal/compat.h:243
static void area(int d1, int d2, int e1, int e2, float weights[2])
T abs(const T &a)
bool paint_curve_poll(bContext *C)
Definition: paint_curve.c:40
void PAINTCURVE_OT_new(wmOperatorType *ot)
Definition: paint_curve.c:158
void PAINTCURVE_OT_add_point(wmOperatorType *ot)
Definition: paint_curve.c:256
void PAINTCURVE_OT_delete_point(wmOperatorType *ot)
Definition: paint_curve.c:348
void PAINTCURVE_OT_draw(wmOperatorType *ot)
Definition: paint_curve.c:689
void PAINTCURVE_OT_cursor(wmOperatorType *ot)
Definition: paint_curve.c:732
void PAINTCURVE_OT_slide(wmOperatorType *ot)
Definition: paint_curve.c:638
void PAINTCURVE_OT_select(wmOperatorType *ot)
Definition: paint_curve.c:492
void PAINT_OT_hide_show(struct wmOperatorType *ot)
Definition: paint_hide.c:405
bool vert_paint_poll(bContext *C)
bool facemask_paint_poll(bContext *C)
Definition: paint_image.cc:998
bool image_texture_paint_poll(bContext *C)
Definition: paint_image.cc:993
void PAINT_OT_sample_color(wmOperatorType *ot)
Definition: paint_image.cc:726
void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
Definition: paint_image.cc:889
void PAINT_OT_brush_colors_flip(wmOperatorType *ot)
Definition: paint_image.cc:946
void PAINT_OT_grab_clone(wmOperatorType *ot)
Definition: paint_image.cc:545
void PAINT_OT_image_paint(wmOperatorType *ot)
void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
void PAINT_OT_add_simple_uvs(wmOperatorType *ot)
void PAINT_OT_project_image(wmOperatorType *ot)
void PAINT_OT_image_from_view(wmOperatorType *ot)
bool vertex_paint_mode_poll(struct bContext *C)
void PAINT_OT_vertex_color_set(struct wmOperatorType *ot)
void PAINT_OT_weight_from_bones(struct wmOperatorType *ot)
void PAINT_OT_face_select_linked_pick(struct wmOperatorType *ot)
Definition: paint_utils.c:634
void PAINT_OT_mask_line_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1693
void PAINT_OT_weight_set(struct wmOperatorType *ot)
void PAINT_OT_face_select_hide(struct wmOperatorType *ot)
Definition: paint_utils.c:737
void PAINT_OT_mask_lasso_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1651
void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot)
void PAINT_OT_vertex_color_hsv(struct wmOperatorType *ot)
bool paint_supports_texture(enum ePaintMode mode)
void PAINT_OT_mask_box_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1672
void PAINT_OT_face_select_all(struct wmOperatorType *ot)
Definition: paint_utils.c:658
void PAINT_OT_weight_sample_group(struct wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot)
Definition: sculpt_uv.c:786
void PAINT_OT_vertex_color_brightness_contrast(struct wmOperatorType *ot)
void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
Definition: paint_mask.c:187
bool weight_paint_mode_poll(struct bContext *C)
void PAINT_OT_weight_paint(struct wmOperatorType *ot)
void PAINT_OT_vertex_paint(struct wmOperatorType *ot)
void PAINT_OT_face_vert_reveal(struct wmOperatorType *ot)
Definition: paint_utils.c:800
void PAINT_OT_vertex_color_smooth(struct wmOperatorType *ot)
void PAINT_OT_vert_select_all(struct wmOperatorType *ot)
Definition: paint_utils.c:681
void PAINT_OT_vert_select_hide(struct wmOperatorType *ot)
Definition: paint_utils.c:761
void PAINT_OT_vert_select_ungrouped(struct wmOperatorType *ot)
Definition: paint_utils.c:711
void PAINT_OT_face_select_linked(struct wmOperatorType *ot)
Definition: paint_utils.c:613
void PAINT_OT_weight_gradient(struct wmOperatorType *ot)
void PAINT_OT_vertex_color_levels(struct wmOperatorType *ot)
struct wmKeyMap * paint_stroke_modal_keymap(struct wmKeyConfig *keyconf)
void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot)
void PAINT_OT_vertex_color_invert(struct wmOperatorType *ot)
void PAINT_OT_weight_sample(struct wmOperatorType *ot)
void PAINT_OT_vertex_color_from_weight(struct wmOperatorType *ot)
void BRUSH_OT_curve_preset(struct wmOperatorType *ot)
Definition: paint_utils.c:580
static void BRUSH_OT_scale_size(wmOperatorType *ot)
Definition: paint_ops.c:303
static int palette_color_move_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:613
static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool)
Definition: paint_ops.c:765
static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:1252
static void PALETTE_OT_join(wmOperatorType *ot)
Definition: paint_ops.c:706
static eGPBrush_Presets gpencil_get_brush_preset_from_tool(bToolRef *tool, enum eContextObjectMode mode)
Definition: paint_ops.c:85
StencilConstraint
Definition: paint_ops.c:982
@ STENCIL_CONSTRAINT_Y
Definition: paint_ops.c:984
@ STENCIL_CONSTRAINT_X
Definition: paint_ops.c:983
static bool stencil_control_poll(bContext *C)
Definition: paint_ops.c:1200
static void PAINT_OT_brush_select(wmOperatorType *ot)
Definition: paint_ops.c:933
static void PALETTE_OT_extract_from_image(wmOperatorType *ot)
Definition: paint_ops.c:493
static void BRUSH_OT_stencil_reset_transform(wmOperatorType *ot)
Definition: paint_ops.c:1363
static bool palette_poll(bContext *C)
Definition: paint_ops.c:348
static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot)
Definition: paint_ops.c:1308
static void BRUSH_OT_add(wmOperatorType *ot)
Definition: paint_ops.c:71
static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
Definition: paint_ops.c:1092
static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_ops.c:50
static int palette_join_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:658
static bool brush_generic_tool_set(bContext *C, Main *bmain, Paint *paint, const int tool, const char *tool_name, const bool create_missing, const bool toggle)
Definition: paint_ops.c:835
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_ops.c:724
static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: paint_ops.c:1038
static void stencil_set_target(StencilControlData *scd)
Definition: paint_ops.c:1006
static Brush * brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)
Definition: paint_ops.c:770
static void BRUSH_OT_add_gpencil(wmOperatorType *ot)
Definition: paint_ops.c:239
static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_ops.c:360
static int palette_extract_img_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:445
static int brush_add_gpencil_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_ops.c:161
static int brush_select_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:896
static void BRUSH_OT_reset(wmOperatorType *ot)
Definition: paint_ops.c:746
static int brush_tool(const Brush *brush, size_t tool_offset)
Definition: paint_ops.c:760
static void PALETTE_OT_new(wmOperatorType *ot)
Definition: paint_ops.c:334
static void PALETTE_OT_color_delete(wmOperatorType *ot)
Definition: paint_ops.c:417
StencilControlMode
Definition: paint_ops.c:971
@ STENCIL_SCALE
Definition: paint_ops.c:973
@ STENCIL_TRANSLATE
Definition: paint_ops.c:972
@ STENCIL_ROTATE
Definition: paint_ops.c:974
StencilTextureMode
Definition: paint_ops.c:977
@ STENCIL_SECONDARY
Definition: paint_ops.c:979
@ STENCIL_PRIMARY
Definition: paint_ops.c:978
static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: paint_ops.c:1145
static void PALETTE_OT_color_move(wmOperatorType *ot)
Definition: paint_ops.c:634
static int palette_new_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_ops.c:321
static int palette_color_delete_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_ops.c:404
static int palette_sort_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:515
static Brush * brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)
Definition: paint_ops.c:813
static void PALETTE_OT_color_add(wmOperatorType *ot)
Definition: paint_ops.c:390
static const ePaintMode brush_select_paint_modes[]
Definition: paint_ops.c:884
#define PIXEL_MARGIN
static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:1329
static void BRUSH_OT_stencil_control(wmOperatorType *ot)
Definition: paint_ops.c:1217
static int brush_scale_size_exec(bContext *C, wmOperator *op)
Definition: paint_ops.c:253
static void stencil_restore(StencilControlData *scd)
Definition: paint_ops.c:1077
static void stencil_control_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: paint_ops.c:1084
static bool palette_extract_img_poll(bContext *C)
Definition: paint_ops.c:432
static void PALETTE_OT_sort(wmOperatorType *ot)
Definition: paint_ops.c:587
void ED_operatormacros_paint(void)
Definition: paint_ops.c:1383
void ED_operatortypes_paint(void)
Definition: paint_ops.c:1399
void ED_keymap_paint(wmKeyConfig *keyconf)
Definition: paint_ops.c:1491
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name)
Definition: rna_access.c:5106
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3402
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
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
bool SCULPT_mode_poll(bContext *C)
Definition: sculpt.c:3957
void sculpt_expand_modal_keymap(wmKeyConfig *keyconf)
struct MTex mtex
float stencil_pos[2]
short ob_mode
float stencil_dimension[2]
float mask_stencil_pos[2]
struct BrushGpencilSettings * gpencil_settings
struct Brush * toggle_brush
struct MTex mask_mtex
float mask_stencil_dimension[2]
float weight
void * next
Definition: DNA_ID.h:369
unsigned int * rect
void * first
Definition: DNA_listBase.h:31
char brush_map_mode
float rot
float size[3]
struct Tex * tex
Definition: BKE_main.h:121
ListBase brushes
Definition: BKE_main.h:193
unsigned short ob_mode
unsigned int tool_offset
struct Paint_Runtime runtime
struct Palette * palette
struct Brush * brush
int active_color
ListBase colors
struct ImageUser iuser
struct Image * image
StencilConstraint constrain_mode
Definition: paint_ops.c:996
float init_sdim[2]
Definition: paint_ops.c:990
float init_spos[2]
Definition: paint_ops.c:989
float area_size[2]
Definition: paint_ops.c:994
StencilControlMode mode
Definition: paint_ops.c:995
float init_mouse[2]
Definition: paint_ops.c:988
short xrepeat
short type
struct Image * ima
short extend
short yrepeat
ListBase areabase
bToolRef_Runtime * runtime
short val
Definition: WM_types.h:680
int mval[2]
Definition: WM_types.h:684
short type
Definition: WM_types.h:678
bool(* poll)(struct bContext *)
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
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
PropertyRNA * prop
Definition: WM_types.h:981
struct ReportList * reports
struct PointerRNA * ptr
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
@ EVT_YKEY
@ EVT_XKEY
@ MOUSEMOVE
@ EVT_ESCKEY
wmOperatorType * ot
Definition: wm_files.c:3479
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
Definition: wm_keymap.c:985
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
bToolRef * WM_toolsystem_ref_set_by_id(bContext *C, const char *name)