[Bf-blender-cvs] [70171cdfdfd] blender-v3.2-release: Fix T98488: GPencil weightpaint not visible if first point is no weight

Antonio Vazquez noreply at git.blender.org
Mon May 30 15:42:11 CEST 2022


Commit: 70171cdfdfd80329f31844bf2b31cfc4dc1376ca
Author: Antonio Vazquez
Date:   Mon May 30 15:41:07 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB70171cdfdfd80329f31844bf2b31cfc4dc1376ca

Fix T98488: GPencil weightpaint not visible if first point is no weight

The problem was because the check was done with the total weights of the first element of the array and if this was null or 0, the weights were not duplicated.

As this bug was introduced fixing T97150 due a problem in the weight data, now instead to duplicate all stroke data to create the perimeter for the PDF/SVG, only the points are duplicated because the weights are not needed. This fix the original bug and also reduce the memory used by the export process.

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

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

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 84621be1960..699f8b356bd 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -867,7 +867,7 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src,
   if (dup_points) {
     gps_dst->points = MEM_dupallocN(gps_src->points);
 
-    if ((gps_src->dvert != NULL) && (gps_src->dvert->totweight > 0)) {
+    if (gps_src->dvert != NULL) {
       gps_dst->dvert = MEM_dupallocN(gps_src->dvert);
       BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
     }
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc
index dd22d64aee1..792474d30ea 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -4209,7 +4209,14 @@ bGPDstroke *BKE_gpencil_stroke_perimeter_from_view(struct RegionView3D *rv3d,
   if (gps->totpoints == 0) {
     return nullptr;
   }
-  bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, true, false);
+  /* Duplicate only points and fill data. Weight and Curve are not needed. */
+  bGPDstroke *gps_temp = (bGPDstroke *)MEM_dupallocN(gps);
+  gps_temp->prev = gps_temp->next = nullptr;
+  gps_temp->triangles = (bGPDtriangle *)MEM_dupallocN(gps->triangles);
+  gps_temp->points = (bGPDspoint *)MEM_dupallocN(gps->points);
+  gps_temp->dvert = nullptr;
+  gps_temp->editcurve = nullptr;
+
   const bool cyclic = ((gps_temp->flag & GP_STROKE_CYCLIC) != 0);
 
   /* If Cyclic, add a new point. */



More information about the Bf-blender-cvs mailing list