Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2018-08-26 17:39:01 +0300
committerAntonioya <blendergit@gmail.com>2018-08-26 17:40:06 +0300
commit1948681440c011ae3008cd5d2a575eb6d45dc7ec (patch)
treec1ae82fe27da01caf3efdeab5d99a6b6e30950d8 /source/blender/editors/gpencil/gpencil_primitive.c
parent85aafba04c18a849eda08fe3f7d46a515ba455d6 (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/editors/gpencil/gpencil_primitive.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 2dfdeeba0b6..6fa7d0b7a81 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -182,7 +182,6 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
/* allocate memory for storage points, but keep empty */
gps->totpoints = 0;
gps->points = MEM_callocN(sizeof(bGPDspoint), "gp_stroke_points");
- gps->dvert = MEM_callocN(sizeof(MDeformVert), "gp_stroke_weights");
/* initialize triangle memory to dummy data */
gps->tot_triangles = 0;
gps->triangles = NULL;
@@ -322,7 +321,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* realloc points to new size */
/* TODO: only do this if the size has changed? */
gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * tgpi->tot_edges);
- gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * tgpi->tot_edges);
+ if (gps->dvert != NULL) {
+ gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * tgpi->tot_edges);
+ }
gps->totpoints = tgpi->tot_edges;
/* compute screen-space coordinates for points */
@@ -344,7 +345,6 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* convert screen-coordinates to 3D coordinates */
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
- MDeformVert *dvert = &gps->dvert[i];
tGPspoint *p2d = &points2D[i];
@@ -355,8 +355,11 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
pt->strength = tgpi->brush->gpencil_settings->draw_strength;
pt->time = 0.0f;
- dvert->totweight = 0;
- dvert->dw = NULL;
+ if (gps->dvert != NULL) {
+ MDeformVert *dvert = &gps->dvert[i];
+ dvert->totweight = 0;
+ dvert->dw = NULL;
+ }
}
/* if axis locked, reproject to plane locked */