Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Dick <hen-di@web.de>2022-03-17 16:09:29 +0300
committerHenrik Dick <hen-di@web.de>2022-03-17 16:09:29 +0300
commit236ef11a0746a572e29e75fd1095d9621b567b41 (patch)
tree3a96d7920a8352054be43c074afd6a2dce99b2e2
parentd0968a9c52019b817c001562adbb875780d94786 (diff)
GPencil: Fix cyclic flag cleared by simplify modifier
Change the sample mode to don't duplicate the last vertex of the stroke and instead use the cyclic flag to close previously cyclic strokes. This is necessary for the following modifiers. Reviewed By: NicksBest Differential Revision: http://developer.blender.org/D14359
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc
index e4ed2a40f10..a5eff1f9d5a 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -451,6 +451,10 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
}
/* TODO: Implement feature point preservation. */
int count = stroke_march_count(gps, dist, sharp_threshold);
+ const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
+ if (is_cyclic) {
+ count--;
+ }
bGPDspoint *new_pt = (bGPDspoint *)MEM_callocN(sizeof(bGPDspoint) * count,
"gp_stroke_points_sampled");
@@ -499,6 +503,9 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
&ratio_result,
&index_from,
&index_to)) > -1) {
+ if (is_cyclic && next_point_index == 0) {
+ break; /* last point finished */
+ }
pt2 = &new_pt[i];
copy_v3_v3(&pt2->x, last_coord);
new_pt[i].pressure = pressure;
@@ -533,10 +540,9 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
gps->dvert = new_dv;
}
+ BLI_assert(i == count);
gps->totpoints = i;
- gps->flag &= (~GP_STROKE_CYCLIC);
-
/* Calc geometry data. */
BKE_gpencil_stroke_geometry_update(gpd, gps);