37 const float radius_squared = radius * radius;
46 float3 average_color(0.0f);
51 params, use_selection_masking, memory);
52 if (!point_selection.
is_empty() && do_points) {
59 view_positions[point_i]) < radius_squared)
67 params, use_selection_masking, memory);
68 if (!fill_selection.is_empty() && do_fill) {
74 fill_selection.foreach_index([&](
const int64_t fill_i) {
76 for (
const int curve_i :
curves) {
77 const IndexRange points = points_by_curve[curve_i];
81 curve_view_positions) < radius)
92 if (color_count <= 0) {
95 average_color = average_color / color_count;
104 params, use_selection_masking, memory);
105 if (!point_selection.
is_empty() && do_points) {
114 view_positions[point_i],
125 params, use_selection_masking, memory);
126 if (!fill_selection.is_empty() && do_fill) {
134 params,
curves.curves_range());
136 fill_selection.foreach_index(
138 const Span<int> fill_curves = fills[fill_i];
141 float influence = 0.0f;
143 const IndexRange points = points_by_curve[curve];
148 curve_view_positions,
168 return std::make_unique<VertexAverageOperation>();
Low-level operations for curves.
Low-level operations for grease pencil.
Span< T > as_span() const
static IndexMask from_indices(Span< T > indices, LinearAllocator<> &memory)
constexpr const T & first() const
OffsetIndices< int > points_by_curve() const
VArray< ColorGeometry4f > vertex_colors() const
std::optional< GroupedSpan< int > > fills() const
const bke::CurvesGeometry & strokes() const
VArray< ColorGeometry4f > fill_colors() const
MutableSpan< ColorGeometry4f > fill_colors_for_write()
MutableSpan< ColorGeometry4f > vertex_colors_for_write()
GreasePencilStrokeOperationCommon()=default
void init_stroke(const bContext &C, const InputSample &start_sample)
void foreach_editable_drawing(const bContext &C, FunctionRef< bool(const GreasePencilStrokeParams ¶ms, const DeltaProjectionFunc &projection_fn)> fn) const
void on_stroke_begin(const bContext &C, const InputSample &start_sample) override
void on_stroke_done(const bContext &C) override
void on_stroke_extended(const bContext &C, const InputSample &extension_sample) override
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
void mix_color(float fac, float4 col1, float4 col2, float4 &outcol)
float closest_distance_to_surface_2d(const float2 pt, const Span< float2 > verts)
IndexMask fill_mask_for_stroke_operation(const GreasePencilStrokeParams ¶ms, bool use_selection_masking, IndexMaskMemory &memory)
bool do_vertex_color_fill(const Brush &brush)
Array< float2 > view_positions_from_curve_mask(const GreasePencilStrokeParams ¶ms, const IndexMask &curve_mask)
IndexMask point_mask_for_stroke_operation(const GreasePencilStrokeParams ¶ms, bool use_selection_masking, IndexMaskMemory &memory)
float brush_point_influence(const Paint &paint, const Brush &brush, const float2 &co, const InputSample &sample, float multi_frame_falloff)
Array< float2 > view_positions_from_point_mask(const GreasePencilStrokeParams ¶ms, const IndexMask &point_mask)
float brush_fill_influence(const Paint &paint, const Brush &brush, Span< float2 > fill_positions, const InputSample &sample, float multi_frame_falloff)
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_average_operation()
bool do_vertex_color_points(const Brush &brush)
float brush_radius(const Paint &paint, const Brush &brush, float pressure)
constexpr ParallelGrainSize grain_size(int grain_size)
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
T interpolate(const T &a, const T &b, const FactorT &t)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T max(const T &a, const T &b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool ED_grease_pencil_any_vertex_mask_selection(const ToolSettings *tool_settings)
Paint * BKE_paint_get_active_from_context(const bContext *C)
Brush * BKE_paint_brush(Paint *paint)
Scene * CTX_data_scene(const bContext *C)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
struct ToolSettings * toolsettings
float multi_frame_falloff
bke::greasepencil::Drawing & drawing