[Bf-blender-cvs] [8c580ec944a] greasepencil-object: GPencil: Fix merge error

Antonio Vazquez noreply at git.blender.org
Thu Aug 8 15:55:57 CEST 2019


Commit: 8c580ec944acf3a0e956dc730688be1cb2a1ee68
Author: Antonio Vazquez
Date:   Thu Aug 8 15:55:41 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rB8c580ec944acf3a0e956dc730688be1cb2a1ee68

GPencil: Fix merge error

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

M	source/blender/blenkernel/intern/gpencil.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index c04afb582c5..73d104961e8 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2723,8 +2723,11 @@ void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short ta
 /* Merge by distance ------------------------------------- */
 /* Reduce a series of points when the distance is below a threshold.
  * Special case for first and last points (both are keeped) for other points,
- * the merge point is interpolated between points.
- *
+ * the merge point always is at first point.
+ * \param gpf: Grease Pencil frame
+ * \param gps: Grease Pencil stroke
+ * \param threshold: Distance between points
+ * \param use_unselected: Set to true to analyze all stroke and not only selected points
  */
 void BKE_gpencil_merge_distance_stroke(bGPDframe *gpf,
                                        bGPDstroke *gps,
@@ -3107,81 +3110,3 @@ void BKE_gpencil_convert_curve(Main *bmain,
   /* Tag for recalculation */
   DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
 }
-
-/* Merge by distance ------------------------------------- */
-/* Reduce a series of points when the distance is below a threshold.
- * Special case for first and last points (both are keeped) for other points,
- * the merge point always is at first point.
- * \param gpf: Grease Pencil frame
- * \param gps: Grease Pencil stroke
- * \param threshold: Distance between points
- * \param use_unselected: Set to true to analyze all stroke and not only selected points
- */
-void BKE_gpencil_merge_distance_stroke(bGPDframe *gpf,
-                                       bGPDstroke *gps,
-                                       const float threshold,
-                                       const bool use_unselected)
-{
-  bGPDspoint *pt = NULL;
-  bGPDspoint *pt_next = NULL;
-  float tagged = false;
-  /* Use square distance to speed up loop */
-  const float th_square = threshold * threshold;
-  /* Need to have something to merge. */
-  if (gps->totpoints < 2) {
-    return;
-  }
-  int i = 0;
-  int step = 1;
-  while ((i < gps->totpoints - 1) && (i + step < gps->totpoints)) {
-    pt = &gps->points[i];
-    if (pt->flag & GP_SPOINT_TAG) {
-      i++;
-      step = 1;
-      continue;
-    }
-    pt_next = &gps->points[i + step];
-    /* Do not recalc tagged points. */
-    if (pt_next->flag & GP_SPOINT_TAG) {
-      step++;
-      continue;
-    }
-    /* Check if contiguous points are selected. */
-    if (!use_unselected) {
-      if (((pt->flag & GP_SPOINT_SELECT) == 0) || ((pt_next->flag & GP_SPOINT_SELECT) == 0)) {
-        i++;
-        step = 1;
-        continue;
-      }
-    }
-    float len_square = len_squared_v3v3(&pt->x, &pt_next->x);
-    if (len_square <= th_square) {
-      tagged = true;
-      if (i != gps->totpoints - 1) {
-        /* Tag second point for delete. */
-        pt_next->flag |= GP_SPOINT_TAG;
-      }
-      else {
-        pt->flag |= GP_SPOINT_TAG;
-      }
-      /* Jump to next pair of points, keeping first point segment equals.*/
-      step++;
-    }
-    else {
-      /* Analyze next point. */
-      i++;
-      step = 1;
-    }
-  }
-
-  /* Always untag extremes. */
-  pt = &gps->points[0];
-  pt->flag &= ~GP_SPOINT_TAG;
-  pt = &gps->points[gps->totpoints - 1];
-  pt->flag &= ~GP_SPOINT_TAG;
-
-  /* Dissolve tagged points */
-  if (tagged) {
-    BKE_gpencil_dissolve_points(gpf, gps, GP_SPOINT_TAG);
-  }
-}



More information about the Bf-blender-cvs mailing list