Blender  V2.93
paint_utils.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <math.h>
25 #include <stdlib.h>
26 
27 #include "DNA_material_types.h"
28 #include "DNA_mesh_types.h"
29 #include "DNA_meshdata_types.h"
30 #include "DNA_object_types.h"
31 
32 #include "DNA_brush_types.h"
33 #include "DNA_scene_types.h"
34 
35 #include "BLI_listbase.h"
36 #include "BLI_math.h"
37 #include "BLI_math_color.h"
38 #include "BLI_rect.h"
39 #include "BLI_utildefines.h"
40 
41 #include "BLT_translation.h"
42 
43 #include "BKE_brush.h"
44 #include "BKE_context.h"
45 #include "BKE_customdata.h"
46 #include "BKE_image.h"
47 #include "BKE_material.h"
48 #include "BKE_mesh_runtime.h"
49 #include "BKE_paint.h"
50 #include "BKE_report.h"
51 
52 #include "DEG_depsgraph.h"
53 #include "DEG_depsgraph_query.h"
54 
55 #include "RNA_access.h"
56 #include "RNA_define.h"
57 
58 #include "GPU_framebuffer.h"
59 #include "GPU_matrix.h"
60 #include "GPU_state.h"
61 #include "GPU_texture.h"
62 
63 #include "IMB_colormanagement.h"
64 #include "IMB_imbuf.h"
65 #include "IMB_imbuf_types.h"
66 
67 #include "RE_texture.h"
68 
69 #include "ED_image.h"
70 #include "ED_screen.h"
71 #include "ED_view3d.h"
72 
73 #include "BLI_sys_types.h"
74 #include "ED_mesh.h" /* for face mask functions */
75 
76 #include "DRW_select_buffer.h"
77 
78 #include "WM_api.h"
79 #include "WM_types.h"
80 
81 #include "paint_intern.h"
82 
83 /* Convert the object-space axis-aligned bounding box (expressed as
84  * its minimum and maximum corners) into a screen-space rectangle,
85  * returns zero if the result is empty */
87  const float bb_min[3],
88  const float bb_max[3],
89  const ARegion *region,
90  RegionView3D *rv3d,
91  Object *ob)
92 {
93  float projection_mat[4][4];
94  int i, j, k;
95 
97 
98  /* return zero if the bounding box has non-positive volume */
99  if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) {
100  return false;
101  }
102 
103  ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat);
104 
105  for (i = 0; i < 2; i++) {
106  for (j = 0; j < 2; j++) {
107  for (k = 0; k < 2; k++) {
108  float vec[3], proj[2];
109  int proj_i[2];
110  vec[0] = i ? bb_min[0] : bb_max[0];
111  vec[1] = j ? bb_min[1] : bb_max[1];
112  vec[2] = k ? bb_min[2] : bb_max[2];
113  /* convert corner to screen space */
114  ED_view3d_project_float_v2_m4(region, vec, proj, projection_mat);
115  /* expand 2D rectangle */
116 
117  /* we could project directly to int? */
118  proj_i[0] = proj[0];
119  proj_i[1] = proj[1];
120 
121  BLI_rcti_do_minmax_v(rect, proj_i);
122  }
123  }
124  }
125 
126  /* return false if the rectangle has non-positive area */
127  return rect->xmin < rect->xmax && rect->ymin < rect->ymax;
128 }
129 
130 /* Get four planes in object-space that describe the projection of
131  * screen_rect from screen into object-space (essentially converting a
132  * 2D screens-space bounding box into four 3D planes) */
133 void paint_calc_redraw_planes(float planes[4][4],
134  const ARegion *region,
135  Object *ob,
136  const rcti *screen_rect)
137 {
138  BoundBox bb;
139  rcti rect;
140 
141  /* use some extra space just in case */
142  rect = *screen_rect;
143  rect.xmin -= 2;
144  rect.xmax += 2;
145  rect.ymin -= 2;
146  rect.ymax += 2;
147 
148  ED_view3d_clipping_calc(&bb, planes, region, ob, &rect);
149 }
150 
151 float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius)
152 {
153  Object *ob = vc->obact;
154  float delta[3], scale, loc[3];
155  const float mval_f[2] = {pixel_radius, 0.0f};
156  float zfac;
157 
158  mul_v3_m4v3(loc, ob->obmat, center);
159 
160  zfac = ED_view3d_calc_zfac(vc->rv3d, loc, NULL);
161  ED_view3d_win_to_delta(vc->region, mval_f, delta, zfac);
162 
163  scale = fabsf(mat4_to_scale(ob->obmat));
164  scale = (scale == 0.0f) ? 1.0f : scale;
165 
166  return len_v3(delta) / scale;
167 }
168 
169 float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
170 {
171  float intensity;
172  float rgba_dummy[4];
173  const float co[3] = {u, v, 0.0f};
174 
175  RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba_dummy);
176 
177  return intensity;
178 }
179 
180 void paint_get_tex_pixel_col(const MTex *mtex,
181  float u,
182  float v,
183  float rgba[4],
184  struct ImagePool *pool,
185  int thread,
186  bool convert_to_linear,
187  struct ColorSpace *colorspace)
188 {
189  const float co[3] = {u, v, 0.0f};
190  float intensity;
191 
192  const bool hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
193 
194  if (!hasrgb) {
195  rgba[0] = intensity;
196  rgba[1] = intensity;
197  rgba[2] = intensity;
198  rgba[3] = 1.0f;
199  }
200 
201  if (convert_to_linear) {
203  }
204 
205  linearrgb_to_srgb_v3_v3(rgba, rgba);
206 
207  clamp_v4(rgba, 0.0f, 1.0f);
208 }
209 
211 {
212  static const EnumPropertyItem stroke_mode_items[] = {
213  {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Regular", "Apply brush normally"},
215  "INVERT",
216  0,
217  "Invert",
218  "Invert action of brush for duration of stroke"},
220  "SMOOTH",
221  0,
222  "Smooth",
223  "Switch brush to smooth mode for duration of stroke"},
224  {0},
225  };
226 
227  PropertyRNA *prop;
228 
229  prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
231 
233  "mode",
234  stroke_mode_items,
236  "Stroke Mode",
237  "Action taken when a paint stroke is made");
238 }
239 
240 /* 3D Paint */
241 
242 static void imapaint_project(const float matrix[4][4], const float co[3], float pco[4])
243 {
244  copy_v3_v3(pco, co);
245  pco[3] = 1.0f;
246 
247  mul_m4_v4(matrix, pco);
248 }
249 
250 static void imapaint_tri_weights(float matrix[4][4],
251  const int view[4],
252  const float v1[3],
253  const float v2[3],
254  const float v3[3],
255  const float co[2],
256  float w[3])
257 {
258  float pv1[4], pv2[4], pv3[4], h[3], divw;
259  float wmat[3][3], invwmat[3][3];
260 
261  /* compute barycentric coordinates */
262 
263  /* project the verts */
264  imapaint_project(matrix, v1, pv1);
265  imapaint_project(matrix, v2, pv2);
266  imapaint_project(matrix, v3, pv3);
267 
268  /* do inverse view mapping, see gluProject man page */
269  h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1.0f;
270  h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1.0f;
271  h[2] = 1.0f;
272 
273  /* solve for (w1,w2,w3)/perspdiv in:
274  * h * perspdiv = Project * Model * (w1 * v1 + w2 * v2 + w3 * v3) */
275 
276  wmat[0][0] = pv1[0];
277  wmat[1][0] = pv2[0];
278  wmat[2][0] = pv3[0];
279  wmat[0][1] = pv1[1];
280  wmat[1][1] = pv2[1];
281  wmat[2][1] = pv3[1];
282  wmat[0][2] = pv1[3];
283  wmat[1][2] = pv2[3];
284  wmat[2][2] = pv3[3];
285 
286  invert_m3_m3(invwmat, wmat);
287  mul_m3_v3(invwmat, h);
288 
289  copy_v3_v3(w, h);
290 
291  /* w is still divided by perspdiv, make it sum to one */
292  divw = w[0] + w[1] + w[2];
293  if (divw != 0.0f) {
294  mul_v3_fl(w, 1.0f / divw);
295  }
296 }
297 
298 /* compute uv coordinates of mouse in face */
299 static void imapaint_pick_uv(
300  Mesh *me_eval, Scene *scene, Object *ob_eval, uint faceindex, const int xy[2], float uv[2])
301 {
302  int i, findex;
303  float p[2], w[3], absw, minabsw;
304  float matrix[4][4], proj[4][4];
305  int view[4];
307 
308  const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
309  const int tottri = me_eval->runtime.looptris.len;
310 
311  const MVert *mvert = me_eval->mvert;
312  const MPoly *mpoly = me_eval->mpoly;
313  const MLoop *mloop = me_eval->mloop;
314  const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
315 
316  /* get the needed opengl matrices */
320  view[0] = view[1] = 0;
321  mul_m4_m4m4(matrix, matrix, ob_eval->obmat);
322  mul_m4_m4m4(matrix, proj, matrix);
323 
324  minabsw = 1e10;
325  uv[0] = uv[1] = 0.0;
326 
327  /* test all faces in the derivedmesh with the original index of the picked face */
328  /* face means poly here, not triangle, indeed */
329  for (i = 0; i < tottri; i++, lt++) {
330  findex = index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly;
331 
332  if (findex == faceindex) {
333  const MLoopUV *mloopuv;
334  const MPoly *mp = &mpoly[lt->poly];
335  const MLoopUV *tri_uv[3];
336  float tri_co[3][3];
337 
338  for (int j = 3; j--;) {
339  copy_v3_v3(tri_co[j], mvert[mloop[lt->tri[j]].v].co);
340  }
341 
342  if (mode == IMAGEPAINT_MODE_MATERIAL) {
343  const Material *ma;
344  const TexPaintSlot *slot;
345 
346  ma = BKE_object_material_get(ob_eval, mp->mat_nr + 1);
347  slot = &ma->texpaintslot[ma->paint_active_slot];
348 
349  if (!(slot && slot->uvname &&
350  (mloopuv = CustomData_get_layer_named(&me_eval->ldata, CD_MLOOPUV, slot->uvname)))) {
351  mloopuv = CustomData_get_layer(&me_eval->ldata, CD_MLOOPUV);
352  }
353  }
354  else {
355  mloopuv = CustomData_get_layer(&me_eval->ldata, CD_MLOOPUV);
356  }
357 
358  tri_uv[0] = &mloopuv[lt->tri[0]];
359  tri_uv[1] = &mloopuv[lt->tri[1]];
360  tri_uv[2] = &mloopuv[lt->tri[2]];
361 
362  p[0] = xy[0];
363  p[1] = xy[1];
364 
365  imapaint_tri_weights(matrix, view, UNPACK3(tri_co), p, w);
366  absw = fabsf(w[0]) + fabsf(w[1]) + fabsf(w[2]);
367  if (absw < minabsw) {
368  uv[0] = tri_uv[0]->uv[0] * w[0] + tri_uv[1]->uv[0] * w[1] + tri_uv[2]->uv[0] * w[2];
369  uv[1] = tri_uv[0]->uv[1] * w[0] + tri_uv[1]->uv[1] * w[1] + tri_uv[2]->uv[1] * w[2];
370  minabsw = absw;
371  }
372  }
373  }
374 }
375 
376 /* returns 0 if not found, otherwise 1 */
377 static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index, uint totpoly)
378 {
379  if (totpoly == 0) {
380  return 0;
381  }
382 
383  /* sample only on the exact position */
385  *r_index = DRW_select_buffer_sample_point(vc->depsgraph, vc->region, vc->v3d, mval);
386 
387  if ((*r_index) == 0 || (*r_index) > (uint)totpoly) {
388  return 0;
389  }
390 
391  (*r_index)--;
392 
393  return 1;
394 }
395 
396 static Image *imapaint_face_image(Object *ob, Mesh *me, int face_index)
397 {
398  Image *ima;
399  MPoly *mp = me->mpoly + face_index;
400  Material *ma = BKE_object_material_get(ob, mp->mat_nr + 1);
401  ima = ma && ma->texpaintslot ? ma->texpaintslot[ma->paint_active_slot].ima : NULL;
402 
403  return ima;
404 }
405 
406 /* Uses symm to selectively flip any axis of a coordinate. */
407 void flip_v3_v3(float out[3], const float in[3], const ePaintSymmetryFlags symm)
408 {
409  if (symm & PAINT_SYMM_X) {
410  out[0] = -in[0];
411  }
412  else {
413  out[0] = in[0];
414  }
415  if (symm & PAINT_SYMM_Y) {
416  out[1] = -in[1];
417  }
418  else {
419  out[1] = in[1];
420  }
421  if (symm & PAINT_SYMM_Z) {
422  out[2] = -in[2];
423  }
424  else {
425  out[2] = in[2];
426  }
427 }
428 
429 void flip_qt_qt(float out[4], const float in[4], const ePaintSymmetryFlags symm)
430 {
431  float axis[3], angle;
432 
433  quat_to_axis_angle(axis, &angle, in);
434  normalize_v3(axis);
435 
436  if (symm & PAINT_SYMM_X) {
437  axis[0] *= -1.0f;
438  angle *= -1.0f;
439  }
440  if (symm & PAINT_SYMM_Y) {
441  axis[1] *= -1.0f;
442  angle *= -1.0f;
443  }
444  if (symm & PAINT_SYMM_Z) {
445  axis[2] *= -1.0f;
446  angle *= -1.0f;
447  }
448 
450 }
451 
452 /* used for both 3d view and image window */
454  bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
455 {
459  Palette *palette = BKE_paint_palette(paint);
460  PaletteColor *color = NULL;
462 
463  CLAMP(x, 0, region->winx);
464  CLAMP(y, 0, region->winy);
465 
466  if (use_palette) {
467  if (!palette) {
468  palette = BKE_palette_add(CTX_data_main(C), "Palette");
469  BKE_paint_palette_set(paint, palette);
470  }
471 
472  color = BKE_palette_color_add(palette);
473  palette->active_color = BLI_listbase_count(&palette->colors) - 1;
474  }
475 
477  const View3D *v3d = CTX_wm_view3d(C);
478 
479  if (v3d && texpaint_proj) {
480  /* first try getting a color directly from the mesh faces if possible */
481  ViewLayer *view_layer = CTX_data_view_layer(C);
482  Object *ob = OBACT(view_layer);
483  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
485  bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
486 
487  if (ob) {
488  CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
489  cddata_masks.pmask |= CD_MASK_ORIGINDEX;
490  Mesh *me = (Mesh *)ob->data;
491  Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob_eval, &cddata_masks);
492 
493  ViewContext vc;
494  const int mval[2] = {x, y};
495  uint faceindex;
496  uint totpoly = me->totpoly;
497 
498  if (CustomData_has_layer(&me_eval->ldata, CD_MLOOPUV)) {
500 
502 
503  if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
504  Image *image;
505 
506  if (use_material) {
507  image = imapaint_face_image(ob_eval, me_eval, faceindex);
508  }
509  else {
510  image = imapaint->canvas;
511  }
512 
513  if (image) {
514  float uv[2];
515  float u, v;
516  /* XXX get appropriate ImageUser instead */
517  ImageUser iuser;
518  BKE_imageuser_default(&iuser);
519  iuser.framenr = image->lastframe;
520 
521  imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv);
522 
523  if (image->source == IMA_SRC_TILED) {
524  float new_uv[2];
525  iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, NULL);
526  u = new_uv[0];
527  v = new_uv[1];
528  }
529  else {
530  u = fmodf(uv[0], 1.0f);
531  v = fmodf(uv[1], 1.0f);
532 
533  if (u < 0.0f) {
534  u += 1.0f;
535  }
536  if (v < 0.0f) {
537  v += 1.0f;
538  }
539  }
540 
541  ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL);
542  if (ibuf && (ibuf->rect || ibuf->rect_float)) {
543  u = u * ibuf->x;
544  v = v * ibuf->y;
545 
546  if (ibuf->rect_float) {
547  float rgba_f[4];
548  bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);
549  straight_to_premul_v4(rgba_f);
550  if (use_palette) {
551  linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);
552  }
553  else {
554  linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
555  BKE_brush_color_set(scene, br, rgba_f);
556  }
557  }
558  else {
559  uchar rgba[4];
560  bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
561  if (use_palette) {
562  rgb_uchar_to_float(color->rgb, rgba);
563  }
564  else {
565  float rgba_f[3];
566  rgb_uchar_to_float(rgba_f, rgba);
567  BKE_brush_color_set(scene, br, rgba_f);
568  }
569  }
570  BKE_image_release_ibuf(image, ibuf, NULL);
571  return;
572  }
573 
574  BKE_image_release_ibuf(image, ibuf, NULL);
575  }
576  }
577  }
578  }
579  }
580  else if (sima != NULL) {
581  /* Sample from the active image buffer. The sampled color is in
582  * Linear Scene Reference Space. */
583  float rgba_f[3];
584  bool is_data;
585  if (ED_space_image_color_sample(sima, region, (int[2]){x, y}, rgba_f, &is_data)) {
586  if (!is_data) {
587  linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
588  }
589 
590  if (use_palette) {
591  copy_v3_v3(color->rgb, rgba_f);
592  }
593  else {
594  BKE_brush_color_set(scene, br, rgba_f);
595  }
596  return;
597  }
598  }
599 
600  /* No sample found; sample directly from the GPU front buffer. */
601  {
602  float rgba_f[4];
604  x + region->winrct.xmin, y + region->winrct.ymin, 1, 1, 4, GPU_DATA_FLOAT, &rgba_f);
605 
606  if (use_palette) {
607  copy_v3_v3(color->rgb, rgba_f);
608  }
609  else {
610  BKE_brush_color_set(scene, br, rgba_f);
611  }
612  }
613 }
614 
616 {
618 
619  if (br) {
621  ViewLayer *view_layer = CTX_data_view_layer(C);
622  BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
624  }
625 
626  return OPERATOR_FINISHED;
627 }
628 
630 {
632 
633  return br && br->curve;
634 }
635 
637 {
638  PropertyRNA *prop;
639  static const EnumPropertyItem prop_shape_items[] = {
640  {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
641  {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
642  {CURVE_PRESET_MAX, "MAX", 0, "Max", ""},
643  {CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
644  {CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
645  {CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
646  {0, NULL, 0, NULL, NULL},
647  };
648 
649  ot->name = "Preset";
650  ot->description = "Set brush shape";
651  ot->idname = "BRUSH_OT_curve_preset";
652 
655 
656  prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
657  RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
658 }
659 
660 /* face-select ops */
662 {
665  return OPERATOR_FINISHED;
666 }
667 
669 {
670  ot->name = "Select Linked";
671  ot->description = "Select linked faces";
672  ot->idname = "PAINT_OT_face_select_linked";
673 
676 
678 }
679 
681 {
682  const bool select = !RNA_boolean_get(op->ptr, "deselect");
686  return OPERATOR_FINISHED;
687 }
688 
690 {
691  ot->name = "Select Linked Pick";
692  ot->description = "Select linked faces under the cursor";
693  ot->idname = "PAINT_OT_face_select_linked_pick";
694 
697 
699 
700  RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items");
701 }
702 
704 {
706  if (paintface_deselect_all_visible(C, ob, RNA_enum_get(op->ptr, "action"), true)) {
708  return OPERATOR_FINISHED;
709  }
710  return OPERATOR_CANCELLED;
711 }
712 
714 {
715  ot->name = "(De)select All";
716  ot->description = "Change selection for all faces";
717  ot->idname = "PAINT_OT_face_select_all";
718 
721 
723 
725 }
726 
728 {
730  paintvert_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), true);
733  return OPERATOR_FINISHED;
734 }
735 
737 {
738  ot->name = "(De)select All";
739  ot->description = "Change selection for all vertices";
740  ot->idname = "PAINT_OT_vert_select_all";
741 
744 
746 
748 }
749 
751 {
753  Mesh *me = ob->data;
754 
755  if (BLI_listbase_is_empty(&ob->defbase) || (me->dvert == NULL)) {
756  BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
757  return OPERATOR_CANCELLED;
758  }
759 
760  paintvert_select_ungrouped(ob, RNA_boolean_get(op->ptr, "extend"), true);
763  return OPERATOR_FINISHED;
764 }
765 
767 {
768  /* identifiers */
769  ot->name = "Select Ungrouped";
770  ot->idname = "PAINT_OT_vert_select_ungrouped";
771  ot->description = "Select vertices without a group";
772 
773  /* api callbacks */
776 
777  /* flags */
779 
780  RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
781 }
782 
784 {
785  const bool unselected = RNA_boolean_get(op->ptr, "unselected");
787  paintface_hide(C, ob, unselected);
789  return OPERATOR_FINISHED;
790 }
791 
793 {
794  ot->name = "Face Select Hide";
795  ot->description = "Hide selected faces";
796  ot->idname = "PAINT_OT_face_select_hide";
797 
800 
802 
804  ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
805 }
806 
808 {
809  const bool select = RNA_boolean_get(op->ptr, "select");
811  paintface_reveal(C, ob, select);
813  return OPERATOR_FINISHED;
814 }
815 
817 {
818  ot->name = "Face Select Reveal";
819  ot->description = "Reveal hidden faces";
820  ot->idname = "PAINT_OT_face_select_reveal";
821 
824 
826 
827  RNA_def_boolean(ot->srna, "select", true, "Select", "");
828 }
void BKE_brush_curve_preset(struct Brush *b, enum eCurveMappingPreset preset)
Definition: brush.c:1938
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3])
Definition: brush.c:2222
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1424
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:800
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
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.c:1919
void * CustomData_get_layer_named(const struct CustomData *data, int type, const char *name)
Definition: customdata.c:3217
void * CustomData_get_layer(const struct CustomData *data, int type)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
Definition: image.c:5113
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
Definition: image.c:5100
int BKE_image_get_tile_from_pos(struct Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
Definition: image.c:707
void BKE_imageuser_default(struct ImageUser *iuser)
Definition: image.c:3451
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
Definition: material.c:697
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
const struct MLoopTri * BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh)
Definition: mesh_runtime.c:155
struct Palette * BKE_paint_palette(struct Paint *paint)
Definition: paint.c:700
struct Palette * BKE_palette_add(struct Main *bmain, const char *name)
Definition: paint.c:751
void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct ViewLayer *view_layer, struct CurveMapping *curve)
Definition: paint.c:259
struct Brush * BKE_paint_brush(struct Paint *paint)
Definition: paint.c:604
void BKE_paint_palette_set(struct Paint *p, struct Palette *palette)
Definition: paint.c:705
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
struct PaletteColor * BKE_palette_color_add(struct Palette *palette)
Definition: paint.c:757
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
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:407
void mul_m3_v3(const float M[3][3], float r[3])
Definition: math_matrix.c:930
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
void mul_m4_v4(const float M[4][4], float r[4])
Definition: math_matrix.c:866
bool invert_m3_m3(float R[3][3], const float A[3][3])
Definition: math_matrix.c:1161
float mat4_to_scale(const float M[4][4])
Definition: math_matrix.c:2196
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:742
void axis_angle_normalized_to_quat(float r[4], const float axis[3], const float angle)
void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
MINLINE float normalize_v3(float r[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void clamp_v4(float vec[4], const float min, const float max)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void BLI_rcti_init_minmax(struct rcti *rect)
Definition: rct.c:516
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition: rct.c:528
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED(x)
#define UNPACK3(a)
#define BLT_I18NCONTEXT_ID_CURVE
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
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
Object is a sort of wrapper for general info.
eImagePaintMode
@ IMAGEPAINT_MODE_MATERIAL
#define OBACT(_view_layer)
ePaintSymmetryFlags
@ PAINT_SYMM_Y
@ PAINT_SYMM_X
@ PAINT_SYMM_Z
@ 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, int mval[2], float r_col[3], bool *r_is_data)
Definition: image_ops.c:3220
bool paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags)
Definition: editface.c:499
void paintface_hide(struct bContext *C, struct Object *ob, const bool unselected)
Definition: editface.c:132
void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], const bool select)
Definition: editface.c:266
bool paintface_deselect_all_visible(struct bContext *C, struct Object *ob, int action, bool flush_flags)
Definition: editface.c:287
void paintvert_tag_select_update(struct bContext *C, struct Object *ob)
Definition: editface.c:489
void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags)
Definition: editface.c:570
void paintface_reveal(struct bContext *C, struct Object *ob, const bool select)
Definition: editface.c:164
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float r_pmat[4][4])
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void ED_view3d_win_to_delta(const struct ARegion *region, const float mval[2], float out[3], const float zfac)
void ED_view3d_select_id_validate(struct ViewContext *vc)
Definition: view3d_draw.c:2192
void ED_view3d_project_float_v2_m4(const struct ARegion *region, const float co[3], float r_co[2], float mat[4][4])
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)
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip)
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:226
#define GPU_matrix_projection_get(x)
Definition: GPU_matrix.h:227
void GPU_viewport_size_get_i(int coords[4])
Definition: gpu_state.cc:288
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:172
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Definition: imageprocess.c:148
Contains defines and structs used throughout the imbuf module.
Group RGB to Bright Vector Camera CLAMP
StructRNA RNA_OperatorStrokeElement
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
@ PROP_HIDDEN
Definition: RNA_types.h:202
#define C
Definition: RandGen.cpp:39
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
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
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
short source
int lastframe
Scene scene
const Depsgraph * depsgraph
void GPU_frontbuffer_read_pixels(int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data)
#define fmodf(x, y)
#define fabsf(x)
bool vert_paint_poll(bContext *C)
Definition: paint_image.c:1370
bool facemask_paint_poll(bContext *C)
Definition: paint_image.c:1365
@ BRUSH_STROKE_SMOOTH
Definition: paint_intern.h:313
@ BRUSH_STROKE_NORMAL
Definition: paint_intern.h:311
@ BRUSH_STROKE_INVERT
Definition: paint_intern.h:312
void paint_sample_color(bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
Definition: paint_utils.c:453
static bool brush_curve_preset_poll(bContext *C)
Definition: paint_utils.c:629
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:180
static int face_select_reveal_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:807
void PAINT_OT_face_select_hide(wmOperatorType *ot)
Definition: paint_utils.c:792
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:615
float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius)
Definition: paint_utils.c:151
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
Definition: paint_utils.c:689
void flip_qt_qt(float out[4], const float in[4], const ePaintSymmetryFlags symm)
Definition: paint_utils.c:429
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
Definition: paint_utils.c:766
float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
Definition: paint_utils.c:169
void BRUSH_OT_curve_preset(wmOperatorType *ot)
Definition: paint_utils.c:636
void PAINT_OT_vert_select_all(wmOperatorType *ot)
Definition: paint_utils.c:736
static int face_select_hide_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:783
static int face_select_all_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:703
void PAINT_OT_face_select_all(wmOperatorType *ot)
Definition: paint_utils.c:713
static int imapaint_pick_face(ViewContext *vc, const int mval[2], uint *r_index, uint totpoly)
Definition: paint_utils.c:377
void PAINT_OT_face_select_linked(wmOperatorType *ot)
Definition: paint_utils.c:668
void flip_v3_v3(float out[3], const float in[3], const ePaintSymmetryFlags symm)
Definition: paint_utils.c:407
static int vert_select_ungrouped_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:750
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:250
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:86
void PAINT_OT_face_select_reveal(wmOperatorType *ot)
Definition: paint_utils.c:816
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:299
static Image * imapaint_face_image(Object *ob, Mesh *me, int face_index)
Definition: paint_utils.c:396
static void imapaint_project(const float matrix[4][4], const float co[3], float pco[4])
Definition: paint_utils.c:242
void paint_calc_redraw_planes(float planes[4][4], const ARegion *region, Object *ob, const rcti *screen_rect)
Definition: paint_utils.c:133
static int vert_select_all_exec(bContext *C, wmOperator *op)
Definition: paint_utils.c:727
static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: paint_utils.c:680
void paint_stroke_operator_properties(wmOperatorType *ot)
Definition: paint_utils.c:210
static int paint_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
Definition: paint_utils.c:661
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4210
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
Definition: rna_define.c:2870
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
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:3771
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 CustomData pdata ldata
struct MVert * mvert
struct MDeformVert * dvert
struct MLoop * mloop
Mesh_Runtime runtime
int totpoly
struct MPoly * mpoly
ListBase defbase
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:75
struct ARegion * region
Definition: ED_view3d.h:80
struct Object * obact
Definition: ED_view3d.h:78
struct View3D * v3d
Definition: ED_view3d.h:81
struct RegionView3D * rv3d
Definition: ED_view3d.h:83
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79
int mval[2]
Definition: WM_types.h:583
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
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])
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
wmOperatorType * ot
Definition: wm_files.c:3156
void WM_operator_properties_select_all(wmOperatorType *ot)