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>2019-07-21 00:01:19 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-07-30 18:11:56 +0300
commit7f29fc7415a49d5688efbe10fa0a81b174d49435 (patch)
tree5feca8d0936990eb434cd860e716fc7316773bfb /source/blender/editors/gpencil/gpencil_fill.c
parentf69e57a53fab92d549a90a0198b86ff766ba0da2 (diff)
Fix T65691: GPencil Drawing long strokes turn invisible
There was a fixed limit to the number of points available in a buffer stroke. Now, the array is expanded as needed using a predefined number of points for each expansion, instead to add one by one. This is done to reduce the number of times the memory allocation is required. As part of the fix, some variables have been renamed to reflect better their use.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_fill.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index d914cdea442..1ac4471547e 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -135,7 +135,7 @@ typedef struct tGPDfill {
short fill_factor;
/** number of elements currently in cache */
- short sbuffer_size;
+ short sbuffer_used;
/** temporary points */
void *sbuffer;
/** depth array for reproject */
@@ -918,7 +918,7 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
{
tGPspoint *ptc;
ToolSettings *ts = tgpf->scene->toolsettings;
- int totpoints = tgpf->sbuffer_size;
+ int totpoints = tgpf->sbuffer_used;
int i = 0;
if (totpoints == 0) {
@@ -984,7 +984,7 @@ static void gpencil_points_from_stack(tGPDfill *tgpf)
return;
}
- tgpf->sbuffer_size = (short)totpoints;
+ tgpf->sbuffer_used = (short)totpoints;
tgpf->sbuffer = MEM_callocN(sizeof(tGPspoint) * totpoints, __func__);
point2D = tgpf->sbuffer;
@@ -1020,7 +1020,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
MDeformVert *dvert = NULL;
tGPspoint *point2D;
- if (tgpf->sbuffer_size == 0) {
+ if (tgpf->sbuffer_used == 0) {
return;
}
@@ -1041,8 +1041,8 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
gps->mat_nr = BKE_gpencil_object_material_ensure(tgpf->bmain, tgpf->ob, tgpf->mat);
/* allocate memory for storage points */
- gps->totpoints = tgpf->sbuffer_size;
- gps->points = MEM_callocN(sizeof(bGPDspoint) * tgpf->sbuffer_size, "gp_stroke_points");
+ gps->totpoints = tgpf->sbuffer_used;
+ gps->points = MEM_callocN(sizeof(bGPDspoint) * tgpf->sbuffer_used, "gp_stroke_points");
/* initialize triangle memory to dummy data */
gps->tot_triangles = 0;
@@ -1069,7 +1069,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
dvert = gps->dvert;
}
- for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) {
+ for (int i = 0; i < tgpf->sbuffer_used && point2D; i++, point2D++, pt++) {
/* convert screen-coordinates to 3D coordinates */
gp_stroke_convertcoords_tpoint(tgpf->scene,
tgpf->ar,
@@ -1120,7 +1120,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
}
/* if parented change position relative to parent object */
- for (int a = 0; a < tgpf->sbuffer_size; a++) {
+ for (int a = 0; a < tgpf->sbuffer_used; a++) {
pt = &gps->points[a];
gp_apply_parent_point(tgpf->depsgraph, tgpf->ob, tgpf->gpd, tgpf->gpl, pt);
}
@@ -1225,7 +1225,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->lock_axis = ts->gp_sculpt.lock_axis;
tgpf->oldkey = -1;
- tgpf->sbuffer_size = 0;
+ tgpf->sbuffer_used = 0;
tgpf->sbuffer = NULL;
tgpf->depth_arr = NULL;