Blender  V3.3
paint.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 by Nicholas Bishop. All rights reserved. */
3 
8 #include <stdlib.h>
9 #include <string.h>
10 
11 #include "MEM_guardedalloc.h"
12 
13 #include "DNA_brush_types.h"
14 #include "DNA_gpencil_types.h"
15 #include "DNA_mesh_types.h"
16 #include "DNA_meshdata_types.h"
17 #include "DNA_modifier_types.h"
18 #include "DNA_object_types.h"
19 #include "DNA_scene_types.h"
20 #include "DNA_space_types.h"
21 #include "DNA_view3d_types.h"
22 #include "DNA_workspace_types.h"
23 
24 #include "BLI_bitmap.h"
25 #include "BLI_hash.h"
26 #include "BLI_listbase.h"
27 #include "BLI_math_vector.h"
28 #include "BLI_utildefines.h"
29 
30 #include "BLT_translation.h"
31 
32 #include "BKE_attribute.h"
33 #include "BKE_brush.h"
34 #include "BKE_ccg.h"
35 #include "BKE_colortools.h"
36 #include "BKE_context.h"
37 #include "BKE_crazyspace.h"
38 #include "BKE_deform.h"
39 #include "BKE_gpencil.h"
40 #include "BKE_idtype.h"
41 #include "BKE_image.h"
42 #include "BKE_key.h"
43 #include "BKE_lib_id.h"
44 #include "BKE_main.h"
45 #include "BKE_material.h"
46 #include "BKE_mesh.h"
47 #include "BKE_mesh_mapping.h"
48 #include "BKE_mesh_runtime.h"
49 #include "BKE_modifier.h"
50 #include "BKE_multires.h"
51 #include "BKE_object.h"
52 #include "BKE_paint.h"
53 #include "BKE_pbvh.h"
54 #include "BKE_subdiv_ccg.h"
55 #include "BKE_subsurf.h"
56 
57 #include "DEG_depsgraph.h"
58 #include "DEG_depsgraph_query.h"
59 
60 #include "RNA_enum_types.h"
61 
62 #include "BLO_read_write.h"
63 
64 #include "bmesh.h"
65 
66 static void palette_init_data(ID *id)
67 {
68  Palette *palette = (Palette *)id;
69 
71 
72  /* Enable fake user by default. */
73  id_fake_user_set(&palette->id);
74 }
75 
76 static void palette_copy_data(Main *UNUSED(bmain),
77  ID *id_dst,
78  const ID *id_src,
79  const int UNUSED(flag))
80 {
81  Palette *palette_dst = (Palette *)id_dst;
82  const Palette *palette_src = (const Palette *)id_src;
83 
84  BLI_duplicatelist(&palette_dst->colors, &palette_src->colors);
85 }
86 
87 static void palette_free_data(ID *id)
88 {
89  Palette *palette = (Palette *)id;
90 
91  BLI_freelistN(&palette->colors);
92 }
93 
94 static void palette_blend_write(BlendWriter *writer, ID *id, const void *id_address)
95 {
96  Palette *palette = (Palette *)id;
97 
99  BLO_write_id_struct(writer, Palette, id_address, &palette->id);
100  BKE_id_blend_write(writer, &palette->id);
101 
102  for (color = palette->colors.first; color; color = color->next) {
104  }
105 }
106 
107 static void palette_blend_read_data(BlendDataReader *reader, ID *id)
108 {
109  Palette *palette = (Palette *)id;
110  BLO_read_list(reader, &palette->colors);
111 }
112 
113 static void palette_undo_preserve(BlendLibReader *UNUSED(reader), ID *id_new, ID *id_old)
114 {
115  /* Whole Palette is preserved across undo-steps, and it has no extra pointer, simple. */
116  /* NOTE: We do not care about potential internal references to self here, Palette has none. */
117  /* NOTE: We do not swap IDProperties, as dealing with potential ID pointers in those would be
118  * fairly delicate. */
119  BKE_lib_id_swap(NULL, id_new, id_old);
120  SWAP(IDProperty *, id_new->properties, id_old->properties);
121 }
122 
124  .id_code = ID_PAL,
125  .id_filter = FILTER_ID_PAL,
126  .main_listbase_index = INDEX_ID_PAL,
127  .struct_size = sizeof(Palette),
128  .name = "Palette",
129  .name_plural = "palettes",
130  .translation_context = BLT_I18NCONTEXT_ID_PALETTE,
131  .flags = IDTYPE_FLAGS_NO_ANIMDATA,
132  .asset_type_info = NULL,
133 
135  .copy_data = palette_copy_data,
136  .free_data = palette_free_data,
137  .make_local = NULL,
138  .foreach_id = NULL,
139  .foreach_cache = NULL,
140  .foreach_path = NULL,
141  .owner_get = NULL,
142 
143  .blend_write = palette_blend_write,
144  .blend_read_data = palette_blend_read_data,
145  .blend_read_lib = NULL,
146  .blend_read_expand = NULL,
147 
148  .blend_read_undo_preserve = palette_undo_preserve,
149 
150  .lib_override_apply_post = NULL,
151 };
152 
153 static void paint_curve_copy_data(Main *UNUSED(bmain),
154  ID *id_dst,
155  const ID *id_src,
156  const int UNUSED(flag))
157 {
158  PaintCurve *paint_curve_dst = (PaintCurve *)id_dst;
159  const PaintCurve *paint_curve_src = (const PaintCurve *)id_src;
160 
161  if (paint_curve_src->tot_points != 0) {
162  paint_curve_dst->points = MEM_dupallocN(paint_curve_src->points);
163  }
164 }
165 
166 static void paint_curve_free_data(ID *id)
167 {
168  PaintCurve *paint_curve = (PaintCurve *)id;
169 
170  MEM_SAFE_FREE(paint_curve->points);
171  paint_curve->tot_points = 0;
172 }
173 
174 static void paint_curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
175 {
176  PaintCurve *pc = (PaintCurve *)id;
177 
178  BLO_write_id_struct(writer, PaintCurve, id_address, &pc->id);
179  BKE_id_blend_write(writer, &pc->id);
180 
182 }
183 
185 {
186  PaintCurve *pc = (PaintCurve *)id;
187  BLO_read_data_address(reader, &pc->points);
188 }
189 
191  .id_code = ID_PC,
192  .id_filter = FILTER_ID_PC,
193  .main_listbase_index = INDEX_ID_PC,
194  .struct_size = sizeof(PaintCurve),
195  .name = "PaintCurve",
196  .name_plural = "paint_curves",
197  .translation_context = BLT_I18NCONTEXT_ID_PAINTCURVE,
198  .flags = IDTYPE_FLAGS_NO_ANIMDATA,
199  .asset_type_info = NULL,
200 
201  .init_data = NULL,
202  .copy_data = paint_curve_copy_data,
203  .free_data = paint_curve_free_data,
204  .make_local = NULL,
205  .foreach_id = NULL,
206  .foreach_cache = NULL,
207  .foreach_path = NULL,
208  .owner_get = NULL,
209 
210  .blend_write = paint_curve_blend_write,
211  .blend_read_data = paint_curve_blend_read_data,
212  .blend_read_lib = NULL,
213  .blend_read_expand = NULL,
214 
215  .blend_read_undo_preserve = NULL,
216 
217  .lib_override_apply_post = NULL,
218 };
219 
220 const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
221 const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
222 const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
223 const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
224 
226 
228 {
229  Paint *p = BKE_paint_get_active(scene, view_layer);
230  if (!p) {
231  return;
232  }
233 
234  Brush *br = p->brush;
235  if (!br) {
236  return;
237  }
238 
239  if (br->mtex.tex == tex) {
241  }
242  if (br->mask_mtex.tex == tex) {
244  }
245 }
246 
248 {
249  Paint *p = BKE_paint_get_active(scene, view_layer);
250  if (p == NULL) {
251  return;
252  }
253 
254  Brush *br = p->brush;
255  if (br && br->curve == curve) {
257  }
258 }
259 
261 {
264 }
265 
267 {
268  return overlay_flags;
269 }
270 
272 {
273  if (flags & BRUSH_OVERLAY_OVERRIDE_MASK) {
276  }
279  }
282  }
283  }
284  else {
286  }
287 }
288 
290 {
291  overlay_flags &= ~(flag);
292 }
293 
295 {
296  ToolSettings *ts = sce->toolsettings;
297  Paint **paint_ptr = NULL;
298  /* Some paint modes don't store paint settings as pointer, for these this can be set and
299  * referenced by paint_ptr. */
300  Paint *paint_tmp = NULL;
301 
302  switch (mode) {
303  case PAINT_MODE_SCULPT:
304  paint_ptr = (Paint **)&ts->sculpt;
305  break;
306  case PAINT_MODE_VERTEX:
307  paint_ptr = (Paint **)&ts->vpaint;
308  break;
309  case PAINT_MODE_WEIGHT:
310  paint_ptr = (Paint **)&ts->wpaint;
311  break;
314  paint_tmp = (Paint *)&ts->imapaint;
315  paint_ptr = &paint_tmp;
316  break;
318  paint_ptr = (Paint **)&ts->uvsculpt;
319  break;
320  case PAINT_MODE_GPENCIL:
321  paint_ptr = (Paint **)&ts->gp_paint;
322  break;
324  paint_ptr = (Paint **)&ts->gp_vertexpaint;
325  break;
327  paint_ptr = (Paint **)&ts->gp_sculptpaint;
328  break;
330  paint_ptr = (Paint **)&ts->gp_weightpaint;
331  break;
333  paint_ptr = (Paint **)&ts->curves_sculpt;
334  break;
335  case PAINT_MODE_INVALID:
336  break;
337  }
338  if (paint_ptr) {
339  BKE_paint_ensure(ts, paint_ptr);
340  return true;
341  }
342  return false;
343 }
344 
346 {
347  if (sce) {
348  ToolSettings *ts = sce->toolsettings;
349 
350  switch (mode) {
351  case PAINT_MODE_SCULPT:
352  return &ts->sculpt->paint;
353  case PAINT_MODE_VERTEX:
354  return &ts->vpaint->paint;
355  case PAINT_MODE_WEIGHT:
356  return &ts->wpaint->paint;
359  return &ts->imapaint.paint;
361  return &ts->uvsculpt->paint;
362  case PAINT_MODE_GPENCIL:
363  return &ts->gp_paint->paint;
365  return &ts->gp_vertexpaint->paint;
367  return &ts->gp_sculptpaint->paint;
369  return &ts->gp_weightpaint->paint;
371  return &ts->curves_sculpt->paint;
372  case PAINT_MODE_INVALID:
373  return NULL;
374  default:
375  return &ts->imapaint.paint;
376  }
377  }
378 
379  return NULL;
380 }
381 
383 {
384  switch (mode) {
385  case PAINT_MODE_SCULPT:
387  case PAINT_MODE_VERTEX:
389  case PAINT_MODE_WEIGHT:
396  case PAINT_MODE_GPENCIL:
406  case PAINT_MODE_INVALID:
407  break;
408  }
409  return NULL;
410 }
411 
413 {
414  switch (mode) {
415  case PAINT_MODE_SCULPT:
416  return "sculpt_tool";
417  case PAINT_MODE_VERTEX:
418  return "vertex_tool";
419  case PAINT_MODE_WEIGHT:
420  return "weight_tool";
423  return "image_tool";
425  return "uv_sculpt_tool";
426  case PAINT_MODE_GPENCIL:
427  return "gpencil_tool";
429  return "gpencil_vertex_tool";
431  return "gpencil_sculpt_tool";
433  return "gpencil_weight_tool";
435  return "curves_sculpt_tool";
436  case PAINT_MODE_INVALID:
437  break;
438  }
439 
440  /* Invalid paint mode. */
441  return NULL;
442 }
443 
445 {
446  if (sce && view_layer) {
447  ToolSettings *ts = sce->toolsettings;
448 
449  if (view_layer->basact && view_layer->basact->object) {
450  switch (view_layer->basact->object->mode) {
451  case OB_MODE_SCULPT:
452  return &ts->sculpt->paint;
454  return &ts->vpaint->paint;
456  return &ts->wpaint->paint;
458  return &ts->imapaint.paint;
460  return &ts->gp_paint->paint;
462  return &ts->gp_vertexpaint->paint;
464  return &ts->gp_sculptpaint->paint;
466  return &ts->gp_weightpaint->paint;
468  return &ts->curves_sculpt->paint;
469  case OB_MODE_EDIT:
470  return ts->uvsculpt ? &ts->uvsculpt->paint : NULL;
471  default:
472  break;
473  }
474  }
475 
476  /* default to image paint */
477  return &ts->imapaint.paint;
478  }
479 
480  return NULL;
481 }
482 
484 {
485  Scene *sce = CTX_data_scene(C);
486  ViewLayer *view_layer = CTX_data_view_layer(C);
487  SpaceImage *sima;
488 
489  if (sce && view_layer) {
490  ToolSettings *ts = sce->toolsettings;
491  Object *obact = NULL;
492 
493  if (view_layer->basact && view_layer->basact->object) {
494  obact = view_layer->basact->object;
495  }
496 
497  if ((sima = CTX_wm_space_image(C)) != NULL) {
498  if (obact && obact->mode == OB_MODE_EDIT) {
499  if (sima->mode == SI_MODE_PAINT) {
500  return &ts->imapaint.paint;
501  }
502  if (sima->mode == SI_MODE_UV) {
503  return &ts->uvsculpt->paint;
504  }
505  }
506  else {
507  return &ts->imapaint.paint;
508  }
509  }
510  else {
511  return BKE_paint_get_active(sce, view_layer);
512  }
513  }
514 
515  return NULL;
516 }
517 
519 {
520  Scene *sce = CTX_data_scene(C);
521  ViewLayer *view_layer = CTX_data_view_layer(C);
522  SpaceImage *sima;
523 
524  if (sce && view_layer) {
525  Object *obact = NULL;
526 
527  if (view_layer->basact && view_layer->basact->object) {
528  obact = view_layer->basact->object;
529  }
530 
531  if ((sima = CTX_wm_space_image(C)) != NULL) {
532  if (obact && obact->mode == OB_MODE_EDIT) {
533  if (sima->mode == SI_MODE_PAINT) {
534  return PAINT_MODE_TEXTURE_2D;
535  }
536  if (sima->mode == SI_MODE_UV) {
537  return PAINT_MODE_SCULPT_UV;
538  }
539  }
540  else {
541  return PAINT_MODE_TEXTURE_2D;
542  }
543  }
544  else if (obact) {
545  switch (obact->mode) {
546  case OB_MODE_SCULPT:
547  return PAINT_MODE_SCULPT;
549  return PAINT_MODE_VERTEX;
551  return PAINT_MODE_WEIGHT;
553  return PAINT_MODE_TEXTURE_3D;
554  case OB_MODE_EDIT:
555  return PAINT_MODE_SCULPT_UV;
558  default:
559  return PAINT_MODE_TEXTURE_2D;
560  }
561  }
562  else {
563  /* default to image paint */
564  return PAINT_MODE_TEXTURE_2D;
565  }
566  }
567 
568  return PAINT_MODE_INVALID;
569 }
570 
572 {
573  if (tref->space_type == SPACE_VIEW3D) {
574  switch (tref->mode) {
575  case CTX_MODE_SCULPT:
576  return PAINT_MODE_SCULPT;
578  return PAINT_MODE_VERTEX;
580  return PAINT_MODE_WEIGHT;
582  return PAINT_MODE_GPENCIL;
584  return PAINT_MODE_TEXTURE_3D;
593  }
594  }
595  else if (tref->space_type == SPACE_IMAGE) {
596  switch (tref->mode) {
597  case SI_MODE_PAINT:
598  return PAINT_MODE_TEXTURE_2D;
599  case SI_MODE_UV:
600  return PAINT_MODE_SCULPT_UV;
601  }
602  }
603 
604  return PAINT_MODE_INVALID;
605 }
606 
608 {
609  return (Brush *)BKE_paint_brush_for_read((const Paint *)p);
610 }
611 
613 {
614  return p ? p->brush : NULL;
615 }
616 
618 {
619  if (p) {
620  id_us_min((ID *)p->brush);
621  id_us_plus((ID *)br);
622  p->brush = br;
623 
625  }
626 }
627 
629 {
630  if (paint == &ts->imapaint.paint) {
631  paint->runtime.tool_offset = offsetof(Brush, imagepaint_tool);
633  }
634  else if (ts->sculpt && paint == &ts->sculpt->paint) {
635  paint->runtime.tool_offset = offsetof(Brush, sculpt_tool);
636  paint->runtime.ob_mode = OB_MODE_SCULPT;
637  }
638  else if (ts->vpaint && paint == &ts->vpaint->paint) {
639  paint->runtime.tool_offset = offsetof(Brush, vertexpaint_tool);
641  }
642  else if (ts->wpaint && paint == &ts->wpaint->paint) {
643  paint->runtime.tool_offset = offsetof(Brush, weightpaint_tool);
645  }
646  else if (ts->uvsculpt && paint == &ts->uvsculpt->paint) {
647  paint->runtime.tool_offset = offsetof(Brush, uv_sculpt_tool);
648  paint->runtime.ob_mode = OB_MODE_EDIT;
649  }
650  else if (ts->gp_paint && paint == &ts->gp_paint->paint) {
651  paint->runtime.tool_offset = offsetof(Brush, gpencil_tool);
653  }
654  else if (ts->gp_vertexpaint && paint == &ts->gp_vertexpaint->paint) {
655  paint->runtime.tool_offset = offsetof(Brush, gpencil_vertex_tool);
657  }
658  else if (ts->gp_sculptpaint && paint == &ts->gp_sculptpaint->paint) {
659  paint->runtime.tool_offset = offsetof(Brush, gpencil_sculpt_tool);
661  }
662  else if (ts->gp_weightpaint && paint == &ts->gp_weightpaint->paint) {
663  paint->runtime.tool_offset = offsetof(Brush, gpencil_weight_tool);
665  }
666  else if (ts->curves_sculpt && paint == &ts->curves_sculpt->paint) {
667  paint->runtime.tool_offset = offsetof(Brush, curves_sculpt_tool);
669  }
670  else {
672  }
673 }
674 
676 {
677  switch (mode) {
680  return offsetof(Brush, imagepaint_tool);
681  case PAINT_MODE_SCULPT:
682  return offsetof(Brush, sculpt_tool);
683  case PAINT_MODE_VERTEX:
684  return offsetof(Brush, vertexpaint_tool);
685  case PAINT_MODE_WEIGHT:
686  return offsetof(Brush, weightpaint_tool);
688  return offsetof(Brush, uv_sculpt_tool);
689  case PAINT_MODE_GPENCIL:
690  return offsetof(Brush, gpencil_tool);
692  return offsetof(Brush, gpencil_vertex_tool);
694  return offsetof(Brush, gpencil_sculpt_tool);
696  return offsetof(Brush, gpencil_weight_tool);
698  return offsetof(Brush, curves_sculpt_tool);
699  case PAINT_MODE_INVALID:
700  break; /* We don't use these yet. */
701  }
702  return 0;
703 }
704 
705 PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
706 {
707  PaintCurve *pc;
708 
709  pc = BKE_id_new(bmain, ID_PC, name);
710 
711  return pc;
712 }
713 
715 {
716  return p ? p->palette : NULL;
717 }
718 
720 {
721  if (p) {
722  id_us_min((ID *)p->palette);
723  p->palette = palette;
724  id_us_plus((ID *)p->palette);
725  }
726 }
727 
729 {
730  if (br) {
731  id_us_min((ID *)br->paint_curve);
732  br->paint_curve = pc;
733  id_us_plus((ID *)br->paint_curve);
734  }
735 }
736 
738 {
739  pc->add_index = (add_index || pc->tot_points == 1) ? (add_index + 1) : 0;
740 }
741 
743 {
744  if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) ==
745  palette->active_color) {
746  palette->active_color--;
747  }
748 
749  BLI_remlink(&palette->colors, color);
750 
751  if (palette->active_color < 0 && !BLI_listbase_is_empty(&palette->colors)) {
752  palette->active_color = 0;
753  }
754 
755  MEM_freeN(color);
756 }
757 
759 {
760  BLI_freelistN(&palette->colors);
761  palette->active_color = 0;
762 }
763 
764 Palette *BKE_palette_add(Main *bmain, const char *name)
765 {
766  Palette *palette = BKE_id_new(bmain, ID_PAL, name);
767  return palette;
768 }
769 
771 {
772  PaletteColor *color = MEM_callocN(sizeof(*color), "Palette Color");
773  BLI_addtail(&palette->colors, color);
774  return color;
775 }
776 
777 bool BKE_palette_is_empty(const struct Palette *palette)
778 {
779  return BLI_listbase_is_empty(&palette->colors);
780 }
781 
782 /* helper function to sort using qsort */
783 static int palettecolor_compare_hsv(const void *a1, const void *a2)
784 {
785  const tPaletteColorHSV *ps1 = a1, *ps2 = a2;
786 
787  /* Hue */
788  if (ps1->h > ps2->h) {
789  return 1;
790  }
791  if (ps1->h < ps2->h) {
792  return -1;
793  }
794 
795  /* Saturation. */
796  if (ps1->s > ps2->s) {
797  return 1;
798  }
799  if (ps1->s < ps2->s) {
800  return -1;
801  }
802 
803  /* Value. */
804  if (1.0f - ps1->v > 1.0f - ps2->v) {
805  return 1;
806  }
807  if (1.0f - ps1->v < 1.0f - ps2->v) {
808  return -1;
809  }
810 
811  return 0;
812 }
813 
814 /* helper function to sort using qsort */
815 static int palettecolor_compare_svh(const void *a1, const void *a2)
816 {
817  const tPaletteColorHSV *ps1 = a1, *ps2 = a2;
818 
819  /* Saturation. */
820  if (ps1->s > ps2->s) {
821  return 1;
822  }
823  if (ps1->s < ps2->s) {
824  return -1;
825  }
826 
827  /* Value. */
828  if (1.0f - ps1->v > 1.0f - ps2->v) {
829  return 1;
830  }
831  if (1.0f - ps1->v < 1.0f - ps2->v) {
832  return -1;
833  }
834 
835  /* Hue */
836  if (ps1->h > ps2->h) {
837  return 1;
838  }
839  if (ps1->h < ps2->h) {
840  return -1;
841  }
842 
843  return 0;
844 }
845 
846 static int palettecolor_compare_vhs(const void *a1, const void *a2)
847 {
848  const tPaletteColorHSV *ps1 = a1, *ps2 = a2;
849 
850  /* Value. */
851  if (1.0f - ps1->v > 1.0f - ps2->v) {
852  return 1;
853  }
854  if (1.0f - ps1->v < 1.0f - ps2->v) {
855  return -1;
856  }
857 
858  /* Hue */
859  if (ps1->h > ps2->h) {
860  return 1;
861  }
862  if (ps1->h < ps2->h) {
863  return -1;
864  }
865 
866  /* Saturation. */
867  if (ps1->s > ps2->s) {
868  return 1;
869  }
870  if (ps1->s < ps2->s) {
871  return -1;
872  }
873 
874  return 0;
875 }
876 
877 static int palettecolor_compare_luminance(const void *a1, const void *a2)
878 {
879  const tPaletteColorHSV *ps1 = a1, *ps2 = a2;
880 
881  float lumi1 = (ps1->rgb[0] + ps1->rgb[1] + ps1->rgb[2]) / 3.0f;
882  float lumi2 = (ps2->rgb[0] + ps2->rgb[1] + ps2->rgb[2]) / 3.0f;
883 
884  if (lumi1 > lumi2) {
885  return -1;
886  }
887  if (lumi1 < lumi2) {
888  return 1;
889  }
890 
891  return 0;
892 }
893 
894 void BKE_palette_sort_hsv(tPaletteColorHSV *color_array, const int totcol)
895 {
896  /* Sort by Hue, Saturation and Value. */
897  qsort(color_array, totcol, sizeof(tPaletteColorHSV), palettecolor_compare_hsv);
898 }
899 
900 void BKE_palette_sort_svh(tPaletteColorHSV *color_array, const int totcol)
901 {
902  /* Sort by Saturation, Value and Hue. */
903  qsort(color_array, totcol, sizeof(tPaletteColorHSV), palettecolor_compare_svh);
904 }
905 
906 void BKE_palette_sort_vhs(tPaletteColorHSV *color_array, const int totcol)
907 {
908  /* Sort by Saturation, Value and Hue. */
909  qsort(color_array, totcol, sizeof(tPaletteColorHSV), palettecolor_compare_vhs);
910 }
911 
912 void BKE_palette_sort_luminance(tPaletteColorHSV *color_array, const int totcol)
913 {
914  /* Sort by Luminance (calculated with the average, enough for sorting). */
915  qsort(color_array, totcol, sizeof(tPaletteColorHSV), palettecolor_compare_luminance);
916 }
917 
918 bool BKE_palette_from_hash(Main *bmain, GHash *color_table, const char *name, const bool linear)
919 {
920  tPaletteColorHSV *color_array = NULL;
921  tPaletteColorHSV *col_elm = NULL;
922  bool done = false;
923 
924  const int totpal = BLI_ghash_len(color_table);
925 
926  if (totpal > 0) {
927  color_array = MEM_calloc_arrayN(totpal, sizeof(tPaletteColorHSV), __func__);
928  /* Put all colors in an array. */
929  GHashIterator gh_iter;
930  int t = 0;
931  GHASH_ITER (gh_iter, color_table) {
933  float r, g, b;
934  float h, s, v;
935  cpack_to_rgb(col, &r, &g, &b);
936  rgb_to_hsv(r, g, b, &h, &s, &v);
937 
938  col_elm = &color_array[t];
939  col_elm->rgb[0] = r;
940  col_elm->rgb[1] = g;
941  col_elm->rgb[2] = b;
942  col_elm->h = h;
943  col_elm->s = s;
944  col_elm->v = v;
945  t++;
946  }
947  }
948 
949  /* Create the Palette. */
950  if (totpal > 0) {
951  /* Sort by Hue and saturation. */
952  BKE_palette_sort_hsv(color_array, totpal);
953 
954  Palette *palette = BKE_palette_add(bmain, name);
955  if (palette) {
956  for (int i = 0; i < totpal; i++) {
957  col_elm = &color_array[i];
958  PaletteColor *palcol = BKE_palette_color_add(palette);
959  if (palcol) {
960  copy_v3_v3(palcol->rgb, col_elm->rgb);
961  if (linear) {
962  linearrgb_to_srgb_v3_v3(palcol->rgb, palcol->rgb);
963  }
964  }
965  }
966  done = true;
967  }
968  }
969  else {
970  done = false;
971  }
972 
973  if (totpal > 0) {
974  MEM_SAFE_FREE(color_array);
975  }
976 
977  return done;
978 }
979 
981 {
982  return ((ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) &&
983  (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) &&
985 }
986 
988 {
989  return ((ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) &&
990  (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) &&
992 }
993 
995 {
997 }
998 
1000 {
1001  return ((ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) &&
1003 }
1004 
1006 {
1007  CurveMapping *cumap = NULL;
1008  CurveMap *cuma = NULL;
1009 
1010  if (!p->cavity_curve) {
1011  p->cavity_curve = BKE_curvemapping_add(1, 0, 0, 1, 1);
1012  }
1013  cumap = p->cavity_curve;
1014  cumap->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
1015  cumap->preset = preset;
1016 
1017  cuma = cumap->cm;
1018  BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
1019  BKE_curvemapping_changed(cumap, false);
1020 }
1021 
1023 {
1024  switch (mode) {
1025  case PAINT_MODE_SCULPT:
1026  return OB_MODE_SCULPT;
1027  case PAINT_MODE_VERTEX:
1028  return OB_MODE_VERTEX_PAINT;
1029  case PAINT_MODE_WEIGHT:
1030  return OB_MODE_WEIGHT_PAINT;
1031  case PAINT_MODE_TEXTURE_2D:
1032  case PAINT_MODE_TEXTURE_3D:
1033  return OB_MODE_TEXTURE_PAINT;
1034  case PAINT_MODE_SCULPT_UV:
1035  return OB_MODE_EDIT;
1036  case PAINT_MODE_INVALID:
1037  default:
1038  return 0;
1039  }
1040 }
1041 
1042 bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
1043 {
1044  Paint *paint = NULL;
1045  if (*r_paint) {
1046  /* Tool offset should never be 0 for initialized paint settings, so it's a reliable way to
1047  * check if already initialized. */
1048  if ((*r_paint)->runtime.tool_offset == 0) {
1049  /* Currently only image painting is initialized this way, others have to be allocated. */
1050  BLI_assert(ELEM(*r_paint, (Paint *)&ts->imapaint));
1051 
1052  BKE_paint_runtime_init(ts, *r_paint);
1053  }
1054  else {
1055  BLI_assert(ELEM(*r_paint,
1056  /* Cast is annoying, but prevent NULL-pointer access. */
1057  (Paint *)ts->gp_paint,
1058  (Paint *)ts->gp_vertexpaint,
1059  (Paint *)ts->gp_sculptpaint,
1060  (Paint *)ts->gp_weightpaint,
1061  (Paint *)ts->sculpt,
1062  (Paint *)ts->vpaint,
1063  (Paint *)ts->wpaint,
1064  (Paint *)ts->uvsculpt,
1065  (Paint *)ts->curves_sculpt,
1066  (Paint *)&ts->imapaint));
1067 #ifdef DEBUG
1068  struct Paint paint_test = **r_paint;
1069  BKE_paint_runtime_init(ts, *r_paint);
1070  /* Swap so debug doesn't hide errors when release fails. */
1071  SWAP(Paint, **r_paint, paint_test);
1072  BLI_assert(paint_test.runtime.ob_mode == (*r_paint)->runtime.ob_mode);
1073  BLI_assert(paint_test.runtime.tool_offset == (*r_paint)->runtime.tool_offset);
1074 #endif
1075  }
1076  return true;
1077  }
1078 
1079  if (((VPaint **)r_paint == &ts->vpaint) || ((VPaint **)r_paint == &ts->wpaint)) {
1080  VPaint *data = MEM_callocN(sizeof(*data), __func__);
1081  paint = &data->paint;
1082  }
1083  else if ((Sculpt **)r_paint == &ts->sculpt) {
1084  Sculpt *data = MEM_callocN(sizeof(*data), __func__);
1085  paint = &data->paint;
1086 
1087  /* Turn on X plane mirror symmetry by default */
1088  paint->symmetry_flags |= PAINT_SYMM_X;
1089 
1090  /* Make sure at least dyntopo subdivision is enabled */
1092  }
1093  else if ((GpPaint **)r_paint == &ts->gp_paint) {
1094  GpPaint *data = MEM_callocN(sizeof(*data), __func__);
1095  paint = &data->paint;
1096  }
1097  else if ((GpVertexPaint **)r_paint == &ts->gp_vertexpaint) {
1098  GpVertexPaint *data = MEM_callocN(sizeof(*data), __func__);
1099  paint = &data->paint;
1100  }
1101  else if ((GpSculptPaint **)r_paint == &ts->gp_sculptpaint) {
1102  GpSculptPaint *data = MEM_callocN(sizeof(*data), __func__);
1103  paint = &data->paint;
1104  }
1105  else if ((GpWeightPaint **)r_paint == &ts->gp_weightpaint) {
1106  GpWeightPaint *data = MEM_callocN(sizeof(*data), __func__);
1107  paint = &data->paint;
1108  }
1109  else if ((UvSculpt **)r_paint == &ts->uvsculpt) {
1110  UvSculpt *data = MEM_callocN(sizeof(*data), __func__);
1111  paint = &data->paint;
1112  }
1113  else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) {
1114  CurvesSculpt *data = MEM_callocN(sizeof(*data), __func__);
1115  paint = &data->paint;
1116  }
1117  else if (*r_paint == &ts->imapaint.paint) {
1118  paint = &ts->imapaint.paint;
1119  }
1120 
1121  paint->flags |= PAINT_SHOW_BRUSH;
1122 
1123  *r_paint = paint;
1124 
1125  BKE_paint_runtime_init(ts, paint);
1126 
1127  return false;
1128 }
1129 
1130 void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const char col[3])
1131 {
1133  Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode);
1134 
1136 
1137  /* If there's no brush, create one */
1138  if (PAINT_MODE_HAS_BRUSH(mode)) {
1139  Brush *brush = BKE_paint_brush(paint);
1140  if (brush == NULL) {
1142  brush = BKE_brush_first_search(bmain, ob_mode);
1143  if (!brush) {
1144  brush = BKE_brush_add(bmain, "Brush", ob_mode);
1145  id_us_min(&brush->id); /* fake user only */
1146  }
1147  BKE_paint_brush_set(paint, brush);
1148  }
1149  }
1150 
1151  memcpy(paint->paint_cursor_col, col, 3);
1152  paint->paint_cursor_col[3] = 128;
1153  ups->last_stroke_valid = false;
1155  ups->average_stroke_counter = 0;
1156  if (!paint->cavity_curve) {
1158  }
1159 }
1160 
1161 void BKE_paint_free(Paint *paint)
1162 {
1164  MEM_SAFE_FREE(paint->tool_slots);
1165 }
1166 
1167 void BKE_paint_copy(Paint *src, Paint *tar, const int flag)
1168 {
1169  tar->brush = src->brush;
1170  tar->cavity_curve = BKE_curvemapping_copy(src->cavity_curve);
1171  tar->tool_slots = MEM_dupallocN(src->tool_slots);
1172 
1173  if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
1174  id_us_plus((ID *)tar->brush);
1175  id_us_plus((ID *)tar->palette);
1176  if (src->tool_slots != NULL) {
1177  for (int i = 0; i < tar->tool_slots_len; i++) {
1178  id_us_plus((ID *)tar->tool_slots[i].brush);
1179  }
1180  }
1181  }
1182 }
1183 
1184 void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3])
1185 {
1187  if (ups->last_stroke_valid && ups->average_stroke_counter > 0) {
1188  float fac = 1.0f / ups->average_stroke_counter;
1189  mul_v3_v3fl(stroke, ups->average_stroke_accum, fac);
1190  }
1191  else {
1192  copy_v3_v3(stroke, ob->obmat[3]);
1193  }
1194 }
1195 
1197 {
1198  if (p->cavity_curve) {
1200  }
1202 }
1203 
1205 {
1206  if (p->num_input_samples < 1) {
1207  p->num_input_samples = 1;
1208  }
1209 
1210  BLO_read_data_address(reader, &p->cavity_curve);
1211  if (p->cavity_curve) {
1213  }
1214  else {
1216  }
1217 
1218  BLO_read_data_address(reader, &p->tool_slots);
1219 
1220  /* Workaround for invalid data written in older versions. */
1221  const size_t expected_size = sizeof(PaintToolSlot) * p->tool_slots_len;
1222  if (p->tool_slots && MEM_allocN_len(p->tool_slots) < expected_size) {
1223  MEM_freeN(p->tool_slots);
1224  p->tool_slots = MEM_callocN(expected_size, "PaintToolSlot");
1225  }
1226 
1228 }
1229 
1231 {
1232  if (p) {
1233  BLO_read_id_address(reader, sce->id.lib, &p->brush);
1234  for (int i = 0; i < p->tool_slots_len; i++) {
1235  if (p->tool_slots[i].brush != NULL) {
1236  BLO_read_id_address(reader, sce->id.lib, &p->tool_slots[i].brush);
1237  }
1238  }
1239  BLO_read_id_address(reader, sce->id.lib, &p->palette);
1240  p->paint_cursor = NULL;
1241 
1243  }
1244 }
1245 
1246 bool paint_is_face_hidden(const MLoopTri *lt, const MVert *mvert, const MLoop *mloop)
1247 {
1248  return ((mvert[mloop[lt->tri[0]].v].flag & ME_HIDE) ||
1249  (mvert[mloop[lt->tri[1]].v].flag & ME_HIDE) ||
1250  (mvert[mloop[lt->tri[2]].v].flag & ME_HIDE));
1251 }
1252 
1253 bool paint_is_grid_face_hidden(const uint *grid_hidden, int gridsize, int x, int y)
1254 {
1255  /* skip face if any of its corners are hidden */
1256  return (BLI_BITMAP_TEST(grid_hidden, y * gridsize + x) ||
1257  BLI_BITMAP_TEST(grid_hidden, y * gridsize + x + 1) ||
1258  BLI_BITMAP_TEST(grid_hidden, (y + 1) * gridsize + x + 1) ||
1259  BLI_BITMAP_TEST(grid_hidden, (y + 1) * gridsize + x));
1260 }
1261 
1263 {
1264  BMLoop *l_iter;
1265  BMLoop *l_first;
1266 
1267  l_iter = l_first = BM_FACE_FIRST_LOOP(f);
1268  do {
1269  if (BM_elem_flag_test(l_iter->v, BM_ELEM_HIDDEN)) {
1270  return true;
1271  }
1272  } while ((l_iter = l_iter->next) != l_first);
1273 
1274  return false;
1275 }
1276 
1278 {
1279  int factor = BKE_ccg_factor(level, gpm->level);
1280  int gridsize = BKE_ccg_gridsize(gpm->level);
1281 
1282  return gpm->data[(y * factor) * gridsize + (x * factor)];
1283 }
1284 
1285 /* threshold to move before updating the brush rotation */
1286 #define RAKE_THRESHHOLD 20
1287 
1289 {
1291  ups->brush_rotation = rotation;
1292  }
1293  else {
1294  ups->brush_rotation = 0.0f;
1295  }
1296 
1298  ups->brush_rotation_sec = rotation;
1299  }
1300  else {
1301  ups->brush_rotation_sec = 0.0f;
1302  }
1303 }
1304 
1306  Brush *brush,
1307  const float mouse_pos[2])
1308 {
1309  bool ok = false;
1312  const float r = RAKE_THRESHHOLD;
1313  float rotation;
1314 
1315  float dpos[2];
1316  sub_v2_v2v2(dpos, ups->last_rake, mouse_pos);
1317 
1318  if (len_squared_v2(dpos) >= r * r) {
1319  rotation = atan2f(dpos[0], dpos[1]);
1320 
1321  copy_v2_v2(ups->last_rake, mouse_pos);
1322 
1323  ups->last_rake_angle = rotation;
1324 
1325  paint_update_brush_rake_rotation(ups, brush, rotation);
1326  ok = true;
1327  }
1328  /* make sure we reset here to the last rotation to avoid accumulating
1329  * values in case a random rotation is also added */
1330  else {
1332  ok = false;
1333  }
1334  }
1335  else {
1336  ups->brush_rotation = ups->brush_rotation_sec = 0.0f;
1337  ok = true;
1338  }
1339  return ok;
1340 }
1341 
1343 {
1344  MEM_SAFE_FREE(ss->orig_cos);
1347 }
1348 
1350 {
1351  struct SculptVertexPaintGeomMap *gmap = NULL;
1352  if (ss->mode_type == OB_MODE_VERTEX_PAINT) {
1353  gmap = &ss->mode.vpaint.gmap;
1354  }
1355  else if (ss->mode_type == OB_MODE_WEIGHT_PAINT) {
1356  gmap = &ss->mode.wpaint.gmap;
1357 
1358  MEM_SAFE_FREE(ss->mode.wpaint.alpha_weight);
1359  if (ss->mode.wpaint.dvert_prev) {
1360  BKE_defvert_array_free_elems(ss->mode.wpaint.dvert_prev, ss->totvert);
1361  MEM_freeN(ss->mode.wpaint.dvert_prev);
1362  ss->mode.wpaint.dvert_prev = NULL;
1363  }
1364  }
1365  else {
1366  return;
1367  }
1368  MEM_SAFE_FREE(gmap->vert_to_loop);
1369  MEM_SAFE_FREE(gmap->vert_map_mem);
1370  MEM_SAFE_FREE(gmap->vert_to_poly);
1371  MEM_SAFE_FREE(gmap->poly_map_mem);
1372 }
1373 
1377 static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
1378 {
1379  SculptSession *ss = ob->sculpt;
1380 
1381  if (ss->bm) {
1382  if (ob->data) {
1383  BMIter iter;
1384  BMFace *efa;
1385  BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
1387  }
1388  if (reorder) {
1390  }
1392  ss->bm,
1393  ob->data,
1394  (&(struct BMeshToMeshParams){
1395  .calc_object_remap = false,
1396  }));
1397  }
1398  }
1399 }
1400 
1401 void BKE_sculptsession_bm_to_me(Object *ob, bool reorder)
1402 {
1403  if (ob && ob->sculpt) {
1405 
1406  /* Ensure the objects evaluated mesh doesn't hold onto arrays
1407  * now realloc'd in the mesh T34473. */
1409  }
1410 }
1411 
1412 static void sculptsession_free_pbvh(Object *object)
1413 {
1414  SculptSession *ss = object->sculpt;
1415 
1416  if (!ss) {
1417  return;
1418  }
1419 
1420  if (ss->pbvh) {
1421  BKE_pbvh_free(ss->pbvh);
1422  ss->pbvh = NULL;
1423  }
1424 
1425  MEM_SAFE_FREE(ss->pmap);
1426  MEM_SAFE_FREE(ss->pmap_mem);
1427 
1428  MEM_SAFE_FREE(ss->epmap);
1429  MEM_SAFE_FREE(ss->epmap_mem);
1430 
1431  MEM_SAFE_FREE(ss->vemap);
1432  MEM_SAFE_FREE(ss->vemap_mem);
1433 
1435 
1437  ss->preview_vert_index_count = 0;
1438 
1440 
1443 
1445 }
1446 
1448 {
1449  if (object && object->sculpt) {
1450  if (object->sculpt->bm) {
1451  /* Ensure no points to old arrays are stored in DM
1452  *
1453  * Apparently, we could not use DEG_id_tag_update
1454  * here because this will lead to the while object
1455  * surface to disappear, so we'll release DM in place.
1456  */
1458 
1460 
1461  /* In contrast with sculptsession_bm_to_me no need in
1462  * DAG tag update here - derived mesh was freed and
1463  * old pointers are nowhere stored.
1464  */
1465  }
1466  }
1467 }
1468 
1470 {
1471  if (ob && ob->sculpt) {
1472  SculptSession *ss = ob->sculpt;
1473 
1474  if (ss->bm) {
1475  BKE_sculptsession_bm_to_me(ob, true);
1476  BM_mesh_free(ss->bm);
1477  }
1478 
1480 
1481  MEM_SAFE_FREE(ss->pmap);
1482  MEM_SAFE_FREE(ss->pmap_mem);
1483 
1484  MEM_SAFE_FREE(ss->epmap);
1485  MEM_SAFE_FREE(ss->epmap_mem);
1486 
1487  MEM_SAFE_FREE(ss->vemap);
1488  MEM_SAFE_FREE(ss->vemap_mem);
1489 
1490  if (ss->bm_log) {
1491  BM_log_free(ss->bm_log);
1492  }
1493 
1494  if (ss->tex_pool) {
1496  }
1497 
1498  MEM_SAFE_FREE(ss->orig_cos);
1501 
1502  if (ss->pose_ik_chain_preview) {
1503  for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
1505  }
1508  }
1509 
1510  if (ss->boundary_preview) {
1516  }
1517 
1519 
1521 
1522  MEM_freeN(ss);
1523 
1524  ob->sculpt = NULL;
1525  }
1526 }
1527 
1529 {
1530  Mesh *me = (Mesh *)ob->data;
1531  ModifierData *md;
1532  VirtualModifierData virtualModifierData;
1533 
1534  if (ob->sculpt && ob->sculpt->bm) {
1535  /* can't combine multires and dynamic topology */
1536  return NULL;
1537  }
1538 
1539  if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
1540  /* multires can't work without displacement layer */
1541  return NULL;
1542  }
1543 
1544  /* Weight paint operates on original vertices, and needs to treat multires as regular modifier
1545  * to make it so that PBVH vertices are at the multires surface. */
1546  if ((ob->mode & OB_MODE_SCULPT) == 0) {
1547  return NULL;
1548  }
1549 
1550  for (md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); md; md = md->next) {
1551  if (md->type == eModifierType_Multires) {
1553 
1555  continue;
1556  }
1557 
1558  if (mmd->sculptlvl > 0 && !(mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh)) {
1559  return mmd;
1560  }
1561 
1562  return NULL;
1563  }
1564  }
1565 
1566  return NULL;
1567 }
1568 
1569 /* Checks if there are any supported deformation modifiers active */
1571 {
1572  ModifierData *md;
1573  Mesh *me = (Mesh *)ob->data;
1574  VirtualModifierData virtualModifierData;
1575 
1576  if (ob->sculpt->bm || BKE_sculpt_multires_active(scene, ob)) {
1577  return false;
1578  }
1579 
1580  /* non-locked shape keys could be handled in the same way as deformed mesh */
1581  if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr) {
1582  return true;
1583  }
1584 
1585  md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData);
1586 
1587  /* exception for shape keys because we can edit those */
1588  for (; md; md = md->next) {
1589  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
1591  continue;
1592  }
1593  if (md->type == eModifierType_Multires && (ob->mode & OB_MODE_SCULPT)) {
1596  continue;
1597  }
1598  }
1599  if (md->type == eModifierType_ShapeKey) {
1600  continue;
1601  }
1602 
1603  if (mti->type == eModifierTypeType_OnlyDeform) {
1604  return true;
1605  }
1606  if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) {
1607  return true;
1608  }
1609  }
1610 
1611  return false;
1612 }
1613 
1618  Object *ob,
1619  Mesh *me_eval,
1620  bool need_pmap,
1621  bool need_mask,
1622  bool is_paint_tool)
1623 {
1625  Sculpt *sd = scene->toolsettings->sculpt;
1626  SculptSession *ss = ob->sculpt;
1627  const Mesh *me = BKE_object_get_original_mesh(ob);
1629  const bool use_face_sets = (ob->mode & OB_MODE_SCULPT) != 0;
1630 
1631  ss->depsgraph = depsgraph;
1632 
1634  ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0;
1635  ss->show_face_sets = (sd->flags & SCULPT_HIDE_FACE_SETS) == 0;
1636 
1637  ss->building_vp_handle = false;
1638 
1639  ss->scene = scene;
1640 
1641  if (need_mask) {
1642  if (mmd == NULL) {
1644  }
1645  else {
1647  }
1648  }
1649 
1650  ss->shapekey_active = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
1651 
1652  /* NOTE: Weight pPaint require mesh info for loop lookup, but it never uses multires code path,
1653  * so no extra checks is needed here. */
1654  if (mmd) {
1655  ss->multires.active = true;
1656  ss->multires.modifier = mmd;
1657  ss->multires.level = mmd->sculptlvl;
1658  ss->totvert = me_eval->totvert;
1659  ss->totpoly = me_eval->totpoly;
1660  ss->totfaces = me->totpoly;
1661 
1662  /* These are assigned to the base mesh in Multires. This is needed because Face Sets operators
1663  * and tools use the Face Sets data from the base mesh when Multires is active. */
1664  ss->mvert = me->mvert;
1665  ss->mpoly = me->mpoly;
1666  ss->mloop = me->mloop;
1667  }
1668  else {
1669  ss->totvert = me->totvert;
1670  ss->totpoly = me->totpoly;
1671  ss->totfaces = me->totpoly;
1672  ss->mvert = me->mvert;
1673  ss->mpoly = me->mpoly;
1674  ss->mloop = me->mloop;
1675  ss->multires.active = false;
1676  ss->multires.modifier = NULL;
1677  ss->multires.level = 0;
1679 
1680  CustomDataLayer *layer;
1681  eAttrDomain domain;
1682 
1683  if (BKE_pbvh_get_color_layer(me, &layer, &domain)) {
1684  if (layer->type == CD_PROP_COLOR) {
1685  ss->vcol = layer->data;
1686  }
1687  else {
1688  ss->mcol = layer->data;
1689  }
1690 
1691  ss->vcol_domain = domain;
1692  ss->vcol_type = layer->type;
1693  }
1694  else {
1695  ss->vcol = NULL;
1696  ss->mcol = NULL;
1697 
1698  ss->vcol_type = -1;
1700  }
1701  }
1702 
1703  /* Sculpt Face Sets. */
1704  if (use_face_sets) {
1707  }
1708  else {
1709  ss->face_sets = NULL;
1710  }
1711 
1712  ss->subdiv_ccg = me_eval->runtime.subdiv_ccg;
1713 
1715  BLI_assert(pbvh == ss->pbvh);
1716  UNUSED_VARS_NDEBUG(pbvh);
1717 
1720 
1722 
1723  if (need_pmap && ob->type == OB_MESH && !ss->pmap) {
1725  &ss->pmap, &ss->pmap_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
1726 
1727  if (ss->pbvh) {
1728  BKE_pbvh_pmap_set(ss->pbvh, ss->pmap);
1729  }
1730  }
1731 
1732  pbvh_show_mask_set(ss->pbvh, ss->show_mask);
1734 
1735  if (ss->deform_modifiers_active) {
1736  if (!ss->orig_cos) {
1737  int a;
1738 
1740 
1741  ss->orig_cos = (ss->shapekey_active) ?
1744 
1747 
1748  for (a = 0; a < me->totvert; a++) {
1749  invert_m3(ss->deform_imats[a]);
1750  }
1751  }
1752  }
1753  else {
1755  }
1756 
1757  if (ss->shapekey_active != NULL && ss->deform_cos == NULL) {
1759  }
1760 
1761  /* if pbvh is deformed, key block is already applied to it */
1762  if (ss->shapekey_active) {
1763  bool pbvh_deformed = BKE_pbvh_is_deformed(ss->pbvh);
1764  if (!pbvh_deformed || ss->deform_cos == NULL) {
1765  float(*vertCos)[3] = BKE_keyblock_convert_to_vertcos(ob, ss->shapekey_active);
1766 
1767  if (vertCos) {
1768  if (!pbvh_deformed) {
1769  /* apply shape keys coordinates to PBVH */
1770  BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, me->totvert);
1771  }
1772  if (ss->deform_cos == NULL) {
1773  ss->deform_cos = vertCos;
1774  }
1775  if (vertCos != ss->deform_cos) {
1776  MEM_freeN(vertCos);
1777  }
1778  }
1779  }
1780  }
1781 
1782  if (is_paint_tool) {
1783  /*
1784  * We should rebuild the PBVH_pixels when painting canvas changes.
1785  *
1786  * The relevant changes are stored/encoded in the paint canvas key.
1787  * These include the active uv map, and resolutions.
1788  */
1789  if (U.experimental.use_sculpt_texture_paint && ss->pbvh) {
1790  char *paint_canvas_key = BKE_paint_canvas_key_get(&scene->toolsettings->paint_mode, ob);
1791  if (ss->last_paint_canvas_key == NULL ||
1792  !STREQ(paint_canvas_key, ss->last_paint_canvas_key)) {
1794  ss->last_paint_canvas_key = paint_canvas_key;
1796  }
1797  else {
1798  MEM_freeN(paint_canvas_key);
1799  }
1800  }
1801 
1802  /* We could be more precise when we have access to the active tool. */
1803  const bool use_paint_slots = (ob->mode & OB_MODE_SCULPT) != 0;
1804  if (use_paint_slots) {
1806  }
1807  }
1808 }
1809 
1811 {
1813  return;
1814  }
1815 
1816  int *new_face_sets = CustomData_add_layer(
1818 
1819  /* Initialize the new Face Set data-layer with a default valid visible ID and set the default
1820  * color to render it white. */
1821  for (int i = 0; i < mesh->totpoly; i++) {
1822  new_face_sets[i] = 1;
1823  }
1825 }
1826 
1828 {
1829  /* Update before mesh evaluation in the dependency graph. */
1830  SculptSession *ss = ob_eval->sculpt;
1831 
1832  if (ss && ss->building_vp_handle == false) {
1833  if (!ss->cache && !ss->filter_cache && !ss->expand_cache) {
1834  /* We free pbvh on changes, except in the middle of drawing a stroke
1835  * since it can't deal with changing PVBH node organization, we hope
1836  * topology does not change in the meantime .. weak. */
1837  sculptsession_free_pbvh(ob_eval);
1838 
1840 
1841  /* In vertex/weight paint, force maps to be rebuilt. */
1843  }
1844  else {
1845  PBVHNode **nodes;
1846  int n, totnode;
1847 
1848  BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
1849 
1850  for (n = 0; n < totnode; n++) {
1851  BKE_pbvh_node_mark_update(nodes[n]);
1852  }
1853 
1854  MEM_freeN(nodes);
1855  }
1856  }
1857 
1858  if (ss) {
1859  Object *ob_orig = DEG_get_original_object(ob_eval);
1862 
1863  /* Ensure attribute layout is still correct. */
1865  BKE_sculpt_mask_layers_ensure(ob_orig, mmd);
1866  }
1867 }
1868 
1870 {
1871  /* Update after mesh evaluation in the dependency graph, to rebuild PBVH or
1872  * other data when modifiers change the mesh. */
1873  Object *ob_orig = DEG_get_original_object(ob_eval);
1874  Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
1875 
1876  BLI_assert(me_eval != NULL);
1877  sculpt_update_object(depsgraph, ob_orig, me_eval, false, false, false);
1878 }
1879 
1881 {
1882  Mesh *orig_me = BKE_object_get_original_mesh(object);
1883 
1885  bool has_color = false;
1886 
1887  for (int i = 0; i < ARRAY_SIZE(types); i++) {
1888  has_color = CustomData_has_layer(&orig_me->vdata, types[i]) ||
1889  CustomData_has_layer(&orig_me->ldata, types[i]);
1890 
1891  if (has_color) {
1892  break;
1893  }
1894  }
1895 
1896  if (has_color) {
1897  return;
1898  }
1899 
1901  CustomDataLayer *layer = orig_me->vdata.layers +
1903 
1904  BKE_mesh_update_customdata_pointers(orig_me, true);
1905 
1906  BKE_id_attributes_active_color_set(&orig_me->id, layer);
1908 
1909  if (object->sculpt && object->sculpt->pbvh) {
1910  BKE_pbvh_update_active_vcol(object->sculpt->pbvh, orig_me);
1911  }
1912 }
1913 
1915  Depsgraph *depsgraph, Object *ob_orig, bool need_pmap, bool need_mask, bool is_paint_tool)
1916 {
1917  BLI_assert(ob_orig == DEG_get_original_object(ob_orig));
1918 
1919  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_orig);
1920  Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
1921  BLI_assert(me_eval != NULL);
1922 
1923  sculpt_update_object(depsgraph, ob_orig, me_eval, need_pmap, need_mask, is_paint_tool);
1924 }
1925 
1927 {
1928  const float *paint_mask;
1929  Mesh *me = ob->data;
1930  int ret = 0;
1931 
1932  paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
1933 
1934  /* if multires is active, create a grid paint mask layer if there
1935  * isn't one already */
1936  if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
1937  GridPaintMask *gmask;
1938  int level = max_ii(1, mmd->sculptlvl);
1939  int gridsize = BKE_ccg_gridsize(level);
1940  int gridarea = gridsize * gridsize;
1941  int i, j;
1942 
1944 
1945  for (i = 0; i < me->totloop; i++) {
1946  GridPaintMask *gpm = &gmask[i];
1947 
1948  gpm->level = level;
1949  gpm->data = MEM_callocN(sizeof(float) * gridarea, "GridPaintMask.data");
1950  }
1951 
1952  /* if vertices already have mask, copy into multires data */
1953  if (paint_mask) {
1954  for (i = 0; i < me->totpoly; i++) {
1955  const MPoly *p = &me->mpoly[i];
1956  float avg = 0;
1957 
1958  /* mask center */
1959  for (j = 0; j < p->totloop; j++) {
1960  const MLoop *l = &me->mloop[p->loopstart + j];
1961  avg += paint_mask[l->v];
1962  }
1963  avg /= (float)p->totloop;
1964 
1965  /* fill in multires mask corner */
1966  for (j = 0; j < p->totloop; j++) {
1967  GridPaintMask *gpm = &gmask[p->loopstart + j];
1968  const MLoop *l = &me->mloop[p->loopstart + j];
1969  const MLoop *prev = ME_POLY_LOOP_PREV(me->mloop, p, j);
1970  const MLoop *next = ME_POLY_LOOP_NEXT(me->mloop, p, j);
1971 
1972  gpm->data[0] = avg;
1973  gpm->data[1] = (paint_mask[l->v] + paint_mask[next->v]) * 0.5f;
1974  gpm->data[2] = (paint_mask[l->v] + paint_mask[prev->v]) * 0.5f;
1975  gpm->data[3] = paint_mask[l->v];
1976  }
1977  }
1978  }
1979 
1981  }
1982 
1983  /* create vertex paint mask layer if there isn't one already */
1984  if (!paint_mask) {
1987  }
1988 
1989  return ret;
1990 }
1991 
1993 {
1995 
1996  Sculpt *sd = scene->toolsettings->sculpt;
1997  if (!sd->detail_size) {
1998  sd->detail_size = 12;
1999  }
2000  if (!sd->detail_percent) {
2001  sd->detail_percent = 25;
2002  }
2003  if (sd->constant_detail == 0.0f) {
2004  sd->constant_detail = 3.0f;
2005  }
2006 
2007  /* Set sane default tiling offsets */
2008  if (!sd->paint.tile_offset[0]) {
2009  sd->paint.tile_offset[0] = 1.0f;
2010  }
2011  if (!sd->paint.tile_offset[1]) {
2012  sd->paint.tile_offset[1] = 1.0f;
2013  }
2014  if (!sd->paint.tile_offset[2]) {
2015  sd->paint.tile_offset[2] = 1.0f;
2016  }
2017 }
2018 
2019 static bool check_sculpt_object_deformed(Object *object, const bool for_construction)
2020 {
2021  bool deformed = false;
2022 
2023  /* Active modifiers means extra deformation, which can't be handled correct
2024  * on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
2025  * stuff and show final evaluated mesh so user would see actual object shape.
2026  */
2027  deformed |= object->sculpt->deform_modifiers_active;
2028 
2029  if (for_construction) {
2030  deformed |= object->sculpt->shapekey_active != NULL;
2031  }
2032  else {
2033  /* As in case with modifiers, we can't synchronize deformation made against
2034  * PBVH and non-locked keyblock, so also use PBVH only for brushes and
2035  * final DM to give final result to user.
2036  */
2037  deformed |= object->sculpt->shapekey_active && (object->shapeflag & OB_SHAPE_LOCK) == 0;
2038  }
2039 
2040  return deformed;
2041 }
2042 
2044 {
2045  const int face_sets_default_visible_id = 1;
2046  const int face_sets_default_hidden_id = -(face_sets_default_visible_id + 1);
2047 
2048  bool initialize_new_face_sets = false;
2049 
2051  /* Make everything visible. */
2052  int *current_face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
2053  for (int i = 0; i < mesh->totpoly; i++) {
2054  current_face_sets[i] = abs(current_face_sets[i]);
2055  }
2056  }
2057  else {
2058  initialize_new_face_sets = true;
2059  int *new_face_sets = CustomData_add_layer(
2061 
2062  /* Initialize the new Face Set data-layer with a default valid visible ID and set the default
2063  * color to render it white. */
2064  for (int i = 0; i < mesh->totpoly; i++) {
2065  new_face_sets[i] = face_sets_default_visible_id;
2066  }
2067  mesh->face_sets_color_default = face_sets_default_visible_id;
2068  }
2069 
2070  int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
2071 
2072  for (int i = 0; i < mesh->totpoly; i++) {
2073  if (!(mesh->mpoly[i].flag & ME_HIDE)) {
2074  continue;
2075  }
2076 
2077  if (initialize_new_face_sets) {
2078  /* When initializing a new Face Set data-layer, assign a new hidden Face Set ID to hidden
2079  * vertices. This way, we get at initial split in two Face Sets between hidden and
2080  * visible vertices based on the previous mesh visibly from other mode that can be
2081  * useful in some cases. */
2082  face_sets[i] = face_sets_default_hidden_id;
2083  }
2084  else {
2085  /* Otherwise, set the already existing Face Set ID to hidden. */
2086  face_sets[i] = -abs(face_sets[i]);
2087  }
2088  }
2089 }
2090 
2092 {
2093  const int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
2094  if (!face_sets) {
2095  return;
2096  }
2097 
2098  for (int i = 0; i < mesh->totpoly; i++) {
2099  const bool is_face_set_visible = face_sets[i] >= 0;
2100  SET_FLAG_FROM_TEST(mesh->mpoly[i].flag, !is_face_set_visible, ME_HIDE);
2101  }
2102 
2104 }
2105 
2107 {
2108  const int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
2109  if (!face_sets) {
2110  return;
2111  }
2112 
2113  if (!subdiv_ccg) {
2114  return;
2115  }
2116 
2117  CCGKey key;
2118  BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
2119  for (int i = 0; i < mesh->totloop; i++) {
2120  const int face_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, i);
2121  const bool is_hidden = (face_sets[face_index] < 0);
2122 
2123  /* Avoid creating and modifying the grid_hidden bitmap if the base mesh face is visible and
2124  * there is not bitmap for the grid. This is because missing grid_hidden implies grid is fully
2125  * visible. */
2126  if (is_hidden) {
2127  BKE_subdiv_ccg_grid_hidden_ensure(subdiv_ccg, i);
2128  }
2129 
2130  BLI_bitmap *gh = subdiv_ccg->grid_hidden[i];
2131  if (gh) {
2132  BLI_bitmap_set_all(gh, is_hidden, key.grid_area);
2133  }
2134  }
2135 }
2136 
2137 void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg)
2138 {
2142 }
2143 
2145 {
2146  Mesh *mesh = BKE_mesh_from_object(object);
2148 
2149  BLI_assert(object->mode == OB_MODE_SCULPT);
2150 
2151  /* Copy the current mesh visibility to the Face Sets. */
2153  if (object->sculpt != NULL) {
2154  /* If a sculpt session is active, ensure we have its face-set data properly up-to-date. */
2155  object->sculpt->face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
2156 
2157  /* NOTE: In theory we could add that on the fly when required by sculpt code.
2158  * But this then requires proper update of depsgraph etc. For now we play safe, optimization is
2159  * always possible later if it's worth it. */
2160  BKE_sculpt_mask_layers_ensure(object, mmd);
2161  }
2162 
2163  /* Tessfaces aren't used and will become invalid. */
2165 
2166  /* We always need to flush updates from depsgraph here, since at the very least
2167  * `BKE_sculpt_face_sets_ensure_from_base_mesh_visibility()` will have updated some data layer of
2168  * the mesh.
2169  *
2170  * All known potential sources of updates:
2171  * - Addition of, or changes to, the `CD_SCULPT_FACE_SETS` data layer
2172  * (`BKE_sculpt_face_sets_ensure_from_base_mesh_visibility`).
2173  * - Addition of a `CD_PAINT_MASK` data layer (`BKE_sculpt_mask_layers_ensure`).
2174  * - Object has any active modifier (modifier stack can be different in Sculpt mode).
2175  * - Multires:
2176  * + Differences of subdiv levels between sculpt and object modes
2177  * (`mmd->sculptlvl != mmd->lvl`).
2178  * + Addition of a `CD_GRID_PAINT_MASK` data layer (`BKE_sculpt_mask_layers_ensure`).
2179  */
2181 }
2182 
2184 {
2185  PBVH *pbvh = BKE_pbvh_new();
2186  BKE_pbvh_build_bmesh(pbvh,
2187  ob->sculpt->bm,
2189  ob->sculpt->bm_log,
2192  pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
2193  pbvh_show_face_sets_set(pbvh, false);
2194  return pbvh;
2195 }
2196 
2197 static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool respect_hide)
2198 {
2200  const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
2201  PBVH *pbvh = BKE_pbvh_new();
2202  BKE_pbvh_respect_hide_set(pbvh, respect_hide);
2203 
2204  MLoopTri *looptri = MEM_malloc_arrayN(looptris_num, sizeof(*looptri), __func__);
2205 
2206  BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri);
2207 
2209 
2210  BKE_pbvh_build_mesh(pbvh,
2211  me,
2212  me->mpoly,
2213  me->mloop,
2214  me->mvert,
2215  me->totvert,
2216  &me->vdata,
2217  &me->ldata,
2218  &me->pdata,
2219  looptri,
2220  looptris_num);
2221 
2222  pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
2224 
2225  const bool is_deformed = check_sculpt_object_deformed(ob, true);
2226  if (is_deformed && me_eval_deform != NULL) {
2227  int totvert;
2228  float(*v_cos)[3] = BKE_mesh_vert_coords_alloc(me_eval_deform, &totvert);
2229  BKE_pbvh_vert_coords_apply(pbvh, v_cos, totvert);
2230  MEM_freeN(v_cos);
2231  }
2232 
2233  return pbvh;
2234 }
2235 
2236 static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect_hide)
2237 {
2238  CCGKey key;
2239  BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
2240  PBVH *pbvh = BKE_pbvh_new();
2241  BKE_pbvh_respect_hide_set(pbvh, respect_hide);
2242 
2243  Mesh *base_mesh = BKE_mesh_from_object(ob);
2244  BKE_sculpt_sync_face_set_visibility(base_mesh, subdiv_ccg);
2245 
2246  BKE_pbvh_build_grids(pbvh,
2247  subdiv_ccg->grids,
2248  subdiv_ccg->num_grids,
2249  &key,
2250  (void **)subdiv_ccg->grid_faces,
2251  subdiv_ccg->grid_flag_mats,
2252  subdiv_ccg->grid_hidden);
2253  pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
2255  return pbvh;
2256 }
2257 
2259 {
2260  if (ob == NULL || ob->sculpt == NULL) {
2261  return NULL;
2262  }
2263 
2264  const bool respect_hide = true;
2265 
2266  PBVH *pbvh = ob->sculpt->pbvh;
2267  if (pbvh != NULL) {
2268  /* NOTE: It is possible that grids were re-allocated due to modifier
2269  * stack. Need to update those pointers. */
2270  if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) {
2271  Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
2272  Mesh *mesh_eval = object_eval->data;
2273  SubdivCCG *subdiv_ccg = mesh_eval->runtime.subdiv_ccg;
2274  if (subdiv_ccg != NULL) {
2275  BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg);
2276  }
2277  }
2278 
2280  BKE_pbvh_pmap_set(pbvh, ob->sculpt->pmap);
2281 
2282  return pbvh;
2283  }
2284 
2285  if (ob->sculpt->bm != NULL) {
2286  /* Sculpting on a BMesh (dynamic-topology) gets a special PBVH. */
2288  }
2289  else {
2290  Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
2291  Mesh *mesh_eval = object_eval->data;
2292  if (mesh_eval->runtime.subdiv_ccg != NULL) {
2293  pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime.subdiv_ccg, respect_hide);
2294  }
2295  else if (ob->type == OB_MESH) {
2296  Mesh *me_eval_deform = object_eval->runtime.mesh_deform_eval;
2297  pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform, respect_hide);
2298  }
2299  }
2300 
2301  BKE_pbvh_pmap_set(pbvh, ob->sculpt->pmap);
2302 
2303  ob->sculpt->pbvh = pbvh;
2304  return pbvh;
2305 }
2306 
2308 {
2309  BKE_pbvh_grids_update(pbvh,
2310  subdiv_ccg->grids,
2311  (void **)subdiv_ccg->grid_faces,
2312  subdiv_ccg->grid_flag_mats,
2313  subdiv_ccg->grid_hidden);
2314 }
2315 
2317 {
2318  SculptSession *ss = ob->sculpt;
2319  if (ss == NULL || ss->pbvh == NULL || ss->mode_type != OB_MODE_SCULPT) {
2320  return false;
2321  }
2322 
2323  if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
2324  /* Regular mesh only draws from PBVH without modifiers and shape keys, or for
2325  * external engines that do not have access to the PBVH like Eevee does. */
2326  const bool external_engine = rv3d && rv3d->render_engine != NULL;
2327  return !(ss->shapekey_active || ss->deform_modifiers_active || external_engine);
2328  }
2329 
2330  /* Multires and dyntopo always draw directly from the PBVH. */
2331  return true;
2332 }
2333 
2334 /* Returns the Face Set random color for rendering in the overlay given its ID and a color seed. */
2335 #define GOLDEN_RATIO_CONJUGATE 0.618033988749895f
2336 void BKE_paint_face_set_overlay_color_get(const int face_set, const int seed, uchar r_color[4])
2337 {
2338  float rgba[4];
2339  float random_mod_hue = GOLDEN_RATIO_CONJUGATE * (abs(face_set) + (seed % 10));
2340  random_mod_hue = random_mod_hue - floorf(random_mod_hue);
2341  const float random_mod_sat = BLI_hash_int_01(abs(face_set) + seed + 1);
2342  const float random_mod_val = BLI_hash_int_01(abs(face_set) + seed + 2);
2343  hsv_to_rgb(random_mod_hue,
2344  0.6f + (random_mod_sat * 0.25f),
2345  1.0f - (random_mod_val * 0.35f),
2346  &rgba[0],
2347  &rgba[1],
2348  &rgba[2]);
2349  rgba_float_to_uchar(r_color, rgba);
2350 }
typedef float(TangentPoint)[2]
Generic geometry attributes built on CustomData.
void BKE_id_attributes_active_color_set(struct ID *id, struct CustomDataLayer *active_layer)
Definition: attribute.cc:715
eAttrDomain
Definition: BKE_attribute.h:25
#define ATTR_DOMAIN_NUM
Definition: BKE_attribute.h:34
struct Brush * BKE_brush_add(struct Main *bmain, const char *name, eObjectMode ob_mode)
Definition: brush.cc:496
struct Brush * BKE_brush_first_search(struct Main *bmain, eObjectMode ob_mode)
Definition: brush.cc:1567
void BKE_curvemapping_changed(struct CurveMapping *cumap, bool rem_doubles)
Definition: colortools.c:855
struct CurveMapping * BKE_curvemapping_copy(const struct CurveMapping *cumap)
void BKE_curvemapping_blend_read(struct BlendDataReader *reader, struct CurveMapping *cumap)
Definition: colortools.c:1300
void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope)
void BKE_curvemapping_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap)
void BKE_curvemapping_free(struct CurveMapping *cumap)
Definition: colortools.c:103
@ CURVEMAP_SLOPE_POSITIVE
struct CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition: colortools.c:72
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
@ CTX_MODE_PAINT_TEXTURE
Definition: BKE_context.h:116
@ CTX_MODE_WEIGHT_GPENCIL
Definition: BKE_context.h:122
@ CTX_MODE_SCULPT
Definition: BKE_context.h:113
@ CTX_MODE_VERTEX_GPENCIL
Definition: BKE_context.h:123
@ CTX_MODE_SCULPT_CURVES
Definition: BKE_context.h:124
@ CTX_MODE_SCULPT_GPENCIL
Definition: BKE_context.h:121
@ CTX_MODE_PAINT_GPENCIL
Definition: BKE_context.h:119
@ CTX_MODE_PAINT_VERTEX
Definition: BKE_context.h:115
@ CTX_MODE_PAINT_WEIGHT
Definition: BKE_context.h:114
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:824
void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float(**deformmats)[3][3], float(**deformcos)[3])
Definition: crazyspace.cc:424
@ CD_CALLOC
@ CD_DEFAULT
bool CustomData_has_layer(const struct CustomData *data, int type)
int CustomData_get_layer_index(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.cc:2776
support for deformation groups and hooks.
void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert)
Definition: deform.c:978
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition: BKE_idtype.h:41
void BKE_image_pool_free(struct ImagePool *pool)
struct KeyBlock * BKE_keyblock_from_object(struct Object *ob)
Definition: key.c:1890
float(* BKE_keyblock_convert_to_vertcos(const struct Object *ob, const struct KeyBlock *kb))[3]
@ LIB_ID_CREATE_NO_USER_REFCOUNT
Definition: BKE_lib_id.h:126
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void id_fake_user_set(struct ID *id)
Definition: lib_id.c:343
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2008
void * BKE_id_new(struct Main *bmain, short type, const char *name)
Definition: lib_id.c:1159
void BKE_lib_id_swap(struct Main *bmain, struct ID *id_a, struct ID *id_b)
Definition: lib_id.c:752
General operations, lookup, etc. for materials.
void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob)
Definition: material.c:1564
void BKE_mesh_tessface_clear(struct Mesh *mesh)
Definition: mesh.cc:1654
struct Mesh * BKE_mesh_from_object(struct Object *ob)
Definition: mesh.cc:1365
void BKE_mesh_recalc_looptri(const struct MLoop *mloop, const struct MPoly *mpoly, const struct MVert *mvert, int totloop, int totpoly, struct MLoopTri *mlooptri)
void BKE_mesh_update_customdata_pointers(struct Mesh *me, bool do_ensure_tess_cd)
Definition: mesh.cc:874
float(* BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3]
void BKE_mesh_flush_hidden_from_polys(struct Mesh *me)
void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const struct MLoop *mloop, int totvert, int totpoly, int totloop)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
struct ModifierData * BKE_modifiers_get_virtual_modifierlist(const struct Object *ob, struct VirtualModifierData *data)
@ eModifierTypeType_OnlyDeform
Definition: BKE_modifier.h:44
General operations, lookup, etc. for blender objects.
struct Mesh * BKE_object_get_evaluated_mesh(const struct Object *object)
void BKE_object_free_derived_caches(struct Object *ob)
Definition: object.cc:1774
struct Mesh * BKE_object_get_original_mesh(const struct Object *object)
char * BKE_paint_canvas_key_get(struct PaintModeSettings *settings, struct Object *ob)
#define PAINT_MODE_HAS_BRUSH(mode)
Definition: BKE_paint.h:89
void BKE_paint_toolslots_brush_update(struct Paint *paint)
ePaintOverlayControlFlags
Definition: BKE_paint.h:92
@ PAINT_OVERLAY_INVALID_CURVE
Definition: BKE_paint.h:95
@ PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY
Definition: BKE_paint.h:94
@ PAINT_OVERLAY_OVERRIDE_CURSOR
Definition: BKE_paint.h:96
@ PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY
Definition: BKE_paint.h:93
@ PAINT_OVERLAY_OVERRIDE_SECONDARY
Definition: BKE_paint.h:98
@ PAINT_OVERLAY_OVERRIDE_PRIMARY
Definition: BKE_paint.h:97
#define PAINT_OVERRIDE_MASK
Definition: BKE_paint.h:101
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_SCULPT_UV
Definition: BKE_paint.h:76
@ 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
@ SCULPT_MASK_LAYER_CALC_VERT
Definition: BKE_paint.h:738
@ SCULPT_MASK_LAYER_CALC_LOOP
Definition: BKE_paint.h:739
A BVH for high poly meshes.
void BKE_pbvh_build_grids(PBVH *pbvh, struct CCGElem **grids, int totgrid, struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats, unsigned int **grid_hidden)
Definition: pbvh.c:608
void BKE_pbvh_node_mark_update(PBVHNode *node)
Definition: pbvh.c:1869
void BKE_pbvh_build_mesh(PBVH *pbvh, struct Mesh *mesh, const struct MPoly *mpoly, const struct MLoop *mloop, struct MVert *verts, int totvert, struct CustomData *vdata, struct CustomData *ldata, struct CustomData *pdata, const struct MLoopTri *looptri, int looptri_num)
void BKE_pbvh_update_active_vcol(PBVH *pbvh, const struct Mesh *mesh)
void BKE_pbvh_pmap_set(PBVH *pbvh, const struct MeshElemMap *pmap)
void pbvh_show_mask_set(PBVH *pbvh, bool show_mask)
Definition: pbvh.c:3185
void BKE_pbvh_free(PBVH *pbvh)
Definition: pbvh.c:663
bool BKE_pbvh_is_deformed(struct PBVH *pbvh)
Definition: pbvh.c:3010
PBVHType BKE_pbvh_type(const PBVH *pbvh)
Definition: pbvh.c:1798
void pbvh_show_face_sets_set(PBVH *pbvh, bool show_face_sets)
Definition: pbvh.c:3190
void BKE_pbvh_subdiv_cgg_set(PBVH *pbvh, struct SubdivCCG *subdiv_ccg)
Definition: pbvh.c:3231
void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh)
Definition: pbvh.c:1885
void BKE_pbvh_build_bmesh(PBVH *pbvh, struct BMesh *bm, bool smooth_shading, struct BMLog *log, int cd_vert_node_offset, int cd_face_node_offset)
Definition: pbvh_bmesh.c:1866
void BKE_pbvh_vert_coords_apply(struct PBVH *pbvh, const float(*vertCos)[3], int totvert)
Definition: pbvh.c:2966
void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default)
Definition: pbvh.c:2843
@ PBVH_GRIDS
Definition: BKE_pbvh.h:235
@ PBVH_FACES
Definition: BKE_pbvh.h:234
PBVH * BKE_pbvh_new(void)
Definition: pbvh.c:655
void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide)
Definition: pbvh.c:3241
void BKE_pbvh_grids_update(PBVH *pbvh, struct CCGElem **grids, void **gridfaces, struct DMFlagMat *flagmats, unsigned int **grid_hidden)
Definition: pbvh.c:2932
void BKE_pbvh_face_sets_set(PBVH *pbvh, int *face_sets)
Definition: pbvh.c:3236
void BKE_pbvh_search_gather(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot)
Definition: pbvh.c:838
bool BKE_pbvh_get_color_layer(const struct Mesh *me, CustomDataLayer **r_layer, eAttrDomain *r_attr)
void BKE_subdiv_ccg_key_top_level(struct CCGKey *key, const SubdivCCG *subdiv_ccg)
Definition: subdiv_ccg.c:668
void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index)
Definition: subdiv_ccg.c:2035
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG *subdiv_ccg, int grid_index)
Definition: subdiv_ccg.c:1940
int BKE_ccg_gridsize(int level)
Definition: CCGSubSurf.c:23
int BKE_ccg_factor(int low_level, int high_level)
Definition: CCGSubSurf.c:28
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:64
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
Definition: bitmap.c:17
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:302
#define GHASH_ITER(gh_iter_, ghash_)
Definition: BLI_ghash.h:321
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:705
BLI_INLINE float BLI_hash_int_01(unsigned int k)
Definition: BLI_hash.h:94
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
int BLI_listbase_count_at_most(const struct ListBase *listbase, int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
MINLINE int max_ii(int a, int b)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
Definition: math_color.c:208
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:13
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
Definition: math_color.c:396
MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void cpack_to_rgb(unsigned int col, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:369
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
bool invert_m3(float R[3][3])
Definition: math_matrix.c:1171
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
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 sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define ARRAY_SIZE(arr)
#define SWAP(type, a, b)
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define POINTER_AS_INT(i)
#define ELEM(...)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define STREQ(a, b)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5172
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
#define BLT_I18NCONTEXT_ID_PALETTE
#define BLT_I18NCONTEXT_ID_PAINTCURVE
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update(struct ID *id, int flag)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
struct Object * DEG_get_original_object(struct Object *object)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
@ ID_RECALC_GEOMETRY_ALL_MODES
Definition: DNA_ID.h:884
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ INDEX_ID_PC
Definition: DNA_ID.h:1045
@ INDEX_ID_PAL
Definition: DNA_ID.h:1044
#define FILTER_ID_PC
Definition: DNA_ID.h:918
#define FILTER_ID_PAL
Definition: DNA_ID.h:917
@ ID_PAL
Definition: DNA_ID_enums.h:76
@ ID_PC
Definition: DNA_ID_enums.h:77
eOverlayFlags
@ BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE
@ BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE
@ BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE
#define BRUSH_OVERLAY_OVERRIDE_MASK
struct PaintCurve PaintCurve
struct Palette Palette
@ CUMA_EXTEND_EXTRAPOLATE
@ CURVE_PRESET_LINE
@ CD_PROP_BYTE_COLOR
@ CD_PAINT_MASK
@ CD_PROP_COLOR
@ CD_SCULPT_FACE_SETS
@ CD_GRID_PAINT_MASK
@ ME_EDIT_PAINT_VERT_SEL
@ ME_EDIT_PAINT_FACE_SEL
@ ME_HIDE
#define ME_POLY_LOOP_PREV(mloop, mp, i)
#define ME_POLY_LOOP_NEXT(mloop, mp, i)
@ eMultiresModifierFlag_UseSculptBaseMesh
@ eModifierMode_Realtime
@ eModifierType_ShapeKey
@ eModifierType_Multires
eObjectMode
@ OB_MODE_VERTEX_GPENCIL
@ OB_MODE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_WEIGHT_GPENCIL
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_SCULPT_GPENCIL
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_VERTEX_PAINT
@ OB_MODE_PAINT_GPENCIL
Object is a sort of wrapper for general info.
@ OB_SHAPE_LOCK
@ OB_MESH
@ SCULPT_HIDE_MASK
@ SCULPT_ONLY_DEFORM
@ SCULPT_DYNTOPO_SUBDIVIDE
@ SCULPT_HIDE_FACE_SETS
@ SCULPT_DYNTOPO_COLLAPSE
struct PaintToolSlot PaintToolSlot
@ PAINT_SHOW_BRUSH
@ PAINT_SYMM_X
@ SPACE_IMAGE
@ SPACE_VIEW3D
@ SI_MODE_PAINT
@ SI_MODE_UV
#define MTEX_ANGLE_RAKE
_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 GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_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
_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
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
static void init_data(ModifierData *md)
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
#define BM_FACE_FIRST_LOOP(p)
Definition: bmesh_class.h:622
@ BM_ELEM_HIDDEN
Definition: bmesh_class.h:472
@ BM_ELEM_SMOOTH
Definition: bmesh_class.h:477
#define BM_elem_flag_set(ele, hflag, val)
Definition: bmesh_inline.h:16
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_FACES_OF_MESH
void BM_log_free(BMLog *log)
Definition: bmesh_log.c:539
void BM_log_mesh_elems_reorder(BMesh *bm, BMLog *log)
Definition: bmesh_log.c:569
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
Definition: bmesh_mesh.cc:258
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMeshParams *params)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
unsigned int U
Definition: btGjkEpa3.h:78
static unsigned long seed
Definition: btSoftBody.h:39
Scene scene
Curve curve
const Depsgraph * depsgraph
SyclQueue void void * src
uint col
static char ** types
Definition: makesdna.c:67
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:34
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:32
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:26
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
static ulong * next
#define atan2f(x, y)
Definition: metal/compat.h:227
#define floorf(x)
Definition: metal/compat.h:224
static unsigned a[3]
Definition: RandGen.cpp:78
T abs(const T &a)
SymEdge< T > * prev(const SymEdge< T > *se)
Definition: delaunay_2d.cc:105
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken rgba("rgba", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
void BKE_palette_sort_vhs(tPaletteColorHSV *color_array, const int totcol)
Definition: paint.c:906
void BKE_sculpt_update_object_after_eval(Depsgraph *depsgraph, Object *ob_eval)
Definition: paint.c:1869
void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
Definition: paint.c:628
void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss)
Definition: paint.c:1349
void BKE_paint_set_overlay_override(eOverlayFlags flags)
Definition: paint.c:271
eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode)
Definition: paint.c:1022
void BKE_sculpt_bvh_update_from_ccg(PBVH *pbvh, SubdivCCG *subdiv_ccg)
Definition: paint.c:2307
void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
Definition: paint.c:2091
bool BKE_paint_select_vert_test(Object *ob)
Definition: paint.c:987
static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
Definition: paint.c:1570
void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
Definition: paint.c:247
static PBVH * build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect_hide)
Definition: paint.c:2236
float paint_grid_paint_mask(const GridPaintMask *gpm, uint level, uint x, uint y)
Definition: paint.c:1277
#define RAKE_THRESHHOLD
Definition: paint.c:1286
Paint * BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
Definition: paint.c:345
void BKE_paint_curve_set(Brush *br, PaintCurve *pc)
Definition: paint.c:728
void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg)
Definition: paint.c:2137
static void palette_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int UNUSED(flag))
Definition: paint.c:76
void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const Tex *tex)
Definition: paint.c:227
static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
Definition: paint.c:1377
void BKE_paint_copy(Paint *src, Paint *tar, const int flag)
Definition: paint.c:1167
void BKE_paint_blend_write(BlendWriter *writer, Paint *p)
Definition: paint.c:1196
void BKE_sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
Definition: paint.c:2106
void BKE_sculptsession_bm_to_me(Object *ob, bool reorder)
Definition: paint.c:1401
void BKE_sculpt_ensure_orig_mesh_data(Scene *scene, Object *object)
Definition: paint.c:2144
void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene)
Definition: paint.c:1992
static PBVH * build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool respect_hide)
Definition: paint.c:2197
static bool check_sculpt_object_deformed(Object *object, const bool for_construction)
Definition: paint.c:2019
bool BKE_palette_from_hash(Main *bmain, GHash *color_table, const char *name, const bool linear)
Definition: paint.c:918
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
Definition: paint.c:2316
static void palette_undo_preserve(BlendLibReader *UNUSED(reader), ID *id_new, ID *id_old)
Definition: paint.c:113
static void paint_curve_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int UNUSED(flag))
Definition: paint.c:153
void BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(Mesh *mesh)
Definition: paint.c:2043
void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3])
Definition: paint.c:1184
static int palettecolor_compare_luminance(const void *a1, const void *a2)
Definition: paint.c:877
void BKE_sculptsession_free(Object *ob)
Definition: paint.c:1469
void BKE_paint_blend_read_lib(BlendLibReader *reader, Scene *sce, Paint *p)
Definition: paint.c:1230
const char PAINT_CURSOR_VERTEX_PAINT[3]
Definition: paint.c:221
Palette * BKE_palette_add(Main *bmain, const char *name)
Definition: paint.c:764
ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
Definition: paint.c:518
const Brush * BKE_paint_brush_for_read(const Paint *p)
Definition: paint.c:612
Paint * BKE_paint_get_active_from_context(const bContext *C)
Definition: paint.c:483
void BKE_sculptsession_free_deformMats(SculptSession *ss)
Definition: paint.c:1342
const char PAINT_CURSOR_SCULPT[3]
Definition: paint.c:220
uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
Definition: paint.c:675
PaintCurve * BKE_paint_curve_add(Main *bmain, const char *name)
Definition: paint.c:705
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
Definition: paint.c:742
bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
Definition: paint.c:294
Brush * BKE_paint_brush(Paint *p)
Definition: paint.c:607
void BKE_palette_sort_hsv(tPaletteColorHSV *color_array, const int totcol)
Definition: paint.c:894
void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Paint *p)
Definition: paint.c:1204
static int palettecolor_compare_svh(const void *a1, const void *a2)
Definition: paint.c:815
void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag)
Definition: paint.c:289
bool paint_is_grid_face_hidden(const uint *grid_hidden, int gridsize, int x, int y)
Definition: paint.c:1253
void BKE_palette_sort_svh(tPaletteColorHSV *color_array, const int totcol)
Definition: paint.c:900
void BKE_paint_brush_set(Paint *p, Brush *br)
Definition: paint.c:617
static PBVH * build_pbvh_for_dynamic_topology(Object *ob)
Definition: paint.c:2183
const EnumPropertyItem * BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
Definition: paint.c:382
bool paint_is_face_hidden(const MLoopTri *lt, const MVert *mvert, const MLoop *mloop)
Definition: paint.c:1246
void BKE_paint_free(Paint *paint)
Definition: paint.c:1161
int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
Definition: paint.c:1926
void BKE_palette_sort_luminance(tPaletteColorHSV *color_array, const int totcol)
Definition: paint.c:912
static void palette_free_data(ID *id)
Definition: paint.c:87
bool BKE_paint_select_elem_test(Object *ob)
Definition: paint.c:994
static void paint_curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: paint.c:174
void paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation)
Definition: paint.c:1288
const char PAINT_CURSOR_WEIGHT_PAINT[3]
Definition: paint.c:222
void BKE_sculpt_update_object_before_eval(const Scene *scene, Object *ob_eval)
Definition: paint.c:1827
bool BKE_paint_select_face_test(Object *ob)
Definition: paint.c:980
static void paint_curve_free_data(ID *id)
Definition: paint.c:166
const char PAINT_CURSOR_TEXTURE_PAINT[3]
Definition: paint.c:223
void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const char col[3])
Definition: paint.c:1130
#define GOLDEN_RATIO_CONJUGATE
Definition: paint.c:2335
void BKE_palette_clear(Palette *palette)
Definition: paint.c:758
void BKE_sculptsession_bm_to_me_for_render(Object *object)
Definition: paint.c:1447
bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
Definition: paint.c:1042
static void sculptsession_free_pbvh(Object *object)
Definition: paint.c:1412
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, const float mouse_pos[2])
Definition: paint.c:1305
static ePaintOverlayControlFlags overlay_flags
Definition: paint.c:225
static void sculpt_update_object(Depsgraph *depsgraph, Object *ob, Mesh *me_eval, bool need_pmap, bool need_mask, bool is_paint_tool)
Definition: paint.c:1617
void BKE_sculpt_update_object_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool need_pmap, bool need_mask, bool is_paint_tool)
Definition: paint.c:1914
bool paint_is_bmesh_face_hidden(BMFace *f)
Definition: paint.c:1262
void BKE_paint_invalidate_overlay_all(void)
Definition: paint.c:260
MultiresModifierData * BKE_sculpt_multires_active(const Scene *scene, Object *ob)
Definition: paint.c:1528
IDTypeInfo IDType_ID_PAL
Definition: paint.c:123
static void palette_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: paint.c:94
static void paint_curve_blend_read_data(BlendDataReader *reader, ID *id)
Definition: paint.c:184
PBVH * BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
Definition: paint.c:2258
IDTypeInfo IDType_ID_PC
Definition: paint.c:190
static int palettecolor_compare_vhs(const void *a1, const void *a2)
Definition: paint.c:846
void BKE_paint_palette_set(Paint *p, Palette *palette)
Definition: paint.c:719
static void palette_init_data(ID *id)
Definition: paint.c:66
static int palettecolor_compare_hsv(const void *a1, const void *a2)
Definition: paint.c:783
const char * BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
Definition: paint.c:412
void BKE_paint_face_set_overlay_color_get(const int face_set, const int seed, uchar r_color[4])
Definition: paint.c:2336
PaletteColor * BKE_palette_color_add(Palette *palette)
Definition: paint.c:770
bool BKE_paint_always_hide_test(Object *ob)
Definition: paint.c:999
void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_index)
Definition: paint.c:737
Palette * BKE_paint_palette(Paint *p)
Definition: paint.c:714
ePaintOverlayControlFlags BKE_paint_get_overlay_flags(void)
Definition: paint.c:266
static void palette_blend_read_data(BlendDataReader *reader, ID *id)
Definition: paint.c:107
void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
Definition: paint.c:1880
void BKE_paint_cavity_curve_preset(Paint *p, int preset)
Definition: paint.c:1005
ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref)
Definition: paint.c:571
Paint * BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
Definition: paint.c:444
bool BKE_palette_is_empty(const struct Palette *palette)
Definition: paint.c:777
static void sculpt_face_sets_ensure(Mesh *mesh)
Definition: paint.c:1810
return ret
const EnumPropertyItem rna_enum_brush_image_tool_items[]
Definition: rna_brush.c:154
const EnumPropertyItem rna_enum_brush_curves_sculpt_tool_items[]
Definition: rna_brush.c:247
const EnumPropertyItem rna_enum_brush_weight_tool_items[]
Definition: rna_brush.c:146
const EnumPropertyItem rna_enum_brush_gpencil_sculpt_types_items[]
Definition: rna_brush.c:193
const EnumPropertyItem rna_enum_brush_sculpt_tool_items[]
Definition: rna_brush.c:91
const EnumPropertyItem rna_enum_brush_vertex_tool_items[]
Definition: rna_brush.c:138
const EnumPropertyItem rna_enum_brush_uv_sculpt_tool_items[]
Definition: rna_brush.c:131
const EnumPropertyItem rna_enum_brush_gpencil_vertex_types_items[]
Definition: rna_brush.c:184
const EnumPropertyItem rna_enum_brush_gpencil_weight_types_items[]
Definition: rna_brush.c:237
const EnumPropertyItem rna_enum_brush_gpencil_types_items[]
Definition: rna_brush.c:164
struct BMVert * v
Definition: bmesh_class.h:153
struct BMLoop * next
Definition: bmesh_class.h:233
struct Object * object
struct MTex mtex
struct CurveMapping * curve
struct MTex mask_mtex
struct PaintCurve * paint_curve
Definition: BKE_ccg.h:32
int grid_area
Definition: BKE_ccg.h:42
CurveMap cm[4]
CustomDataLayer * layers
unsigned int level
short id_code
Definition: BKE_idtype.h:114
Definition: DNA_ID.h:368
struct Library * lib
Definition: DNA_ID.h:372
IDProperty * properties
Definition: DNA_ID.h:409
void * first
Definition: DNA_listBase.h:31
unsigned int tri[3]
unsigned int v
char brush_angle_mode
struct Tex * tex
Definition: BKE_main.h:121
struct SubdivCCG * subdiv_ccg
CustomData vdata
struct MVert * mvert
int totvert
struct MLoop * mloop
Mesh_Runtime runtime
CustomData pdata
int totpoly
int face_sets_color_seed
int face_sets_color_default
int totloop
struct Key * key
struct MPoly * mpoly
CustomData ldata
struct ModifierData * next
ModifierTypeType type
Definition: BKE_modifier.h:160
struct Mesh * mesh_deform_eval
short shapenr
Object_Runtime runtime
float obmat[4][4]
struct SculptSession * sculpt
void * data
char shapeflag
PaintCurvePoint * points
struct Brush * brush
unsigned short ob_mode
unsigned int tool_offset
struct Paint_Runtime runtime
float tile_offset[3]
int tool_slots_len
int num_input_samples
struct PaintToolSlot * tool_slots
int symmetry_flags
void * paint_cursor
unsigned char paint_cursor_col[4]
struct CurveMapping * cavity_curve
struct Palette * palette
struct Brush * brush
int active_color
ListBase colors
struct RenderEngine * render_engine
struct ToolSettings * toolsettings
struct SculptBoundaryEditInfo * edit_info
Definition: BKE_paint.h:453
int * vertices
Definition: BKE_paint.h:417
float * distance
Definition: BKE_paint.h:424
SculptBoundaryPreviewEdge * edges
Definition: BKE_paint.h:427
int * fake_neighbor_index
Definition: BKE_paint.h:480
SculptPoseIKChainSegment * segments
Definition: BKE_paint.h:297
struct SubdivCCG * subdiv_ccg
Definition: BKE_paint.h:547
struct ImagePool * tex_pool
Definition: BKE_paint.h:561
int cd_face_node_offset
Definition: BKE_paint.h:541
SculptPoseIKChain * pose_ik_chain_preview
Definition: BKE_paint.h:599
struct MeshElemMap * epmap
Definition: BKE_paint.h:520
bool bm_smooth_shading
Definition: BKE_paint.h:542
int cd_vert_node_offset
Definition: BKE_paint.h:540
int preview_vert_index_count
Definition: BKE_paint.h:595
struct Depsgraph * depsgraph
Definition: BKE_paint.h:495
struct SculptSession::@53::@54 vpaint
SculptVertexInfo vertex_info
Definition: BKE_paint.h:608
bool show_mask
Definition: BKE_paint.h:551
float(* orig_cos)[3]
Definition: BKE_paint.h:556
int * face_sets
Definition: BKE_paint.h:536
int * pmap_mem
Definition: BKE_paint.h:517
struct MVert * mvert
Definition: BKE_paint.h:498
eCustomDataType vcol_type
Definition: BKE_paint.h:510
struct MPropCol * vcol
Definition: BKE_paint.h:506
struct KeyBlock * shapekey_active
Definition: BKE_paint.h:505
bool show_face_sets
Definition: BKE_paint.h:552
struct BMesh * bm
Definition: BKE_paint.h:539
int * preview_vert_index_list
Definition: BKE_paint.h:594
SculptBoundary * boundary_preview
Definition: BKE_paint.h:602
struct MeshElemMap * vemap
Definition: BKE_paint.h:524
struct BMLog * bm_log
Definition: BKE_paint.h:544
struct SculptSession::@53::@55 wpaint
union SculptSession::@53 mode
char * last_paint_canvas_key
Definition: BKE_paint.h:664
struct Scene * scene
Definition: BKE_paint.h:591
int * epmap_mem
Definition: BKE_paint.h:521
float * vmask
Definition: BKE_paint.h:512
struct MeshElemMap * pmap
Definition: BKE_paint.h:516
struct MLoop * mloop
Definition: BKE_paint.h:500
struct SculptSession::@52 multires
struct MPoly * mpoly
Definition: BKE_paint.h:499
eObjectMode mode_type
Definition: BKE_paint.h:642
struct MultiresModifierData * modifier
Definition: BKE_paint.h:490
float(* deform_imats)[3][3]
Definition: BKE_paint.h:558
struct StrokeCache * cache
Definition: BKE_paint.h:563
eAttrDomain vcol_domain
Definition: BKE_paint.h:509
float(* deform_cos)[3]
Definition: BKE_paint.h:557
struct ExpandCache * expand_cache
Definition: BKE_paint.h:565
struct MLoopCol * mcol
Definition: BKE_paint.h:507
SculptFakeNeighbors fake_neighbors
Definition: BKE_paint.h:609
SculptPersistentBase * persistent_base
Definition: BKE_paint.h:606
struct FilterCache * filter_cache
Definition: BKE_paint.h:564
bool building_vp_handle
Definition: BKE_paint.h:645
struct PBVH * pbvh
Definition: BKE_paint.h:550
int * vemap_mem
Definition: BKE_paint.h:525
bool deform_modifiers_active
Definition: BKE_paint.h:555
int * connected_component
Definition: BKE_paint.h:392
BLI_bitmap * boundary
Definition: BKE_paint.h:395
struct MeshElemMap * vert_to_loop
Definition: BKE_paint.h:272
struct MeshElemMap * vert_to_poly
Definition: BKE_paint.h:274
float detail_percent
Paint paint
float detail_size
float constant_detail
struct CCGElem ** grids
SubdivCCGFace ** grid_faces
BLI_bitmap ** grid_hidden
struct DMFlagMat * grid_flag_mats
GpWeightPaint * gp_weightpaint
struct ImagePaintSettings imapaint
GpPaint * gp_paint
GpSculptPaint * gp_sculptpaint
struct PaintModeSettings paint_mode
struct UnifiedPaintSettings unified_paint_settings
CurvesSculpt * curves_sculpt
UvSculpt * uvsculpt
GpVertexPaint * gp_vertexpaint
struct Base * basact