From 55162916ca6b4cae67c2cd0edc2980ea9fabf406 Mon Sep 17 00:00:00 2001 From: Falk David Date: Tue, 9 Jul 2024 16:07:56 +0200 Subject: [PATCH] Fix: GPv3: Draw Tool: Prevent `trim_end_points` from removing entire stroke The `trim_end_points` in the draw tool was only supposed to be able to remove end points of the stroke. Make sure to clamp the value so that at least one point remains in the curve. --- source/blender/editors/sculpt_paint/grease_pencil_paint.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc index 1a46d230e9a..9b4d3567284 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc @@ -1266,6 +1266,11 @@ static int trim_end_points(bke::greasepencil::Drawing &drawing, return 0; } + /* Don't remove the entire stroke. Leave at least one point. */ + if (points.size() - num_points_to_remove < 1) { + num_points_to_remove = points.size() - 1; + } + if (!on_back) { curves.resize(curves.points_num() - num_points_to_remove, curves.curves_num()); curves.offsets_for_write().last() = curves.points_num();