Blender V5.3
sculpt_filter_color.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "MEM_guardedalloc.h"
10
13#include "BLI_math_color_c.hh"
14#include "BLI_math_vector.hh"
15
16#include "BLT_translation.hh"
17
18#include "BKE_attribute.hh"
19#include "BKE_brush.hh"
20#include "BKE_context.hh"
21#include "BKE_layer.hh"
22#include "BKE_mesh.hh"
23#include "BKE_object_types.hh"
24#include "BKE_paint.hh"
25#include "BKE_paint_bvh.hh"
26
28
29#include "WM_api.hh"
30#include "WM_toolsystem.hh"
31#include "WM_types.hh"
32
33#include "ED_paint.hh"
34#include "ED_screen.hh"
35
36#include "mesh_brush_common.hh"
37#include "sculpt_automask.hh"
38#include "sculpt_color.hh"
39#include "sculpt_filter.hh"
40#include "sculpt_intern.hh"
41#include "sculpt_smooth.hh"
42#include "sculpt_undo.hh"
43
44#include "RNA_access.hh"
45#include "RNA_define.hh"
46
48#include "UI_resources.hh"
49
50#include <cmath>
51
53
66
67static const float fill_filter_default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
68
69static float3 fill_color_resolve_from_paint(const bContext *C, const bool use_secondary_color)
70{
72 const Sculpt *sd = ts->sculpt;
73 const Paint *paint = &sd->paint;
75
76 /* Use brush colors if a brush tool is active, otherwise use unified paint colors. */
78 const float3 color = use_secondary_color ? BKE_brush_secondary_color_get(paint, brush) :
80 return color;
81 }
82
83 /* Use unified paint colors when filter tool is active. */
84 const float3 color = use_secondary_color ? paint->unified_paint_settings.secondary_color :
85 paint->unified_paint_settings.color;
86 return color;
87}
88
89static float3 fill_color_resolve(const bContext *C, wmOperator *op, const bool use_secondary_color)
90{
91 if (RNA_struct_property_is_set(op->ptr, "fill_color")) {
92 float3 fill_color;
93 RNA_float_get_array(op->ptr, "fill_color", fill_color);
94 return fill_color;
95 }
96
97 return fill_color_resolve_from_paint(C, use_secondary_color);
98}
99
100/* Stores the used color as the fill color to ensure the redo panel works as expected. */
102{
103 const bool use_secondary_color = RNA_boolean_get(op->ptr, "use_secondary_color");
104 const float3 fill_color = fill_color_resolve_from_paint(C, use_secondary_color);
105 RNA_float_set_array(op->ptr, "fill_color", fill_color);
106}
107
109 {int(FilterType::Fill), "FILL", 0, "Fill", "Fill with a specific color"},
110 {int(FilterType::Hue), "HUE", 0, "Hue", "Change hue"},
111 {int(FilterType::Saturation), "SATURATION", 0, "Saturation", "Change saturation"},
112 {int(FilterType::Value), "VALUE", 0, "Value", "Change value"},
113 {int(FilterType::Brightness), "BRIGHTNESS", 0, "Brightness", "Change brightness"},
114 {int(FilterType::Contrast), "CONTRAST", 0, "Contrast", "Change contrast"},
115 {int(FilterType::Smooth), "SMOOTH", 0, "Smooth", "Smooth colors"},
116 {int(FilterType::Red), "RED", 0, "Red", "Change red channel"},
117 {int(FilterType::Green), "GREEN", 0, "Green", "Change green channel"},
118 {int(FilterType::Blue), "BLUE", 0, "Blue", "Change blue channel"},
119 {0, nullptr, 0, nullptr, nullptr},
120};
121
130
132 const float min,
133 const float max)
134{
135 for (float &factor : factors) {
136 factor = std::clamp(factor, min, max);
137 }
138}
139
140static void color_filter_task(const Depsgraph &depsgraph,
141 Object &ob,
142 const OffsetIndices<int> faces,
143 const Span<int> corner_verts,
144 const GroupedSpan<int> vert_to_face_map,
145 const MeshAttributeData &attribute_data,
146 const FilterType mode,
147 const float filter_strength,
148 const float3 &filter_fill_color,
150 LocalData &tls,
151 bke::GSpanAttributeWriter &color_attribute)
152{
154
155 const Span<float4> orig_colors = orig_color_data_get_mesh(ob, node);
156
157 const Span<int> verts = node.verts();
158
160 fill_factor_from_hide_and_mask(attribute_data.hide_vert, attribute_data.mask, verts, factors);
162 depsgraph, ob, ss.filter_cache->automasking.get(), node, verts, factors);
163 scale_factors(factors, filter_strength);
164
166
167 /* Copy alpha. */
168 for (const int i : verts.index_range()) {
169 new_colors[i][3] = orig_colors[i][3];
170 }
171
172 switch (mode) {
173 case FilterType::Fill: {
174 clamp_factors(factors, 0.0f, 1.0f);
175 for (const int i : verts.index_range()) {
176 float fill_color_rgba[4];
177 copy_v3_v3(fill_color_rgba, filter_fill_color);
178 fill_color_rgba[3] = 1.0f;
179 mul_v4_fl(fill_color_rgba, factors[i]);
180 blend_color_mix_float(new_colors[i], orig_colors[i], fill_color_rgba);
181 }
182 break;
183 }
184 case FilterType::Hue: {
185 for (const int i : verts.index_range()) {
186 float3 hsv_color;
187 rgb_to_hsv_v(orig_colors[i], hsv_color);
188 const float hue = hsv_color[0];
189 hsv_color[0] = fmod((hsv_color[0] + fabs(factors[i])) - hue, 1);
190 hsv_to_rgb_v(hsv_color, new_colors[i]);
191 }
192 break;
193 }
195 for (const int i : verts.index_range()) {
196 float3 hsv_color;
197 rgb_to_hsv_v(orig_colors[i], hsv_color);
198
199 if (hsv_color[1] > 0.001f) {
200 hsv_color[1] = std::clamp(hsv_color[1] + factors[i] * hsv_color[1], 0.0f, 1.0f);
201 hsv_to_rgb_v(hsv_color, new_colors[i]);
202 }
203 else {
204 copy_v3_v3(new_colors[i], orig_colors[i]);
205 }
206 }
207 break;
208 }
209 case FilterType::Value: {
210 for (const int i : verts.index_range()) {
211 float3 hsv_color;
212 rgb_to_hsv_v(orig_colors[i], hsv_color);
213 hsv_color[2] = std::clamp(hsv_color[2] + factors[i], 0.0f, 1.0f);
214 hsv_to_rgb_v(hsv_color, new_colors[i]);
215 }
216 break;
217 }
218 case FilterType::Red: {
219 for (const int i : verts.index_range()) {
220 copy_v3_v3(new_colors[i], orig_colors[i]);
221 new_colors[i][0] = std::clamp(orig_colors[i][0] + factors[i], 0.0f, 1.0f);
222 }
223 break;
224 }
225 case FilterType::Green: {
226 for (const int i : verts.index_range()) {
227 copy_v3_v3(new_colors[i], orig_colors[i]);
228 new_colors[i][1] = std::clamp(orig_colors[i][1] + factors[i], 0.0f, 1.0f);
229 }
230 break;
231 }
232 case FilterType::Blue: {
233 for (const int i : verts.index_range()) {
234 copy_v3_v3(new_colors[i], orig_colors[i]);
235 new_colors[i][2] = std::clamp(orig_colors[i][2] + factors[i], 0.0f, 1.0f);
236 }
237 break;
238 }
240 clamp_factors(factors, -1.0f, 1.0f);
241 for (const int i : verts.index_range()) {
242 const float brightness = factors[i];
243 const float contrast = 0;
244 float delta = contrast / 2.0f;
245 const float gain = 1.0f - delta * 2.0f;
246 delta *= -1;
247 const float offset = gain * (brightness + delta);
248 for (int component = 0; component < 3; component++) {
249 new_colors[i][component] = std::clamp(
250 gain * orig_colors[i][component] + offset, 0.0f, 1.0f);
251 }
252 }
253 break;
254 }
256 clamp_factors(factors, -1.0f, 1.0f);
257 for (const int i : verts.index_range()) {
258 const float brightness = 0;
259 const float contrast = factors[i];
260 float delta = contrast / 2.0f;
261 float gain = 1.0f - delta * 2.0f;
262
263 float offset;
264 if (contrast > 0) {
265 gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
266 offset = gain * (brightness - delta);
267 }
268 else {
269 delta *= -1;
270 offset = gain * (brightness + delta);
271 }
272 for (int component = 0; component < 3; component++) {
273 new_colors[i][component] = std::clamp(
274 gain * orig_colors[i][component] + offset, 0.0f, 1.0f);
275 }
276 }
277 break;
278 }
279 case FilterType::Smooth: {
280 clamp_factors(factors, -1.0f, 1.0f);
281
283 for (const int i : verts.index_range()) {
284 colors[i] = color_vert_get(faces,
285 corner_verts,
286 vert_to_face_map,
287 color_attribute.span,
288 color_attribute.domain,
289 verts[i]);
290 }
291
292 const GroupedSpan<int> neighbors = calc_vert_neighbors(faces,
293 corner_verts,
294 vert_to_face_map,
295 {},
296 verts,
298 tls.neighbor_data);
299
300 Array<float4, bke::pbvh::MESH_LEAF_LIMIT> average_colors(verts.size());
302 corner_verts,
303 vert_to_face_map,
304 color_attribute.span,
305 color_attribute.domain,
306 neighbors,
307 average_colors);
308
309 for (const int i : verts.index_range()) {
310 const int vert = verts[i];
311
312 if (factors[i] < 0.0f) {
313 interp_v4_v4v4(average_colors[i], average_colors[i], colors[i], 0.5f);
314 }
315
316 bool copy_alpha = colors[i][3] == average_colors[i][3];
317
318 if (factors[i] < 0.0f) {
319 float4 delta_color;
320
321 /* Unsharp mask. */
322 copy_v4_v4(delta_color, ss.filter_cache->pre_smoothed_color[vert]);
323 delta_color -= average_colors[i];
324
325 copy_v4_v4(new_colors[i], colors[i]);
326 madd_v4_v4fl(new_colors[i], delta_color, factors[i]);
327 }
328 else {
329 blend_color_interpolate_float(new_colors[i], colors[i], average_colors[i], factors[i]);
330 }
331
332 new_colors[i] = math::clamp(new_colors[i], 0.0f, 1.0f);
333
334 /* Prevent accumulated numeric error from corrupting alpha. */
335 if (copy_alpha) {
336 new_colors[i][3] = average_colors[i][3];
337 }
338 }
339 break;
340 }
341 }
342
343 for (const int i : verts.index_range()) {
344 color_vert_set(faces,
345 corner_verts,
346 vert_to_face_map,
347 color_attribute.domain,
348 verts[i],
349 new_colors[i],
350 color_attribute.span);
351 }
352}
353
354static void sculpt_color_presmooth_init(const Mesh &mesh, Object &object)
355{
356 SculptSession &ss = *object.runtime->sculpt_session;
359 const IndexMask &node_mask = ss.filter_cache->node_mask;
360 const OffsetIndices<int> faces = mesh.faces();
361 const Span<int> corner_verts = mesh.corner_verts();
362 const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
363 const bke::GAttributeReader color_attribute = active_color_attribute(mesh);
364 const GVArraySpan colors = *color_attribute;
365
366 if (ss.filter_cache->pre_smoothed_color.is_empty()) {
368 }
369 const MutableSpan<float4> pre_smoothed_color = ss.filter_cache->pre_smoothed_color;
370
371 node_mask.foreach_index(
372 [&](const int i) {
373 for (const int vert : nodes[i].verts()) {
374 pre_smoothed_color[vert] = color_vert_get(
375 faces, corner_verts, vert_to_face_map, colors, color_attribute.domain, vert);
376 }
377 },
379
380 struct LocalData {
383 Vector<float4> averaged_colors;
384 };
386 for ([[maybe_unused]] const int iteration : IndexRange(2)) {
387 node_mask.foreach_index(
388 [&](const int i) {
389 LocalData &tls = all_tls.local();
390 const Span<int> verts = nodes[i].verts();
391
392 const GroupedSpan<int> neighbors = calc_vert_neighbors(faces,
393 corner_verts,
394 vert_to_face_map,
395 {},
396 verts,
398 tls.neighbor_data);
399
400 Array<float4, bke::pbvh::MESH_LEAF_LIMIT> averaged_colors(verts.size());
402 pre_smoothed_color.as_span(), neighbors, averaged_colors.as_mutable_span());
403
404 for (const int i : verts.index_range()) {
405 pre_smoothed_color[verts[i]] = math::interpolate(
406 pre_smoothed_color[verts[i]], averaged_colors[i], 0.5f);
407 }
408 },
410 }
411}
412
414{
415 const Depsgraph &depsgraph = *CTX_data_depsgraph_pointer(C);
416 const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
420
421 const FilterType mode = FilterType(RNA_enum_get(op->ptr, "type"));
422 float filter_strength = RNA_float_get(op->ptr, "strength");
423 const bool use_secondary_color = RNA_boolean_get(op->ptr, "use_secondary_color");
424 const float3 fill_color = fill_color_resolve(C, op, use_secondary_color);
425
426 Mesh &mesh = *id_cast<Mesh *>(ob.data);
427 if (filter_strength < 0.0 && ss.filter_cache->pre_smoothed_color.is_empty()) {
429 }
430
431 const IndexMask &node_mask = ss.filter_cache->node_mask;
432 if (auto_mask::is_enabled(sd.paint, ob, nullptr) && ss.filter_cache->automasking &&
434 {
435 ss.filter_cache->automasking->calc_cavity_factor(depsgraph, ob, node_mask);
436 }
437
438 const OffsetIndices<int> faces = mesh.faces();
439 const Span<int> corner_verts = mesh.corner_verts();
440 const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
442 const MeshAttributeData attribute_data(mesh);
443
445 node_mask.foreach_index(
446 [&](const int i) {
447 LocalData &tls = all_tls.local();
448 color_filter_task(depsgraph,
449 ob,
450 faces,
451 corner_verts,
452 vert_to_face_map,
453 attribute_data,
454 mode,
455 filter_strength,
456 fill_color,
457 nodes[i],
458 tls,
459 color_attribute);
460 },
462 pbvh.tag_attribute_changed(node_mask, mesh.active_color_attribute);
463 color_attribute.finish();
465}
466
468{
470
471 if (FilterType(RNA_enum_get(op->ptr, "type")) == FilterType::Fill &&
472 !RNA_struct_property_is_set(op->ptr, "fill_color"))
473 {
475 }
476
477 undo::push_end(ob);
478 MEM_delete(ss.filter_cache);
479 ss.filter_cache = nullptr;
481}
482
484 wmOperator *op,
485 const wmEvent *event)
486{
489
490 if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
491 /* For Fill: if this was a click (not a drag), apply once at the tool's configured strength */
492 if (FilterType(RNA_enum_get(op->ptr, "type")) == FilterType::Fill &&
494 {
497 }
498
499 sculpt_color_filter_end(C, op, ob);
500 return OPERATOR_FINISHED;
501 }
502
503 if (event->type != MOUSEMOVE) {
505 }
506
507 /* Use a pixel threshold to distinguish a click from a drag */
508 int2 start_mouse;
509 RNA_int_get_array(op->ptr, "start_mouse", &start_mouse[0]);
510 const int2 mouse_2d(event->mval[0], event->mval[1]);
511
512 const int drag_threshold = WM_event_drag_threshold(event);
513 ss.filter_cache->has_dragged |= math::distance_manhattan(start_mouse, mouse_2d) > drag_threshold;
514
515 if (!ss.filter_cache->has_dragged) {
517 }
518
519 const float len = (start_mouse[0] - event->mval[0]) * 0.001f;
520 float filter_strength = ss.filter_cache->start_filter_strength * -len;
521
522 RNA_float_set(op->ptr, "strength", filter_strength);
523
525
527}
528
530{
531 const Scene &scene = *CTX_data_scene(C);
534 View3D *v3d = CTX_wm_view3d(C);
535
536 const Base *base = CTX_data_active_base(C);
537 if (!BKE_base_is_visible(v3d, base)) {
538 return OPERATOR_CANCELLED;
539 }
540
541 int mval[2];
542 RNA_int_get_array(op->ptr, "start_mouse", mval);
543 float mval_fl[2] = {float(mval[0]), float(mval[1])};
544
545 const bool use_automasking = auto_mask::is_enabled(sd.paint, ob, nullptr);
546 if (use_automasking) {
547 if (v3d) {
548 /* Update the active face set manually as the paint cursor is not enabled when using the Mesh
549 * Filter Tool. */
550 cursor_geometry_info_update(C, mval_fl, false);
551 }
552 }
553
554 /* Disable for multires and dyntopo for now */
555 if (!color_supported_check(scene, ob, op->reports)) {
556 return OPERATOR_CANCELLED;
557 }
558
559 /* Ensure that we have a PBVH to be able to push changes on only visible nodes. */
561
562 undo::push_begin(scene, ob, op);
564
565 /* CTX_data_ensure_evaluated_depsgraph should be used at the end to include the potential
566 * creation of color layer data. */
567 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
568 BKE_sculptsession_update_for_edit(depsgraph, &ob, true);
569
571 ob,
572 sd,
574 mval_fl,
575 RNA_float_get(op->ptr, "area_normal_radius"),
576 RNA_float_get(op->ptr, "strength"));
577 const SculptSession &ss = *ob.runtime->sculpt_session;
578 filter::Cache *filter_cache = ss.filter_cache;
579 filter_cache->active_face_set = face_set_none_id;
580 if (auto_mask::is_enabled(sd.paint, ob, nullptr)) {
581 auto_mask::filter_cache_ensure(*depsgraph, sd.paint, ob);
582 }
583
585}
586
600
602 wmOperator *op,
603 const wmEvent *event)
604{
606 View3D *v3d = CTX_wm_view3d(C);
607 if (v3d && v3d->shading.type == OB_SOLID) {
609 }
610
611 RNA_int_set_array(op->ptr, "start_mouse", event->mval);
612
613 /* Immediate execution path (used by key-bindings like `Ctrl+X`). */
614 if (RNA_boolean_get(op->ptr, "use_immediate")) {
615 RNA_float_set(op->ptr, "strength", 1.0f);
616 }
617
619 return OPERATOR_CANCELLED;
620 }
621
622 if (RNA_boolean_get(op->ptr, "use_immediate")) {
624 sculpt_color_filter_end(C, op, ob);
625 return OPERATOR_FINISHED;
626 }
627
629
632}
633
635{
636 PropertyRNA *prop = RNA_struct_find_property(ptr, "type");
637 const int value = RNA_property_enum_get(ptr, prop);
638 const char *ui_name = nullptr;
639
640 RNA_property_enum_name_gettexted(nullptr, ptr, prop, value, &ui_name);
641 return ui_name;
642}
643
645{
646 ui::Layout &layout = *op->layout;
647
648 layout.prop(op->ptr, "strength", UI_ITEM_NONE, std::nullopt, ICON_NONE);
649
650 if (FilterType(RNA_enum_get(op->ptr, "type")) == FilterType::Fill) {
651 layout.prop(op->ptr, "fill_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
652 }
653}
654
656{
657 /* identifiers */
658 ot->name = "Filter Color";
659 ot->idname = "SCULPT_OT_color_filter";
660 ot->description = "Applies a filter to modify the active color attribute";
661
662 /* API callbacks. */
669
671
672 /* rna */
674
676 ot->srna, "type", prop_color_filter_types, int(FilterType::Fill), "Filter Type", "");
677
679 "fill_color",
680 3,
682 0.0f,
683 FLT_MAX,
684 "Fill Color",
685 "",
686 0.0f,
687 1.0f);
690
691 prop = RNA_def_boolean(ot->srna,
692 "use_immediate",
693 false,
694 "Immediate Apply",
695 "Apply once without entering modal interaction");
697
698 prop = RNA_def_boolean(ot->srna, "use_secondary_color", false, "Use Secondary Color", "");
700}
701
702} // namespace blender::ed::sculpt_paint::color
A BVH for high poly meshes.
#define BLT_I18NCONTEXT_ID_MESH
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define BLI_NOINLINE
btScalar max
Array(Allocator allocator={}) noexcept
Definition BLI_array.hh:78
constexpr IndexRange()=default
constexpr Span< T > as_span() const
Definition BLI_span.hh:667
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
#define FLT_MAX
#define FLT_EPSILON
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
ccl_device_inline float2 fmod(const float2 a, const float b)
pbvh::Tree & pbvh_ensure(Depsgraph &depsgraph, Object &object)
pbvh::Tree * pbvh_get(Object &object)
bool is_enabled(const Paint &paint, const Object &object, const Brush *br)
void calc_vert_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::MeshNode &node, Span< int > verts, MutableSpan< float > factors)
Cache & filter_cache_ensure(const Depsgraph &depsgraph, const Paint &paint, Object &ob)
bke::GSpanAttributeWriter active_color_attribute_for_write(Mesh &mesh)
static std::string sculpt_color_filter_get_name(wmOperatorType *, PointerRNA *ptr)
static const float fill_filter_default_color[4]
static BLI_NOINLINE void clamp_factors(const MutableSpan< float > factors, const float min, const float max)
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)
static float3 fill_color_resolve(const bContext *C, wmOperator *op, const bool use_secondary_color)
void color_vert_set(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face_map, bke::AttrDomain color_domain, int vert, const float4 &color, GMutableSpan color_attribute)
static int sculpt_color_filter_init(bContext *C, wmOperator *op)
void SCULPT_OT_color_filter(wmOperatorType *ot)
static void fill_color_store_current(const bContext *C, wmOperator *op)
static float3 fill_color_resolve_from_paint(const bContext *C, const bool use_secondary_color)
bke::GAttributeReader active_color_attribute(const Mesh &mesh)
static void sculpt_color_presmooth_init(const Mesh &mesh, Object &object)
static void sculpt_color_filter_end(bContext *C, wmOperator *op, Object &ob)
static wmOperatorStatus sculpt_color_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus sculpt_color_filter_exec(bContext *C, wmOperator *op)
static void sculpt_color_filter_apply(bContext *C, wmOperator *op, Object &ob)
static void sculpt_color_filter_ui(bContext *, wmOperator *op)
static EnumPropertyItem prop_color_filter_types[]
static void color_filter_task(const Depsgraph &depsgraph, Object &ob, const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face_map, const MeshAttributeData &attribute_data, const FilterType mode, const float filter_strength, const float3 &filter_fill_color, const bke::pbvh::MeshNode &node, LocalData &tls, bke::GSpanAttributeWriter &color_attribute)
static wmOperatorStatus sculpt_color_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void cache_init(bContext *C, Object &ob, Sculpt &sd, undo::Type undo_type, const float mval_fl[2], float area_normal_radius, float start_strength)
void register_operator_props(wmOperatorType *ot)
void neighbor_data_average_mesh(const Span< T > src, const GroupedSpan< int > vert_neighbors, const MutableSpan< T > dst)
void neighbor_color_average(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face_map, const GSpan color_attribute, const bke::AttrDomain color_domain, const GroupedSpan< int > vert_neighbors, const MutableSpan< float4 > smooth_colors)
void push_begin(const Scene &scene, Object &ob, const wmOperator *op)
void fill_factor_from_hide_and_mask(Span< bool > hide_vert, Span< float > mask, Span< int > verts, MutableSpan< float > r_factors)
Definition sculpt.cc:7128
GroupedSpan< int > calc_vert_neighbors(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face, Span< bool > hide_poly, Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
Definition sculpt.cc:7949
bool sculpt_mode_poll(bContext *C)
Definition sculpt.cc:3800
bool color_supported_check(const Scene &scene, Object &object, ReportList *reports)
Definition sculpt.cc:5432
void scale_factors(MutableSpan< float > factors, float strength)
Definition sculpt.cc:7856
Span< float4 > orig_color_data_get_mesh(const Object &object, const bke::pbvh::MeshNode &node)
void flush_update_step(bContext *C, const UpdateType update_type)
Definition sculpt.cc:5090
void flush_update_done(bContext *C, Object &ob, const UpdateType update_type)
Definition sculpt.cc:5131
std::optional< CursorGeometryInfo > cursor_geometry_info_update(bContext *C, const float2 &mval, const bool use_sampled_normal)
Definition sculpt.cc:4584
constexpr ParallelGrainSize grain_size(int grain_size)
T clamp(const T &a, const T &min, const T &max)
T interpolate(const T &a, const T &b, const FactorT &t)
T distance_manhattan(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void ED_paint_brush_type_update_sticky_shading_color(bContext *C, Object *ob)
int WM_event_drag_threshold(const wmEvent *event)
Base * CTX_data_active_base(const bContext *C)
VecBase< float, 4 > float4
bool RNA_property_enum_name_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_name)
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
VecBase< int32_t, 2 > int2
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
Definition math_color.cc:61
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
@ V3D_SHADING_VERTEX_COLOR
void BKE_sculpt_color_layer_create_if_needed(Object *object)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
@ BRUSH_AUTOMASKING_CAVITY_ALL
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
bool WM_toolsystem_active_tool_is_brush(const bContext *C)
@ 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
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1253
MINLINE void copy_v4_v4(float r[4], const float a[4])
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
MINLINE void mul_v4_fl(float r[4], float f)
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)
Object * CTX_data_active_object(const bContext *C)
float RNA_float_get(PointerRNA *ptr, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float3 BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1297
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
bke::ObjectRuntime * runtime
ed::sculpt_paint::filter::Cache * filter_cache
Definition BKE_paint.hh:410
eV3DShadingColorType color_type
View3DShading shading
std::unique_ptr< auto_mask::Cache > automasking
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
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
void(*) ui(bContext *C, wmOperator *op)
Definition WM_types.hh:1176
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
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191
struct ReportList * reports