[Bf-blender-cvs] [e3ad8a951b3] temp-npr-gpencil-modifiers: Gpencil: Add BKE_gpencil_add_stroke_existing_style() function.

YimingWu noreply at git.blender.org
Sat Nov 2 06:36:02 CET 2019


Commit: e3ad8a951b3915bc9cc9c25bc0155284b4d89102
Author: YimingWu
Date:   Wed Oct 30 19:49:18 2019 +0800
Branches: temp-npr-gpencil-modifiers
https://developer.blender.org/rBe3ad8a951b3915bc9cc9c25bc0155284b4d89102

Gpencil: Add BKE_gpencil_add_stroke_existing_style() function.

This additionally copies the temp drawing color fields in gps->runtime.
So that when adding new strokes in the modifier the style is preserved.

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

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

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 564844f04e3..21356db8abf 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -125,6 +125,12 @@ struct bGPDstroke *BKE_gpencil_add_stroke(struct bGPDframe *gpf,
                                           int totpoints,
                                           short thickness);
 
+struct bGPDstroke *BKE_gpencil_add_stroke_existing_style(struct bGPDframe *gpf,
+                                                         struct bGPDstroke *existing,
+                                                         int mat_idx,
+                                                         int totpoints,
+                                                         short thickness);
+
 /* Stroke and Fill - Alpha Visibility Threshold */
 #define GPENCIL_ALPHA_OPACITY_THRESH 0.001f
 #define GPENCIL_STRENGTH_MIN 0.003f
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 9fb287c2155..1ccc8553d76 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -505,6 +505,18 @@ bGPDstroke *BKE_gpencil_add_stroke(bGPDframe *gpf, int mat_idx, int totpoints, s
   return gps;
 }
 
+/* Add a stroke and copy the temporary drawing color value from one of the existing stroke */
+bGPDstroke *BKE_gpencil_add_stroke_existing_style(
+    bGPDframe *gpf, bGPDstroke *existing, int mat_idx, int totpoints, short thickness)
+{
+  bGPDstroke *gps = BKE_gpencil_add_stroke(gpf, mat_idx, totpoints, thickness);
+  /* Copy runtime color data so that strokes added in the modifier has the style.
+   * There are depsgrapgh reference pointers inside,
+   * change the copy function if interfere with future drawing implementation. */
+  memcpy(&gps->runtime, &existing->runtime, sizeof(bGPDstroke_Runtime));
+  return gps;
+}
+
 /* ************************************************** */
 /* Data Duplication */



More information about the Bf-blender-cvs mailing list