GPv3: Draw Tool: Replace "Input Samples" with "Spacing"

The GPv2 draw tool used a setting called "Input Samples" to
generate points (subdivisions) when two samples are far apart
from one another.

In GPv3 we have the same feature, but with a bit more control.
Users can now specifiy the maximum distance between two
points based on a percentage of the brush size (in pixels).
This commit is contained in:
Falk David
2024-05-29 11:55:59 +02:00
parent 6e76b9f6b3
commit bf676e8973
2 changed files with 6 additions and 3 deletions

View File

@@ -2620,7 +2620,7 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_advanced(View3DPanel, Panel):
row.prop(size_owner, "use_locked_size", expand=True)
col.separator()
col.prop(gp_settings, "input_samples")
col.prop(brush, "spacing", slider=True)
col.separator()
col.prop(gp_settings, "active_smooth_factor")

View File

@@ -542,8 +542,11 @@ struct PaintOperationExecutor {
/* If the next sample is far away, we subdivide the segment to add more points. */
int new_points_num = 1;
const float distance_px = math::distance(coords, prev_coords);
if (distance_px > float(settings_->input_samples)) {
const int subdivisions = int(math::floor(distance_px / float(settings_->input_samples))) - 1;
/* TODO: Do we need to calculate the screen space brush size here? */
const float max_spacing_px = (float(brush_->spacing) / 100.0f) *
BKE_brush_size_get(scene, brush_);
if (distance_px > max_spacing_px) {
const int subdivisions = int(math::floor(distance_px / max_spacing_px)) - 1;
new_points_num += subdivisions;
}