[Bf-blender-cvs] [f78e149828f] temp-npr-gpencil-modifiers: Gpencil: Fix length shrinking function. It was a wrong distance accumulator.

YimingWu noreply at git.blender.org
Sun Sep 15 15:21:37 CEST 2019


Commit: f78e149828fb11ec15d8ed09d281ba16b41b48b5
Author: YimingWu
Date:   Sun Sep 15 21:20:39 2019 +0800
Branches: temp-npr-gpencil-modifiers
https://developer.blender.org/rBf78e149828fb11ec15d8ed09d281ba16b41b48b5

Gpencil: Fix length shrinking function.
It was a wrong distance accumulator.

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

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

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 2eda448a762..fd9de765c4f 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1933,9 +1933,9 @@ bool BKE_gpencil_shrink_stroke(bGPDstroke *gps, const float dist)
   int index_start, index_end;
 
   i = 1;
-  while (len1 < dist && gps->totpoints > i) {
+  while (len1 < dist && gps->totpoints > i-1) {
     next_pt = &pt[i];
-    this_len1 = len_v3v3(&next_pt->x, &pt->x);
+    this_len1 = len_v3v3(&pt[i].x, &pt[i+1].x);
     len1 += this_len1;
     cut_len1 = len1 - dist;
     i++;
@@ -1945,7 +1945,7 @@ bool BKE_gpencil_shrink_stroke(bGPDstroke *gps, const float dist)
   i = 2;
   while (len2 < dist && gps->totpoints >= i) {
     second_last = &pt[gps->totpoints - i];
-    this_len2 = len_v3v3(&last_pt->x, &second_last->x);
+    this_len2 = len_v3v3(&second_last[1].x, &second_last->x);
     len2 += this_len2;
     cut_len2 = len2 - dist;
     i++;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
index 29c98eced26..c019245a3da 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
@@ -90,7 +90,7 @@ static void applyLength(bGPDstroke *gps, float length, float percentage)
   if (len < FLT_EPSILON) {
     return;
   }
-  float length2 = len * percentage;
+  float length2 = len * percentage / 2; /* Srinking from two tips. */
 
   stretchOrShrinkStroke(gps, length2);
 }



More information about the Bf-blender-cvs mailing list