17 const int point_num = BLI_kdtree_2d_find_nearest_n(
30 float distance_sum = 0.0f;
32 distance_sum += nearest_points[
i].dist;
34 if (distance_sum == 0.0f) {
37 float blur_weight_sum = 0.0f;
39 blur_weight_sum += (1.0f - nearest_points[
i].dist / distance_sum) *
40 touched_points.
weights[nearest_points[
i].index];
42 const float blur_weight = blur_weight_sum / (point_num - 1);
67 for (
const int frame_group : drawings_per_frame.
index_range()) {
81 std::atomic<bool> drawing_changed =
false;
84 Array<DrawingWeightData> &drawing_weights = this->drawing_weight_data[frame_group];
88 threading::parallel_for_each(drawing_weights, [&](DrawingWeightData &drawing_weight) {
89 for (const int point_index : drawing_weight.point_positions.index_range()) {
90 const float2 &co = drawing_weight.point_positions[point_index];
93 this->add_point_under_brush_to_brush_buffer(co, drawing_weight, point_index);
104 bool point_changed =
false;
110 this->apply_blur_brush(point, drawing_weight, touched_points);
111 point_changed =
true;
123 drawing_changed.store(
true, std::memory_order_relaxed);
128 BLI_kdtree_2d_free(touched_points.
kdtree);
131 if (drawing_changed) {
142 return std::make_unique<BlurWeightPaintOperation>();
Scene * CTX_data_scene(const bContext *C)
void DEG_id_tag_update(ID *id, unsigned int flags)
IndexRange index_range() const
void on_stroke_done(const bContext &) override
void on_stroke_begin(const bContext &C, const InputSample &start_sample) override
void on_stroke_extended(const bContext &C, const InputSample &extension_sample) override
void ensure_active_vertex_group_in_object()
void get_mouse_input_sample(const InputSample &input_sample, const float brush_widen_factor=1.0f)
Array< Array< DrawingWeightData > > drawing_weight_data
PointsTouchedByBrush create_affected_points_kdtree(const Span< DrawingWeightData > drawing_weights)
void get_brush_settings(const bContext &C, const InputSample &start_sample)
void get_locked_and_bone_deformed_vertex_groups()
GreasePencil * grease_pencil
void init_weight_data_for_drawings(const bContext &C, const Span< ed::greasepencil::MutableDrawingInfo > &drawings, const int frame_group)
void apply_weight_to_point(const BrushPoint &point, const float target_weight, DrawingWeightData &drawing_weight)
void normalize_vertex_weights(MDeformVert &dvert, const int active_vertex_group, const Span< bool > vertex_group_is_locked, const Span< bool > vertex_group_is_bone_deformed)
Array< Vector< MutableDrawingInfo > > retrieve_editable_drawings_grouped_per_frame(const Scene &scene, GreasePencil &grease_pencil)
std::unique_ptr< GreasePencilStrokeOperation > new_weight_paint_blur_operation()
static constexpr int BLUR_NEIGHBOUR_NUM
void parallel_for_each(Range &&range, const Function &function)
Vector< bool > locked_vgroups
Vector< BrushPoint > points_in_brush
MutableSpan< MDeformVert > deform_verts
Array< float2 > point_positions
Vector< bool > bone_deformed_vgroups
Array< bool > point_is_read_only
void WM_event_add_notifier(const bContext *C, uint type, void *reference)