[Bf-blender-cvs] [d32e08aecf8] greasepencil-refactor: GPencil: New function to create strokes

Antonio Vazquez noreply at git.blender.org
Tue Feb 4 17:38:13 CET 2020


Commit: d32e08aecf8e74cf8699b63c1c6a607a14db4351
Author: Antonio Vazquez
Date:   Tue Feb 4 17:36:47 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBd32e08aecf8e74cf8699b63c1c6a607a14db4351

GPencil: New function to create strokes

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

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 079d964c9bc..495fe4eb7f6 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -143,6 +143,7 @@ void BKE_gpencil_stroke_add_points(struct bGPDstroke *gps,
                                    const int totpoints,
                                    const float mat[4][4]);
 
+struct bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness);
 struct bGPDstroke *BKE_gpencil_stroke_add(
     struct bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head);
 
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 4aae1525d81..6b2fcf8334d 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -474,9 +474,8 @@ void BKE_gpencil_stroke_add_points(bGPDstroke *gps,
   }
 }
 
-/* Create a new stroke, with pre-allocated data buffers */
-bGPDstroke *BKE_gpencil_stroke_add(
-    bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head)
+/* Create a new stroke, with pre-allocated data buffers. */
+bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness)
 {
   /* allocate memory for a new stroke */
   bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
@@ -502,12 +501,23 @@ bGPDstroke *BKE_gpencil_stroke_add(
 
   gps->mat_nr = mat_idx;
 
+  return gps;
+}
+
+/* Create a new stroke and add to frame. */
+bGPDstroke *BKE_gpencil_stroke_add(
+    bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head)
+{
+  bGPDstroke *gps = BKE_gpencil_stroke_new(mat_idx, totpoints, thickness);
+
   /* Add to frame. */
-  if (!insert_at_head) {
-    BLI_addtail(&gpf->strokes, gps);
-  }
-  else {
-    BLI_addhead(&gpf->strokes, gps);
+  if ((gps != NULL) && (gpf != NULL)) {
+    if (!insert_at_head) {
+      BLI_addtail(&gpf->strokes, gps);
+    }
+    else {
+      BLI_addhead(&gpf->strokes, gps);
+    }
   }
 
   return gps;



More information about the Bf-blender-cvs mailing list