91 if (num_handles == 1) {
94 const int64_t num_segments = num_handles - 1;
95 const int64_t num_points = num_segments * resolution;
100 for (
const int64_t segment_i : range) {
101 IndexRange segment_range(segment_i * resolution, resolution);
103 curve_segments[segment_i * 3 + 1],
104 curve_segments[segment_i * 3 + 2],
105 curve_segments[segment_i * 3 + 3],
128 accumulated_lengths_target, accumulated_lengths_src, segment_indices, segment_factors);
131 target, segment_indices, segment_factors, dst.
drop_back(1));
168 fill_guides_brush->
size = 2;
177 fill_guides_brush->
spacing = 100;
182 return fill_guides_brush;
192 float fill_opacity_sum_ = 0.0f;
193 int fill_opacity_count_ = 0;
214 int active_smooth_start_index_ = 0;
220 std::optional<float> last_stroke_placement_depth_;
222 std::optional<int> last_stroke_placement_point_;
228 float accum_distance_ = 0.0f;
232 float stroke_random_radius_factor_;
233 float stroke_random_opacity_factor_;
234 float stroke_random_rotation_factor_;
236 float stroke_random_hue_factor_;
237 float stroke_random_sat_factor_;
238 float stroke_random_val_factor_;
246 bool do_fill_guides_;
250 Brush *saved_active_brush_;
251 Brush *fill_guides_brush_;
258 PaintOperation(
const bool do_fill_guides =
false) : do_fill_guides_(do_fill_guides) {}
318 const int material_index,
319 const bool use_stroke,
329 const std::optional<float> depth = self.placement_.
get_depth(start_coords);
331 start_location = self.placement_.
place(start_coords, *depth);
334 start_location = self.placement_.
project(start_coords);
338 start_location = self.placement_.
project(start_coords);
350 *
settings_, self.stroke_random_radius_factor_, 0.0f, start_radius, start_sample.
pressure);
355 self.stroke_random_opacity_factor_,
361 *
settings_, self.rng_, self.stroke_random_rotation_factor_, start_sample.
pressure);
365 self.stroke_random_hue_factor_,
366 self.stroke_random_sat_factor_,
367 self.stroke_random_val_factor_,
377 self.screen_space_coords_orig_.append(start_coords);
378 self.screen_space_curve_fitted_coords_.append(
Vector<float2>({start_coords}));
379 self.screen_space_jitter_offsets_.append(
float2(0.0f));
380 self.screen_space_smoothed_coords_.append(start_coords);
381 self.screen_space_final_coords_.append(start_coords);
387 const int active_curve = on_back ?
curves.curves_range().first() :
388 curves.curves_range().last();
390 const int last_active_point = curve_points.
last();
393 self.active_smooth_start_index_ = 1;
398 curves.positions_for_write()[last_active_point] = start_location;
401 point_attributes_to_skip.
add_multiple({
"position",
"radius",
"opacity"});
404 point_attributes_to_skip.
add(
"vertex_color");
406 if (use_fill || attributes.
contains(
"fill_color")) {
408 curve_attributes_to_skip.
add(
"fill_color");
412 delta_times.
span[last_active_point] = 0.0f;
413 point_attributes_to_skip.
add(
"delta_time");
420 cyclic.
span[active_curve] = cyclic_stroke;
421 materials.
span[active_curve] = material_index;
422 curve_attributes_to_skip.
add_multiple({
"material_index",
"cyclic"});
429 curve_attributes_to_skip.
add(
"softness");
433 u_scale.
span[active_curve] = 1.0f;
434 curve_attributes_to_skip.
add(
"u_scale");
439 curve_attributes_to_skip.
add(
"aspect_ratio");
445 hide_stroke.
span[active_curve] =
true;
446 curve_attributes_to_skip.
add(
"hide_stroke");
455 fill_id.span[active_curve] = 0;
457 fill_id.span[active_curve] = new_fill_id;
458 curve_attributes_to_skip.
add(
"fill_id");
466 rotations.
span[last_active_point] = start_rotation;
467 point_attributes_to_skip.
add(
"rotation");
476 curve_attributes_to_skip.
add(
"start_cap");
484 curve_attributes_to_skip.
add(
"end_cap");
488 self.fill_opacity_sum_ = use_fill ? start_opacity : 0.0f;
489 self.fill_opacity_count_ = use_fill ? 1 : 0;
491 if (attributes.
contains(
"fill_opacity") ||
492 (use_fill && (start_opacity < 1.0f || hide_fill_while_drawing)))
500 fill_opacities.
span[active_curve] = !hide_fill_while_drawing ? start_opacity : 0.1f;
503 fill_opacities.
span[active_curve] = 1.0f;
505 curve_attributes_to_skip.
add(
"fill_opacity");
513 curve_attributes_to_skip.
add(
"init_time");
516 if (self.do_fill_guides_) {
519 is_fill_boundary.
span[active_curve] =
true;
520 curve_attributes_to_skip.
add(
".is_fill_guide");
521 is_fill_boundary.
finish();
525 curve_attributes_to_skip.
add(
"curve_type");
526 curves.update_curve_types();
529 self.stroke_placement_depths_.append(self.stroke_placement_depths_.is_empty() ?
531 self.stroke_placement_depths_.last());
558 const Span<float2> coords_to_smooth = self.screen_space_coords_orig_.as_span().slice(
562 const float corner_min_radius_px = 5.0f;
563 const float corner_max_radius_px = 30.0f;
564 const int64_t corner_max_samples = 64;
565 const float corner_angle_threshold = 0.6f;
569 corner_min_radius_px,
570 corner_max_radius_px,
572 corner_angle_threshold,
578 const int pre_blur_iterations = 3;
589 const float max_error_threshold_px = 5.0f;
594 const int64_t sample_resolution = 32;
601 MutableSpan<float2> window_coords = self.screen_space_smoothed_coords_.as_mutable_span().slice(
603 const float converging_threshold_px = 0.1f;
604 bool stop_counting_converged =
false;
605 int num_converged = 0;
608 self.screen_space_curve_fitted_coords_[window_i].append(coords_smoothed[window_i]);
609 Span<float2> fit_coords = self.screen_space_curve_fitted_coords_[window_i];
614 if (!stop_counting_converged) {
615 float2 prev_pos = window_coords[window_i];
616 if (
math::distance(new_pos, prev_pos) < converging_threshold_px) {
620 stop_counting_converged =
true;
625 window_coords[window_i] = new_pos;
629 if (num_converged > 0) {
630 self.active_smooth_start_index_ += num_converged;
631 self.screen_space_curve_fitted_coords_.remove(0, num_converged);
636 const int new_points_num,
637 const float brush_radius_px,
638 const float pressure,
642 float jitter_factor = 1.0f;
648 for ([[maybe_unused]]
const int _ :
IndexRange(new_points_num)) {
649 const float rand = self.rng_.
get_float() * 2.0f - 1.0f;
651 self.screen_space_jitter_offsets_.append(cotangent * factor * brush_radius_px);
653 const Span<float2> jitter_slice = self.screen_space_jitter_offsets_.as_mutable_span().slice(
656 self.screen_space_smoothed_coords_.as_mutable_span().slice(active_window);
657 MutableSpan<float2> final_coords = self.screen_space_final_coords_.as_mutable_span().slice(
661 BLI_assert(self.stroke_placement_depths_.size() == self.screen_space_coords_orig_.size());
663 self.stroke_placement_depths_.as_span().slice(active_window);
665 final_coords[window_i] = smoothed_coords[window_i] + jitter_slice[window_i];
666 const std::optional<float> depth = stroke_depths[window_i];
667 positions_slice[window_i] = depth ? self.placement_.
place(final_coords[window_i], *depth) :
668 self.placement_.
project(final_coords[window_i]);
673 final_coords[window_i] = smoothed_coords[window_i] + jitter_slice[window_i];
674 positions_slice[window_i] = self.placement_.
project(final_coords[window_i]);
692 const std::optional<float> depth = self.stroke_placement_depths_.is_empty() ?
694 self.stroke_placement_depths_.last();
724 const int active_curve = on_back ?
curves.curves_range().first() :
725 curves.curves_range().last();
731 self.fill_opacity_sum_ += opacity;
732 self.fill_opacity_count_++;
733 if (!hide_fill_while_drawing) {
737 if (fill_opacities) {
738 fill_opacities.
span[active_curve] = self.fill_opacity_sum_ / self.fill_opacity_count_;
744 const IndexRange curve_points = points_by_curve[active_curve];
745 const int last_active_point = curve_points.
last();
747 const float2 prev_coords = self.screen_space_coords_orig_.last();
748 float prev_radius = self.drawing_->
radii()[last_active_point];
749 const float prev_opacity = self.drawing_->
opacities()[last_active_point];
752 const bool is_first_sample = (curve_points.
size() == 1);
757 if (is_first_sample) {
758 self.smoothed_pen_direction_ = self.screen_space_coords_orig_.last() - coords;
765 constexpr float smoothing_rate_factor = 0.3f;
767 self.screen_space_coords_orig_.last() -
769 smoothing_rate_factor);
773 float radius_factor = 1.0f;
786 radius *= radius_factor;
791 constexpr float point_override_threshold_px = 2.0f;
792 if (distance_px < point_override_threshold_px) {
793 self.accum_distance_ += distance_px;
795 if (!is_first_sample) {
800 self.stroke_random_radius_factor_,
801 self.accum_distance_,
807 self.stroke_random_opacity_factor_,
808 self.accum_distance_,
820 prev_radius = self.drawing_->
radii()[last_active_point];
824 constexpr int max_points_per_pixel = 4;
827 float(brush_radius_px),
828 1.0f /
float(max_points_per_pixel));
830 const int new_points_num = (distance_px > max_spacing_px) ?
835 curves, on_back ==
false, curve_points.
size() + new_points_num);
839 const IndexRange new_points =
curves.points_by_curve()[active_curve].take_back(new_points_num);
850 point_attributes_to_skip.
add_multiple({
"position",
"radius",
"opacity"});
854 for (
const int i :
IndexRange(new_points_num)) {
856 self.stroke_random_radius_factor_,
857 self.accum_distance_ +
866 for (
const int i :
IndexRange(new_points_num)) {
868 self.stroke_random_opacity_factor_,
869 self.accum_distance_ +
881 for (
const int i :
IndexRange(new_points_num)) {
883 *
settings_, self.rng_, self.stroke_random_rotation_factor_, extension_sample.
pressure);
885 point_attributes_to_skip.
add(
"rotation");
895 for (
const int i :
IndexRange(new_points_num)) {
898 self.stroke_random_hue_factor_,
899 self.stroke_random_sat_factor_,
900 self.stroke_random_val_factor_,
901 self.accum_distance_ +
903 new_vertex_colors[i],
907 point_attributes_to_skip.
add(
"vertex_color");
914 float(self.delta_time_),
float(new_delta_time), delta_times.
span.slice(new_points));
915 point_attributes_to_skip.
add(
"delta_time");
919 self.accum_distance_ += distance_px;
922 self.delta_time_ = new_delta_time;
925 self.screen_space_coords_orig_.extend(new_screen_space_coords);
926 self.screen_space_smoothed_coords_.extend(new_screen_space_coords);
927 self.screen_space_final_coords_.extend(new_screen_space_coords);
928 for (
float2 new_position : new_screen_space_coords) {
929 self.screen_space_curve_fitted_coords_.append(
Vector<float2>({new_position}));
932 const std::optional<float> last_depth = self.stroke_placement_depths_.is_empty() ?
934 self.stroke_placement_depths_.last();
935 self.stroke_placement_depths_.append_n_times(last_depth, new_points_num);
939 constexpr int64_t min_active_smoothing_points_num = 8;
940 const IndexRange smooth_window = self.screen_space_coords_orig_.index_range().drop_front(
941 self.active_smooth_start_index_);
942 if (smooth_window.
size() < min_active_smoothing_points_num) {
945 self.stroke_placement_depths_.as_mutable_span().take_back(new_points_num);
947 const std::optional<float> depth = new_depths[i];
949 new_positions[i] = self.placement_.
place(coords, *depth);
952 new_positions[i] = self.placement_.
project(coords);
957 self.placement_.
project(new_screen_space_coords, new_positions);
979 self.screen_space_smoothed_coords_.as_mutable_span().slice(smooth_window);
980 MutableSpan<float2> final_coords = self.screen_space_final_coords_.as_mutable_span().slice(
986 BLI_assert(self.stroke_placement_depths_.size() == self.screen_space_coords_orig_.size());
988 self.stroke_placement_depths_.as_mutable_span().slice(smooth_window);
990 const std::optional<float> depth = stroke_depths[window_i];
991 curve_positions_slice[window_i] = depth ?
992 self.placement_.
place(final_coords[window_i],
994 self.placement_.
project(final_coords[window_i]);
999 curve_positions_slice[window_i] = self.placement_.
project(final_coords[window_i]);
1014 curves.points_range().take_back(new_points_num));
1027 const int active_curve = on_back ?
curves.curves_range().first() :
1028 curves.curves_range().last();
1055 BLI_assert(placement_.use_project_to_stroke() || placement_.use_project_to_surface());
1057 const std::optional<float> new_stroke_placement_depth = placement_.get_depth(
1059 if (!new_stroke_placement_depth) {
1064 switch (snap_mode) {
1066 const float start_depth = last_stroke_placement_depth_ ? *last_stroke_placement_depth_ :
1067 *new_stroke_placement_depth;
1068 const float end_depth = *new_stroke_placement_depth;
1070 last_stroke_placement_point_, start_depth, end_depth);
1072 if (!reprojected_points.
is_empty()) {
1073 last_stroke_placement_point_ = reprojected_points.
one_after_last();
1076 last_stroke_placement_depth_ = new_stroke_placement_depth;
1080 const float start_depth = last_stroke_placement_depth_ ? *last_stroke_placement_depth_ :
1081 *new_stroke_placement_depth;
1082 const float end_depth = *new_stroke_placement_depth;
1084 last_stroke_placement_point_, start_depth, end_depth);
1087 if (!last_stroke_placement_depth_) {
1089 if (!reprojected_points.
is_empty()) {
1090 last_stroke_placement_point_ = reprojected_points.
one_after_last();
1092 last_stroke_placement_depth_ = new_stroke_placement_depth;
1098 if (!last_stroke_placement_depth_) {
1099 const float start_depth = *new_stroke_placement_depth;
1100 const float end_depth = *new_stroke_placement_depth;
1103 last_stroke_placement_depth_ = new_stroke_placement_depth;
1113 const float from_depth,
1114 const float to_depth)
1125 const IndexRange all_points = points_by_curve[active_curve];
1126 BLI_assert(screen_space_final_coords_.size() == all_points.
size());
1143 active_curve_points);
1147 active_curve_points);
1148 const float step_size = 1.0f / std::max(
int(active_points.
size()) - 1, 1);
1152 positions[i] = placement_.place(final_coords[i], *depths[i]);
1155 return active_points;
1167 saved_active_brush_ = current_brush;
1175 saved_active_brush_ =
nullptr;
1178 fill_guides_brush_ =
nullptr;
1191 if (do_fill_guides_) {
1195 Paint *
paint = &scene_->toolsettings->gp_paint->paint;
1198 if (
brush->gpencil_settings ==
nullptr) {
1217 if (placement_.use_project_to_surface() || placement_.use_project_to_stroke()) {
1218 placement_.cache_viewport_depths(depsgraph, region,
view3d);
1226 texture_space_ = texture_space_ *
layer.to_object_space(*object_);
1233 stroke_random_radius_factor_ = rng_.get_float() * 2.0f - 1.0f;
1234 stroke_random_opacity_factor_ = rng_.get_float() * 2.0f - 1.0f;
1235 stroke_random_rotation_factor_ = rng_.get_float() * 2.0f - 1.0f;
1237 stroke_random_hue_factor_ = rng_.get_float() * 2.0f - 1.0f;
1238 stroke_random_sat_factor_ = rng_.get_float() * 2.0f - 1.0f;
1239 stroke_random_val_factor_ = rng_.get_float() * 2.0f - 1.0f;
1249 frame_number_ = scene_->r.cfra;
1274 executor.
execute(*
this,
C, extension_sample);
1281 const float influence,
1282 const int iterations,
1283 const int active_curve)
1334 const float subdivisions,
1335 const int active_curve)
1343 use_cuts.
as_mutable_span().slice(points_by_curve[active_curve]).fill(subdivisions);
1350 const float epsilon,
1351 const int active_curve)
1357 ".draw_tool_screen_space_positions");
1366 curves.cyclic()[active_curve],
1368 screen_space_positions,
1373 if (!points_to_delete.
is_empty()) {
1384 std::array<bke::GeometrySet, 2> geometry_sets;
1399 const int active_curve,
1406 ".draw_tool_screen_space_positions");
1418 stroke, screen_space_positions, curve_mask, curve_mask,
true);
1433 const int active_curve,
1436 const float outline_radius,
1437 const int material_index,
1461 const float epsilon,
1463 const int active_curve)
1470 int64_t num_points_to_remove = 0;
1472 if (radii[
index] < epsilon) {
1473 num_points_to_remove++;
1480 if (num_points_to_remove <= 0) {
1485 if (points.
size() - num_points_to_remove < 1) {
1486 num_points_to_remove = points.
size() - 1;
1491 curves.offsets_for_write().last() =
curves.points_num();
1492 return num_points_to_remove;
1498 const int current_points_num =
curves.points_by_curve()[0].size();
1499 const int new_points_num = current_points_num - num_points_to_remove;
1513 for (
const int src_curve :
curves.curves_range().drop_front(1)) {
1514 offsets[src_curve] = offsets[src_curve] - num_points_to_remove;
1518 return num_points_to_remove;
1523 const int active_curve)
1531 for (
const StringRef selection_attribute_name :
1552 const int active_curve)
1577 Object *ob_arm =
nullptr;
1590 if (amd ==
nullptr) {
1601 if (channel ==
nullptr) {
1610 if (channel ==
nullptr) {
1616 const float4x4 postmat = obinv * ob_arm->object_to_world();
1639 src_offsets.as_span(),
1640 dst_offsets.as_span(),
1644 src_offsets = {curve, curve + 1};
1645 dst_offsets = {0, 1};
1651 src_offsets.as_span(),
1652 dst_offsets.as_span(),
1661 const int current_frame,
1668 if (drawing_info.frame_number == current_frame) {
1676 const int active_curve,
1677 const float threshold,
1691 options.convert_bezier_handles_to_poly_points =
false;
1692 options.convert_bezier_handles_to_catmull_rom_points =
false;
1693 options.keep_bezier_shape_as_nurbs =
true;
1694 options.keep_catmull_rom_shape_as_nurbs =
true;
1699 options.convert_bezier_handles_to_poly_points =
false;
1700 options.convert_bezier_handles_to_catmull_rom_points =
false;
1701 options.keep_bezier_shape_as_nurbs =
true;
1702 options.keep_catmull_rom_shape_as_nurbs =
true;
1714 Paint *
paint = &scene_->toolsettings->gp_paint->paint;
1719 const bool do_automerge_endpoints = (scene_->toolsettings->gpencil_flags &
1732 const IndexRange points = points_by_curve[active_curve];
1741 screen_space_positions.
span.slice(points).copy_from(this->screen_space_final_coords_);
1742 screen_space_positions.
finish();
1744 if (use_fill && hide_fill_while_drawing) {
1749 fill_opacities.
span[active_curve] = fill_opacity_sum_ / fill_opacity_count_;
1756 if (do_post_processing) {
1775 const int material_index = [&]() {
1798 attributes.
remove(
".draw_tool_screen_space_positions");
1802 if (do_automerge_endpoints) {
1803 constexpr float merge_distance = 20.0f;
1807 *region, drawing.
strokes(), layer_to_world, merge_distance, selection, {});
1810 if (do_automerge_endpoints || on_back) {
1817 const bool use_multi_frame_editing = (scene_->toolsettings->gpencil_flags &
1820 if (use_multi_frame_editing) {
1822 drawing.
strokes(), active_curve, frame_number_, on_back, multi_frame_drawings_);
1828 if (do_fill_guides_) {
1838 return std::make_unique<PaintOperation>(do_fill_guides);
Blender kernel action and pose functionality.
Low-level operations for curves.
Low-level operations for grease pencil.
Utility functions for vertex groups in grease pencil objects.
General operations, lookup, etc. for materials.
Platform independent time functions.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
Array(Allocator allocator={}) noexcept
GMutableSpan slice(const int64_t start, int64_t size) const
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr int64_t first() const
constexpr int64_t one_after_last() const
constexpr IndexRange shift(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr IndexRange()=default
constexpr int64_t start() const
static constexpr IndexRange from_single(const int64_t index)
constexpr IndexRange index_range() const
static constexpr IndexRange from_begin_end_inclusive(const int64_t begin, const int64_t last)
constexpr int64_t size() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr MutableSpan drop_back(const int64_t n) const
constexpr IndexRange index_range() const
constexpr void copy_from(Span< T > values) const
constexpr T & last(const int64_t n=0) const
static RandomNumberGenerator from_random_seed()
void add_multiple(Span< Key > keys)
constexpr Span drop_front(int64_t n) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr Span drop_back(int64_t n) const
constexpr int64_t size() const
constexpr const T & last(const int64_t n=0) const
constexpr const T * end() const
constexpr const T * begin() const
Span< T > get_internal_span() const
static VArray from_single(T value, const int64_t size)
static VArray from_span(Span< T > values)
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
bool contains(StringRef name) const
GAttributeReader lookup(const StringRef name) const
MutableSpan< float3 > positions_for_write()
void remove_points(const IndexMask &points_to_delete, const AttributeFilter &attribute_filter)
AttributeAccessor attributes() const
Span< float3 > positions() const
IndexRange curves_range() const
void remove_curves(const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter)
OffsetIndices< int > points_by_curve() const
MutableAttributeAccessor attributes_for_write()
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef name)
GSpanAttributeWriter convert_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter convert_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
GSpanAttributeWriter lookup_for_write_span(StringRef name)
VArray< ColorGeometry4f > vertex_colors() const
MutableSpan< float > opacities_for_write()
MutableSpan< float > radii_for_write()
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
VArray< float > radii() const
void tag_positions_changed()
void tag_topology_changed()
VArray< float > opacities() const
MutableSpan< ColorGeometry4f > fill_colors_for_write()
MutableSpan< ColorGeometry4f > vertex_colors_for_write()
void set_texture_matrices(Span< float4x2 > matrices, const IndexMask &selection)
float4x4 to_world_space(const Object &object) const
constexpr const char * data() const
bool use_project_to_surface() const
std::optional< float > get_depth(float2 co) const
float3 place(float2 co, float depth) const
bool use_project_to_stroke() const
float4x4 to_world_space() const
float3 reproject(float3 pos) const
float3 project(float2 co, bool &clipped) const
friend struct PaintOperationExecutor
bool update_stroke_depth_placement(const InputSample &sample)
PaintOperation(const bool do_fill_guides=false)
void on_stroke_done(const bContext &C) override
void toggle_fill_guides_brush_off(const bContext &C)
void toggle_fill_guides_brush_on(const bContext &C)
void on_stroke_extended(const bContext &C, const InputSample &extension_sample) override
void on_stroke_begin(const bContext &C, const InputSample &start_sample) override
IndexRange interpolate_stroke_depth(std::optional< int > start_point, float from_depth, float to_depth)
CCL_NAMESPACE_BEGIN struct Options options
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void shift_left(GMutableSpan data, int src_begin, int src_end, int dst_begin)
T mix2(float factor, const T &a, const T &b)
void evaluate_segment(const T &point_0, const T &point_1, const T &point_2, const T &point_3, MutableSpan< T > result)
int get_next_available_fill_id(Span< int > fill_ids)
void assign_to_vertex_group_from_mask(CurvesGeometry &curves, const IndexMask &mask, StringRef name, float weight)
CurvesGeometry curves_copy_curve_selection(const CurvesGeometry &curves, const IndexMask &curves_to_copy, const AttributeFilter &attribute_filter)
auto attribute_filter_from_skip_ref(const Span< StringRef > skip)
void fill_attribute_range_default(MutableAttributeAccessor dst_attributes, AttrDomain domain, const AttributeFilter &attribute_filter, IndexRange range)
void copy_attributes_group_to_group(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
Curves * curves_new_nomain(int points_num, int curves_num)
void fill_selection_false(GMutableSpan selection)
Span< StringRef > get_curves_selection_attribute_names(const bke::CurvesGeometry &curves)
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, bke::AttrType create_type, StringRef attribute_name)
bke::CurvesGeometry trim_curve_segment_ends(const bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, const IndexMask &editable_curves, const IndexMask &visible_curves, const bool keep_caps)
float opacity_from_input_sample(const float pressure, const Paint &paint, const Brush *brush, const BrushGpencilSettings *settings)
float randomize_rotation(const BrushGpencilSettings &settings, const float stroke_factor, const float distance, const float pressure)
void resize_single_curve(bke::CurvesGeometry &curves, const bool at_end, const int new_points_num)
float randomize_opacity(const BrushGpencilSettings &settings, const float stroke_factor, const float distance, const float opacity, const float pressure)
ColorGeometry4f randomize_color(const BrushGpencilSettings &settings, const std::optional< BrushColorJitterSettings > &jitter, const float stroke_hue_factor, const float stroke_saturation_factor, const float stroke_value_factor, const float distance, const ColorGeometry4f color, const float pressure)
float randomize_radius(const BrushGpencilSettings &settings, const float stroke_factor, const float distance, const float radius, const float pressure)
IndexMask polyline_detect_corners(Span< float2 > points, const float radius_min, const float radius_max, const int samples_max, const float angle_threshold, IndexMaskMemory &memory)
bke::CurvesGeometry curves_merge_endpoints_by_distance(const ARegion ®ion, const bke::CurvesGeometry &src_curves, const float4x4 &layer_to_world, const float merge_distance, const IndexMask &selection, const bke::AttributeFilter &attribute_filter)
Array< float2 > polyline_fit_curve(Span< float2 > points, const float error_threshold, const IndexMask &corner_mask)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
float4x2 calculate_texture_space(const Scene *scene, const ARegion *region, const float2 &mouse, const DrawingPlacement &placement)
void add_single_curve(bke::greasepencil::Drawing &drawing, const bool at_end)
bke::CurvesGeometry create_curves_outline(const bke::greasepencil::Drawing &drawing, const IndexMask &strokes, const float4x4 &transform, const int corner_subdivisions, const float outline_radius, const float outline_offset, const int material_index)
float radius_from_input_sample(const RegionView3D *rv3d, const ARegion *region, const Paint &paint, const Brush *brush, const float pressure, const float3 &location, const float4x4 &to_world, const BrushGpencilSettings *settings)
static void convert_stroke_type(bke::greasepencil::Drawing &drawing, const int active_curve, const float threshold, const int8_t curve_type)
static void append_stroke_to_multiframe_drawings(const bke::CurvesGeometry &src_strokes, const int curve, const int current_frame, const bool on_back, Span< ed::greasepencil::MutableDrawingInfo > drawings)
std::unique_ptr< GreasePencilStrokeOperation > new_paint_operation(bool do_fill_guides=false)
static StrokeSnapMode get_snap_mode(const Scene &scene)
static void trim_stroke_ends(bke::greasepencil::Drawing &drawing, const int active_curve, const bool on_back)
static float brush_radius_to_pixel_radius(const RegionView3D *rv3d, const Paint *paint, const Brush *brush, const float3 pos)
static float2 arithmetic_mean(Span< float2 > values)
static bke::CurvesGeometry get_single_stroke(const bke::CurvesGeometry &src, const int curve)
static int trim_end_points(bke::greasepencil::Drawing &drawing, const float epsilon, const bool on_back, const int active_curve)
bool brush_using_vertex_color(const GpPaint *gp_paint, const Brush *brush)
static void morph_points_to_curve(Span< float2 > src, Span< float2 > target, MutableSpan< float2 > dst)
static void subdivide_stroke(bke::greasepencil::Drawing &drawing, const float subdivisions, const int active_curve)
static void simplify_stroke(bke::greasepencil::Drawing &drawing, const float epsilon, const int active_curve)
static void process_stroke_weights(const Scene &scene, const Object &object, bke::greasepencil::Drawing &drawing, const int active_curve)
static void smooth_stroke(bke::greasepencil::Drawing &drawing, const float influence, const int iterations, const int active_curve)
static Brush * create_fill_guide_brush()
static void deselect_stroke(Scene *scene, bke::greasepencil::Drawing &drawing, const int active_curve)
static Array< float2 > sample_curve_2d(Span< float2 > positions, const int64_t resolution)
static void outline_stroke(bke::greasepencil::Drawing &drawing, const int active_curve, const float4x4 &viewmat, const ed::greasepencil::DrawingPlacement &placement, const float outline_radius, const int material_index, const bool on_back)
static void linear_interpolation(const T &a, const T &b, MutableSpan< T > dst)
static void add_strokes_to_drawing(const bool on_back, Curves *strokes, bke::greasepencil::Drawing &drawing)
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt, bool allow_merging_instance_references=true)
void smooth_curve_attribute(const IndexMask &curves_to_smooth, const OffsetIndices< int > points_by_curve, const VArray< bool > &point_selection, const VArray< bool > &cyclic, int iterations, float influence, bool smooth_ends, bool keep_shape, GMutableSpan attribute_data)
bke::CurvesGeometry fit_poly_to_bezier_curves(const bke::CurvesGeometry &src_curves, const IndexMask &curve_selection, const VArray< float > &thresholds, const VArray< bool > &corners, FitMethod method, const bke::AttributeFilter &attribute_filter)
bke::CurvesGeometry subdivide_curves(const bke::CurvesGeometry &src_curves, const IndexMask &selection, const VArray< int > &cuts, const bke::AttributeFilter &attribute_filter={})
void curve_simplify(const Span< float3 > positions, const bool cyclic, const float epsilon, const GSpan attribute_data, MutableSpan< bool > points_to_delete)
void gaussian_blur_1D(const GSpan src, int iterations, const VArray< float > &influence_by_point, const bool smooth_ends, const bool keep_shape, const bool is_cyclic, GMutableSpan dst)
bke::CurvesGeometry convert_curves(const bke::CurvesGeometry &src_curves, const IndexMask &selection, CurveType dst_type, const bke::AttributeFilter &attribute_filter, const ConvertCurvesOptions &options={})
void accumulate_lengths(const Span< T > values, const bool cyclic, MutableSpan< float > lengths)
void sample_at_lengths(Span< float > accumulated_segment_lengths, Span< float > sample_lengths, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
void interpolate(const Span< T > src, const Span< int > indices, const Span< float > factors, MutableSpan< T > dst)
T cos(const AngleRadianBase< T > &a)
T distance(const T &a, const T &b)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
CartesianBasis invert(const CartesianBasis &basis)
T interpolate(const T &a, const T &b, const FactorT &t)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T sin(const AngleRadianBase< T > &a)
T max(const T &a, const T &b)
void transform_points(const float4x4 &transform, MutableSpan< float3 > points, bool use_threading=true)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
@ GP_BRUSH_MODE_VERTEXCOLOR
const ListBaseT< bDeformGroup > * BKE_object_defgroup_list(const Object *ob)
MINLINE void copy_v3_v3(float r[3], const float a[3])
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
@ eModifierType_GreasePencilArmature
void BKE_id_free_ex(Main *bmain, void *idv, int flag_orig, bool use_flag_from_idtag)
void BKE_brush_init_gpencil_settings(Brush *brush)
MatBase< float, 4, 4 > float4x4
float BKE_brush_unprojected_radius_get(const Paint *paint, const Brush *brush)
void BKE_curvemapping_init(CurveMapping *cumap)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
@ GP_TOOL_FLAG_CREATE_WEIGHTS
@ GP_TOOL_FLAG_PAINT_ONBACK
@ GP_TOOL_FLAG_AUTOMERGE_STROKE
@ GP_USE_MULTI_FRAME_EDITING
VecBase< float, 2 > float2
void DEG_id_tag_update(ID *id, unsigned int flags)
@ OB_MODE_PAINT_GREASE_PENCIL
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
MatBase< float, 4, 2 > float4x2
bke::AttrDomain ED_grease_pencil_edit_selection_domain_get(const ToolSettings *tool_settings)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
bool BKE_paint_brush_set(Paint *paint, Brush *brush)
int BKE_object_material_index_get(Object *ob, const Material *ma)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void * BKE_id_new_nomain(short type, const char *name)
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
Main * CTX_data_main(const bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
std::optional< BrushColorJitterSettings > BKE_brush_color_jitter_get_settings(const Paint *paint, const Brush *brush)
Brush * BKE_paint_brush(Paint *paint)
double BLI_time_now_seconds()
Material * BKE_grease_pencil_object_material_ensure_from_brush(Main *bmain, Object *ob, Brush *brush)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
@ GP_PROJECT_DEPTH_STROKE_ENDPOINTS
@ GP_PROJECT_DEPTH_STROKE_FIRST
VecBase< float, 3 > float3
@ GP_BRUSH_OUTLINE_STROKE
@ GP_BRUSH_USE_STRENGTH_PRESSURE
@ GP_BRUSH_DISSABLE_LASSO
@ GP_BRUSH_GROUP_SETTINGS
@ GP_BRUSH_USE_CYCLIC_STROKE
@ GP_BRUSH_USE_JITTER_PRESSURE
@ GP_STROKE_CAP_TYPE_ROUND
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
Material * BKE_grease_pencil_object_material_alt_ensure_from_brush(Main *bmain, Object *ob, Brush *brush)
int BKE_object_defgroup_active_index_get(const Object *ob)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float conversion_threshold
struct CurveMapping * curve_sensitivity
struct CurveMapping * curve_jitter
struct CurveMapping * curve_rand_strength
struct CurveMapping * curve_rand_uv
eGP_BrushMode brush_draw_mode
struct CurveMapping * curve_rand_pressure
struct CurveMapping * curve_strength
float draw_random_strength
struct CurveMapping * curve_rand_value
struct CurveMapping * curve_rand_saturation
struct BrushGpencilSettings * gpencil_settings
struct CurveMapping * curve_rand_hue
eBrushUnifiedPaintFlags unified_paint_flags
static MatBase identity()
struct ToolSettings * toolsettings
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
MutableVArraySpan< T > span
PaintOperationExecutor(Scene &scene)
void process_start_sample(PaintOperation &self, const bContext &C, const InputSample &start_sample, const int material_index, const bool use_stroke, const bool use_fill)
GreasePencil * grease_pencil_
void active_smoothing(PaintOperation &self, const IndexRange smooth_window)
void process_extension_sample(PaintOperation &self, const bContext &C, const InputSample &extension_sample)
ColorGeometry4f vertex_color_
ColorGeometry4f fill_color_
BrushGpencilSettings * settings_
bool use_settings_random_
std::optional< BrushColorJitterSettings > jitter_settings_
void active_jitter(PaintOperation &self, const int new_points_num, const float brush_radius_px, const float pressure, const IndexRange active_window, MutableSpan< float3 > curve_positions)
void execute(PaintOperation &self, const bContext &C, const InputSample &extension_sample)