diff options
author | Hans Goudey <h.goudey@me.com> | 2021-07-14 17:11:41 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-07-14 17:11:41 +0300 |
commit | 2acebcae24a6cb7cc5dcef6ddc437396e129da46 (patch) | |
tree | 1c902c7ee3dbaf1f3b4bde813e397047cfa0d90f /source/blender/blenkernel | |
parent | 3de3c3c23a930943086ab9719f0abe5c069cc4b5 (diff) |
Cleanup: Avoid duplication in line art stroke generation
The BKE_gpencil_stroke_add_points API function worked well for
creating the primitives in the add object menu, but it expected a
specific data format that doesn't make sense in a dynamic context.
As evidence of that we can see the way source data was duplicated
in the line art file just to use this API function.
This commit solves that problem in two ways:
- Clean up the line art function (this should make it faster too).
- Move/rename the function so its intended use is more clear.
Differential Revision: https://developer.blender.org/D11909
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_gpencil.h | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 26 |
2 files changed, 0 insertions, 37 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index c11c34cb312..1f9c3e766aa 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -154,17 +154,6 @@ bool BKE_gpencil_merge_materials(struct Object *ob, /* statistics functions */ void BKE_gpencil_stats_update(struct bGPdata *gpd); -/* Utilities for creating and populating GP strokes */ -/* - Number of values defining each point in the built-in data - * buffers for primitives (e.g. 2D Monkey) - */ -#define GP_PRIM_DATABUF_SIZE 5 - -void BKE_gpencil_stroke_add_points(struct bGPDstroke *gps, - const float *array, - 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 529096b8523..e13b9d543d7 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -806,32 +806,6 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) /* Utilities for easier bulk-creation of geometry */ /** - * Populate stroke with point data from data buffers. - * \param gps: Grease pencil stroke - * \param array: Flat array of point data values. Each entry has #GP_PRIM_DATABUF_SIZE values. - * \param totpoints: Total of points - * \param mat: 4x4 transform matrix to transform points into the right coordinate space. - */ -void BKE_gpencil_stroke_add_points(bGPDstroke *gps, - const float *array, - const int totpoints, - const float mat[4][4]) -{ - for (int i = 0; i < totpoints; i++) { - bGPDspoint *pt = &gps->points[i]; - const int x = GP_PRIM_DATABUF_SIZE * i; - - pt->x = array[x]; - pt->y = array[x + 1]; - pt->z = array[x + 2]; - mul_m4_v3(mat, &pt->x); - - pt->pressure = array[x + 3]; - pt->strength = array[x + 4]; - } -} - -/** * Create a new stroke, with pre-allocated data buffers. * \param mat_idx: Index of the material * \param totpoints: Total points |