[Bf-blender-cvs] [09b6834877c] temp-gpencil-io: GPencil: Fix missing segment exporting cyclic strokes

Antonio Vazquez noreply at git.blender.org
Wed Jan 20 13:03:34 CET 2021


Commit: 09b6834877c1c20004059a4620762d9a8ee1fa2b
Author: Antonio Vazquez
Date:   Wed Jan 20 13:03:28 2021 +0100
Branches: temp-gpencil-io
https://developer.blender.org/rB09b6834877c1c20004059a4620762d9a8ee1fa2b

GPencil: Fix missing segment exporting cyclic strokes

When use perimeter, the cyclic segment was missing. Now a new point is added to the temp stroke to have a full closed figure.

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

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

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

diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 0b189fd6ce4..5c77fd35e5d 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -3892,6 +3892,21 @@ bGPDstroke *BKE_gpencil_stroke_perimeter_from_view(struct RegionView3D *rv3d,
     return NULL;
   }
   bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, true, false);
+  const bool cyclic = ((gps_temp->flag & GP_STROKE_CYCLIC) != 0);
+
+  /* If Cyclic, add a new point. */
+  if ((cyclic) && (gps_temp->totpoints > 1)) {
+    gps_temp->totpoints++;
+    gps_temp->points = MEM_recallocN(gps_temp->points,
+                                     sizeof(*gps_temp->points) * gps_temp->totpoints);
+    bGPDspoint *pt_src = &gps_temp->points[0];
+    bGPDspoint *pt_dst = &gps_temp->points[gps_temp->totpoints - 1];
+    copy_v3_v3(&pt_dst->x, &pt_src->x);
+    pt_dst->pressure = pt_src->pressure;
+    pt_dst->strength = pt_src->strength;
+    pt_dst->uv_fac = 1.0f;
+    pt_dst->uv_rot = 0;
+  }
 
   BKE_gpencil_stroke_to_view_space(rv3d, gps_temp, diff_mat);
   int num_perimeter_points = 0;



More information about the Bf-blender-cvs mailing list