[Bf-blender-cvs] [c10f834b327] soc-2019-npr: GPENCIL: Prevent sampling from crashing. Need a new implementation to calculate acturate segment count.

YimingWu noreply at git.blender.org
Tue Jun 25 08:35:45 CEST 2019


Commit: c10f834b3278f0e5fbd8c8d37ae0418672d17adf
Author: YimingWu
Date:   Tue Jun 25 14:33:07 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBc10f834b3278f0e5fbd8c8d37ae0418672d17adf

GPENCIL: Prevent sampling from crashing. Need a new implementation to calculate acturate segment count.

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

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

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 30f0f80fb7e..afef9a8424f 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1538,9 +1538,10 @@ bool BKE_gpencil_sample_stroke(bGPDstroke *gps, float dist)
     pt1 = &gps->points[i];
     copy_v3_v3(this_coord, &pt1->x);
     length += len_v3v3(last_coord, this_coord);
+    copy_v3_v3(last_coord, &pt1->x);
   }
 
-  int count = (int)(length / dist) + 1;
+  int count = (int)(length / dist) + 3; /* Head + tail + float point precision tolerance */
 
   bGPDspoint *new_pt = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points_sampled");
   MDeformVert *new_dv = NULL;



More information about the Bf-blender-cvs mailing list