[Bf-blender-cvs] [1957304f9b8] greasepencil-object: GPencil: Spread the point os sampled points

Antonio Vazquez noreply at git.blender.org
Wed Jun 24 16:01:37 CEST 2020


Commit: 1957304f9b80bef9b9622e83b3aa7e46e7f6c5c7
Author: Antonio Vazquez
Date:   Wed Jun 24 16:00:33 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB1957304f9b80bef9b9622e83b3aa7e46e7f6c5c7

GPencil: Spread the point os sampled points

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

M	source/blender/editors/gpencil/gpencil_utils.c

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

diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 2db8ef27116..201ee7b5128 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -3145,7 +3145,7 @@ void ED_gpencil_stroke_buffer_spread_segment(struct Brush *brush,
     return;
   }
 
-  const int totpoints = to_index - from_index;
+  const int totpoints = to_index - from_index - 1;
 
   /* Increase the buffer size to hold the new points.
    * As the function add 1, add only spread point minus 1. */
@@ -3156,11 +3156,24 @@ void ED_gpencil_stroke_buffer_spread_segment(struct Brush *brush,
   gpd->runtime.sbuffer_used++;
 
   /* Move original points to the right index depending of spread value. */
+  int step = spread + 1;
+  int offset = gpd->runtime.sbuffer_used - 1;
   for (int i = totpoints; i > 0; i--) {
-    tGPspoint *pt_orig = ((tGPspoint *)(gpd->runtime.sbuffer) + from_index + i);
-    tGPspoint *pt_dst = ((tGPspoint *)(gpd->runtime.sbuffer) + from_index + (spread * i));
+    tGPspoint *pt_orig = ((tGPspoint *)(gpd->runtime.sbuffer) + from_index + i + 1);
+    tGPspoint *pt_dst = ((tGPspoint *)(gpd->runtime.sbuffer) + offset);
     gpencil_copy_buffer_point(pt_orig, pt_dst);
+    offset -= step;
   }
 
-  /* Copy each point is his segment. */
+  /* Copy each point to its segment. */
+  for (int i = 0; i < totpoints; i++) {
+    int idx = from_index + (step * i) + 1;
+    tGPspoint *pt_orig = ((tGPspoint *)(gpd->runtime.sbuffer) + idx);
+    for (int x = 0; x < spread; x++) {
+      tGPspoint *pt_dst = ((tGPspoint *)(gpd->runtime.sbuffer) + idx + x + 1);
+      gpencil_copy_buffer_point(pt_orig, pt_dst);
+    }
+    /* Spread the points. */
+    gpencil_spread_points(brush, gsc, spread, idx);
+  }
 }



More information about the Bf-blender-cvs mailing list