39 const float radius_squared = radius * radius;
48 float3 average_color(0.0f);
53 params, use_selection_masking, memory);
54 if (!point_selection.
is_empty() && do_points) {
61 view_positions[point_i]) < radius_squared)
69 params, use_selection_masking, memory);
70 if (!fill_selection.is_empty() && do_fill) {
75 fill_selection.foreach_index([&](
const int64_t curve_i) {
76 const IndexRange points = points_by_curve[curve_i];
80 curve_view_positions) < radius)
90 if (color_count <= 0) {
93 average_color = average_color / color_count;
95 const ColorGeometry4f mix_color(average_color.x, average_color.y, average_color.z, 1.0f);
100 params, use_selection_masking, memory);
101 if (!point_selection.
is_empty() && do_points) {
107 scene, brush, view_positions[point_i], extension_sample,
params.multi_frame_falloff);
115 params, use_selection_masking, memory);
116 if (!fill_selection.is_empty() && do_fill) {
122 const IndexRange points = points_by_curve[curve_i];
125 scene, brush, curve_view_positions, extension_sample,
params.multi_frame_falloff);
139 return std::make_unique<VertexAverageOperation>();
Scene * CTX_data_scene(const bContext *C)
Low-level operations for curves.
Low-level operations for grease pencil.
Paint * BKE_paint_get_active_from_context(const bContext *C)
Brush * BKE_paint_brush(Paint *paint)
#define GPENCIL_ANY_VERTEX_MASK(flag)
eGP_vertex_SelectMaskFlag
Span< T > as_span() const
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) const
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)
IndexMask point_mask_for_stroke_operation(const GreasePencilStrokeParams ¶ms, bool use_selection_masking, IndexMaskMemory &memory)
Array< float2 > calculate_view_positions(const GreasePencilStrokeParams ¶ms, const IndexMask &selection)
float brush_point_influence(const Scene &scene, const Brush &brush, const float2 &co, const InputSample &sample, float multi_frame_falloff)
float brush_fill_influence(const Scene &scene, 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 Scene &scene, const Brush &brush, float pressure)
T interpolate(const T &a, const T &b, const FactorT &t)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
struct ToolSettings * toolsettings