13 float average_sum = 0.0f;
16 for (
const BrushPoint &point : drawing_weight.points_in_brush) {
25 return math::clamp(average_sum / point_num, 0.0f, 1.0f);
48 for (
const int frame_group : drawings_per_frame.
index_range()) {
62 std::atomic<bool> drawing_changed =
false;
65 Array<DrawingWeightData> &drawing_weights = this->drawing_weight_data[frame_group];
69 threading::parallel_for_each(drawing_weights, [&](DrawingWeightData &drawing_weight) {
70 for (const int point_index : drawing_weight.point_positions.index_range()) {
71 const float2 &co = drawing_weight.point_positions[point_index];
74 this->add_point_under_brush_to_brush_buffer(co, drawing_weight, point_index);
79 const float average_weight = this->get_average_weight_in_brush_buffer(drawing_weights);
83 bool point_changed =
false;
102 drawing_changed.store(
true, std::memory_order_relaxed);
108 if (drawing_changed) {
119 return std::make_unique<AverageWeightPaintOperation>();
Scene * CTX_data_scene(const bContext *C)
void DEG_id_tag_update(ID *id, unsigned int flags)
IndexRange index_range() const
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 on_stroke_done(const bContext &) 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
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_average_operation()
T clamp(const T &a, const T &min, const T &max)
void parallel_for_each(Range &&range, const Function &function)
Vector< bool > locked_vgroups
Vector< BrushPoint > points_in_brush
MutableSpan< MDeformVert > deform_verts
Vector< bool > bone_deformed_vgroups
Array< bool > point_is_read_only
void WM_event_add_notifier(const bContext *C, uint type, void *reference)