diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-26 17:39:01 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-26 17:40:06 +0300 |
commit | 1948681440c011ae3008cd5d2a575eb6d45dc7ec (patch) | |
tree | c1ae82fe27da01caf3efdeab5d99a6b6e30950d8 /source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c | |
parent | 85aafba04c18a849eda08fe3f7d46a515ba455d6 (diff) |
GP: Reduce weight paint data memory footprint
Before, the weight data array was created always, but now only is added when a weight value is assigned.
This change was suggested by algorithm, and both agreed it was good idea.
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index 945afec002d..6435ca1ce70 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -118,7 +118,10 @@ static void gpf_clear_all_strokes(bGPDframe *gpf) static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eBuildGpencil_Transition transition) { bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * num_points, __func__); - MDeformVert *new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__); + MDeformVert *new_dvert = NULL; + if (gps->dvert != NULL) { + new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__); + } /* Which end should points be removed from */ // TODO: free stroke weights @@ -128,14 +131,15 @@ static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eB { /* copy over point data */ memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points); - memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points); + if (gps->dvert != NULL) { + memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points); - /* free unused point weights */ - for (int i = num_points; i < gps->totpoints; i++) { - MDeformVert *dvert = &gps->dvert[i]; - BKE_gpencil_free_point_weights(dvert); + /* free unused point weights */ + for (int i = num_points; i < gps->totpoints; i++) { + MDeformVert *dvert = &gps->dvert[i]; + BKE_gpencil_free_point_weights(dvert); + } } - break; } @@ -149,14 +153,15 @@ static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eB /* copy over point data */ memcpy(new_points, gps->points + offset, sizeof(bGPDspoint) * num_points); - memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points); + if (gps->dvert != NULL) { + memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points); - /* free unused weights */ - for (int i = 0; i < offset; i++) { - MDeformVert *dvert = &gps->dvert[i]; - BKE_gpencil_free_point_weights(dvert); + /* free unused weights */ + for (int i = 0; i < offset; i++) { + MDeformVert *dvert = &gps->dvert[i]; + BKE_gpencil_free_point_weights(dvert); + } } - break; } |