Blender V4.3
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_geom.h"
22#include "BLI_math_matrix.h"
23#include "BLI_math_matrix.hh"
24#include "BLI_math_vector.hh"
25#include "BLI_rect.h"
26#include "BLI_utildefines.h"
27
28#include "BLT_translation.hh"
29
30#include "BKE_brush.hh"
31#include "BKE_bvhutils.hh"
32#include "BKE_colortools.hh"
33#include "BKE_context.hh"
34#include "BKE_customdata.hh"
35#include "BKE_image.hh"
36#include "BKE_layer.hh"
37#include "BKE_material.h"
38#include "BKE_mesh.hh"
39#include "BKE_mesh_sample.hh"
40#include "BKE_object.hh"
41#include "BKE_paint.hh"
42#include "BKE_report.hh"
43
44#include "DEG_depsgraph.hh"
46
47#include "RNA_access.hh"
48#include "RNA_define.hh"
49#include "RNA_prototypes.hh"
50
51#include "IMB_imbuf_types.hh"
52#include "IMB_interp.hh"
53
54#include "RE_texture.h"
55
56#include "ED_image.hh"
57#include "ED_screen.hh"
58#include "ED_select_utils.hh"
59#include "ED_view3d.hh"
60
61#include "BLI_sys_types.h"
62#include "ED_mesh.hh" /* for face mask functions */
63
64#include "WM_api.hh"
65#include "WM_types.hh"
66
67#include "paint_intern.hh"
68
70 const float bb_min[3],
71 const float bb_max[3],
72 const ARegion &region,
73 const RegionView3D &rv3d,
74 const Object &ob)
75{
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 const blender::float4x4 projection = ED_view3d_ob_project_mat_get(&rv3d, &ob);
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];
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 const blender::float2 proj = ED_view3d_project_float_v2_m4(&region, vec, projection);
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
112void paint_calc_redraw_planes(float planes[4][4],
113 const ARegion &region,
114 const 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
131 const blender::float3 &center,
132 const float pixel_radius)
133{
134 Object *ob = vc.obact;
135 float delta[3], scale, loc[3];
136 const float xy_delta[2] = {pixel_radius, 0.0f};
137
138 mul_v3_m4v3(loc, ob->object_to_world().ptr(), center);
139
140 const float zfac = ED_view3d_calc_zfac(vc.rv3d, loc);
141 ED_view3d_win_to_delta(vc.region, xy_delta, zfac, delta);
142
143 scale = fabsf(mat4_to_scale(ob->object_to_world().ptr()));
144 scale = (scale == 0.0f) ? 1.0f : scale;
145
146 return len_v3(delta) / scale;
147}
148
149bool paint_get_tex_pixel(const MTex *mtex,
150 float u,
151 float v,
152 ImagePool *pool,
153 int thread,
154 /* Return arguments. */
155 float *r_intensity,
156 float r_rgba[4])
157{
158 const float co[3] = {u, v, 0.0f};
159 float intensity;
160 const bool has_rgb = RE_texture_evaluate(
161 mtex, co, thread, pool, false, false, &intensity, r_rgba);
162 *r_intensity = intensity;
163
164 if (!has_rgb) {
165 r_rgba[0] = intensity;
166 r_rgba[1] = intensity;
167 r_rgba[2] = intensity;
168 r_rgba[3] = 1.0f;
169 }
170
171 return has_rgb;
172}
173
175{
176 static const EnumPropertyItem stroke_mode_items[] = {
177 {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Regular", "Apply brush normally"},
179 "INVERT",
180 0,
181 "Invert",
182 "Invert action of brush for duration of stroke"},
184 "SMOOTH",
185 0,
186 "Smooth",
187 "Switch brush to smooth mode for duration of stroke"},
189 "ERASE",
190 0,
191 "Erase",
192 "Switch brush to erase mode for duration of stroke"},
193 {0},
194 };
195
196 PropertyRNA *prop;
197
198 prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
200
201 prop = RNA_def_enum(ot->srna,
202 "mode",
203 stroke_mode_items,
205 "Stroke Mode",
206 "Action taken when a paint stroke is made");
208}
209
210/* 3D Paint */
211
212/* compute uv coordinates of mouse in face */
213static blender::float2 imapaint_pick_uv(const Mesh *mesh_eval,
214 Scene *scene,
215 Object *ob_eval,
216 const int tri_index,
217 const blender::float3 &bary_coord)
218{
220
221 const blender::Span<blender::int3> tris = mesh_eval->corner_tris();
222 const blender::Span<int> tri_faces = mesh_eval->corner_tri_faces();
223
224 const int *material_indices = (const int *)CustomData_get_layer_named(
225 &mesh_eval->face_data, CD_PROP_INT32, "material_index");
226
227 /* face means poly here, not triangle, indeed */
228 const int face_i = tri_faces[tri_index];
229
230 const float(*mloopuv)[2];
231
232 if (mode == PAINT_CANVAS_SOURCE_MATERIAL) {
233 const Material *ma;
234 const TexPaintSlot *slot;
235
236 ma = BKE_object_material_get(ob_eval,
237 material_indices == nullptr ? 1 : material_indices[face_i] + 1);
238 slot = &ma->texpaintslot[ma->paint_active_slot];
239
240 if (!(slot && slot->uvname &&
241 (mloopuv = static_cast<const float(*)[2]>(CustomData_get_layer_named(
242 &mesh_eval->corner_data, CD_PROP_FLOAT2, slot->uvname)))))
243 {
244 mloopuv = static_cast<const float(*)[2]>(
246 }
247 }
248 else {
249 mloopuv = static_cast<const float(*)[2]>(
251 }
252
254 bary_coord,
255 tris[tri_index],
256 blender::Span(reinterpret_cast<const blender::float2 *>(mloopuv), mesh_eval->corners_num));
257}
258
259/* returns 0 if not found, otherwise 1 */
261 const int mval[2],
262 int *r_tri_index,
263 int *r_face_index,
264 blender::float3 *r_bary_coord,
265 const Mesh &mesh)
266{
267 using namespace blender;
268 if (mesh.faces_num == 0) {
269 return 0;
270 }
271
272 float3 start_world, end_world;
274 vc->depsgraph, vc->region, vc->v3d, float2(mval[0], mval[1]), start_world, end_world, true);
275
276 const float4x4 &world_to_object = vc->obact->world_to_object();
277 const float3 start_object = math::transform_point(world_to_object, start_world);
278 const float3 end_object = math::transform_point(world_to_object, end_world);
279
280 BVHTreeFromMesh mesh_bvh;
282 BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&mesh_bvh); });
283
284 BVHTreeRayHit ray_hit;
285 ray_hit.dist = FLT_MAX;
286 ray_hit.index = -1;
287 BLI_bvhtree_ray_cast(mesh_bvh.tree,
288 start_object,
289 math::normalize(end_object - start_object),
290 0.0f,
291 &ray_hit,
292 mesh_bvh.raycast_callback,
293 &mesh_bvh);
294 if (ray_hit.index == -1) {
295 return 0;
296 }
297
299 mesh.vert_positions(), mesh.corner_verts(), mesh.corner_tris()[ray_hit.index], ray_hit.co);
300
301 *r_tri_index = ray_hit.index;
302 *r_face_index = mesh.corner_tri_faces()[ray_hit.index];
303 return 1;
304}
305
307 bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
308{
309 using namespace blender;
310 Scene *scene = CTX_data_scene(C);
313 Palette *palette = BKE_paint_palette(paint);
314 PaletteColor *color = nullptr;
316
317 CLAMP(x, 0, region->winx);
318 CLAMP(y, 0, region->winy);
319
320 if (use_palette) {
321 if (!palette) {
322 palette = BKE_palette_add(CTX_data_main(C), "Palette");
323 BKE_paint_palette_set(paint, palette);
324 }
325
326 color = BKE_palette_color_add(palette);
327 palette->active_color = BLI_listbase_count(&palette->colors) - 1;
328 }
329
331 const View3D *v3d = CTX_wm_view3d(C);
332
333 if (v3d && texpaint_proj) {
334 /* first try getting a color directly from the mesh faces if possible */
335 ViewLayer *view_layer = CTX_data_view_layer(C);
336 BKE_view_layer_synced_ensure(scene, view_layer);
339 ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
340 bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
341
342 if (ob) {
343 const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval);
344 const int *material_indices = (const int *)CustomData_get_layer_named(
345 &mesh_eval->face_data, CD_PROP_INT32, "material_index");
346
349
350 const int mval[2] = {x, y};
351 int tri_index;
352 float3 bary_coord;
353 int faceindex;
354 if (imapaint_pick_face(&vc, mval, &tri_index, &faceindex, &bary_coord, *mesh_eval)) {
355 Image *image = nullptr;
357
358 if (use_material) {
359 /* Image and texture interpolation from material. */
361 ob_eval, material_indices ? material_indices[faceindex] + 1 : 1);
362
363 /* Force refresh since paint slots are not updated when changing interpolation. */
364 BKE_texpaint_slot_refresh_cache(scene, ma, ob);
365
366 if (ma && ma->texpaintslot) {
369 }
370 }
371 else {
372 /* Image and texture interpolation from tool settings. */
373 image = imapaint->canvas;
374 interp = imapaint->interp;
375 }
376
377 if (image) {
378 /* XXX get appropriate ImageUser instead */
379 ImageUser iuser;
380 BKE_imageuser_default(&iuser);
381 iuser.framenr = image->lastframe;
382
383 float2 uv = imapaint_pick_uv(mesh_eval, scene, ob_eval, tri_index, bary_coord);
384
385 if (image->source == IMA_SRC_TILED) {
386 float new_uv[2];
387 iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, nullptr);
388 uv[0] = new_uv[0];
389 uv[1] = new_uv[1];
390 }
391
392 ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, nullptr);
393 if (ibuf && (ibuf->byte_buffer.data || ibuf->float_buffer.data)) {
394 float u = uv[0] * ibuf->x;
395 float v = uv[1] * ibuf->y;
396
397 if (ibuf->float_buffer.data) {
398 float4 rgba_f = interp == SHD_INTERP_CLOSEST ?
401 rgba_f = math::clamp(rgba_f, 0.0f, 1.0f);
402 straight_to_premul_v4(rgba_f);
403 if (use_palette) {
404 linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);
405 }
406 else {
407 linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
408 BKE_brush_color_set(scene, paint, br, rgba_f);
409 }
410 }
411 else {
415 if (use_palette) {
416 rgb_uchar_to_float(color->rgb, rgba);
417 }
418 else {
419 float rgba_f[3];
420 rgb_uchar_to_float(rgba_f, rgba);
421 BKE_brush_color_set(scene, paint, br, rgba_f);
422 }
423 }
424 BKE_image_release_ibuf(image, ibuf, nullptr);
425 return;
426 }
427
428 BKE_image_release_ibuf(image, ibuf, nullptr);
429 }
430 }
431 }
432 }
433 }
434 else if (sima != nullptr) {
435 /* Sample from the active image buffer. The sampled color is in
436 * Linear Scene Reference Space. */
437 float rgba_f[3];
438 bool is_data;
439 if (ED_space_image_color_sample(sima, region, blender::int2(x, y), rgba_f, &is_data)) {
440 if (!is_data) {
441 linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
442 }
443
444 if (use_palette) {
445 copy_v3_v3(color->rgb, rgba_f);
446 }
447 else {
448 BKE_brush_color_set(scene, paint, br, rgba_f);
449 }
450 return;
451 }
452 }
453
454 /* No sample found; sample directly from the GPU front buffer. */
455 {
456 float rgb_fl[3];
459 blender::int2(x + region->winrct.xmin, y + region->winrct.ymin),
460 rgb_fl);
461 if (use_palette) {
462 copy_v3_v3(color->rgb, rgb_fl);
463 }
464 else {
465 BKE_brush_color_set(scene, paint, br, rgb_fl);
466 }
467 }
468}
469
471{
473
474 if (br) {
475 Scene *scene = CTX_data_scene(C);
476 ViewLayer *view_layer = CTX_data_view_layer(C);
478 BKE_paint_invalidate_cursor_overlay(scene, view_layer, br->curve);
479 }
480
481 return OPERATOR_FINISHED;
482}
483
485{
487
488 return br && br->curve;
489}
490
492 {CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
493 {CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
494 {CURVE_PRESET_MAX, "MAX", 0, "Max", ""},
495 {CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
496 {CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
497 {CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
498 {0, nullptr, 0, nullptr, nullptr},
499};
500
502{
503 ot->name = "Preset";
504 ot->description = "Set brush shape";
505 ot->idname = "BRUSH_OT_curve_preset";
506
509
510 PropertyRNA *prop;
511 prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
513 BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
514}
515
521
532
534{
535 ot->name = "Curve Falloff Preset";
536 ot->description = "Set Curve Falloff Preset";
537 ot->idname = "BRUSH_OT_sculpt_curves_falloff_preset";
538
541
542 PropertyRNA *prop;
543 prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
545 BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
546}
547
548/* face-select ops */
555
557{
558 ot->name = "Select Linked";
559 ot->description = "Select linked faces";
560 ot->idname = "PAINT_OT_face_select_linked";
561
563 ot->poll = facemask_paint_poll;
564
566}
567
576
578{
579 ot->name = "Select Linked Pick";
580 ot->description = "Select linked faces under the cursor";
581 ot->idname = "PAINT_OT_face_select_linked_pick";
582
584 ot->poll = facemask_paint_poll;
585
587
588 RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
589}
590
592{
594 if (paintface_deselect_all_visible(C, ob, RNA_enum_get(op->ptr, "action"), true)) {
596 return OPERATOR_FINISHED;
597 }
598 return OPERATOR_CANCELLED;
599}
600
602{
603 ot->name = "(De)select All";
604 ot->description = "Change selection for all faces";
605 ot->idname = "PAINT_OT_face_select_all";
606
607 ot->exec = face_select_all_exec;
608 ot->poll = facemask_paint_poll;
609
611
613}
614
616{
618 Mesh *mesh = BKE_mesh_from_object(ob);
619 if (mesh == nullptr || mesh->faces_num == 0) {
620 return OPERATOR_CANCELLED;
621 }
622
623 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
625 paintface_flush_flags(C, ob, true, false);
626
628 return OPERATOR_FINISHED;
629}
630
632{
633 ot->name = "Select More";
634 ot->description = "Select Faces connected to existing selection";
635 ot->idname = "PAINT_OT_face_select_more";
636
638 ot->poll = facemask_paint_poll;
639
641
643 ot->srna, "face_step", true, "Face Step", "Also select faces that only touch on a corner");
644}
645
647{
649 Mesh *mesh = BKE_mesh_from_object(ob);
650 if (mesh == nullptr || mesh->faces_num == 0) {
651 return OPERATOR_CANCELLED;
652 }
653
654 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
656 paintface_flush_flags(C, ob, true, false);
657
659 return OPERATOR_FINISHED;
660}
661
663{
664 ot->name = "Select Less";
665 ot->description = "Deselect Faces connected to existing selection";
666 ot->idname = "PAINT_OT_face_select_less";
667
669 ot->poll = facemask_paint_poll;
670
672
674 ot->srna, "face_step", true, "Face Step", "Also deselect faces that only touch on a corner");
675}
676
678{
679 const bool select = RNA_boolean_get(op->ptr, "select");
680 const bool extend = RNA_boolean_get(op->ptr, "extend");
681 if (!extend) {
683 }
687 return OPERATOR_FINISHED;
688}
689
691{
692 ot->name = "Select Loop";
693 ot->description = "Select face loop under the cursor";
694 ot->idname = "PAINT_OT_face_select_loop";
695
697 ot->poll = facemask_paint_poll;
698
700
701 RNA_def_boolean(ot->srna, "select", true, "Select", "If false, faces will be deselected");
702 RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
703}
704
713
715{
716 ot->name = "(De)select All";
717 ot->description = "Change selection for all vertices";
718 ot->idname = "PAINT_OT_vert_select_all";
719
720 ot->exec = vert_select_all_exec;
721 ot->poll = vert_paint_poll;
722
724
726}
727
729{
731 Mesh *mesh = static_cast<Mesh *>(ob->data);
732
733 if (BLI_listbase_is_empty(&mesh->vertex_group_names) || mesh->deform_verts().is_empty()) {
734 BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
735 return OPERATOR_CANCELLED;
736 }
737
738 paintvert_select_ungrouped(ob, RNA_boolean_get(op->ptr, "extend"), true);
741 return OPERATOR_FINISHED;
742}
743
745{
746 /* identifiers */
747 ot->name = "Select Ungrouped";
748 ot->idname = "PAINT_OT_vert_select_ungrouped";
749 ot->description = "Select vertices without a group";
750
751 /* api callbacks */
753 ot->poll = vert_paint_poll;
754
755 /* flags */
757
758 RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
759}
760
767
769{
770 ot->name = "Select Linked Vertices";
771 ot->description = "Select linked vertices";
772 ot->idname = "PAINT_OT_vert_select_linked";
773
775 ot->poll = vert_paint_poll;
776
778}
779
789
791{
792 ot->name = "Select Linked Vertices Pick";
793 ot->description = "Select linked vertices under the cursor";
794 ot->idname = "PAINT_OT_vert_select_linked_pick";
795
797 ot->poll = vert_paint_poll;
798
800
801 RNA_def_boolean(ot->srna,
802 "select",
803 true,
804 "Select",
805 "Whether to select or deselect linked vertices under the cursor");
806}
807
809{
811 Mesh *mesh = BKE_mesh_from_object(ob);
812 if (mesh == nullptr || mesh->faces_num == 0) {
813 return OPERATOR_CANCELLED;
814 }
815
816 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
818
822
823 return OPERATOR_FINISHED;
824}
825
827{
828 ot->name = "Select More";
829 ot->description = "Select Vertices connected to existing selection";
830 ot->idname = "PAINT_OT_vert_select_more";
831
833 ot->poll = vert_paint_poll;
834
836
838 ot->srna, "face_step", true, "Face Step", "Also select faces that only touch on a corner");
839}
840
842{
844 Mesh *mesh = BKE_mesh_from_object(ob);
845 if (mesh == nullptr || mesh->faces_num == 0) {
846 return OPERATOR_CANCELLED;
847 }
848
849 const bool face_step = RNA_boolean_get(op->ptr, "face_step");
851
855
856 return OPERATOR_FINISHED;
857}
858
860{
861 ot->name = "Select Less";
862 ot->description = "Deselect Vertices connected to existing selection";
863 ot->idname = "PAINT_OT_vert_select_less";
864
866 ot->poll = vert_paint_poll;
867
869
871 ot->srna, "face_step", true, "Face Step", "Also deselect faces that only touch on a corner");
872}
873
875{
876 const bool unselected = RNA_boolean_get(op->ptr, "unselected");
878 paintface_hide(C, ob, unselected);
880 return OPERATOR_FINISHED;
881}
882
884{
885 ot->name = "Face Select Hide";
886 ot->description = "Hide selected faces";
887 ot->idname = "PAINT_OT_face_select_hide";
888
890 ot->poll = facemask_paint_poll;
891
893
895 ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected objects");
896}
897
899{
900 const bool unselected = RNA_boolean_get(op->ptr, "unselected");
902 paintvert_hide(C, ob, unselected);
904 return OPERATOR_FINISHED;
905}
906
908{
909 ot->name = "Vertex Select Hide";
910 ot->description = "Hide selected vertices";
911 ot->idname = "PAINT_OT_vert_select_hide";
912
914 ot->poll = vert_paint_poll;
915
917
918 RNA_def_boolean(ot->srna,
919 "unselected",
920 false,
921 "Unselected",
922 "Hide unselected rather than selected vertices");
923}
924
926{
927 const bool select = RNA_boolean_get(op->ptr, "select");
929
932 }
933 else {
935 }
936
938 return OPERATOR_FINISHED;
939}
940
942{
944
945 /* Allow using this operator when no selection is enabled but hiding is applied. */
947}
948
950{
951 ot->name = "Reveal Faces/Vertices";
952 ot->description = "Reveal hidden faces and vertices";
953 ot->idname = "PAINT_OT_face_vert_reveal";
954
957
959
960 RNA_def_boolean(ot->srna,
961 "select",
962 true,
963 "Select",
964 "Specifies whether the newly revealed geometry should be selected");
965}
void BKE_brush_curve_preset(Brush *b, enum eCurveMappingPreset preset)
Definition brush.cc:744
void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3])
Definition brush.cc:1047
void BKE_brush_tag_unsaved_changes(Brush *brush)
Definition brush.cc:621
void free_bvhtree_from_mesh(BVHTreeFromMesh *data)
Definition bvhutils.cc:1160
BVHTree * BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, const Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
Definition bvhutils.cc:899
@ BVHTREE_FROM_CORNER_TRIS
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.
struct Material * BKE_object_material_get(struct Object *ob, short act)
void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma, const struct Object *ob)
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:1392
void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
Definition paint.cc:273
bool BKE_paint_always_hide_test(const Object *ob)
Definition paint.cc:1638
bool BKE_paint_select_elem_test(const Object *ob)
Definition paint.cc:1632
bool BKE_paint_select_vert_test(const Object *ob)
Definition paint.cc:1614
Paint * BKE_paint_get_active_from_context(const bContext *C)
Definition paint.cc:477
Palette * BKE_palette_add(Main *bmain, const char *name)
Definition paint.cc:1386
Brush * BKE_paint_brush(Paint *paint)
Definition paint.cc:649
Palette * BKE_paint_palette(Paint *paint)
Definition paint.cc:1345
void BKE_paint_palette_set(Paint *paint, Palette *palette)
Definition paint.cc:1350
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
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 struct ListBase *lb)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
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
#define BLI_SCOPED_DEFER(function_to_defer)
void BLI_rcti_init_minmax(struct rcti *rect)
Definition rct.c:478
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition rct.c:490
#define CLAMP(a, b, c)
#define BLT_I18NCONTEXT_ID_CURVE_LEGACY
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
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
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:1227
void paintvert_select_more(Mesh *mesh, bool face_step)
Definition editface.cc:968
void paintvert_select_less(Mesh *mesh, bool face_step)
Definition editface.cc:1026
void paintvert_flush_flags(Object *ob)
Definition editface.cc:822
void paintface_select_less(Mesh *mesh, bool face_step)
Definition editface.cc:613
void paintvert_tag_select_update(bContext *C, Object *ob)
Definition editface.cc:1081
void paintvert_hide(bContext *C, Object *ob, bool unselected)
Definition editface.cc:1193
void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
Definition editface.cc:1155
void paintface_reveal(bContext *C, Object *ob, bool select)
Definition editface.cc:193
void paintface_flush_flags(bContext *C, Object *ob, bool flush_selection, bool flush_hidden)
Definition editface.cc:49
bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
Definition editface.cc:1087
void paintvert_select_linked(bContext *C, Object *ob)
Definition editface.cc:945
void paintvert_select_linked_pick(bContext *C, Object *ob, const int region_coordinates[2], bool select)
Definition editface.cc:931
void paintface_select_linked(bContext *C, Object *ob, const int mval[2], bool select)
Definition editface.cc:319
void paintface_select_loop(bContext *C, Object *ob, const int mval[2], bool select)
Definition editface.cc:457
void paintface_hide(bContext *C, Object *ob, bool unselected)
Definition editface.cc:159
bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool flush_flags)
Definition editface.cc:658
void paintface_select_more(Mesh *mesh, bool face_step)
Definition editface.cc:559
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:634
@ 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)
void view3d_operator_needs_opengl(const bContext *C)
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves 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 Invert a color
PropertyFlag
Definition RNA_types.hh:201
@ PROP_SKIP_SAVE
Definition RNA_types.hh:245
@ PROP_HIDDEN
Definition RNA_types.hh:239
#define C
Definition RandGen.cpp:29
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
#define fabsf(x)
draw_view in_light_buf[] float
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
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
MatBase< float, 4, 4 > float4x4
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 int paintface_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
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 int face_vert_reveal_exec(bContext *C, wmOperator *op)
static int paintvert_select_linked_exec(bContext *C, wmOperator *)
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)
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
void PAINT_OT_vert_select_linked_pick(wmOperatorType *ot)
static int vert_select_hide_exec(bContext *C, wmOperator *op)
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
static int paint_select_more_exec(bContext *C, wmOperator *op)
void BRUSH_OT_sculpt_curves_falloff_preset(wmOperatorType *ot)
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 int face_select_hide_exec(bContext *C, wmOperator *op)
static int face_select_all_exec(bContext *C, wmOperator *op)
void PAINT_OT_face_select_all(wmOperatorType *ot)
static int paintvert_select_less_exec(bContext *C, wmOperator *op)
void PAINT_OT_face_select_linked(wmOperatorType *ot)
static int paint_select_less_exec(bContext *C, wmOperator *op)
static bool face_vert_reveal_poll(bContext *C)
static int paintvert_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int vert_select_ungrouped_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 int paintvert_select_more_exec(bContext *C, wmOperator *op)
static int paint_select_linked_exec(bContext *C, wmOperator *)
static int vert_select_all_exec(bContext *C, wmOperator *op)
void PAINT_OT_vert_select_hide(wmOperatorType *ot)
static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
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])
void PAINT_OT_face_vert_reveal(wmOperatorType *ot)
void paint_stroke_operator_properties(wmOperatorType *ot)
static int brush_sculpt_curves_falloff_preset_exec(bContext *C, wmOperator *op)
float paint_calc_object_space_radius(const ViewContext &vc, const blender::float3 &center, const float pixel_radius)
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
BVHTree_RayCastCallback raycast_callback
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 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:76
ARegion * region
Definition ED_view3d.hh:73
View3D * v3d
Definition ED_view3d.hh:74
Object * obact
Definition ED_view3d.hh:71
Depsgraph * depsgraph
Definition ED_view3d.hh:68
int ymin
int ymax
int xmin
int xmax
int mval[2]
Definition WM_types.hh:728
struct ReportList * reports
struct PointerRNA * ptr
VecBase< float, 4 > float4
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:1419
wmOperatorType * ot
Definition wm_files.cc:4125
void WM_operator_properties_select_all(wmOperatorType *ot)