[Bf-blender-cvs] [236ef11a074] master: GPencil: Fix cyclic flag cleared by simplify modifier

Henrik Dick noreply at git.blender.org
Thu Mar 17 14:14:39 CET 2022


Commit: 236ef11a0746a572e29e75fd1095d9621b567b41
Author: Henrik Dick
Date:   Thu Mar 17 14:09:29 2022 +0100
Branches: master
https://developer.blender.org/rB236ef11a0746a572e29e75fd1095d9621b567b41

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

===================================================================

M	source/blender/blenkernel/intern/gpencil_geom.cc

===================================================================

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);



More information about the Bf-blender-cvs mailing list