Blender V5.3
curves/sculpt_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include <algorithm>
6
7#include "BLI_kdtree_new.hh"
8#include "BLI_listbase.hh"
9#include "BLI_math_vector.hh"
10#include "BLI_rand.hh"
11#include "BLI_task.hh"
12#include "BLI_utildefines.hh"
13#include "BLI_vector_set.hh"
14
15#include "BKE_attribute.hh"
16#include "BKE_brush.hh"
17#include "BKE_bvh.hh"
18#include "BKE_bvhutils.hh"
19#include "BKE_colortools.hh"
20#include "BKE_context.hh"
21#include "BKE_curves.hh"
22#include "BKE_modifier.hh"
23#include "BKE_object.hh"
24#include "BKE_paint.hh"
25#include "BKE_paint_types.hh"
26
27#include "BLT_translation.hh"
28
29#include "WM_api.hh"
30#include "WM_message.hh"
31#include "WM_toolsystem.hh"
32
33#include "ED_curves.hh"
34#include "ED_curves_sculpt.hh"
35#include "ED_object.hh"
36#include "ED_paint.hh"
37#include "ED_screen.hh"
38#include "ED_space_api.hh"
39#include "ED_view3d.hh"
40
41#include "DEG_depsgraph.hh"
43
44#include "DNA_brush_types.h"
45#include "DNA_curves_types.h"
46#include "DNA_mesh_types.h"
47#include "DNA_screen_types.h"
48
49#include "RNA_access.hh"
50#include "RNA_define.hh"
51#include "RNA_enum_types.hh"
52
53#include "../paint_intern.hh"
54#include "sculpt_intern.hh"
55
56#include "UI_interface.hh"
58#include "UI_resources.hh"
59
60#include "GPU_immediate.hh"
61#include "GPU_immediate_util.hh"
62#include "GPU_matrix.hh"
63#include "GPU_state.hh"
64
65namespace blender {
66
67namespace ed::sculpt_paint {
68
69/* -------------------------------------------------------------------- */
72
74{
75 const Object *ob = CTX_data_active_object(C);
76 return ob && ob->mode & OB_MODE_SCULPT_CURVES;
77}
78
80{
81 if (!curves_sculpt_poll(C)) {
82 return false;
83 }
84 if (CTX_wm_region_view3d(C) == nullptr) {
85 return false;
86 }
87 return true;
88}
89
91
92/* -------------------------------------------------------------------- */
95
96float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension)
97{
99 return BKE_curvemapping_evaluateF(brush.curve_size, 0, stroke_extension.pressure);
100 }
101 return 1.0f;
102}
103
105 const Brush &brush,
106 const StrokeExtension &stroke_extension)
107{
108 return BKE_brush_radius_get(&paint, &brush) * brush_radius_factor(brush, stroke_extension);
109}
110
111float brush_strength_factor(const Brush &brush, const StrokeExtension &stroke_extension)
112{
114 return BKE_curvemapping_evaluateF(brush.curve_strength, 0, stroke_extension.pressure);
115 }
116 return 1.0f;
117}
118
120 const Brush &brush,
121 const StrokeExtension &stroke_extension)
122{
123 return BKE_brush_alpha_get(&paint, &brush) * brush_strength_factor(brush, stroke_extension);
124}
125
126static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(
127 wmOperator &op,
128 Scene &scene,
129 Depsgraph &depsgraph,
130 ARegion &region,
131 View3D &v3d,
132 const Object &object,
133 const StrokeExtension &stroke_start)
134{
135 const auto mode = BrushStrokeMode(RNA_enum_get(op.ptr, "mode"));
136 const auto brush_switch_mode = BrushSwitchMode(RNA_enum_get(op.ptr, "brush_toggle"));
137
138 const CurvesSculpt &curves_sculpt = *scene.toolsettings->curves_sculpt;
139 const Brush &brush = *BKE_paint_brush_for_read(&curves_sculpt.paint);
140 const eBrushCurvesSculptType brush_type = eBrushCurvesSculptType(brush.curves_sculpt_brush_type);
141 if (brush_switch_mode == BrushSwitchMode::Smooth) {
143 /* The selection brush uses the BrushSwitchMode::Smooth mode to indicate that the
144 * current selection should be added to. It should not toggle to the smooth brush itself. */
145 }
146 else {
147 return new_smooth_operation();
148 }
149 }
150
151 switch (brush_type) {
153 return new_comb_operation();
155 return new_delete_operation();
159 return new_add_operation();
161 return new_grow_shrink_operation(mode, scene);
163 return new_selection_paint_operation(mode, brush_switch_mode, scene);
165 return new_pinch_operation(mode, scene);
167 return new_smooth_operation();
169 return new_puff_operation();
171 return new_density_operation(mode, scene, depsgraph, region, v3d, object, stroke_start);
173 return new_slide_operation();
175 return new_cut_operation();
176 }
178 return {};
179}
180
183 : PaintStroke(C, op, event, PaintMode::SculptCurves)
184 {
185 }
186
187 std::optional<float3> get_location(float2 mouse, bool force_original) override;
188 bool test_start(wmOperator *op, float2 mouse) override;
189 void redraw(bool final) override;
190 bool test_cancel() override;
191 void update_step(wmOperator *op, const StrokeStep &stroke_step) override;
192 void done(bool is_cancel, bool stroke_started) override;
193
194 private:
195 std::unique_ptr<CurvesSculptStrokeOperation> operation_;
196};
197
198std::optional<float3> SculptCurvesBrushStroke::get_location(const float2 mouse,
199 bool /*force_original*/)
200{
201 return float3(mouse.x, mouse.y, 0.0f);
202}
203
205{
206 return true;
207}
208
210{
211 StrokeExtension stroke_extension;
212 stroke_extension.mouse_position = stroke_step.mouse;
213 stroke_extension.pressure = stroke_step.pressure;
214 stroke_extension.reports = op->reports;
215
216 if (!operation_) {
217 stroke_extension.is_first = true;
218 operation_ = start_brush_operation(*op,
219 *this->vc.scene,
220 *this->vc.depsgraph,
221 *this->vc.region,
222 *this->vc.v3d,
223 *this->object,
224 stroke_extension);
225 }
226 else {
227 stroke_extension.is_first = false;
228 }
229
230 if (operation_) {
231 operation_->on_stroke_extended(*this, stroke_extension);
232 }
233}
234
235void SculptCurvesBrushStroke::redraw(bool /*final*/) {}
237{
238 return false;
239}
240
241void SculptCurvesBrushStroke::done(const bool /*is_cancel*/, bool /*stroke_started*/) {}
242
244 wmOperator *op,
245 const wmEvent *event)
246{
247 Scene *scene = CTX_data_scene(C);
249 const Brush *brush = paint ? BKE_paint_brush_for_read(paint) : nullptr;
250 if (brush == nullptr) {
251 return OPERATOR_CANCELLED;
252 }
253
254 SculptCurvesBrushStroke *op_data = MEM_new<SculptCurvesBrushStroke>(__func__, C, op, event);
255 op->customdata = op_data;
256
257 const wmOperatorStatus retval = op->type->modal(C, op, event);
258 OPERATOR_RETVAL_CHECK(retval);
259
260 if (retval == OPERATOR_FINISHED) {
261 if (op->customdata != nullptr) {
262 op_data->finish(C);
263 MEM_delete(op_data);
264 }
265 return OPERATOR_FINISHED;
266 }
267
270}
271
273 wmOperator *op,
274 const wmEvent *event)
275{
276 SculptCurvesBrushStroke *op_data = static_cast<SculptCurvesBrushStroke *>(op->customdata);
277 wmOperatorStatus retval = op_data->modal(C, op, event);
279 MEM_delete(op_data);
280 op->customdata = nullptr;
281 }
282 return retval;
283}
284
286{
287 if (op->customdata != nullptr) {
288 SculptCurvesBrushStroke *op_data = static_cast<SculptCurvesBrushStroke *>(op->customdata);
289 op_data->cancel(C);
290 MEM_delete(op_data);
291 }
292}
293
295{
296 ot->name = "Stroke Curves Sculpt";
297 ot->idname = "SCULPT_CURVES_OT_brush_stroke";
298 ot->description = "Sculpt curves using a brush";
299
303
305
307}
308
310
311/* -------------------------------------------------------------------- */
314
316{
317 Scene *scene = CTX_data_scene(C);
319
322 reinterpret_cast<Paint **>(&scene->toolsettings->curves_sculpt));
323 CurvesSculpt *curves_sculpt = scene->toolsettings->curves_sculpt;
324
326
328
330
332 paint_init_pivot(ob, scene, paint);
333
334 /* Necessary to change the object mode on the evaluated object. */
336 WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode);
338}
339
341{
343 ob->mode = OB_MODE_OBJECT;
344}
345
347{
350
351 const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES;
352
353 if (is_mode_set) {
355 return OPERATOR_CANCELLED;
356 }
357 }
358
359 if (is_mode_set) {
361 }
362 else {
364 }
365
367
368 /* Necessary to change the object mode on the evaluated object. */
370 WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode);
372 return OPERATOR_FINISHED;
373}
374
376{
377 ot->name = "Curve Sculpt Mode Toggle";
378 ot->idname = "CURVES_OT_sculptmode_toggle";
379 ot->description = "Enter/Exit sculpt mode for curves";
380
383
385}
386
388
389namespace select_random {
390
392{
394
395 const int seed = RNA_int_get(op->ptr, "seed");
397
398 const bool partial = RNA_boolean_get(op->ptr, "partial");
399 const bool constant_per_curve = RNA_boolean_get(op->ptr, "constant_per_curve");
400 const float probability = RNA_float_get(op->ptr, "probability");
401 const float min_value = RNA_float_get(op->ptr, "min");
402 const auto next_partial_random_value = [&]() {
403 return rng.get_float() * (1.0f - min_value) + min_value;
404 };
405 const auto next_bool_random_value = [&]() { return rng.get_float() <= probability; };
406
407 for (Curves *curves_id : unique_curves) {
408 CurvesGeometry &curves = curves_id->geometry.wrap();
409 const bool was_anything_selected = curves::has_anything_selected(curves);
410
412 MutableSpan<float> selection = attribute.span;
413 if (!was_anything_selected) {
414 selection.fill(1.0f);
415 }
416 const OffsetIndices points_by_curve = curves.points_by_curve();
417 switch (bke::AttrDomain(curves_id->selection_domain)) {
419 if (partial) {
420 if (constant_per_curve) {
421 for (const int curve_i : curves.curves_range()) {
422 const float random_value = next_partial_random_value();
423 const IndexRange points = points_by_curve[curve_i];
424 for (const int point_i : points) {
425 selection[point_i] *= random_value;
426 }
427 }
428 }
429 else {
430 for (const int point_i : selection.index_range()) {
431 const float random_value = next_partial_random_value();
432 selection[point_i] *= random_value;
433 }
434 }
435 }
436 else {
437 if (constant_per_curve) {
438 for (const int curve_i : curves.curves_range()) {
439 const bool random_value = next_bool_random_value();
440 const IndexRange points = points_by_curve[curve_i];
441 if (!random_value) {
442 selection.slice(points).fill(0.0f);
443 }
444 }
445 }
446 else {
447 for (const int point_i : selection.index_range()) {
448 const bool random_value = next_bool_random_value();
449 if (!random_value) {
450 selection[point_i] = 0.0f;
451 }
452 }
453 }
454 }
455 break;
456 }
458 if (partial) {
459 for (const int curve_i : curves.curves_range()) {
460 const float random_value = next_partial_random_value();
461 selection[curve_i] *= random_value;
462 }
463 }
464 else {
465 for (const int curve_i : curves.curves_range()) {
466 const bool random_value = next_bool_random_value();
467 if (!random_value) {
468 selection[curve_i] = 0.0f;
469 }
470 }
471 }
472 break;
473 }
474 default:
476 break;
477 }
478
479 attribute.finish();
480
481 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
482 * attribute for now. */
483 DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
484 WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
485 }
486 return OPERATOR_FINISHED;
487}
488
489static void select_random_ui(bContext * /*C*/, wmOperator *op)
490{
491 ui::Layout &layout = *op->layout;
492
493 layout.prop(op->ptr, "seed", UI_ITEM_NONE, std::nullopt, ICON_NONE);
494 layout.prop(op->ptr, "constant_per_curve", UI_ITEM_NONE, std::nullopt, ICON_NONE);
495 layout.prop(op->ptr, "partial", UI_ITEM_NONE, std::nullopt, ICON_NONE);
496
497 if (RNA_boolean_get(op->ptr, "partial")) {
498 layout.prop(op->ptr, "min", ui::ITEM_R_SLIDER, IFACE_("Min"), ICON_NONE);
499 }
500 else {
501 layout.prop(op->ptr, "probability", ui::ITEM_R_SLIDER, IFACE_("Probability"), ICON_NONE);
502 }
503}
504
505} // namespace select_random
506
508{
509 ot->name = "Select Random";
510 ot->idname = __func__;
511 ot->description = "Randomizes existing selection or create new random selection";
512
516
518
519 RNA_def_int(ot->srna,
520 "seed",
521 0,
522 INT32_MIN,
523 INT32_MAX,
524 "Seed",
525 "Source of randomness",
526 INT32_MIN,
527 INT32_MAX);
529 ot->srna, "partial", false, "Partial", "Allow points or curves to be selected partially");
531 "probability",
532 0.5f,
533 0.0f,
534 1.0f,
535 "Probability",
536 "Chance of every point or curve being included in the selection",
537 0.0f,
538 1.0f);
540 "min",
541 0.0f,
542 0.0f,
543 1.0f,
544 "Min",
545 "Minimum value for the random selection",
546 0.0f,
547 1.0f);
549 "constant_per_curve",
550 true,
551 "Constant per Curve",
552 "The generated random number is the same for every control point of a curve");
553}
554namespace select_grow {
555
568
573
575 const float distance,
576 MutableSpan<float> points_selection)
577{
578 if (distance > 0.0f) {
579 data.unselected_points.foreach_index(
580 [&](const int point_i, const int index_pos) {
581 const float distance_to_selected = data.distances_to_selected[index_pos];
582 const float selection = distance_to_selected <= distance ? 1.0f : 0.0f;
583 points_selection[point_i] = selection;
584 },
586 data.selected_points.foreach_index(
587 [&](const int point_i) { points_selection[point_i] = 1.0f; }, exec_mode::grain_size(512));
588 }
589 else {
590 data.selected_points.foreach_index(
591 [&](const int point_i, const int index_pos) {
592 const float distance_to_unselected = data.distances_to_unselected[index_pos];
593 const float selection = distance_to_unselected <= -distance ? 0.0f : 1.0f;
594 points_selection[point_i] = selection;
595 },
597 data.unselected_points.foreach_index(
598 [&](const int point_i) { points_selection[point_i] = 0.0f; }, exec_mode::grain_size(512));
599 }
600}
601
602static int select_grow_update(bContext *C, wmOperator *op, const float mouse_diff_x)
603{
604 GrowOperatorData &op_data = *static_cast<GrowOperatorData *>(op->customdata);
605
606 for (std::unique_ptr<GrowOperatorDataPerCurve> &curve_op_data : op_data.per_curve) {
607 Curves &curves_id = *curve_op_data->curves_id;
608 CurvesGeometry &curves = curves_id.geometry.wrap();
609 const float distance = curve_op_data->pixel_to_distance_factor * mouse_diff_x;
610
612 const OffsetIndices points_by_curve = curves.points_by_curve();
613
614 /* Grow or shrink selection based on precomputed distances. */
615 switch (selection.domain) {
617 update_points_selection(*curve_op_data, distance, selection.span);
618 break;
619 }
621 Array<float> new_points_selection(curves.points_num());
622 update_points_selection(*curve_op_data, distance, new_points_selection);
623 /* Propagate grown point selection to the curve selection. */
624 MutableSpan<float> curves_selection = selection.span;
625 for (const int curve_i : curves.curves_range()) {
626 const IndexRange points = points_by_curve[curve_i];
627 const Span<float> points_selection = new_points_selection.as_span().slice(points);
628 const float max_selection = *std::max_element(points_selection.begin(),
629 points_selection.end());
630 curves_selection[curve_i] = max_selection;
631 }
632 break;
633 }
634 default:
636 }
637
638 selection.finish();
639
640 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
641 * attribute for now. */
643 WM_event_add_notifier(C, NC_GEOM | ND_DATA, &curves_id);
644 }
645
646 return OPERATOR_FINISHED;
647}
648
649static void select_grow_invoke_per_curve(const Curves &curves_id,
650 const Object &curves_ob,
651 const ARegion &region,
652 const View3D &v3d,
653 const RegionView3D &rv3d,
654 GrowOperatorDataPerCurve &curve_op_data)
655{
656 const CurvesGeometry &curves = curves_id.geometry.wrap();
657 const Span<float3> positions = curves.positions();
658
659 if (const bke::GAttributeReader original_selection = curves.attributes().lookup(".selection")) {
660 curve_op_data.original_selection = GArray<>(original_selection.varray.type(),
661 original_selection.varray.size());
662 original_selection.varray.materialize(curve_op_data.original_selection.data());
663 }
664
665 /* Find indices of selected and unselected points. */
667 curves_id, curve_op_data.selected_points_memory);
668 curve_op_data.unselected_points = curve_op_data.selected_points.complement(
669 curves.points_range(), curve_op_data.unselected_points_memory);
670
672 1024 < curve_op_data.selected_points.size() + curve_op_data.unselected_points.size(),
673 [&]() {
674 /* For each unselected point, compute the distance to the closest selected point. */
675 KDTreeNew<float3> kdtree(positions, curve_op_data.selected_points);
676 curve_op_data.distances_to_selected.reinitialize(curve_op_data.unselected_points.size());
677 curve_op_data.unselected_points.foreach_index(
678 [&](const int point, const int pos) {
679 float distance_sq = FLT_MAX;
680 kdtree.find_nearest(positions[point], &distance_sq);
681 curve_op_data.distances_to_selected[pos] = std::sqrt(distance_sq);
682 },
684 },
685 [&]() {
686 /* For each selected point, compute the distance to the closest unselected point. */
687 KDTreeNew<float3> kdtree(positions, curve_op_data.unselected_points);
688 curve_op_data.distances_to_unselected.reinitialize(curve_op_data.selected_points.size());
689 curve_op_data.selected_points.foreach_index(
690 [&](const int point, const int pos) {
691 float distance_sq = FLT_MAX;
692 kdtree.find_nearest(positions[point], &distance_sq);
693 curve_op_data.distances_to_unselected[pos] = std::sqrt(distance_sq);
694 },
696 });
697
698 const float4x4 &curves_to_world_mat = curves_ob.object_to_world();
699 float4x4 world_to_curves_mat = math::invert(curves_to_world_mat);
700
701 const float4x4 projection = ED_view3d_ob_project_mat_get(&rv3d, &curves_ob);
702
703 /* Compute how mouse movements in screen space are converted into grow/shrink distances in
704 * object space. */
705 curve_op_data.pixel_to_distance_factor = threading::parallel_reduce(
706 curve_op_data.selected_points.index_range(),
707 256,
708 FLT_MAX,
709 [&](const IndexRange range, float pixel_to_distance_factor) {
710 for (const int i : range) {
711 const int point_i = curve_op_data.selected_points[i];
712 const float3 &pos_cu = positions[point_i];
713
714 const float2 pos_re = ED_view3d_project_float_v2_m4(&region, pos_cu, projection);
715 if (pos_re.x < 0 || pos_re.y < 0 || pos_re.x > region.winx || pos_re.y > region.winy) {
716 continue;
717 }
718 /* Compute how far this point moves in curve space when it moves one unit in screen
719 * space. */
720 const float2 pos_offset_re = pos_re + float2(1, 0);
721 float3 pos_offset_wo;
722 ED_view3d_win_to_3d(&v3d,
723 &region,
724 math::transform_point(curves_to_world_mat, pos_cu),
725 pos_offset_re,
726 pos_offset_wo);
727 const float3 pos_offset_cu = math::transform_point(world_to_curves_mat, pos_offset_wo);
728 const float dist_cu = math::distance(pos_cu, pos_offset_cu);
729 const float dist_re = math::distance(pos_re, pos_offset_re);
730 const float factor = dist_cu / dist_re;
731 math::min_inplace(pixel_to_distance_factor, factor);
732 }
733 return pixel_to_distance_factor;
734 },
735 [](const float a, const float b) { return std::min(a, b); });
736}
737
739{
740 Object *active_ob = CTX_data_active_object(C);
741 ARegion *region = CTX_wm_region(C);
742 View3D *v3d = CTX_wm_view3d(C);
744
745 GrowOperatorData *op_data = MEM_new<GrowOperatorData>(__func__);
746 op->customdata = op_data;
747
748 op_data->initial_mouse_x = event->xy[0];
749
750 Curves &curves_id = *id_cast<Curves *>(active_ob->data);
751 auto curve_op_data = std::make_unique<GrowOperatorDataPerCurve>();
752 curve_op_data->curves_id = &curves_id;
753 select_grow_invoke_per_curve(curves_id, *active_ob, *region, *v3d, *rv3d, *curve_op_data);
754 op_data->per_curve.append(std::move(curve_op_data));
755
758}
759
761{
762 GrowOperatorData &op_data = *static_cast<GrowOperatorData *>(op->customdata);
763 const int mouse_x = event->xy[0];
764 const int mouse_diff_x = mouse_x - op_data.initial_mouse_x;
765 switch (event->type) {
766 case MOUSEMOVE: {
767 select_grow_update(C, op, mouse_diff_x);
768 break;
769 }
770 case LEFTMOUSE: {
771 MEM_delete(&op_data);
772 return OPERATOR_FINISHED;
773 }
774 case EVT_ESCKEY:
775 case RIGHTMOUSE: {
776 /* Undo operator by resetting the selection to the original value. */
777 for (std::unique_ptr<GrowOperatorDataPerCurve> &curve_op_data : op_data.per_curve) {
778 Curves &curves_id = *curve_op_data->curves_id;
779 CurvesGeometry &curves = curves_id.geometry.wrap();
780 bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
781
782 attributes.remove(".selection");
783 if (!curve_op_data->original_selection.is_empty()) {
784 attributes.add(
785 ".selection",
786 bke::AttrDomain(curves_id.selection_domain),
787 bke::cpp_type_to_attribute_type(curve_op_data->original_selection.type()),
788 bke::AttributeInitVArray(GVArray::from_span(curve_op_data->original_selection)));
789 }
790
791 /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
792 * attribute for now. */
794 WM_event_add_notifier(C, NC_GEOM | ND_DATA, &curves_id);
795 }
796 MEM_delete(&op_data);
797 return OPERATOR_CANCELLED;
798 }
799 default: {
800 break;
801 }
802 }
804}
805
806} // namespace select_grow
807
809{
810 ot->name = "Select Grow";
811 ot->idname = __func__;
812 ot->description = "Select curves which are close to curves that are selected already";
813
817
819
820 PropertyRNA *prop;
821 prop = RNA_def_float(ot->srna,
822 "distance",
823 0.1f,
824 -FLT_MAX,
825 FLT_MAX,
826 "Distance",
827 "By how much to grow the selection",
828 -10.0f,
829 10.0f);
831}
832
834
836{
838 return false;
839 }
840 Scene *scene = CTX_data_scene(C);
842 if (brush == nullptr) {
843 return false;
844 }
845 if (brush->curves_sculpt_brush_type != CURVES_SCULPT_BRUSH_TYPE_DENSITY) {
846 return false;
847 }
848 return true;
849}
850
871
873{
875 ARegion *region = op_data.region;
876
877 const float min_distance = op_data.brush->curves_sculpt_settings->minimum_distance;
878 const float brush_radius = BKE_brush_radius_get(paint, op_data.brush);
879
880 float3 tangent_x_cu = math::cross(op_data.normal_cu, float3{0, 0, 1});
881 if (math::is_zero(tangent_x_cu)) {
882 tangent_x_cu = math::cross(op_data.normal_cu, float3{0, 1, 0});
883 }
884 tangent_x_cu = math::normalize(tangent_x_cu);
885 const float3 tangent_y_cu = math::normalize(math::cross(op_data.normal_cu, tangent_x_cu));
886
887 /* Sample a few points to get a good estimate of how large the grid has to be. */
888 Vector<float3> points_wo;
889 points_wo.append(op_data.pos_cu + min_distance * tangent_x_cu);
890 points_wo.append(op_data.pos_cu + min_distance * tangent_y_cu);
891 points_wo.append(op_data.pos_cu - min_distance * tangent_x_cu);
892 points_wo.append(op_data.pos_cu - min_distance * tangent_y_cu);
893
894 Vector<float2> points_re;
895 for (const float3 &pos_wo : points_wo) {
896 float2 pos_re;
897 ED_view3d_project_v2(region, pos_wo, pos_re);
898 points_re.append(pos_re);
899 }
900
901 float2 origin_re;
902 ED_view3d_project_v2(region, op_data.pos_cu, origin_re);
903
904 int needed_points = 0;
905 for (const float2 &pos_re : points_re) {
906 const float distance = math::length(pos_re - origin_re);
907 const int needed_points_iter = (brush_radius * 2.0f) / distance;
908
909 needed_points = std::max(needed_points_iter, needed_points);
910 }
911
912 /* Limit to a hard-coded number since it only adds noise at some point. */
913 return std::min(300, needed_points);
914}
915
917 const int2 & /*xy*/,
918 const float2 & /*tilt*/,
919 void *customdata)
920{
922 MinDistanceEditData &op_data = *static_cast<MinDistanceEditData *>(customdata);
923
924 const float min_distance = op_data.brush->curves_sculpt_settings->minimum_distance;
925
926 float3 tangent_x_cu = math::cross(op_data.normal_cu, float3{0, 0, 1});
927 if (math::is_zero(tangent_x_cu)) {
928 tangent_x_cu = math::cross(op_data.normal_cu, float3{0, 1, 0});
929 }
930 tangent_x_cu = math::normalize(tangent_x_cu);
931 const float3 tangent_y_cu = math::normalize(math::cross(op_data.normal_cu, tangent_x_cu));
932
933 const int points_per_side = calculate_points_per_side(C, op_data);
934 const int points_per_axis_num = 2 * points_per_side + 1;
935
936 Vector<float3> points_wo;
937 for (const int x_i : IndexRange(points_per_axis_num)) {
938 for (const int y_i : IndexRange(points_per_axis_num)) {
939 const float x_iter = min_distance * (x_i - (points_per_axis_num - 1) / 2.0f);
940 const float y_iter = min_distance * (y_i - (points_per_axis_num - 1) / 2.0f);
941
942 const float3 point_pos_cu = op_data.pos_cu + op_data.normal_cu * 0.0001f +
943 x_iter * tangent_x_cu + y_iter * tangent_y_cu;
944 const float3 point_pos_wo = math::transform_point(op_data.curves_to_world_mat, point_pos_cu);
945 points_wo.append(point_pos_wo);
946 }
947 }
948
949 float4 circle_col = float4(op_data.brush->add_col);
950 float circle_alpha = op_data.brush->cursor_overlay_alpha * 0.01f;
951 float brush_radius_re = BKE_brush_radius_get(paint, op_data.brush);
952
953 /* Draw the grid. */
957
958 ARegion *region = op_data.region;
959 RegionView3D *rv3d = op_data.rv3d;
960 wmWindow *win = CTX_wm_window(C);
961
962 /* It does the same as: `view3d_operator_needs_gpu(C);`. */
963 wmViewport(&region->winrct);
965 GPU_matrix_set(rv3d->viewmat);
966
967 GPUVertFormat *format3d = immVertexFormat();
968
969 const uint pos3d = GPU_vertformat_attr_add(format3d, "pos", gpu::VertAttrType::SFLOAT_32_32_32);
970 const uint col3d = GPU_vertformat_attr_add(
971 format3d, "color", gpu::VertAttrType::SFLOAT_32_32_32_32);
972 const uint siz3d = GPU_vertformat_attr_add(format3d, "size", gpu::VertAttrType::SFLOAT_32);
973
976 immBegin(GPU_PRIM_POINTS, points_wo.size());
977
978 float3 brush_origin_wo = math::transform_point(op_data.curves_to_world_mat, op_data.pos_cu);
979 float2 brush_origin_re;
980 ED_view3d_project_v2(region, brush_origin_wo, brush_origin_re);
981
982 /* Smooth alpha transition until the brush edge. */
983 const int alpha_border_re = 20;
984 const float dist_to_inner_border_re = brush_radius_re - alpha_border_re;
985
986 for (const float3 &pos_wo : points_wo) {
987 float2 pos_re;
988 ED_view3d_project_v2(region, pos_wo, pos_re);
989
990 const float dist_to_point_re = math::distance(pos_re, brush_origin_re);
991 const float alpha = clamp_f(
992 1.0f - ((dist_to_point_re - dist_to_inner_border_re) / alpha_border_re), 0.0f, 1.0f);
993
994 immAttr1f(siz3d, 3.0f);
995 immAttr4f(col3d, 0.9f, 0.9f, 0.9f, alpha);
996 immVertex3fv(pos3d, pos_wo);
997 }
998 immEnd();
1000
1001 /* Reset the drawing settings. */
1002 GPU_point_size(1.0f);
1005
1006 int4 scissor;
1007 GPU_scissor_get(scissor);
1008 wmWindowViewport(win);
1009 GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
1010
1011 /* Draw the brush circle. */
1012 GPU_matrix_translate_2f(float(op_data.initial_mouse.x), float(op_data.initial_mouse.y));
1013
1014 GPUVertFormat *format = immVertexFormat();
1015 uint pos2d = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
1016
1018
1019 immUniformColor3fvAlpha(circle_col, circle_alpha);
1020 imm_draw_circle_wire_2d(pos2d, 0.0f, 0.0f, brush_radius_re, 80);
1021
1024}
1025
1027{
1028 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
1029 ARegion *region = CTX_wm_region(C);
1030 View3D *v3d = CTX_wm_view3d(C);
1031 Scene *scene = CTX_data_scene(C);
1032
1033 Object &curves_ob_orig = *CTX_data_active_object(C);
1034 Curves &curves_id_orig = *id_cast<Curves *>(curves_ob_orig.data);
1035 Object &surface_ob_orig = *curves_id_orig.surface;
1036 Object *surface_ob_eval = DEG_get_evaluated(depsgraph, &surface_ob_orig);
1037 if (surface_ob_eval == nullptr) {
1038 return OPERATOR_CANCELLED;
1039 }
1040 Mesh *surface_me_eval = BKE_object_get_evaluated_mesh(surface_ob_eval);
1041 if (surface_me_eval == nullptr) {
1042 return OPERATOR_CANCELLED;
1043 }
1044
1045 const bke::bvh::Tree &surface_bvh_eval = surface_me_eval->bvh_tris();
1046
1047 const int2 mouse_pos_int_re{event->mval};
1048 const float2 mouse_pos_re{mouse_pos_int_re};
1049
1050 float3 ray_start_wo, ray_end_wo;
1052 depsgraph, region, v3d, mouse_pos_re, ray_start_wo, ray_end_wo, true);
1053
1054 const CurvesSurfaceTransforms transforms{curves_ob_orig, &surface_ob_orig};
1055
1056 const float3 ray_start_su = math::transform_point(transforms.world_to_surface, ray_start_wo);
1057 const float3 ray_end_su = math::transform_point(transforms.world_to_surface, ray_end_wo);
1058 const float3 ray_direction_su = math::normalize(ray_end_su - ray_start_su);
1059
1060 const bke::bvh::Ray ray(ray_start_su, ray_direction_su);
1061 const std::optional<bke::bvh::RayHit> ray_hit = surface_bvh_eval.ray_intersect(ray);
1062 if (!ray_hit) {
1063 WM_global_report(RPT_ERROR, "Cursor must be over the surface mesh");
1064 return OPERATOR_CANCELLED;
1065 }
1066
1067 const float3 hit_pos_su = ray_hit->position(ray);
1068 const float3 hit_normal_su = math::normalize(ray_hit->normal);
1069
1070 const float3 hit_pos_cu = math::transform_point(transforms.surface_to_curves, hit_pos_su);
1071 const float3 hit_normal_cu = math::normalize(
1072 math::transform_direction(transforms.surface_to_curves_normal, hit_normal_su));
1073
1074 MinDistanceEditData *op_data = MEM_new<MinDistanceEditData>(__func__);
1075 op_data->curves_to_world_mat = transforms.curves_to_world;
1076 op_data->normal_cu = hit_normal_cu;
1077 op_data->pos_cu = hit_pos_cu;
1078 op_data->initial_mouse = event->xy;
1081
1082 if (op_data->initial_minimum_distance <= 0.0f) {
1083 op_data->initial_minimum_distance = 0.01f;
1084 }
1085
1086 op->customdata = op_data;
1087
1088 /* Temporarily disable other paint cursors. */
1090 op_data->orig_paintcursors = wm->runtime->paintcursors;
1091 wm->runtime->paintcursors.clear_no_delete();
1092
1093 /* Add minimum distance paint cursor. */
1096
1097 op_data->region = CTX_wm_region(C);
1098 op_data->rv3d = CTX_wm_region_view3d(C);
1099
1101 ED_region_tag_redraw(region);
1103}
1104
1106{
1107 ARegion *region = CTX_wm_region(C);
1108 MinDistanceEditData &op_data = *static_cast<MinDistanceEditData *>(op->customdata);
1109
1110 auto finish = [&]() {
1112
1113 /* Remove cursor. */
1114 WM_paint_cursor_end(static_cast<wmPaintCursor *>(op_data.cursor));
1115 /* Restore original paint cursors. */
1116 wm->runtime->paintcursors = op_data.orig_paintcursors;
1117
1118 ED_region_tag_redraw(region);
1119 MEM_delete(&op_data);
1120 };
1121
1122 switch (event->type) {
1123 case MOUSEMOVE: {
1124 const int2 mouse_pos_int_re{event->xy};
1125 const float2 mouse_pos_re{mouse_pos_int_re};
1126
1127 const float mouse_diff_x = mouse_pos_int_re.x - op_data.initial_mouse.x;
1128 const float factor = powf(2, mouse_diff_x / UI_UNIT_X / 10.0f);
1130 factor;
1131
1132 ED_region_tag_redraw(region);
1134 break;
1135 }
1136 case LEFTMOUSE: {
1137 if (event->val == KM_PRESS) {
1139 finish();
1140 return OPERATOR_FINISHED;
1141 }
1142 break;
1143 }
1144 case RIGHTMOUSE:
1145 case EVT_ESCKEY: {
1147 finish();
1149 return OPERATOR_CANCELLED;
1150 }
1151 default: {
1152 break;
1153 }
1154 }
1155
1157}
1158
1159} // namespace min_distance_edit
1160
1162{
1163 ot->name = "Edit Minimum Distance";
1164 ot->idname = __func__;
1165 ot->description = "Change the minimum distance used by the density brush";
1166
1170
1172}
1173
1174} // namespace ed::sculpt_paint
1175
1176/* -------------------------------------------------------------------- */
1179
1189
1191
1192} // namespace blender
Low-level operations for curves.
General operations, lookup, etc. for blender objects.
#define INT32_MAX
#define INT32_MIN
#define final(a, b, c)
Definition BLI_hash_c.hh:21
#define IFACE_(msgid)
#define RGN_TYPE_ANY
#define SPACE_TYPE_ANY
#define OPERATOR_RETVAL_CHECK(ret)
#define C
Definition RandGen.cpp:29
#define UI_UNIT_X
#define UI_ITEM_NONE
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define ND_MODE
Definition WM_types.hh:464
#define NC_SCENE
Definition WM_types.hh:391
#define ND_TOOLSETTINGS
Definition WM_types.hh:468
#define BLI_assert_unreachable()
#define ELEM(...)
Span< T > as_span() const
Definition BLI_array.hh:254
GArray(Allocator allocator={}) noexcept
const void * data() const
static GVArray from_span(GSpan span)
constexpr IndexRange()=default
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
Definition BLI_span.hh:579
constexpr void fill(const T &value) const
Definition BLI_span.hh:523
constexpr IndexRange index_range() const
Definition BLI_span.hh:676
constexpr const T * end() const
Definition BLI_span.hh:228
constexpr const T * begin() const
Definition BLI_span.hh:224
int64_t size() const
void append(const T &value)
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
std::optional< RayHit > ray_intersect(const Ray &ray) const
Definition bvh.cc:439
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
IndexMask complement(const IndexMask &universe, LinearAllocator<> &memory) const
#define powf(x, y)
#define FLT_MAX
#define attribute(slot)
float distance(float, float) RET
AttrType cpp_type_to_attribute_type(const CPPType &type)
bool has_anything_selected(const VArray< bool > &varray, const IndexRange range_to_check)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, LinearAllocator<> &memory)
VectorSet< Curves * > get_unique_editable_curves(const bContext &C)
bool editable_curves_poll(bContext *C)
bool curves_with_surface_poll(bContext *C)
bool curves_poll(bContext *C)
bool mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports)
static wmOperatorStatus min_distance_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int calculate_points_per_side(bContext *C, MinDistanceEditData &op_data)
static wmOperatorStatus min_distance_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void min_distance_edit_draw(bContext *C, const int2 &, const float2 &, void *customdata)
static int select_grow_update(bContext *C, wmOperator *op, const float mouse_diff_x)
static void update_points_selection(const GrowOperatorDataPerCurve &data, const float distance, MutableSpan< float > points_selection)
static wmOperatorStatus select_grow_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void select_grow_invoke_per_curve(const Curves &curves_id, const Object &curves_ob, const ARegion &region, const View3D &v3d, const RegionView3D &rv3d, GrowOperatorDataPerCurve &curve_op_data)
static wmOperatorStatus select_grow_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus select_random_exec(bContext *C, wmOperator *op)
static void select_random_ui(bContext *, wmOperator *op)
bool curves_sculpt_poll(bContext *C)
std::unique_ptr< CurvesSculptStrokeOperation > new_add_operation()
std::unique_ptr< CurvesSculptStrokeOperation > new_pinch_operation(BrushStrokeMode brush_mode, const Scene &scene)
static wmOperatorStatus sculpt_curves_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void curves_sculptmode_exit(bContext *C)
std::unique_ptr< CurvesSculptStrokeOperation > new_comb_operation()
float brush_strength_get(const Paint &paint, const Brush &brush, const StrokeExtension &stroke_extension)
std::unique_ptr< CurvesSculptStrokeOperation > new_selection_paint_operation(BrushStrokeMode brush_mode, BrushSwitchMode brush_switch_mode, const Scene &scene)
static void SCULPT_CURVES_OT_select_grow(wmOperatorType *ot)
bke::SpanAttributeWriter< float > float_selection_ensure(Curves &curves_id)
static wmOperatorStatus curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
static void CURVES_OT_sculptmode_toggle(wmOperatorType *ot)
static void curves_sculptmode_enter(bContext *C)
std::unique_ptr< CurvesSculptStrokeOperation > new_snake_hook_operation()
bool curves_sculpt_poll_view3d(bContext *C)
static wmOperatorStatus sculpt_curves_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
std::unique_ptr< CurvesSculptStrokeOperation > new_smooth_operation()
std::unique_ptr< CurvesSculptStrokeOperation > new_cut_operation()
std::unique_ptr< CurvesSculptStrokeOperation > new_delete_operation()
std::unique_ptr< CurvesSculptStrokeOperation > new_grow_shrink_operation(const BrushStrokeMode brush_mode, const Scene &scene)
float brush_radius_get(const Paint &paint, const Brush &brush, const StrokeExtension &stroke_extension)
static std::unique_ptr< CurvesSculptStrokeOperation > start_brush_operation(wmOperator &op, Scene &scene, Depsgraph &depsgraph, ARegion &region, View3D &v3d, const Object &object, const StrokeExtension &stroke_start)
static void SCULPT_CURVES_OT_select_random(wmOperatorType *ot)
std::unique_ptr< CurvesSculptStrokeOperation > new_density_operation(BrushStrokeMode brush_mode, const Scene &scene, const Depsgraph &depsgraph, const ARegion &region, const View3D &v3d, const Object &object, const StrokeExtension &stroke_start)
static void SCULPT_CURVES_OT_min_distance_edit(wmOperatorType *ot)
static void sculpt_curves_stroke_cancel(bContext *C, wmOperator *op)
std::unique_ptr< CurvesSculptStrokeOperation > new_slide_operation()
std::unique_ptr< CurvesSculptStrokeOperation > new_puff_operation()
float brush_strength_factor(const Brush &brush, const StrokeExtension &stroke_extension)
float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension)
static void SCULPT_CURVES_OT_brush_stroke(wmOperatorType *ot)
constexpr ParallelGrainSize grain_size(int grain_size)
T distance(const T &a, const T &b)
T length(const VecBase< T, Size > &a)
bool is_zero(const T &a)
CartesianBasis invert(const CartesianBasis &basis)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void parallel_invoke(Functions &&...functions)
Definition BLI_task.hh:197
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
Definition BLI_task.hh:127
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
int RNA_enum_get(PointerRNA *ptr, const char *name)
void wmViewport(const rcti *winrct)
void immAttr4f(uint attr_id, float x, float y, float z, float w)
VecBase< int32_t, 4 > int4
void immEnd()
unsigned int uint
Definition BKE_text.h:55
void wmWindowViewport(const wmWindow *win)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
GPUVertFormat * immVertexFormat()
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1366
void GPU_point_size(float size)
Definition gpu_state.cc:157
void immBegin(GPUPrimType, uint vertex_len)
int RNA_int_get(PointerRNA *ptr, const char *name)
wmWindow * CTX_wm_window(const bContext *C)
void ED_view3d_project_v2(const ARegion *region, const float world[3], float r_region_co[2])
MatBase< float, 4, 4 > float4x4
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
void immUnbindProgram()
bool BKE_brush_use_alpha_pressure(const Brush *brush)
Definition brush.cc:1385
void ED_paint_cursor_start(Paint *paint, bool(*poll)(bContext *C))
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
void BKE_brush_tag_unsaved_changes(Brush *brush)
Definition brush.cc:843
VecBase< float, 4 > float4
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
unsigned int uint32_t
Definition BKE_text.h:81
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void DEG_id_tag_update(ID *id, unsigned int flags)
@ OB_MODE_SCULPT_CURVES
BMesh const char void * data
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR
void GPU_scissor_get(int coords[4])
Definition gpu_state.cc:253
wmWindowManager * CTX_wm_manager(const bContext *C)
void BKE_paint_brushes_ensure(Main *bmain, Paint *paint)
void WM_toolsystem_update_from_context_view3d(bContext *C)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:165
void WM_global_report(eReportType type, const char *message)
@ CURVES_SCULPT_BRUSH_TYPE_COMB
@ CURVES_SCULPT_BRUSH_TYPE_SMOOTH
@ CURVES_SCULPT_BRUSH_TYPE_ADD
@ CURVES_SCULPT_BRUSH_TYPE_SLIDE
@ CURVES_SCULPT_BRUSH_TYPE_DENSITY
@ CURVES_SCULPT_BRUSH_TYPE_PINCH
@ CURVES_SCULPT_BRUSH_TYPE_SNAKE_HOOK
@ CURVES_SCULPT_BRUSH_TYPE_GROW_SHRINK
@ CURVES_SCULPT_BRUSH_TYPE_DELETE
@ CURVES_SCULPT_BRUSH_TYPE_CUT
@ CURVES_SCULPT_BRUSH_TYPE_PUFF
@ CURVES_SCULPT_BRUSH_TYPE_SELECTION_PAINT
RegionView3D * CTX_wm_region_view3d(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void GPU_matrix_projection_set(const float m[4][4])
void GPU_matrix_translate_2f(float x, float y)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, wmPaintCursorPoll poll, wmPaintCursorDraw draw, void *customdata)
void paint_stroke_operator_properties(wmOperatorType *ot)
bool BKE_brush_use_size_pressure(const Brush *brush)
Definition brush.cc:1380
void immAttr1f(uint attr_id, float x)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void GPU_scissor(int x, int y, int width, int height)
Definition gpu_state.cc:178
void immVertex3fv(uint attr_id, const float data[3])
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
Main * CTX_data_main(const bContext *C)
void GPU_matrix_pop_projection()
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)
void paint_init_pivot(Object *ob, Scene *scene, Paint *paint)
Paint * BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
Brush * BKE_paint_brush(Paint *paint)
Scene * CTX_data_scene(const bContext *C)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
VecBase< float, 3 > float3
void ED_operatortypes_sculpt_curves()
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_DISTANCE
Definition RNA_types.hh:313
bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
void GPU_matrix_pop()
void immUniformColor3fvAlpha(const float rgb[3], float a)
void GPU_matrix_push_projection()
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
void GPU_matrix_set(const float m[4][4])
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
float RNA_float_get(PointerRNA *ptr, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
float BKE_brush_alpha_get(const Paint *paint, const Brush *brush)
Definition brush.cc:1454
void GPU_matrix_push()
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
Definition object.cc:4436
MINLINE float clamp_f(float value, float min, float max)
bool WM_paint_cursor_end(wmPaintCursor *handle)
struct BrushCurvesSculptSettings * curves_sculpt_settings
struct ToolSettings * toolsettings
CurvesSculpt * curves_sculpt
wmOperatorStatus modal(bContext *C, wmOperator *op, const wmEvent *event)
void update_step(wmOperator *op, const StrokeStep &stroke_step) override
std::optional< float3 > get_location(float2 mouse, bool force_original) override
SculptCurvesBrushStroke(bContext *C, wmOperator *op, const wmEvent *event)
bool test_start(wmOperator *op, float2 mouse) override
void done(bool is_cancel, bool stroke_started) override
Vector< std::unique_ptr< GrowOperatorDataPerCurve > > per_curve
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(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
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
struct ReportList * reports
struct wmOperatorType * type
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)