Blender  V3.3
paint_utils.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <math.h>
9 #include <stdlib.h>
10 
11 #include "DNA_material_types.h"
12 #include "DNA_mesh_types.h"
13 #include "DNA_meshdata_types.h"
14 #include "DNA_object_types.h"
15 
16 #include "DNA_brush_types.h"
17 #include "DNA_scene_types.h"
18 
19 #include "BLI_listbase.h"
20 #include "BLI_math.h"
21 #include "BLI_math_color.h"
22 #include "BLI_rect.h"
23 #include "BLI_utildefines.h"
24 
25 #include "BLT_translation.h"
26 
27 #include "BKE_brush.h"
28 #include "BKE_context.h"
29 #include "BKE_customdata.h"
30 #include "BKE_image.h"
31 #include "BKE_material.h"
32 #include "BKE_mesh_runtime.h"
33 #include "BKE_paint.h"
34 #include "BKE_report.h"
35 
36 #include "DEG_depsgraph.h"
37 #include "DEG_depsgraph_query.h"
38 
39 #include "RNA_access.h"
40 #include "RNA_define.h"
41 #include "RNA_prototypes.h"
42 
43 #include "GPU_framebuffer.h"
44 #include "GPU_matrix.h"
45 #include "GPU_state.h"
46 #include "GPU_texture.h"
47 
48 #include "IMB_colormanagement.h"
49 #include "IMB_imbuf.h"
50 #include "IMB_imbuf_types.h"
51 
52 #include "RE_texture.h"
53 
54 #include "ED_image.h"
55 #include "ED_screen.h"
56 #include "ED_view3d.h"
57 
58 #include "BLI_sys_types.h"
59 #include "ED_mesh.h" /* for face mask functions */
60 
61 #include "DRW_select_buffer.h"
62 
63 #include "WM_api.h"
64 #include "WM_types.h"
65 
66 #include "paint_intern.h"
67 
69  const float bb_min[3],
70  const float bb_max[3],
71  const ARegion *region,
72  RegionView3D *rv3d,
73  Object *ob)
74 {
75  float projection_mat[4][4];
76  int i, j, k;
77 
79 
80  /* return zero if the bounding box has non-positive volume */
81  if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) {
82  return false;
83  }
84 
85  ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat);
86 
87  for (i = 0; i < 2; i++) {
88  for (j = 0; j < 2; j++) {
89  for (k = 0; k < 2; k++) {
90  float vec[3], proj[2];
91  int proj_i[2];
92  vec[0] = i ? bb_min[0] : bb_max[0];
93  vec[1] = j ? bb_min[1] : bb_max[1];
94  vec[2] = k ? bb_min[2] : bb_max[2];
95  /* convert corner to screen space */
96  ED_view3d_project_float_v2_m4(region, vec, proj, projection_mat);
97  /* expand 2D rectangle */
98 
99  /* we could project directly to int? */
100  proj_i[0] = proj[0];
101  proj_i[1] = proj[1];
102 
103  BLI_rcti_do_minmax_v(rect, proj_i);
104  }
105  }
106  }
107 
108  /* return false if the rectangle has non-positive area */
109  return rect->xmin < rect->xmax && rect->ymin < rect->ymax;
110 }
111 
112 void paint_calc_redraw_planes(float planes[4][4],
113  const ARegion *region,
114  Object *ob,
115  const rcti *screen_rect)
116 {
117  BoundBox bb;
118  rcti rect;
119 
120  /* use some extra space just in case */
121  rect = *screen_rect;
122  rect.xmin -= 2;
123  rect.xmax += 2;
124  rect.ymin -= 2;
125  rect.ymax += 2;
126 
127  ED_view3d_clipping_calc(&bb, planes, region, ob, &rect);
128 }
129 
130 float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius)
131 {
132  Object *ob = vc->obact;
133  float delta[3], scale, loc[3];
134  const float xy_delta[2] = {pixel_radius, 0.0f};
135 
136  mul_v3_m4v3(loc, ob->obmat, center);
137 
138  const float zfac = ED_view3d_calc_zfac(vc->rv3d, loc);
139  ED_view3d_win_to_delta(vc->region, xy_delta, zfac, delta);
140 
141  scale = fabsf(mat4_to_scale(ob->obmat));
142  scale = (scale == 0.0f) ? 1.0f : scale;
143 
144  return len_v3(delta) / scale;
145 }
146 
147 float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
148 {
149  float intensity;
150  float rgba_dummy[4];
151  const float co[3] = {u, v, 0.0f};
152 
153  RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba_dummy);
154 
155  return intensity;
156 }
157 
158 void paint_get_tex_pixel_col(const MTex *mtex,
159  float u,
160  float v,
161  float rgba[4],
162  struct ImagePool *pool,
163  int thread,
164  bool convert_to_linear,
165  struct ColorSpace *colorspace)
166 {
167  const float co[3] = {u, v, 0.0f};
168  float intensity;
169 
170  const bool hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
171 
172  if (!hasrgb) {
173  rgba[0] = intensity;
174  rgba[1] = intensity;
175  rgba[2] = intensity;
176  rgba[3] = 1.0f;
177  }
178 
179  if (convert_to_linear) {
181  }
182 
184 
185  clamp_v4(rgba, 0.0f, 1.0f);
186 }
187 
189 {
190  static const EnumPropertyItem stroke_mode_items[] = {
191  {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Regular", "Apply brush normally"},
193  "INVERT",
194  0,
195  "Invert",
196  "Invert action of brush for duration of stroke"},
198  "SMOOTH",
199  0,
200  "Smooth",
201  "Switch brush to smooth mode for duration of stroke"},
202  {0},
203  };
204 
205  PropertyRNA *prop;
206 
207  prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
209 
211  "mode",
212  stroke_mode_items,
214  "Stroke Mode",
215  "Action taken when a paint stroke is made");
216 }
217 
218 /* 3D Paint */
219 
220 static void imapaint_project(const float matrix[4][4], const float co[3], float pco[4])
221 {
222  copy_v3_v3(pco, co);
223  pco[3] = 1.0f;
224 
225  mul_m4_v4(matrix, pco);
226 }
227 
228 static void imapaint_tri_weights(float matrix[4][4],
229  const int view[4],
230  const float v1[3],
231  const float v2[3],
232  const float v3[3],
233  const float co[2],
234  float w[3])
235 {
236  float pv1[4], pv2[4], pv3[4], h[3], divw;
237  float wmat[3][3], invwmat[3][3];
238 
239  /* compute barycentric coordinates */
240 
241  /* project the verts */
242  imapaint_project(matrix, v1, pv1);
243  imapaint_project(matrix, v2, pv2);
244  imapaint_project(matrix, v3, pv3);
245 
246  /* do inverse view mapping, see gluProject man page */
247  h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1.0f;
248  h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1.0f;
249  h[2] = 1.0f;
250 
251  /* solve for (w1,w2,w3)/perspdiv in:
252  * h * perspdiv = Project * Model * (w1 * v1 + w2 * v2 + w3 * v3) */
253 
254  wmat[0][0] = pv1[0];
255  wmat[1][0] = pv2[0];
256  wmat[2][0] = pv3[0];
257  wmat[0][1] = pv1[1];
258  wmat[1][1] = pv2[1];
259  wmat[2][1] = pv3[1];
260  wmat[0][2] = pv1[3];
261  wmat[1][2] = pv2[3];
262  wmat[2][2] = pv3[3];
263 
264  invert_m3_m3(invwmat, wmat);
265  mul_m3_v3(invwmat, h);
266 
267  copy_v3_v3(w, h);
268 
269  /* w is still divided by perspdiv, make it sum to one */
270  divw = w[0] + w[1] + w[2];
271  if (divw != 0.0f) {
272  mul_v3_fl(w, 1.0f / divw);
273  }
274 }
275 
276 /* compute uv coordinates of mouse in face */
277 static void imapaint_pick_uv(
278  Mesh *me_eval, Scene *scene, Object *ob_eval, uint faceindex, const int xy[2], float uv[2])
279 {
280  int i, findex;
281  float p[2], w[3], absw, minabsw;
282  float matrix[4][4], proj[4][4];
283  int view[4];
285 
286  const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
287  const int tottri = me_eval->runtime.looptris.len;
288 
289  const MVert *mvert = me_eval->mvert;
290  const MPoly *mpoly = me_eval->mpoly;
291  const MLoop *mloop = me_eval->mloop;
292  const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
293 
294  /* get the needed opengl matrices */
298  view[0] = view[1] = 0;
299  mul_m4_m4m4(matrix, matrix, ob_eval->obmat);
300  mul_m4_m4m4(matrix, proj, matrix);
301 
302  minabsw = 1e10;
303  uv[0] = uv[1] = 0.0;
304 
305  /* test all faces in the derivedmesh with the original index of the picked face */
306  /* face means poly here, not triangle, indeed */
307  for (i = 0; i < tottri; i++, lt++) {
308  findex = index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly;
309 
310  if (findex == faceindex) {
311  const MLoopUV *mloopuv;
312  const MPoly *mp = &mpoly[lt->poly];
313  const MLoopUV *tri_uv[3];
314  float tri_co[3][3];
315 
316  for (int j = 3; j--;) {
317  copy_v3_v3(tri_co[j], mvert[mloop[lt->tri[j]].v].co);
318  }
319 
320  if (mode == PAINT_CANVAS_SOURCE_MATERIAL) {
321  const Material *ma;
322  const TexPaintSlot *slot;
323 
324  ma = BKE_object_material_get(ob_eval, mp->mat_nr + 1);
325  slot = &ma->texpaintslot[ma->paint_active_slot];
326 
327  if (!(slot && slot->uvname &&
328  (mloopuv = CustomData_get_layer_named(&me_eval->ldata, CD_MLOOPUV, slot->uvname)))) {
329  mloopuv = CustomData_get_layer(&me_eval->ldata, CD_MLOOPUV);
330  }
331  }
332  else {
333  mloopuv = CustomData_get_layer(&me_eval->ldata, CD_MLOOPUV);
334  }
335 
336  tri_uv[0] = &mloopuv[lt->tri[0]];
337  tri_uv[1] = &mloopuv[lt->tri[1]];
338  tri_uv[2] = &mloopuv[lt->tri[2]];
339 
340  p[0] = xy[0];
341  p[1] = xy[1];
342 
343  imapaint_tri_weights(matrix, view, UNPACK3(tri_co), p, w);
344  absw = fabsf(w[0]) + fabsf(w[1]) + fabsf(w[2]);
345  if (absw < minabsw) {
346  uv[0] = tri_uv[0]->uv[0] * w[0] + tri_uv[1]->uv[0] * w[1] + tri_uv[2]->uv[0] * w[2];
347  uv[1] = tri_uv[0]->uv[1] * w[0] + tri_uv[1]->uv[1] * w[1] + tri_uv[2]->uv[1] * w[2];
348  minabsw = absw;
349  }
350  }
351  }
352 }
353 
354 /* returns 0 if not found, otherwise 1 */
355 static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index, uint totpoly)
356 {
357  if (totpoly == 0) {
358  return 0;
359  }
360 
361  /* sample only on the exact position */
363  *r_index = DRW_select_buffer_sample_point(vc->depsgraph, vc->region, vc->v3d, mval);
364 
365  if ((*r_index) == 0 || (*r_index) > (uint)totpoly) {
366  return 0;
367  }
368 
369  (*r_index)--;
370 
371  return 1;
372 }
373 
375  bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
376 {
380  Palette *palette = BKE_paint_palette(paint);
383 
384  CLAMP(x, 0, region->winx);
385  CLAMP(y, 0, region->winy);
386 
387  if (use_palette) {
388  if (!palette) {
389  palette = BKE_palette_add(CTX_data_main(C), "Palette");
390  BKE_paint_palette_set(paint, palette);
391  }
392 
393  color = BKE_palette_color_add(palette);
394  palette->active_color = BLI_listbase_count(&palette->colors) - 1;
395  }
396 
398  const View3D *v3d = CTX_wm_view3d(C);
399 
400  if (v3d && texpaint_proj) {
401  /* first try getting a color directly from the mesh faces if possible */
402  ViewLayer *view_layer = CTX_data_view_layer(C);
403  Object *ob = OBACT(view_layer);
404  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
406  bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
407 
408  if (ob) {
409  CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
410  cddata_masks.pmask |= CD_MASK_ORIGINDEX;
411  Mesh *me = (Mesh *)ob->data;
412  Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob_eval, &cddata_masks);
413 
414  ViewContext vc;
415  const int mval[2] = {x, y};
416  uint faceindex;
417  uint totpoly = me->totpoly;
418 
419  if (CustomData_has_layer(&me_eval->ldata, CD_MLOOPUV)) {
421 
423 
424  if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
425  Image *image = NULL;
427 
428  if (use_material) {
429  /* Image and texture interpolation from material. */
430  MPoly *mp = me_eval->mpoly + faceindex;
431  Material *ma = BKE_object_material_get(ob_eval, mp->mat_nr + 1);
432 
433  /* Force refresh since paint slots are not updated when changing interpolation. */
435 
436  if (ma && ma->texpaintslot) {
439  }
440  }
441  else {
442  /* Image and texture interpolation from tool settings. */
443  image = imapaint->canvas;
444  interp = imapaint->interp;
445  }
446 
447  if (image) {
448  float uv[2];
449  float u, v;
450  /* XXX get appropriate ImageUser instead */
451  ImageUser iuser;
452  BKE_imageuser_default(&iuser);
453  iuser.framenr = image->lastframe;
454 
455  imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv);
456 
457  if (image->source == IMA_SRC_TILED) {
458  float new_uv[2];
459  iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, NULL);
460  u = new_uv[0];
461  v = new_uv[1];
462  }
463  else {
464  u = fmodf(uv[0], 1.0f);
465  v = fmodf(uv[1], 1.0f);
466 
467  if (u < 0.0f) {
468  u += 1.0f;
469  }
470  if (v < 0.0f) {
471  v += 1.0f;
472  }
473  }
474 
475  ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL);
476  if (ibuf && (ibuf->rect || ibuf->rect_float)) {
477  u = u * ibuf->x;
478  v = v * ibuf->y;
479 
480  if (ibuf->rect_float) {
481  float rgba_f[4];
482  if (interp == SHD_INTERP_CLOSEST) {
483  nearest_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
484  }
485  else {
486  bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
487  }
488  straight_to_premul_v4(rgba_f);
489  if (use_palette) {
490  linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);
491  }
492  else {
493  linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
494  BKE_brush_color_set(scene, br, rgba_f);
495  }
496  }
497  else {
498  uchar rgba[4];
499  if (interp == SHD_INTERP_CLOSEST) {
501  }
502  else {
504  }
505  if (use_palette) {
507  }
508  else {
509  float rgba_f[3];
510  rgb_uchar_to_float(rgba_f, rgba);
511  BKE_brush_color_set(scene, br, rgba_f);
512  }
513  }
515  return;
516  }
517 
519  }
520  }
521  }
522  }
523  }
524  else if (sima != NULL) {
525  /* Sample from the active image buffer. The sampled color is in
526  * Linear Scene Reference Space. */
527  float rgba_f[3];
528  bool is_data;
529  if (ED_space_image_color_sample(sima, region, (int[2]){x, y}, rgba_f, &is_data)) {
530  if (!is_data) {
531  linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
532  }
533 
534  if (use_palette) {
535  copy_v3_v3(color->rgb, rgba_f);
536  }
537  else {
538  BKE_brush_color_set(scene, br, rgba_f);
539  }
540  return;
541  }
542  }
543 
544  /* No sample found; sample directly from the GPU front buffer. */
545  {
546  float rgba_f[4];
548  x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, 4, GPU_DATA_FLOAT, &rgba_f);
549 
550  if (use_palette) {
551  copy_v3_v3(color->rgb, rgba_f);
552  }
553  else {
554  BKE_brush_color_set(scene, br, rgba_f);
555  }
556  }
557 }
558 
560 {
562 
563  if (br) {
565  ViewLayer *view_layer = CTX_data_view_layer(C);
566  BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
568  }
569 
570  return OPERATOR_FINISHED;
571 }
572 
574 {
576 
577  return br && br->curve;
578 }
579 
581 {
582  PropertyRNA *prop;
583  static const EnumPropertyItem prop_shape_items[] = {
584  {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
585  {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
586  {CURVE_PRESET_MAX, "MAX", 0, "Max", ""},
587  {CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
588  {CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
589  {CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
590  {0, NULL, 0, NULL, NULL},
591  };
592 
593  ot->name = "Preset";
594  ot->description = "Set brush shape";
595  ot->idname = "BRUSH_OT_curve_preset";
596 
599 
600  prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
602  BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
603 }
604 
605 /* face-select ops */
607 {
610  return OPERATOR_FINISHED;
611 }
612 
614 {
615  ot->name = "Select Linked";
616  ot->description = "Select linked faces";
617  ot->idname = "PAINT_OT_face_select_linked";
618 
621 
623 }
624 
626 {
627  const bool select = !RNA_boolean_get(op->ptr, "deselect");
631  return OPERATOR_FINISHED;
632 }
633 
635 {
636  ot->name = "Select Linked Pick";
637  ot->description = "Select linked faces under the cursor";
638  ot->idname = "PAINT_OT_face_select_linked_pick";
639 
642 
644 
645  RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
646 }
647 
649 {
651  if (paintface_deselect_all_visible(C, ob, RNA_enum_get(op->ptr, "action"), true)) {
653  return OPERATOR_FINISHED;
654  }
655  return OPERATOR_CANCELLED;
656 }
657 
659 {
660  ot->name = "(De)select All";
661  ot->description = "Change selection for all faces";
662  ot->idname = "PAINT_OT_face_select_all";
663 
666 
668 
670 }
671 
673 {
675  paintvert_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), true);
678  return OPERATOR_FINISHED;
679 }
680 
682 {
683  ot->name = "(De)select All";
684  ot->description = "Change selection for all vertices";
685  ot->idname = "PAINT_OT_vert_select_all";
686 
689 
691 
693 }
694 
696 {
698  Mesh *me = ob->data;
699 
700  if (BLI_listbase_is_empty(&me->vertex_group_names) || (me->dvert == NULL)) {
701  BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
702  return OPERATOR_CANCELLED;
703  }
704 
705  paintvert_select_ungrouped(ob, RNA_boolean_get(op->ptr, "extend"), true);
708  return OPERATOR_FINISHED;
709 }
710 
712 {
713  /* identifiers */
714  ot->name = "Select Ungrouped";
715  ot->idname = "PAINT_OT_vert_select_ungrouped";
716  ot->description = "Select vertices without a group";
717 
718  /* api callbacks */
721 
722  /* flags */
724 
725  RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
726 }
727 
729 {
730  const bool unselected = RNA_boolean_get(op->ptr, "unselected");
732  paintface_hide(C, ob, unselected);
734  return OPERATOR_FINISHED;
735 }
736 
738 {
739  ot->name = "Face Select Hide";
740  ot->description = "Hide selected faces";
741  ot->idname = "PAINT_OT_face_select_hide";
742 
745 
747 
749  ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
750 }
751 
753 {
754  const bool unselected = RNA_boolean_get(op->ptr, "unselected");
756  paintvert_hide(C, ob, unselected);
758  return OPERATOR_FINISHED;
759 }
760 
762 {
763  ot->name = "Vertex Select Hide";
764  ot->description = "Hide selected vertices";
765  ot->idname = "PAINT_OT_vert_select_hide";
766 
769 
771 
773  ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected vertices");
774 }
775 
777 {
778  const bool select = RNA_boolean_get(op->ptr, "select");
780 
781  if (BKE_paint_select_vert_test(ob)) {
782  paintvert_reveal(C, ob, select);
783  }
784  else {
785  paintface_reveal(C, ob, select);
786  }
787 
789  return OPERATOR_FINISHED;
790 }
791 
793 {
795 
796  /* Allow using this operator when no selection is enabled but hiding is applied. */
798 }
799 
801 {
802  ot->name = "Reveal Faces/Vertices";
803  ot->description = "Reveal hidden faces and vertices";
804  ot->idname = "PAINT_OT_face_vert_reveal";
805 
808 
810 
812  "select",
813  true,
814  "Select",
815  "Specifies whether the newly revealed geometry should be selected");
816 }
void BKE_brush_curve_preset(struct Brush *b, enum eCurveMappingPreset preset)
Definition: brush.cc:1942
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3])
Definition: brush.cc:2222
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1353
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:824
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
CustomData interface, see also DNA_customdata_types.h.
bool CustomData_has_layer(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_BAREMESH
Definition: customdata.cc:2051
void * CustomData_get_layer_named(const struct CustomData *data, int type, const char *name)
void * CustomData_get_layer(const struct CustomData *data, int type)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
int BKE_image_get_tile_from_pos(struct Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
void BKE_imageuser_default(struct ImageUser *iuser)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
Definition: material.c:687
void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma, const struct Object *ob)
Definition: material.c:1501
const struct MLoopTri * BKE_mesh_runtime_looptri_ensure(const struct Mesh *mesh)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Palette * BKE_paint_palette(struct Paint *paint)
Definition: paint.c:714
struct Palette * BKE_palette_add(struct Main *bmain, const char *name)
Definition: paint.c:764
void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct ViewLayer *view_layer, struct CurveMapping *curve)
Definition: paint.c:247
bool BKE_paint_select_elem_test(struct Object *ob)
Definition: paint.c:994
struct Brush * BKE_paint_brush(struct Paint *paint)
Definition: paint.c:607
void BKE_paint_palette_set(struct Paint *p, struct Palette *palette)
Definition: paint.c:719
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
bool BKE_paint_select_vert_test(struct Object *ob)
Definition: paint.c:987
struct PaletteColor * BKE_palette_color_add(struct Palette *palette)
Definition: paint.c:770
bool BKE_paint_always_hide_test(struct Object *ob)
Definition: paint.c:999
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void straight_to_premul_v4(float color[4])
MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
Definition: math_color.c:376
void mul_m3_v3(const float M[3][3], float r[3])
Definition: math_matrix.c:926
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void mul_m4_v4(const float M[4][4], float r[4])
Definition: math_matrix.c:862
bool invert_m3_m3(float R[3][3], const float A[3][3])
Definition: math_matrix.c:1180
float mat4_to_scale(const float M[4][4])
Definition: math_matrix.c:2185
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
MINLINE void clamp_v4(float vec[4], float min, float max)
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void BLI_rcti_init_minmax(struct rcti *rect)
Definition: rct.c:477
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition: rct.c:489
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED(x)
#define UNPACK3(a)
#define BLT_I18NCONTEXT_ID_CURVE_LEGACY
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
@ CURVE_PRESET_ROOT
@ CURVE_PRESET_SMOOTH
@ CURVE_PRESET_ROUND
@ CURVE_PRESET_LINE
@ CURVE_PRESET_SHARP
@ CURVE_PRESET_MAX
#define CD_MASK_ORIGINDEX
@ CD_ORIGINDEX
@ CD_MLOOPUV
@ IMA_SRC_TILED
#define SHD_INTERP_CLOSEST
#define SHD_INTERP_LINEAR
Object is a sort of wrapper for general info.
#define IMAGEPAINT_MODE_MATERIAL
#define OBACT(_view_layer)
ePaintCanvasSource
@ PAINT_CANVAS_SOURCE_MATERIAL
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int center[2])
bool ED_space_image_color_sample(struct SpaceImage *sima, struct ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
Definition: image_ops.c:3215
void paintface_reveal(struct bContext *C, struct Object *ob, bool select)
Definition: editface.cc:141
bool paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags)
Definition: editface.cc:464
bool paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags)
Definition: editface.cc:255
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], bool select)
Definition: editface.cc:235
void paintvert_hide(struct bContext *C, struct Object *ob, bool unselected)
Definition: editface.cc:555
void paintface_hide(struct bContext *C, struct Object *ob, bool unselected)
Definition: editface.cc:116
void paintvert_reveal(struct bContext *C, struct Object *ob, bool select)
Definition: editface.cc:583
void paintvert_tag_select_update(struct bContext *C, struct Object *ob)
Definition: editface.cc:458
void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags)
Definition: editface.cc:527
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:655
void ED_view3d_win_to_delta(const struct ARegion *region, const float xy_delta[2], float zfac, float r_out[3])
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, const struct Object *ob, float r_pmat[4][4])
void ED_view3d_select_id_validate(struct ViewContext *vc)
Definition: view3d_draw.c:2190
void ED_view3d_project_float_v2_m4(const struct ARegion *region, const float co[3], float r_co[2], const float mat[4][4])
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3])
void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], const struct ARegion *region, const struct Object *ob, const struct rcti *rect)
void view3d_operator_needs_opengl(const struct bContext *C)
static AppView * view
NSNotificationCenter * center
_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 v1
#define GPU_matrix_model_view_get(x)
Definition: GPU_matrix.h:227
#define GPU_matrix_projection_get(x)
Definition: GPU_matrix.h:228
void GPU_viewport_size_get_i(int coords[4])
Definition: gpu_state.cc:268
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
void nearest_interpolation_color_wrap(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:289
void bilinear_interpolation_color_wrap(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:142
Contains defines and structs used throughout the imbuf module.
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
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_HIDDEN
Definition: RNA_types.h:216
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Definition: thread.h:34
Scene scene
const Depsgraph * depsgraph
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
void GPU_frontbuffer_read_pixels(int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data)
ccl_device_inline float2 interp(const float2 &a, const float2 &b, float t)
Definition: math_float2.h:232
#define fmodf(x, y)
Definition: metal/compat.h:230
#define fabsf(x)
Definition: metal/compat.h:219
static const pxr::TfToken rgba("rgba", pxr::TfToken::Immortal)
bool vert_paint_poll(bContext *C)
bool facemask_paint_poll(bContext *C)
Definition: paint_image.cc:998
@ BRUSH_STROKE_SMOOTH
Definition: paint_intern.h:451
@ BRUSH_STROKE_NORMAL
Definition: paint_intern.h:449
@ BRUSH_STROKE_INVERT
Definition: paint_intern.h:450
void paint_sample_color(bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
Definition: paint_utils.c:374
static bool brush_curve_preset_poll(bContext *C)
Definition: paint_utils.c:573
void paint_get_tex_pixel_col(const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
Definition: paint_utils.c:158
static int face_vert_reveal_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:776
void PAINT_OT_face_select_hide(wmOperatorType *ot)
Definition: paint_utils.c:737
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:559
float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius)
Definition: paint_utils.c:130
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
Definition: paint_utils.c:634
static int vert_select_hide_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:752
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
Definition: paint_utils.c:711
float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
Definition: paint_utils.c:147
void BRUSH_OT_curve_preset(wmOperatorType *ot)
Definition: paint_utils.c:580
void PAINT_OT_vert_select_all(wmOperatorType *ot)
Definition: paint_utils.c:681
static int face_select_hide_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:728
static int face_select_all_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:648
void PAINT_OT_face_select_all(wmOperatorType *ot)
Definition: paint_utils.c:658
static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index, uint totpoly)
Definition: paint_utils.c:355
void PAINT_OT_face_select_linked(wmOperatorType *ot)
Definition: paint_utils.c:613
static bool face_vert_reveal_poll(bContext *C)
Definition: paint_utils.c:792
static int vert_select_ungrouped_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:695
static void imapaint_tri_weights(float matrix[4][4], const int view[4], const float v1[3], const float v2[3], const float v3[3], const float co[2], float w[3])
Definition: paint_utils.c:228
bool paint_convert_bb_to_rect(rcti *rect, const float bb_min[3], const float bb_max[3], const ARegion *region, RegionView3D *rv3d, Object *ob)
Definition: paint_utils.c:68
static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, uint faceindex, const int xy[2], float uv[2])
Definition: paint_utils.c:277
static void imapaint_project(const float matrix[4][4], const float co[3], float pco[4])
Definition: paint_utils.c:220
void paint_calc_redraw_planes(float planes[4][4], const ARegion *region, Object *ob, const rcti *screen_rect)
Definition: paint_utils.c:112
static int vert_select_all_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:672
void PAINT_OT_vert_select_hide(wmOperatorType *ot)
Definition: paint_utils.c:761
static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: paint_utils.c:625
void PAINT_OT_face_vert_reveal(wmOperatorType *ot)
Definition: paint_utils.c:800
void paint_stroke_operator_properties(wmOperatorType *ot)
Definition: paint_utils.c:188
static int paint_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_utils.c:606
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4221
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
Definition: rna_define.c:2848
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
struct CurveMapping * curve
unsigned int * rect
float * rect_float
struct Image * canvas
unsigned int poly
unsigned int tri[3]
unsigned int v
short mat_nr
float co[3]
short paint_active_slot
struct TexPaintSlot * texpaintslot
struct MLoopTri_Store looptris
struct MVert * mvert
struct MDeformVert * dvert
ListBase vertex_group_names
struct MLoop * mloop
Mesh_Runtime runtime
CustomData pdata
int totpoly
struct MPoly * mpoly
CustomData ldata
float obmat[4][4]
void * data
int active_color
ListBase colors
struct ToolSettings * toolsettings
struct Image * ima
struct ImagePaintSettings imapaint
struct Depsgraph * depsgraph
Definition: ED_view3d.h:64
struct ARegion * region
Definition: ED_view3d.h:69
struct Object * obact
Definition: ED_view3d.h:67
struct View3D * v3d
Definition: ED_view3d.h:70
struct RegionView3D * rv3d
Definition: ED_view3d.h:72
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63
int mval[2]
Definition: WM_types.h:684
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct ReportList * reports
struct PointerRNA * ptr
bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview, float *r_intensity, float r_rgba[4])
int xy[2]
Definition: wm_draw.c:135
wmOperatorType * ot
Definition: wm_files.c:3479
void WM_operator_properties_select_all(wmOperatorType *ot)