Blender V4.5
paint_utils.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10#include <cstdlib>
11
12#include "DNA_material_types.h"
13#include "DNA_mesh_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_color.h"
21#include "BLI_math_matrix.h"
22#include "BLI_math_matrix.hh"
23#include "BLI_math_vector.hh"
24#include "BLI_rect.h"
25#include "BLI_utildefines.h"
26
27#include "BLT_translation.hh"
28
29#include "BKE_brush.hh"
30#include "BKE_bvhutils.hh"
31#include "BKE_colortools.hh"
32#include "BKE_context.hh"
33#include "BKE_customdata.hh"
34#include "BKE_image.hh"
35#include "BKE_layer.hh"
36#include "BKE_material.hh"
37#include "BKE_mesh.hh"
38#include "BKE_mesh_sample.hh"
39#include "BKE_object.hh"
40#include "BKE_paint.hh"
41#include "BKE_report.hh"
42
43#include "DEG_depsgraph.hh"
45
46#include "RNA_access.hh"
47#include "RNA_define.hh"
48#include "RNA_prototypes.hh"
49
50#include "IMB_imbuf_types.hh"
51#include "IMB_interp.hh"
52
53#include "RE_texture.h"
54
55#include "ED_image.hh"
56#include "ED_screen.hh"
57#include "ED_select_utils.hh"
58#include "ED_view3d.hh"
59
60#include "ED_mesh.hh" /* for face mask functions */
61
62#include "WM_api.hh"
63#include "WM_types.hh"
64
65#include "paint_intern.hh"
66
68 const float bb_min[3],
69 const float bb_max[3],
70 const ARegion &region,
71 const RegionView3D &rv3d,
72 const Object &ob)
73{
74 int i, j, k;
75
77
78 /* return zero if the bounding box has non-positive volume */
79 if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) {
80 return false;
81 }
82
83 const blender::float4x4 projection = ED_view3d_ob_project_mat_get(&rv3d, &ob);
84
85 for (i = 0; i < 2; i++) {
86 for (j = 0; j < 2; j++) {
87 for (k = 0; k < 2; k++) {
88 float vec[3];
89 int proj_i[2];
90 vec[0] = i ? bb_min[0] : bb_max[0];
91 vec[1] = j ? bb_min[1] : bb_max[1];
92 vec[2] = k ? bb_min[2] : bb_max[2];
93 /* convert corner to screen space */
94 const blender::float2 proj = ED_view3d_project_float_v2_m4(&region, vec, projection);
95 /* expand 2D rectangle */
96
97 /* we could project directly to int? */
98 proj_i[0] = proj[0];
99 proj_i[1] = proj[1];
100
101 BLI_rcti_do_minmax_v(rect, proj_i);
102 }
103 }
104 }
105
106 /* return false if the rectangle has non-positive area */
107 return rect->xmin < rect->xmax && rect->ymin < rect->ymax;
108}
109
110void paint_calc_redraw_planes(float planes[4][4],
111 const ARegion &region,
112 const Object &ob,
113 const rcti &screen_rect)
114{
115 BoundBox bb;
116 rcti rect;
117
118 /* use some extra space just in case */
119 rect = screen_rect;
120 rect.xmin -= 2;
121 rect.xmax += 2;
122 rect.ymin -= 2;
123 rect.ymax += 2;
124
125 ED_view3d_clipping_calc(&bb, planes, &region, &ob, &rect);
126}
127
129 const blender::float3 &center,
130 const 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->object_to_world().ptr(), 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->object_to_world().ptr()));
142 scale = (scale == 0.0f) ? 1.0f : scale;
143
144 return len_v3(delta) / scale;
145}
146
147bool paint_get_tex_pixel(const MTex *mtex,
148 float u,
149 float v,
150 ImagePool *pool,
151 int thread,
152 /* Return arguments. */
153 float *r_intensity,
154 float r_rgba[4])
155{
156 const float co[3] = {u, v, 0.0f};
157 float intensity;
158 const bool has_rgb = RE_texture_evaluate(
159 mtex, co, thread, pool, false, false, &intensity, r_rgba);
160 *r_intensity = intensity;
161
162 if (!has_rgb) {
163 r_rgba[0] = intensity;
164 r_rgba[1] = intensity;
165 r_rgba[2] = intensity;
166 r_rgba[3] = 1.0f;
167 }
168
169 return has_rgb;
170}
171
173{
174 static const EnumPropertyItem stroke_mode_items[] = {
175 {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Regular", "Apply brush normally"},
177 "INVERT",
178 0,
179 "Invert",
180 "Invert action of brush for duration of stroke"},
182 "SMOOTH",
183 0,
184 "Smooth",
185 "Switch brush to smooth mode for duration of stroke"},
187 "ERASE",
188 0,
189 "Erase",
190 "Switch brush to erase mode for duration of stroke"},
191 {0},
192 };
193
194 PropertyRNA *prop;
195
196 prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
198
199 prop = RNA_def_enum(ot->srna,
200 "mode",
201 stroke_mode_items,
203 "Stroke Mode",
204 "Action taken when a paint stroke is made");
207
208 /* TODO: Pen flip logic should likely be combined into the stroke mode logic instead of being
209 * an entirely separate concept. */
210 prop = RNA_def_boolean(
211 ot->srna, "pen_flip", false, "Pen Flip", "Whether a tablet's eraser mode is being used");
213}
214
215/* 3D Paint */
216
217/* compute uv coordinates of mouse in face */
218static blender::float2 imapaint_pick_uv(const Mesh *mesh_eval,
219 Scene *scene,
220 Object *ob_eval,
221 const int tri_index,
222 const blender::float3 &bary_coord)
223{
225
226 const blender::Span<blender::int3> tris = mesh_eval->corner_tris();
227 const blender::Span<int> tri_faces = mesh_eval->corner_tri_faces();
228
229 const int *material_indices = (const int *)CustomData_get_layer_named(
230 &mesh_eval->face_data, CD_PROP_INT32, "material_index");
231
232 /* face means poly here, not triangle, indeed */
233 const int face_i = tri_faces[tri_index];
234
235 const float(*mloopuv)[2];
236
237 if (mode == PAINT_CANVAS_SOURCE_MATERIAL) {
238 const Material *ma;
239 const TexPaintSlot *slot;
240
241 ma = BKE_object_material_get(ob_eval,
242 material_indices == nullptr ? 1 : material_indices[face_i] + 1);
243 slot = &ma->texpaintslot[ma->paint_active_slot];
244
245 if (!(slot && slot->uvname &&
246 (mloopuv = static_cast<const float(*)[2]>(CustomData_get_layer_named(
247 &mesh_eval->corner_data, CD_PROP_FLOAT2, slot->uvname)))))
248 {
249 mloopuv = static_cast<const float(*)[2]>(
251 }
252 }
253 else {
254 mloopuv = static_cast<const float(*)[2]>(
256 }
257
259 bary_coord,
260 tris[tri_index],
261 blender::Span(reinterpret_cast<const blender::float2 *>(mloopuv), mesh_eval->corners_num));
262}
263
264/* returns 0 if not found, otherwise 1 */
266 const int mval[2],
267 int *r_tri_index,
268 int *r_face_index,
269 blender::float3 *r_bary_coord,
270 const Mesh &mesh)
271{
272 using namespace blender;
273 if (mesh.faces_num == 0) {
274 return 0;
275 }
276
277 float3 start_world, end_world;
279 vc->depsgraph, vc->region, vc->v3d, float2(mval[0], mval[1]), start_world, end_world, true);
280
281 const float4x4 &world_to_object = vc->obact->world_to_object();
282 const float3 start_object = math::transform_point(world_to_object, start_world);
283 const float3 end_object = math::transform_point(world_to_object, end_world);
284
285 bke::BVHTreeFromMesh mesh_bvh = mesh.bvh_corner_tris();
286
287 BVHTreeRayHit ray_hit;
288 ray_hit.dist = FLT_MAX;
289 ray_hit.index = -1;
290 BLI_bvhtree_ray_cast(mesh_bvh.tree,
291 start_object,
292 math::normalize(end_object - start_object),
293 0.0f,
294 &ray_hit,
295 mesh_bvh.raycast_callback,
296 &mesh_bvh);
297 if (ray_hit.index == -1) {
298 return 0;
299 }
300
302 mesh.vert_positions(), mesh.corner_verts(), mesh.corner_tris()[ray_hit.index], ray_hit.co);
303
304 *r_tri_index = ray_hit.index;
305 *r_face_index = mesh.corner_tri_faces()[ray_hit.index];
306 return 1;
307}
308
310 bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
311{
312 using namespace blender;
313 Scene *scene = CTX_data_scene(C);
316 Palette *palette = BKE_paint_palette(paint);
317 PaletteColor *color = nullptr;
319
320 CLAMP(x, 0, region->winx);
321 CLAMP(y, 0, region->winy);
322
323 if (use_palette) {
324 if (!palette) {
325 palette = BKE_palette_add(CTX_data_main(C), "Palette");
326 BKE_paint_palette_set(paint, palette);
327 }
328
329 color = BKE_palette_color_add(palette);
330 palette->active_color = BLI_listbase_count(&palette->colors) - 1;
331 }
332
334 const View3D *v3d = CTX_wm_view3d(C);
335
336 if (v3d && texpaint_proj) {
337 /* first try getting a color directly from the mesh faces if possible */
338 ViewLayer *view_layer = CTX_data_view_layer(C);
339 BKE_view_layer_synced_ensure(scene, view_layer);
341 Object *ob_eval = DEG_get_evaluated(depsgraph, ob);
342 ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
343 bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
344
345 if (ob) {
346 const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval);
347 const int *material_indices = (const int *)CustomData_get_layer_named(
348 &mesh_eval->face_data, CD_PROP_INT32, "material_index");
349
352
353 const int mval[2] = {x, y};
354 int tri_index;
355 float3 bary_coord;
356 int faceindex;
357 const VArray<bool> hide_poly = *mesh_eval->attributes().lookup_or_default<bool>(
358 ".hide_poly", bke::AttrDomain::Face, false);
359 const bool is_hit = imapaint_pick_face(
360 &vc, mval, &tri_index, &faceindex, &bary_coord, *mesh_eval) &&
361 !hide_poly[faceindex];
362
363 if (is_hit) {
364 Image *image = nullptr;
366
367 if (use_material) {
368 /* Image and texture interpolation from material. */
370 ob_eval, material_indices ? material_indices[faceindex] + 1 : 1);
371
372 /* Force refresh since paint slots are not updated when changing interpolation. */
373 BKE_texpaint_slot_refresh_cache(scene, ma, ob);
374
375 if (ma && ma->texpaintslot) {
376 image = ma->texpaintslot[ma->paint_active_slot].ima;
378 }
379 }
380 else {
381 /* Image and texture interpolation from tool settings. */
382 image = imapaint->canvas;
383 interp = imapaint->interp;
384 }
385
386 if (image) {
387 /* XXX get appropriate ImageUser instead */
388 ImageUser iuser;
389 BKE_imageuser_default(&iuser);
390 iuser.framenr = image->lastframe;
391
392 float2 uv = imapaint_pick_uv(mesh_eval, scene, ob_eval, tri_index, bary_coord);
393
394 if (image->source == IMA_SRC_TILED) {
395 float new_uv[2];
396 iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, nullptr);
397 uv[0] = new_uv[0];
398 uv[1] = new_uv[1];
399 }
400
401 ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, nullptr);
402 if (ibuf && (ibuf->byte_buffer.data || ibuf->float_buffer.data)) {
403 float u = uv[0] * ibuf->x;
404 float v = uv[1] * ibuf->y;
405
406 if (ibuf->float_buffer.data) {
407 float4 rgba_f = interp == SHD_INTERP_CLOSEST ?
410 rgba_f = math::clamp(rgba_f, 0.0f, 1.0f);
411 straight_to_premul_v4(rgba_f);
412 if (use_palette) {
413 linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);
414 }
415 else {
416 linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
417 BKE_brush_color_set(scene, paint, br, rgba_f);
418 }
419 }
420 else {
424 if (use_palette) {
425 rgb_uchar_to_float(color->rgb, rgba);
426 }
427 else {
428 float rgba_f[3];
429 rgb_uchar_to_float(rgba_f, rgba);
430 BKE_brush_color_set(scene, paint, br, rgba_f);
431 }
432 }
433 BKE_image_release_ibuf(image, ibuf, nullptr);
434 return;
435 }
436
437 BKE_image_release_ibuf(image, ibuf, nullptr);
438 }
439 }
440 }
441 }
442 }
443 else if (sima != nullptr) {
444 /* Sample from the active image buffer. The sampled color is in
445 * Linear Scene Reference Space. */
446 float rgba_f[3];
447 bool is_data;
448 if (ED_space_image_color_sample(sima, region, blender::int2(x, y), rgba_f, &is_data)) {
449 if (!is_data) {
450 linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
451 }
452
453 if (use_palette) {
454 copy_v3_v3(color->rgb, rgba_f);
455 }
456 else {
457 BKE_brush_color_set(scene, paint, br, rgba_f);
458 }
459 return;
460 }
461 }
462
463 /* No sample found; sample directly from the GPU front buffer. */
464 {
465 float rgb_fl[3];
468 blender::int2(x + region->winrct.xmin, y + region->winrct.ymin),
469 rgb_fl);
470 if (use_palette) {
471 copy_v3_v3(color->rgb, rgb_fl);
472 }
473 else {
474 BKE_brush_color_set(scene, paint, br, rgb_fl);
475 }
476 }
477}
478
480{
482
483 if (br) {
484 Scene *scene = CTX_data_scene(C);
485 ViewLayer *view_layer = CTX_data_view_layer(C);
487 BKE_paint_invalidate_cursor_overlay(scene, view_layer, br->curve);
488 }
489
490 return OPERATOR_FINISHED;
491}
492
494{
496
497 return br && br->curve;
498}
499
501 {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
502 {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
503 {CURVE_PRESET_MAX, "MAX", 0, "Max", ""},
504 {CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
505 {CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
506 {CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
507 {0, nullptr, 0, nullptr, nullptr},
508};
509
511{
512 ot->name = "Preset";
513 ot->description = "Set brush shape";
514 ot->idname = "BRUSH_OT_curve_preset";
515
518
519 PropertyRNA *prop;
520 prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
522 BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
523}
524
530
541
543{
544 ot->name = "Curve Falloff Preset";
545 ot->description = "Set Curve Falloff Preset";
546 ot->idname = "BRUSH_OT_sculpt_curves_falloff_preset";
547
550
551 PropertyRNA *prop;
552 prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
554 BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
555}
556
557/* face-select ops */
564
566{
567 ot->name = "Select Linked";
568 ot->description = "Select linked faces";
569 ot->idname = "PAINT_OT_face_select_linked";
570
572 ot->poll = facemask_paint_poll;
573
575}
576
587
589{
590 ot->name = "Select Linked Pick";
591 ot->description = "Select linked faces under the cursor";
592 ot->idname = "PAINT_OT_face_select_linked_pick";
593
595 ot->poll = facemask_paint_poll;
596
598
599 RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
600}
601
611
613{
614 ot->name = "(De)select All";
615 ot->description = "Change selection for all faces";
616 ot->idname = "PAINT_OT_face_select_all";
617
618 ot->exec = face_select_all_exec;
619 ot->poll = facemask_paint_poll;
620
622
624}
625
627{
629 Mesh *mesh = BKE_mesh_from_object(ob);
630 if (mesh == nullptr || mesh->faces_num == 0) {
631 return OPERATOR_CANCELLED;
632 }
633
634 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
636 paintface_flush_flags(C, ob, true, false);
637
639 return OPERATOR_FINISHED;
640}
641
643{
644 ot->name = "Select More";
645 ot->description = "Select Faces connected to existing selection";
646 ot->idname = "PAINT_OT_face_select_more";
647
649 ot->poll = facemask_paint_poll;
650
652
654 ot->srna, "face_step", true, "Face Step", "Also select faces that only touch on a corner");
655}
656
658{
660 Mesh *mesh = BKE_mesh_from_object(ob);
661 if (mesh == nullptr || mesh->faces_num == 0) {
662 return OPERATOR_CANCELLED;
663 }
664
665 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
667 paintface_flush_flags(C, ob, true, false);
668
670 return OPERATOR_FINISHED;
671}
672
674{
675 ot->name = "Select Less";
676 ot->description = "Deselect Faces connected to existing selection";
677 ot->idname = "PAINT_OT_face_select_less";
678
680 ot->poll = facemask_paint_poll;
681
683
685 ot->srna, "face_step", true, "Face Step", "Also deselect faces that only touch on a corner");
686}
687
689 wmOperator *op,
690 const wmEvent *event)
691{
692 const bool select = RNA_boolean_get(op->ptr, "select");
693 const bool extend = RNA_boolean_get(op->ptr, "extend");
694 if (!extend) {
696 }
700 return OPERATOR_FINISHED;
701}
702
704{
705 ot->name = "Select Loop";
706 ot->description = "Select face loop under the cursor";
707 ot->idname = "PAINT_OT_face_select_loop";
708
710 ot->poll = facemask_paint_poll;
711
713
714 RNA_def_boolean(ot->srna, "select", true, "Select", "If false, faces will be deselected");
715 RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
716}
717
726
728{
729 ot->name = "(De)select All";
730 ot->description = "Change selection for all vertices";
731 ot->idname = "PAINT_OT_vert_select_all";
732
733 ot->exec = vert_select_all_exec;
734 ot->poll = vert_paint_poll;
735
737
739}
740
742{
744 Mesh *mesh = static_cast<Mesh *>(ob->data);
745
746 if (BLI_listbase_is_empty(&mesh->vertex_group_names) || mesh->deform_verts().is_empty()) {
747 BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
748 return OPERATOR_CANCELLED;
749 }
750
751 paintvert_select_ungrouped(ob, RNA_boolean_get(op->ptr, "extend"), true);
754 return OPERATOR_FINISHED;
755}
756
758{
759 /* identifiers */
760 ot->name = "Select Ungrouped";
761 ot->idname = "PAINT_OT_vert_select_ungrouped";
762 ot->description = "Select vertices without a group";
763
764 /* API callbacks. */
766 ot->poll = vert_paint_poll;
767
768 /* flags */
770
771 RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
772}
773
780
782{
783 ot->name = "Select Linked Vertices";
784 ot->description = "Select linked vertices";
785 ot->idname = "PAINT_OT_vert_select_linked";
786
788 ot->poll = vert_paint_poll;
789
791}
792
804
806{
807 ot->name = "Select Linked Vertices Pick";
808 ot->description = "Select linked vertices under the cursor";
809 ot->idname = "PAINT_OT_vert_select_linked_pick";
810
812 ot->poll = vert_paint_poll;
813
815
816 RNA_def_boolean(ot->srna,
817 "select",
818 true,
819 "Select",
820 "Whether to select or deselect linked vertices under the cursor");
821}
822
824{
826 Mesh *mesh = BKE_mesh_from_object(ob);
827 if (mesh == nullptr || mesh->faces_num == 0) {
828 return OPERATOR_CANCELLED;
829 }
830
831 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
833
837
838 return OPERATOR_FINISHED;
839}
840
842{
843 ot->name = "Select More";
844 ot->description = "Select Vertices connected to existing selection";
845 ot->idname = "PAINT_OT_vert_select_more";
846
848 ot->poll = vert_paint_poll;
849
851
853 ot->srna, "face_step", true, "Face Step", "Also select faces that only touch on a corner");
854}
855
857{
859 Mesh *mesh = BKE_mesh_from_object(ob);
860 if (mesh == nullptr || mesh->faces_num == 0) {
861 return OPERATOR_CANCELLED;
862 }
863
864 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
866
870
871 return OPERATOR_FINISHED;
872}
873
875{
876 ot->name = "Select Less";
877 ot->description = "Deselect Vertices connected to existing selection";
878 ot->idname = "PAINT_OT_vert_select_less";
879
881 ot->poll = vert_paint_poll;
882
884
886 ot->srna, "face_step", true, "Face Step", "Also deselect faces that only touch on a corner");
887}
888
890{
891 const bool unselected = RNA_boolean_get(op->ptr, "unselected");
893 paintface_hide(C, ob, unselected);
895 return OPERATOR_FINISHED;
896}
897
899{
900 ot->name = "Face Select Hide";
901 ot->description = "Hide selected faces";
902 ot->idname = "PAINT_OT_face_select_hide";
903
905 ot->poll = facemask_paint_poll;
906
908
910 ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected objects");
911}
912
914{
915 const bool unselected = RNA_boolean_get(op->ptr, "unselected");
917 paintvert_hide(C, ob, unselected);
919 return OPERATOR_FINISHED;
920}
921
923{
924 ot->name = "Vertex Select Hide";
925 ot->description = "Hide selected vertices";
926 ot->idname = "PAINT_OT_vert_select_hide";
927
929 ot->poll = vert_paint_poll;
930
932
933 RNA_def_boolean(ot->srna,
934 "unselected",
935 false,
936 "Unselected",
937 "Hide unselected rather than selected vertices");
938}
939
941{
942 const bool select = RNA_boolean_get(op->ptr, "select");
944
947 }
948 else {
950 }
951
953 return OPERATOR_FINISHED;
954}
955
957{
959
960 /* Allow using this operator when no selection is enabled but hiding is applied. */
962}
963
965{
966 ot->name = "Reveal Faces/Vertices";
967 ot->description = "Reveal hidden faces and vertices";
968 ot->idname = "PAINT_OT_face_vert_reveal";
969
972
974
975 RNA_def_boolean(ot->srna,
976 "select",
977 true,
978 "Select",
979 "Specifies whether the newly revealed geometry should be selected");
980}
void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3])
Definition brush.cc:1182
void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset)
Definition brush.cc:843
void BKE_brush_tag_unsaved_changes(Brush *brush)
Definition brush.cc:720
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
@ CURVEMAP_SLOPE_POSITIVE
SpaceImage * CTX_wm_space_image(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
void BKE_imageuser_default(ImageUser *iuser)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
General operations, lookup, etc. for materials.
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const Object *ob)
Material * BKE_object_material_get(Object *ob, short act)
Mesh * BKE_mesh_from_object(Object *ob)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
PaletteColor * BKE_palette_color_add(Palette *palette)
Definition paint.cc:1390
void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
Definition paint.cc:270
bool BKE_paint_always_hide_test(const Object *ob)
Definition paint.cc:1630
bool BKE_paint_select_elem_test(const Object *ob)
Definition paint.cc:1624
bool BKE_paint_select_vert_test(const Object *ob)
Definition paint.cc:1606
Paint * BKE_paint_get_active_from_context(const bContext *C)
Definition paint.cc:467
Palette * BKE_palette_add(Main *bmain, const char *name)
Definition paint.cc:1384
Brush * BKE_paint_brush(Paint *paint)
Definition paint.cc:636
Palette * BKE_paint_palette(Paint *paint)
Definition paint.cc:1343
void BKE_paint_palette_set(Paint *paint, Palette *palette)
Definition paint.cc:1348
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
int BLI_bvhtree_ray_cast(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:524
MINLINE void straight_to_premul_v4(float color[4])
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])
float mat4_to_scale(const float mat[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
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.cc:474
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition rct.cc:486
#define CLAMP(a, b, c)
#define BLT_I18NCONTEXT_ID_CURVE_LEGACY
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
eCurveMappingPreset
@ CURVE_PRESET_ROOT
@ CURVE_PRESET_SMOOTH
@ CURVE_PRESET_ROUND
@ CURVE_PRESET_LINE
@ CURVE_PRESET_SHARP
@ CURVE_PRESET_MAX
@ CD_PROP_INT32
@ CD_PROP_FLOAT2
@ IMA_SRC_TILED
@ SHD_INTERP_LINEAR
@ SHD_INTERP_CLOSEST
Object is a sort of wrapper for general info.
#define IMAGEPAINT_MODE_MATERIAL
ePaintCanvasSource
@ PAINT_CANVAS_SOURCE_MATERIAL
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
void paintvert_reveal(bContext *C, Object *ob, bool select)
Definition editface.cc:1192
void paintvert_select_more(Mesh *mesh, bool face_step)
Definition editface.cc:933
void paintvert_select_less(Mesh *mesh, bool face_step)
Definition editface.cc:991
void paintvert_flush_flags(Object *ob)
Definition editface.cc:787
void paintface_select_less(Mesh *mesh, bool face_step)
Definition editface.cc:578
void paintvert_tag_select_update(bContext *C, Object *ob)
Definition editface.cc:1046
void paintvert_hide(bContext *C, Object *ob, bool unselected)
Definition editface.cc:1158
void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
Definition editface.cc:1120
void paintface_reveal(bContext *C, Object *ob, bool select)
Definition editface.cc:184
void paintface_flush_flags(bContext *C, Object *ob, bool flush_selection, bool flush_hidden)
Definition editface.cc:40
bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
Definition editface.cc:1052
void paintvert_select_linked(bContext *C, Object *ob)
Definition editface.cc:910
void paintvert_select_linked_pick(bContext *C, Object *ob, const int region_coordinates[2], bool select)
Definition editface.cc:896
void paintface_select_linked(bContext *C, Object *ob, const int mval[2], bool select)
Definition editface.cc:310
void paintface_select_loop(bContext *C, Object *ob, const int mval[2], bool select)
Definition editface.cc:418
void paintface_hide(bContext *C, Object *ob, bool unselected)
Definition editface.cc:150
bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
Definition editface.cc:623
void paintface_select_more(Mesh *mesh, bool face_step)
Definition editface.cc:524
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:639
@ SEL_DESELECT
blender::float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const blender::float4x4 &mat)
void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], const ARegion *region, const Object *ob, const rcti *rect)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
void ED_view3d_win_to_delta(const ARegion *region, const float xy_delta[2], float zfac, float r_out[3])
blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
bool ED_view3d_win_to_segment_clipped(const Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_end[3], bool do_clip_planes)
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
void view3d_operator_needs_gpu(const bContext *C)
@ PROP_SKIP_SAVE
Definition RNA_types.hh:330
@ PROP_HIDDEN
Definition RNA_types.hh:324
#define C
Definition RandGen.cpp:29
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
AttributeSet attributes
#define fabsf(x)
VecBase< float, 4 > float4
MatBase< 4, 4 > float4x4
#define select(A, B, C)
ccl_device_inline float interp(const float a, const float b, const float t)
Definition math_base.h:502
static BMFace * face_step(BMEdge *edge, BMFace *f)
float3 compute_bary_coord_in_triangle(Span< float3 > vert_positions, Span< int > corner_verts, const int3 &corner_tri, const float3 &position)
T sample_corner_attribute_with_bary_coords(const float3 &bary_weights, const int3 &corner_tri, const Span< T > corner_attribute)
uchar4 interpolate_nearest_wrap_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:42
uchar4 interpolate_bilinear_wrap_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:95
float4 interpolate_nearest_wrap_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:46
float4 interpolate_bilinear_wrap_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:99
T clamp(const T &a, const T &min, const T &max)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
bool vert_paint_poll(bContext *C)
bool facemask_paint_poll(bContext *C)
@ BRUSH_STROKE_SMOOTH
@ BRUSH_STROKE_NORMAL
@ BRUSH_STROKE_INVERT
@ BRUSH_STROKE_ERASE
void paint_sample_color(bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
static bool brush_curve_preset_poll(bContext *C)
static blender::float2 imapaint_pick_uv(const Mesh *mesh_eval, Scene *scene, Object *ob_eval, const int tri_index, const blender::float3 &bary_coord)
void PAINT_OT_face_select_more(wmOperatorType *ot)
void PAINT_OT_vert_select_less(wmOperatorType *ot)
static bool brush_sculpt_curves_falloff_preset_poll(bContext *C)
static wmOperatorStatus paintface_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool paint_convert_bb_to_rect(rcti *rect, const float bb_min[3], const float bb_max[3], const ARegion &region, const RegionView3D &rv3d, const Object &ob)
void PAINT_OT_face_select_hide(wmOperatorType *ot)
void PAINT_OT_face_select_loop(wmOperatorType *ot)
static int imapaint_pick_face(ViewContext *vc, const int mval[2], int *r_tri_index, int *r_face_index, blender::float3 *r_bary_coord, const Mesh &mesh)
void PAINT_OT_vert_select_linked(wmOperatorType *ot)
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
static wmOperatorStatus face_select_all_exec(bContext *C, wmOperator *op)
static wmOperatorStatus face_select_hide_exec(bContext *C, wmOperator *op)
void PAINT_OT_vert_select_linked_pick(wmOperatorType *ot)
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
static wmOperatorStatus paintvert_select_less_exec(bContext *C, wmOperator *op)
static wmOperatorStatus paint_select_less_exec(bContext *C, wmOperator *op)
void BRUSH_OT_sculpt_curves_falloff_preset(wmOperatorType *ot)
static wmOperatorStatus vert_select_ungrouped_exec(bContext *C, wmOperator *op)
void BRUSH_OT_curve_preset(wmOperatorType *ot)
static const EnumPropertyItem prop_shape_items[]
void PAINT_OT_face_select_less(wmOperatorType *ot)
void PAINT_OT_vert_select_all(wmOperatorType *ot)
static wmOperatorStatus brush_curve_preset_exec(bContext *C, wmOperator *op)
static wmOperatorStatus paintvert_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_face_select_all(wmOperatorType *ot)
static wmOperatorStatus paintvert_select_more_exec(bContext *C, wmOperator *op)
void PAINT_OT_face_select_linked(wmOperatorType *ot)
static bool face_vert_reveal_poll(bContext *C)
static wmOperatorStatus brush_sculpt_curves_falloff_preset_exec(bContext *C, wmOperator *op)
void paint_calc_redraw_planes(float planes[4][4], const ARegion &region, const Object &ob, const rcti &screen_rect)
static wmOperatorStatus paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus vert_select_hide_exec(bContext *C, wmOperator *op)
static wmOperatorStatus vert_select_all_exec(bContext *C, wmOperator *op)
static wmOperatorStatus paintvert_select_linked_exec(bContext *C, wmOperator *)
void PAINT_OT_vert_select_hide(wmOperatorType *ot)
void PAINT_OT_vert_select_more(wmOperatorType *ot)
bool paint_get_tex_pixel(const MTex *mtex, float u, float v, ImagePool *pool, int thread, float *r_intensity, float r_rgba[4])
static wmOperatorStatus face_vert_reveal_exec(bContext *C, wmOperator *op)
void PAINT_OT_face_vert_reveal(wmOperatorType *ot)
void paint_stroke_operator_properties(wmOperatorType *ot)
static wmOperatorStatus paint_select_more_exec(bContext *C, wmOperator *op)
float paint_calc_object_space_radius(const ViewContext &vc, const blender::float3 &center, const float pixel_radius)
static wmOperatorStatus paint_select_linked_exec(bContext *C, wmOperator *)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
#define FLT_MAX
Definition stdcycles.h:14
struct CurveMapping * curve_parameter_falloff
struct CurveMapping * curve
struct BrushCurvesSculptSettings * curves_sculpt_settings
CurveMap cm[4]
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
struct Image * canvas
short source
short paint_active_slot
struct TexPaintSlot * texpaintslot
int corners_num
CustomData corner_data
CustomData face_data
ListBase vertex_group_names
int faces_num
ListBase colors
struct ToolSettings * toolsettings
struct Image * ima
struct ImagePaintSettings imapaint
RegionView3D * rv3d
Definition ED_view3d.hh:80
ARegion * region
Definition ED_view3d.hh:77
View3D * v3d
Definition ED_view3d.hh:78
Object * obact
Definition ED_view3d.hh:75
Depsgraph * depsgraph
Definition ED_view3d.hh:72
BVHTree_RayCastCallback raycast_callback
int ymin
int ymax
int xmin
int xmax
int mval[2]
Definition WM_types.hh:760
struct ReportList * reports
struct PointerRNA * ptr
i
Definition text_draw.cc:230
bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, ImagePool *pool, const bool skip_load_image, const bool texnode_preview, float *r_intensity, float r_rgba[4])
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
Definition wm_draw.cc:1459
wmOperatorType * ot
Definition wm_files.cc:4226
void WM_operator_properties_select_all(wmOperatorType *ot)