32 return (centered * this->cell_size_px) +
center;
39 return pos + ((this->size + 1) / 2);
46 if (
pos.x >= 0 &&
pos.x < this->size &&
pos.y >= 0 &&
pos.y < this->size) {
47 return pos.y * this->size +
pos.x;
66void VertexSmearOperation::init_color_grid(
const bContext &C,
const float2 start_position)
78 color_grid_.
center = start_position;
82 const int grid_array_length = color_grid_.
size * color_grid_.
size;
83 color_grid_.
colors.reinitialize(grid_array_length);
98 Array<int> points_per_cell(grid_array_length, 0);
100 const float2 view_pos = view_positions[point_i];
101 const float view_radius = radii[point_i];
106 const int2 bounds_min = bounds_center - (bounds_size / 2);
107 const int2 bounds_max = bounds_center + (bounds_size / 2);
108 if (!(bounds_min.x < color_grid_.
size && bounds_max.x >= 0 &&
109 bounds_min.y < color_grid_.
size && bounds_max.y >= 0))
114 for (
int y = bounds_min.y; y <= bounds_max.y; y++) {
115 for (
int x = bounds_min.x; x <= bounds_max.x; x++) {
123 color_grid_.
colors[cell_i] +=
float4(color.r, color.g, color.b, 1.0f);
124 points_per_cell[cell_i]++;
130 for (
const int cell_i : color_grid_.colors.index_range()) {
131 if (points_per_cell[cell_i] > 0) {
132 color_grid_.
colors[cell_i] *= 1.0f /
float(points_per_cell[cell_i]);
166 const float2 view_pos = view_positions[point_i];
169 if (cell_i == -1 || color_grid_.
colors[cell_i][3] == 0.0f) {
180 params.multi_frame_falloff) *
182 if (influence > 0.0f) {
184 const float alpha = color.a;
197 return std::make_unique<VertexSmearOperation>();
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
GreasePencilStrokeOperationCommon()
void init_stroke(const bContext &C, const InputSample &start_sample)
void foreach_editable_drawing(const bContext &C, FunctionRef< bool(const GreasePencilStrokeParams ¶ms)> fn) const
void on_stroke_done(const bContext &C) override
void on_stroke_extended(const bContext &C, const InputSample &extension_sample) override
void on_stroke_begin(const bContext &C, const InputSample &start_sample) override
void foreach_index(Fn &&fn) const
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
Array< float > calculate_view_radii(const GreasePencilStrokeParams ¶ms, const IndexMask &selection)
IndexMask point_selection_mask(const GreasePencilStrokeParams ¶ms, const bool use_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)
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_smear_operation()
float brush_radius(const Scene &scene, const Brush &brush, float pressure)
T clamp(const T &a, const T &min, const T &max)
T distance(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
int pos_to_index(const int2 pos) const
float2 pos_to_coords(const int2 pos, const float2 center) const
int2 coords_to_pos(const float2 coord, const float2 center) const