mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix #147195: Grease Pencil: Draw tool implement subdivisions
This implements brush subdivisions as a post processing step. This was simply never implemented. Pull Request: https://projects.blender.org/blender/blender/pulls/159380
This commit is contained in:
parent
60dbeb4abb
commit
e5a91bf45e
2 changed files with 21 additions and 0 deletions
|
|
@ -2026,6 +2026,7 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_post_processing(View3DPanel, Panel)
|
|||
|
||||
col1 = col.column(align=True)
|
||||
col1.prop(gp_settings, "pen_subdivision_steps", text="Subdivisions")
|
||||
col1.active = gp_settings.simplify_pixel_threshold == 0
|
||||
|
||||
col1 = col.column(align=True)
|
||||
col1.prop(gp_settings, "simplify_pixel_threshold", slider=True)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include "GEO_set_curve_type.hh"
|
||||
#include "GEO_simplify_curves.hh"
|
||||
#include "GEO_smooth_curves.hh"
|
||||
#include "GEO_subdivide_curves.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
|
@ -1327,6 +1328,22 @@ static void smooth_stroke(bke::greasepencil::Drawing &drawing,
|
|||
}
|
||||
}
|
||||
|
||||
static void subdivide_stroke(bke::greasepencil::Drawing &drawing,
|
||||
const float subdivisions,
|
||||
const int active_curve)
|
||||
{
|
||||
bke::CurvesGeometry &curves = drawing.strokes_for_write();
|
||||
const IndexRange stroke = IndexRange::from_single(active_curve);
|
||||
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
|
||||
|
||||
Array<int> use_cuts(curves.points_num(), 0);
|
||||
|
||||
use_cuts.as_mutable_span().slice(points_by_curve[active_curve]).fill(subdivisions);
|
||||
const VArray<int> cuts = VArray<int>::from_span(use_cuts.as_span());
|
||||
|
||||
curves = geometry::subdivide_curves(curves, stroke, cuts);
|
||||
}
|
||||
|
||||
static void simplify_stroke(bke::greasepencil::Drawing &drawing,
|
||||
const float epsilon,
|
||||
const int active_curve)
|
||||
|
|
@ -1733,6 +1750,9 @@ void PaintOperation::on_stroke_done(const bContext &C)
|
|||
trim_end_points(drawing, 1e-5f, on_back, active_curve);
|
||||
|
||||
if (do_post_processing) {
|
||||
if (settings->draw_subdivide > 0 && settings->simplify_px == 0.0f) {
|
||||
subdivide_stroke(drawing, settings->draw_subdivide, active_curve);
|
||||
}
|
||||
if (settings->draw_smoothfac > 0.0f && settings->draw_smoothlvl > 0) {
|
||||
smooth_stroke(drawing, settings->draw_smoothfac, settings->draw_smoothlvl, active_curve);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue