Blender V5.3
paint_sample_color.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
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.hh"
20#include "BLI_math_color_c.hh"
21#include "BLI_math_matrix.hh"
22#include "BLI_math_vector.hh"
23#include "BLI_rect.hh"
24#include "BLI_string_utf8.hh"
25#include "BLI_utildefines.hh"
26
27#include "BLT_translation.hh"
28
29#include "BKE_brush.hh"
30#include "BKE_bvh.hh"
31#include "BKE_bvhutils.hh"
32#include "BKE_context.hh"
33#include "BKE_customdata.hh"
34#include "BKE_global.hh"
35#include "BKE_image.hh"
36#include "BKE_layer.hh"
37#include "BKE_material.hh"
38#include "BKE_mesh.hh"
39#include "BKE_mesh_sample.hh"
40#include "BKE_object.hh"
41#include "BKE_paint.hh"
42#include "BKE_paint_types.hh"
43#include "BKE_report.hh"
44
46
47#include "RNA_access.hh"
48#include "RNA_define.hh"
49
50#include "IMB_imbuf_types.hh"
51#include "IMB_interp.hh"
52
53#include "ED_grease_pencil.hh"
54#include "ED_image.hh"
55#include "ED_screen.hh"
56#include "ED_view3d.hh"
57
58#include "ED_mesh.hh" /* for face mask functions */
59
60#include "UI_interface_types.hh"
61
62#include "WM_api.hh"
63#include "WM_types.hh"
64
66
67#include "paint_intern.hh"
68
69#include "mesh/sculpt_color.hh"
70#include "mesh/sculpt_intern.hh"
71
72/* -------------------------------------------------------------------- */
75
77
78/* compute uv coordinates of mouse in face */
79static float2 imapaint_pick_uv(const Mesh *mesh_eval,
80 Scene &scene,
81 Object *ob_eval,
82 const int tri_index,
83 const float3 &bary_coord)
84{
86
87 const Span<int3> tris = mesh_eval->corner_tris();
88 const Span<int> tri_faces = mesh_eval->corner_tri_faces();
89
90 const bke::AttributeAccessor attributes = mesh_eval->attributes();
91 const VArray<int> material_indices = *attributes.lookup_or_default<int>(
92 "material_index", bke::AttrDomain::Face, 0);
93
94 /* face means poly here, not triangle, indeed */
95 const int face_i = tri_faces[tri_index];
96
97 VArraySpan<float2> uv_map;
98
99 if (mode == PAINT_CANVAS_SOURCE_MATERIAL) {
100 const Material *ma = BKE_object_material_get(ob_eval, material_indices[face_i] + 1);
101 const TexPaintSlot *slot = &ma->texpaintslot[ma->paint_active_slot];
102 if (slot && slot->uvname) {
103 uv_map = *attributes.lookup<float2>(slot->uvname, bke::AttrDomain::Corner);
104 }
105 }
106
107 if (uv_map.is_empty()) {
108 uv_map = *attributes.lookup<float2>(mesh_eval->active_uv_map_name(), bke::AttrDomain::Corner);
109 }
110
112 bary_coord, tris[tri_index], uv_map);
113}
114
115/* returns 0 if not found, otherwise 1 */
117 const int mval[2],
118 int *r_tri_index,
119 int *r_face_index,
120 float3 *r_bary_coord,
121 const Mesh &mesh)
122{
123 if (mesh.faces_num == 0) {
124 return false;
125 }
126
127 float3 start_world;
128 float3 end_world;
130 vc->depsgraph, vc->region, vc->v3d, float2(mval[0], mval[1]), start_world, end_world, true);
131
132 const float4x4 &world_to_object = vc->obact->world_to_object();
133 const float3 start_object = math::transform_point(world_to_object, start_world);
134 const float3 end_object = math::transform_point(world_to_object, end_world);
135
136 const bke::bvh::Tree &mesh_bvh = mesh.bvh_tris();
137 const bke::bvh::Ray ray(start_object, math::normalize(end_object - start_object));
138 const std::optional<bke::bvh::RayHit> ray_hit = mesh_bvh.ray_intersect(ray);
139 if (!ray_hit) {
140 return false;
141 }
142
144 mesh.vert_positions(),
145 mesh.corner_verts(),
146 mesh.corner_tris()[ray_hit->index],
147 ray_hit->position(ray));
148
149 *r_tri_index = ray_hit->index;
150 *r_face_index = mesh.corner_tri_faces()[ray_hit->index];
151 return true;
152}
153
154static std::optional<float3> sample_texture_paint_color(
155 const Depsgraph &depsgraph, Scene &scene, ViewContext &vc, Object *object, const int2 mval)
156{
157 if (!object) {
158 return std::nullopt;
159 }
160
161 Object *ob_eval = DEG_get_evaluated(&depsgraph, object);
162
163 const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval);
164 const bke::AttributeAccessor attributes = mesh_eval->attributes();
165 const VArray<int> material_indices = *attributes.lookup_or_default<int>(
166 "material_index", bke::AttrDomain::Face, 0);
167
168 if (mesh_eval->uv_map_names().is_empty()) {
169 return std::nullopt;
170 }
171
172 int tri_index;
174 int face_index;
175 const VArray<bool> hide_poly = *mesh_eval->attributes().lookup_or_default<bool>(
176 ".hide_poly", bke::AttrDomain::Face, false);
177 const bool is_hit = imapaint_pick_face(
178 &vc, mval, &tri_index, &face_index, &bary_coord, *mesh_eval) &&
179 !hide_poly[face_index];
180
181 if (!is_hit) {
182 return std::nullopt;
183 }
184
185 ImagePaintSettings *imapaint = &scene.toolsettings->imapaint;
186 bool use_material = imapaint->mode == IMAGEPAINT_MODE_MATERIAL;
187 Image *image = nullptr;
189 if (use_material) {
190 /* Image and texture interpolation from material. */
191 Material *ma = BKE_object_material_get(ob_eval, material_indices[face_index] + 1);
192
193 /* Force refresh since paint slots are not updated when changing interpolation. */
194 BKE_texpaint_slot_refresh_cache(&scene, ma, object);
195
196 if (ma && ma->texpaintslot) {
197 image = ma->texpaintslot[ma->paint_active_slot].ima;
198 interp = ma->texpaintslot[ma->paint_active_slot].interp;
199 }
200 }
201 else {
202 /* Image and texture interpolation from tool settings. */
203 image = imapaint->canvas;
204 interp = imapaint->interp;
205 }
206
207 if (!image) {
208 return std::nullopt;
209 }
210
211 /* XXX get appropriate ImageUser instead */
212 ImageUser iuser;
213 BKE_imageuser_default(&iuser);
214 iuser.framenr = image->lastframe;
215
216 float2 uv = imapaint_pick_uv(mesh_eval, scene, ob_eval, tri_index, bary_coord);
217 if (image->source == IMA_SRC_TILED) {
218 float new_uv[2];
219 iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, nullptr);
220 uv[0] = new_uv[0];
221 uv[1] = new_uv[1];
222 }
223
224 ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, nullptr);
225 BLI_SCOPED_DEFER([&]() { BKE_image_release_ibuf(image, ibuf, nullptr); });
226 if (!ibuf || (!ibuf->byte_data() && !ibuf->float_data())) {
227 return std::nullopt;
228 }
229
230 float u = uv[0] * ibuf->x;
231 float v = uv[1] * ibuf->y;
232 if (interp != SHD_INTERP_CLOSEST) {
233 u -= 0.5f;
234 v -= 0.5f;
235 }
236
237 float4 rgba_f;
238 if (ibuf->float_data()) {
241 rgba_f = math::clamp(rgba_f, 0.0f, 1.0f);
242 straight_to_premul_v4(rgba_f);
243 }
244 else {
247 rgba_uchar_to_float(rgba_f, rgba);
248
249 if (!ibuf->colorspace_is_data()) {
251 }
252 }
253 return rgba_f.xyz();
254}
255
256static std::optional<float3> sample_mesh_attribute_color(ViewContext &vc,
257 Object &object,
258 int2 mval)
259{
260 const Mesh &mesh = *id_cast<const Mesh *>(object.data);
261 const OffsetIndices<int> faces = mesh.faces();
262 const Span<int> corner_verts = mesh.corner_verts();
263 const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
265
266 std::optional<ActiveElementInfo> active_element = active_element_info_get(vc, float2(mval));
267
268 if (!color_attribute || !active_element || !std::holds_alternative<int>(active_element->vert)) {
269 return std::nullopt;
270 }
271
272 const GVArraySpan colors = *color_attribute;
273 const int vert = std::get<int>(active_element->vert);
274 const int face = active_element->active_face_idx;
275
276 if ((color_attribute.domain == bke::AttrDomain::Corner) && (face != -1)) {
277 const int corner = bke::mesh::face_find_corner_from_vert(faces[face], corner_verts, vert);
278 float4 sampled_color = color::color_corner_get(colors, corner);
279 return sampled_color.xyz();
280 }
281 else if (color_attribute.domain == bke::AttrDomain::Point) {
283 faces, corner_verts, vert_to_face_map, colors, color_attribute.domain, vert)
284 .xyz();
285 }
286 return std::nullopt;
287}
288
289static void apply_sampled_color(Main &bMain,
290 Paint &paint,
291 const float3 &sampled_color,
292 const bool use_palette)
293{
294 if (use_palette) {
295 Palette *palette = BKE_paint_palette(&paint);
296 if (!palette) {
297 palette = BKE_palette_add(&bMain, "Palette");
298 BKE_paint_palette_set(&paint, palette);
299 }
300
302 palette->active_color = palette->colors.count() - 1;
303 BKE_palette_color_set(color, sampled_color);
304 }
305 else {
307 BKE_brush_color_set(&paint, br, sampled_color);
308 }
309}
310
312 ARegion *region,
313 const int2 mval,
314 const bool use_merged_texture)
315{
316 const Main *bmain = CTX_data_main(C);
317 Scene *scene = CTX_data_scene(C);
318 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
320
322 const View3D *v3d = CTX_wm_view3d(C);
324
325 std::optional<float3> sampled_color;
326 if (v3d && !use_merged_texture) {
327 ViewLayer *view_layer = CTX_data_view_layer(C);
328 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
330
331 if (mode == PaintMode::Texture3D) {
332 /* Attempt to sample from the mesh & active texture */
333
334 sampled_color = sample_texture_paint_color(*depsgraph, *scene, vc, ob, mval);
335 }
336 else if (ELEM(mode, PaintMode::Sculpt, PaintMode::Vertex)) {
337 BKE_sculptsession_update_for_edit(depsgraph, ob, false);
338 sampled_color = sample_mesh_attribute_color(vc, *ob, mval);
339 }
340 }
341 else if (sima != nullptr) {
342 /* Sample from the active image buffer. The sampled color is in
343 * Linear Scene Reference Space. */
344 float3 rgba_f;
345 bool is_data;
346 if (ED_space_image_color_sample(sima, region, mval, rgba_f, &is_data)) {
347 sampled_color = rgba_f;
348 }
349 }
350
351 /* No sample found; sample directly from the GPU front buffer. */
352 if (!sampled_color) {
353 float3 rgb_f;
356 int2(mval.x + region->winrct.xmin, mval.y + region->winrct.ymin),
357 rgb_f);
358
359 /* The sampled color is in display colorspace, convert to scene linear. */
363 sampled_color = rgb_f;
364 }
365
366 BLI_assert(sampled_color);
367 return sampled_color.value_or(float3(0.0f));
368}
369
378
380{
381 char msg[UI_MAX_DRAW_STR];
382 ScrArea *area = CTX_wm_area(C);
383
384 if (area) {
385 SNPRINTF_UTF8(msg,
386 IFACE_("Sample color for %s"),
387 !data->sample_palette ?
388 IFACE_("Brush. Use Left Click to sample for palette instead") :
389 IFACE_("Palette. Use Left Click to sample more colors"));
391 }
392}
393
395{
396 if (data == nullptr) {
397 return sampled_color;
398 }
399
400 data->accum_color += sampled_color;
401 data->num_samples++;
402
403 return data->accum_color / float(data->num_samples);
404}
405
407{
408 Scene &scene = *CTX_data_scene(C);
409 Object &object = *CTX_data_active_object(C);
410 SampleColorData *data = static_cast<SampleColorData *>(op->customdata);
413 ARegion *region = CTX_wm_region(C);
414 wmWindow *win = CTX_wm_window(C);
415
416 const bool use_merged_texture = RNA_boolean_get(op->ptr, "merged");
418 if (ELEM(mode, PaintMode::Vertex, PaintMode::Sculpt) && !use_merged_texture) {
419 if (!color_supported_check(scene, object, op->reports)) {
420 return OPERATOR_CANCELLED;
421 }
422 }
423
424 const bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
425 paint->flags &= ~PAINT_SHOW_BRUSH;
426
427 /* force redraw without cursor */
428 WM_paint_cursor_tag_redraw(win, region);
430
431 int2 location;
432 RNA_int_get_array(op->ptr, "location", location);
433 location.x = std::clamp(location.x, 0, int(region->winx));
434 location.y = std::clamp(location.y, 0, int(region->winy));
435
436 const bool use_palette = RNA_boolean_get(op->ptr, "palette");
437
438 const float3 sampled_color = paint_sample_color(C, region, location, use_merged_texture);
439 const float3 average_color = sample_average_color(data, sampled_color);
440 apply_sampled_color(*CTX_data_main(C), *paint, average_color, use_palette);
441
442 if (show_cursor) {
443 paint->flags |= PAINT_SHOW_BRUSH;
444 }
445
447
448 return OPERATOR_FINISHED;
449}
450
452{
453 Scene &scene = *CTX_data_scene(C);
454 Object &object = *CTX_data_active_object(C);
457 ARegion *region = CTX_wm_region(C);
458 wmWindow *win = CTX_wm_window(C);
459
460 const bool use_merged_texture = RNA_boolean_get(op->ptr, "merged");
462 if (ELEM(mode, PaintMode::Vertex, PaintMode::Sculpt) && !use_merged_texture) {
463 if (!color_supported_check(scene, object, op->reports)) {
464 return OPERATOR_CANCELLED;
465 }
466 }
467
468 SampleColorData *data = MEM_new<SampleColorData>(__func__);
469
470 data->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
471 data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
472 data->initial_color = BKE_brush_color_get(paint, brush);
473 data->sample_palette = false;
474 op->customdata = data;
475 paint->flags &= ~PAINT_SHOW_BRUSH;
476
477 data->accum_color = float3(0.0f);
478 data->num_samples = 0;
479
481
483
484 /* force redraw without cursor */
485 WM_paint_cursor_tag_redraw(win, region);
487
488 RNA_int_set_array(op->ptr, "location", event->mval);
489
490 int2 mval(std::clamp(event->mval[0], 0, int(region->winx)),
491 std::clamp(event->mval[1], 0, int(region->winy)));
492 const float3 sampled_color = paint_sample_color(C, region, mval, use_merged_texture);
493 const float3 average_color = sample_average_color(data, sampled_color);
494 /* On initial invoke, we never sample to the palette. */
495 apply_sampled_color(*CTX_data_main(C), *paint, average_color, false);
496
498
500
502}
503
505{
506 SampleColorData *data = static_cast<SampleColorData *>(op->customdata);
509 Main &bmain = *CTX_data_main(C);
510
511 if ((event->type == data->launch_event) && (event->val == KM_RELEASE)) {
512 if (data->show_cursor) {
513 paint->flags |= PAINT_SHOW_BRUSH;
514 }
515
516 if (data->sample_palette) {
517 /* If we sampled any colors to the palette, reset the brush to its initial color */
518 BKE_brush_color_set(paint, brush, data->initial_color);
519 RNA_boolean_set(op->ptr, "palette", true);
521 }
523 MEM_delete(data);
524 ED_workspace_status_text(C, nullptr);
525
526 return OPERATOR_FINISHED;
527 }
528 ARegion *region = CTX_wm_region(C);
529 int2 mval(std::clamp(event->mval[0], 0, int(region->winx)),
530 std::clamp(event->mval[1], 0, int(region->winy)));
531
532 const bool use_merged_texture = RNA_boolean_get(op->ptr, "merged");
533
534 switch (event->type) {
535 case MOUSEMOVE: {
536 RNA_int_set_array(op->ptr, "location", event->mval);
537 const float3 sampled_color = paint_sample_color(C, region, mval, use_merged_texture);
538 const float3 average_color = sample_average_color(data, sampled_color);
539 apply_sampled_color(bmain, *paint, average_color, false);
541 break;
542 }
543
544 case LEFTMOUSE:
545 if (event->val == KM_PRESS) {
546 RNA_int_set_array(op->ptr, "location", event->mval);
547 const float3 sampled_color = paint_sample_color(C, region, mval, use_merged_texture);
548 const float3 average_color = sample_average_color(data, sampled_color);
549 apply_sampled_color(bmain, *paint, average_color, true);
550 if (!data->sample_palette) {
551 data->sample_palette = true;
553 BKE_report(op->reports, RPT_INFO, "Sampling color for palette");
554 }
556 }
557 break;
558 default: {
559 break;
560 }
561 }
562
564}
565
567{
568 /* Requires a window with pixel-data. */
569 if (G.background) {
570 return false;
571 }
575}
576
578{
579 /* identifiers */
580 ot->name = "Sample Color";
581 ot->idname = "PAINT_OT_sample_color";
582 ot->description = "Use the mouse to sample a color in the image";
583
584 /* API callbacks. */
589
590 /* flags */
592
593 /* properties */
594 PropertyRNA *prop;
595
596 prop = RNA_def_int_vector(
597 ot->srna, "location", 2, nullptr, 0, INT_MAX, "Location", "", 0, 16384);
599
600 RNA_def_boolean(ot->srna, "merged", false, "Sample Merged", "Sample the output display color");
601 RNA_def_boolean(ot->srna, "palette", false, "Add to Palette", "");
602}
603
604} // namespace blender::ed::sculpt_paint
605
CustomData interface, see also DNA_customdata_types.h.
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define BLI_SCOPED_DEFER(function_to_defer)
#define SNPRINTF_UTF8(dst, format,...)
#define IFACE_(msgid)
Object is a sort of wrapper for general info.
#define IMAGEPAINT_MODE_MATERIAL
#define C
Definition RandGen.cpp:29
#define UI_MAX_DRAW_STR
#define NC_BRUSH
Definition WM_types.hh:398
#define NA_EDITED
Definition WM_types.hh:634
#define ELEM(...)
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef name) const
std::optional< RayHit > ray_intersect(const Ray &ray) const
Definition bvh.cc:439
constexpr bool is_empty() const
#define INT_MAX
#define bary_coord
ccl_device_inline float interp(const float a, const float b, const float t)
Definition math_base.h:549
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)
int face_find_corner_from_vert(const IndexRange face, const Span< int > corner_verts, const int vert)
Definition BKE_mesh.hh:327
bool grease_pencil_vertex_painting_poll(bContext *C)
bool grease_pencil_painting_poll(bContext *C)
float4 color_vert_get(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face_map, GSpan color_attribute, bke::AttrDomain color_domain, int vert)
bke::GAttributeReader active_color_attribute(const Mesh &mesh)
float4 color_corner_get(const GSpan color_attribute, int corner_index)
void PAINT_OT_sample_color(wmOperatorType *ot)
static void apply_sampled_color(Main &bMain, Paint &paint, const float3 &sampled_color, const bool use_palette)
static wmOperatorStatus sample_color_exec(bContext *C, wmOperator *op)
static void sample_color_update_header(SampleColorData *data, bContext *C)
static float3 paint_sample_color(bContext *C, ARegion *region, const int2 mval, const bool use_merged_texture)
bool sculpt_mode_poll(bContext *C)
Definition sculpt.cc:3800
static wmOperatorStatus sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool imapaint_pick_face(ViewContext *vc, const int mval[2], int *r_tri_index, int *r_face_index, float3 *r_bary_coord, const Mesh &mesh)
bool color_supported_check(const Scene &scene, Object &object, ReportList *reports)
Definition sculpt.cc:5432
static wmOperatorStatus sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
static std::optional< float3 > sample_mesh_attribute_color(ViewContext &vc, Object &object, int2 mval)
std::optional< ActiveElementInfo > active_element_info_get(ViewContext &vc, const float2 &mval)
Definition sculpt.cc:4512
static bool sample_color_poll(bContext *C)
static float3 sample_average_color(SampleColorData *data, const float3 &sampled_color)
static std::optional< float3 > sample_texture_paint_color(const Depsgraph &depsgraph, Scene &scene, ViewContext &vc, Object *object, const int2 mval)
static float2 imapaint_pick_uv(const Mesh *mesh_eval, Scene &scene, Object *ob_eval, const int tri_index, const float3 &bary_coord)
uchar4 interpolate_nearest_wrap_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:44
uchar4 interpolate_bilinear_wrap_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:97
float4 interpolate_nearest_wrap_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:48
float4 interpolate_bilinear_wrap_fl(const ImBuf *in, float u, float v)
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)
int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
VecBase< uint8_t, 4 > uchar4
ScrArea * CTX_wm_area(const bContext *C)
void BKE_palette_color_set(PaletteColor *color, const float rgb[3])
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
bool vertex_paint_poll_ignore_tool(bContext *C)
Material * BKE_object_material_get(Object *ob, short act)
void WM_cursor_modal_set(wmWindow *win, int val)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
wmWindow * CTX_wm_window(const bContext *C)
ATTR_WARN_UNUSED_RESULT const BMVert * v
MatBase< float, 4, 4 > float4x4
ViewLayer * CTX_data_view_layer(const bContext *C)
Global G
Definition blender.cc:57
VecBase< float, 4 > float4
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const Object *ob)
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
Definition wm_draw.cc:1583
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
Palette * BKE_paint_palette(Paint *paint)
void BKE_brush_color_set(Paint *paint, Brush *brush, const float3 &color)
Definition brush.cc:1305
void WM_cursor_modal_restore(wmWindow *win)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void WM_redraw_windows(bContext *C)
Definition wm_draw.cc:1806
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], const ColorManagedDisplay *display, ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
PaletteColor * BKE_palette_color_add(Palette *palette)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
SpaceImage * CTX_wm_space_image(const bContext *C)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
@ WM_CURSOR_EYEDROPPER
Definition wm_cursors.hh:38
Main * CTX_data_main(const bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
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)
@ PAINT_CANVAS_SOURCE_MATERIAL
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
void BKE_sculptsession_update_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
@ KM_RELEASE
Definition WM_types.hh:325
Brush * BKE_paint_brush(Paint *paint)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1253
const ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
int WM_userdef_event_type_from_keymap_type(int kmitype)
void BKE_imageuser_default(ImageUser *iuser)
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
void BKE_paint_palette_set(Paint *paint, Palette *palette)
MINLINE void straight_to_premul_v4(float color[4])
View3D * CTX_wm_view3d(const bContext *C)
bool image_paint_poll_ignore_tool(bContext *C)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *)
Definition wm_draw.cc:1698
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
ocio::Display ColorManagedDisplay
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
Definition object.cc:4436
Palette * BKE_palette_add(Main *bmain, const char *name)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const ColorSpace * colorspace
ImBufByteBuffer byte_buffer
const uint8_t * byte_data() const
bool colorspace_is_data() const
const float * float_data() const
eImagePaint_Interpolation interp
ListBaseT< PaletteColor > colors
ColorManagedDisplaySettings display_settings
struct ToolSettings * toolsettings
struct ImagePaintSettings imapaint
Depsgraph * depsgraph
Definition ED_view3d.hh:78
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports