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/editors | |
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/editors')
-rw-r--r-- | source/blender/editors/gpencil/editaction_gpencil.c | 6 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 9 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 28 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_fill.c | 10 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_interpolate.c | 32 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_old.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 45 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 13 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 35 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_ruler.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ruler.c | 2 |
11 files changed, 124 insertions, 62 deletions
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 88f935eb8bf..2c3159692bf 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -492,8 +492,10 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) /* make a copy of stroke, then of its points array */ gpsn = MEM_dupallocN(gps); gpsn->points = MEM_dupallocN(gps->points); - gpsn->dvert = MEM_dupallocN(gps->dvert); - BKE_gpencil_stroke_weights_duplicate(gps, gpsn); + if (gps->dvert != NULL) { + gpsn->dvert = MEM_dupallocN(gps->dvert); + BKE_gpencil_stroke_weights_duplicate(gps, gpsn); + } /* duplicate triangle information */ gpsn->triangles = MEM_dupallocN(gps->triangles); /* append stroke to frame */ diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index ddce148a3a3..4ab344c7861 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -876,6 +876,9 @@ static bool gp_brush_weight_apply( tGP_BrushEditData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2]) { + /* create dvert */ + BKE_gpencil_dvert_ensure(gps); + bGPDspoint *pt = gps->points + pt_index; MDeformVert *dvert = gps->dvert + pt_index; float inf; @@ -1055,8 +1058,10 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) new_stroke = MEM_dupallocN(gps); new_stroke->points = MEM_dupallocN(gps->points); - new_stroke->dvert = MEM_dupallocN(gps->dvert); - BKE_gpencil_stroke_weights_duplicate(gps, new_stroke); + if (gps->dvert != NULL) { + new_stroke->dvert = MEM_dupallocN(gps->dvert); + BKE_gpencil_stroke_weights_duplicate(gps, new_stroke); + } new_stroke->triangles = MEM_dupallocN(gps->triangles); new_stroke->next = new_stroke->prev = NULL; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 81a5fbdf069..d8fb5bed5af 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2921,6 +2921,8 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDspoint *temp_points; const int cuts = RNA_int_get(op->ptr, "number_cuts"); + MDeformVert *temp_dvert = NULL; + MDeformVert *dvert_final = NULL; int totnewpoints, oldtotpoints; int i2; @@ -2942,7 +2944,9 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) /* duplicate points in a temp area */ temp_points = MEM_dupallocN(gps->points); oldtotpoints = gps->totpoints; - + if (gps->dvert != NULL) { + temp_dvert = MEM_dupallocN(gps->dvert); + } /* resize the points arrys */ gps->totpoints += totnewpoints; gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints); @@ -2957,7 +2961,10 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) bGPDspoint *pt = &temp_points[i]; bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert_final = &gps->dvert[i2]; + MDeformVert *dvert = NULL; + if (gps->dvert != NULL) { + dvert = &temp_dvert[i]; + } /* copy current point */ copy_v3_v3(&pt_final->x, &pt->x); @@ -2966,8 +2973,11 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) pt_final->time = pt->time; pt_final->flag = pt->flag; - dvert_final->totweight = 0; - dvert_final->dw = NULL; + if (gps->dvert != NULL) { + dvert_final = &gps->dvert[i2]; + dvert_final->totweight = dvert->totweight; + dvert_final->dw = dvert->dw; + } i2++; /* if next point is selected add a half way point */ @@ -2987,16 +2997,18 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op) pt_final->time = interpf(pt->time, next->time, 0.5f); pt_final->flag |= GP_SPOINT_SELECT; - dvert_final->totweight = 0; - dvert_final->dw = NULL; - + if (gps->dvert != NULL) { + dvert_final->totweight = 0; + dvert_final->dw = NULL; + } i2++; } } } } /* free temp memory */ - MEM_freeN(temp_points); + MEM_SAFE_FREE(temp_points); + MEM_SAFE_FREE(temp_dvert); } } } diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index c6df07ae83e..d3132d78aa4 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -846,7 +846,6 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) /* allocate memory for storage points */ gps->totpoints = tgpf->sbuffer_size; gps->points = MEM_callocN(sizeof(bGPDspoint) * tgpf->sbuffer_size, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * tgpf->sbuffer_size, "gp_stroke_weights"); /* initialize triangle memory to dummy data */ gps->tot_triangles = 0; @@ -865,7 +864,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) pt = gps->points; dvert = gps->dvert; point2D = (tGPspoint *)tgpf->sbuffer; - for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++, dvert++) { + for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) { /* convert screen-coordinates to 3D coordinates */ gp_stroke_convertcoords_tpoint( tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob, @@ -877,8 +876,11 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) pt->strength = 1.0f;; pt->time = 0.0f; - dvert->totweight = 0; - dvert->dw = NULL; + if (gps->dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + dvert++; + } } /* smooth stroke */ diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 6541e9f012a..ccf600a2584 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -1,4 +1,4 @@ -/* +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -119,7 +119,6 @@ static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_t for (int i = 0; i < new_stroke->totpoints; i++) { prev = &gps_from->points[i]; pt = &new_stroke->points[i]; - dvert = &new_stroke->dvert[i]; next = &gps_to->points[i]; /* Interpolate all values */ @@ -128,8 +127,10 @@ static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_t pt->strength = interpf(prev->strength, next->strength, 1.0f - factor); CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); - dvert->totweight = 0; - dvert->dw = NULL; + /* GPXX interpolate dverts */ + //dvert = &new_stroke->dvert[i]; + //dvert->totweight = 0; + //dvert->dw = NULL; } } @@ -301,7 +302,9 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) /* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */ if (gps_from->totpoints > gps_to->totpoints) { new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points) * gps_to->totpoints); - new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + if (new_stroke->dvert != NULL) { + new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + } new_stroke->totpoints = gps_to->totpoints; new_stroke->tot_triangles = 0; new_stroke->flag |= GP_STROKE_RECALC_CACHES; @@ -313,7 +316,9 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) /* need an empty stroke to keep index correct for lookup, but resize to smallest size */ new_stroke->totpoints = 0; new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points)); - new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert)); + if (new_stroke->dvert != NULL) { + new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert)); + } new_stroke->tot_triangles = 0; new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles)); new_stroke->flag |= GP_STROKE_RECALC_CACHES; @@ -587,8 +592,10 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent /* make copy of source stroke, then adjust pointer to points too */ gps_dst = MEM_dupallocN(gps_src); gps_dst->points = MEM_dupallocN(gps_src->points); - gps_dst->dvert = MEM_dupallocN(gps_src->dvert); - BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst); + if (gps_src->dvert != NULL) { + gps_dst->dvert = MEM_dupallocN(gps_src->dvert); + BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst); + } gps_dst->triangles = MEM_dupallocN(gps_src->triangles); gps_dst->flag |= GP_STROKE_RECALC_CACHES; BLI_addtail(&gpf_dst->strokes, gps_dst); @@ -1016,10 +1023,15 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) /* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */ if (gps_from->totpoints > gps_to->totpoints) { /* free weights of removed points */ - BKE_defvert_array_free_elems(gps_from->dvert + gps_to->totpoints, gps_from->totpoints - gps_to->totpoints); + if (gps_from->dvert != NULL) { + BKE_defvert_array_free_elems(gps_from->dvert + gps_to->totpoints, gps_from->totpoints - gps_to->totpoints); + } new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points) * gps_to->totpoints); - new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + + if (new_stroke->dvert != NULL) { + new_stroke->dvert = MEM_recallocN(new_stroke->dvert, sizeof(*new_stroke->dvert) * gps_to->totpoints); + } new_stroke->totpoints = gps_to->totpoints; new_stroke->tot_triangles = 0; new_stroke->flag |= GP_STROKE_RECALC_CACHES; diff --git a/source/blender/editors/gpencil/gpencil_old.c b/source/blender/editors/gpencil/gpencil_old.c index a384d6d7ae8..5c01de55885 100644 --- a/source/blender/editors/gpencil/gpencil_old.c +++ b/source/blender/editors/gpencil/gpencil_old.c @@ -146,8 +146,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op)) { gps->mat_nr = ob->totcol - 1; gps->colorname[0] = '\0'; - /* create weights array */ - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); + /* weights array */ + gps->dvert = NULL; } } } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index b50624d07d2..aa163e02cfe 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -758,13 +758,16 @@ static short gp_stroke_addpoint( /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->runtime.sbuffer_size == 0) { gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); - gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * (gps->totpoints + 1)); + if (gps->dvert != NULL) { + gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * (gps->totpoints + 1)); + } gps->totpoints++; } pts = &gps->points[gps->totpoints - 1]; - dvert = &gps->dvert[gps->totpoints - 1]; - + if (gps->dvert != NULL) { + dvert = &gps->dvert[gps->totpoints - 1]; + } /* special case for poly lines: normally, * depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, @@ -789,8 +792,10 @@ static short gp_stroke_addpoint( pts->uv_fac = pt->uv_fac; pts->uv_rot = pt->uv_rot; - dvert->totweight = 0; - dvert->dw = NULL; + if (gps->dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + } /* force fill recalc */ gps->flag |= GP_STROKE_RECALC_CACHES; @@ -895,7 +900,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; - MDeformVert *dvert; + MDeformVert *dvert = NULL; Brush *brush = p->brush; ToolSettings *ts = p->scene->toolsettings; Depsgraph *depsgraph = p->depsgraph; @@ -949,7 +954,6 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) const int subdivide = brush->gpencil_settings->draw_subdivide; gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); /* initialize triangle memory to dummy data */ gps->triangles = MEM_callocN(sizeof(bGPDtriangle), "GP Stroke triangulation"); @@ -959,7 +963,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) gp_update_cache(p->gpd); /* set pointer to first non-initialized point */ pt = gps->points + (gps->totpoints - totelem); - dvert = gps->dvert + (gps->totpoints - totelem); + if (gps->dvert != NULL) { + dvert = gps->dvert + (gps->totpoints - totelem); + } /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { @@ -975,12 +981,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; + pt++; - dvert->totweight = 0; - dvert->dw = NULL; + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; - pt++; - dvert++; + dvert++; + } } if (totelem == 2) { @@ -995,8 +1003,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; - dvert->totweight = 0; - dvert->dw = NULL; + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + } } /* reproject to plane (only in 3d space) */ @@ -1023,9 +1033,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; - dvert->totweight = 0; - dvert->dw = NULL; - + if (dvert != NULL) { + dvert->totweight = 0; + dvert->dw = NULL; + } } else { float *depth_arr = NULL; 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 */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index cd352579b4a..3e05dcc3004 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -946,7 +946,9 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) /* resize the points arrys */ gps->totpoints += totnewpoints; gps->points = MEM_recallocN(gps->points, sizeof(*gps->points) * gps->totpoints); - gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints); + if (gps->dvert != NULL) { + gps->dvert = MEM_recallocN(gps->dvert, sizeof(*gps->dvert) * gps->totpoints); + } gps->flag |= GP_STROKE_RECALC_CACHES; /* move points from last to first to new place */ @@ -954,8 +956,6 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) for (int i = oldtotpoints - 1; i > 0; i--) { bGPDspoint *pt = &temp_points[i]; bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert = &gps->dvert[i]; - MDeformVert *dvert_final = &gps->dvert[i2]; copy_v3_v3(&pt_final->x, &pt->x); pt_final->pressure = pt->pressure; @@ -965,8 +965,13 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) pt_final->uv_fac = pt->uv_fac; pt_final->uv_rot = pt->uv_rot; - dvert_final->totweight = dvert->totweight; - dvert_final->dw = dvert->dw; + if (gps->dvert != NULL) { + MDeformVert *dvert = &gps->dvert[i]; + MDeformVert *dvert_final = &gps->dvert[i2]; + + dvert_final->totweight = dvert->totweight; + dvert_final->dw = dvert->dw; + } i2 -= 2; } @@ -976,7 +981,6 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) bGPDspoint *pt = &temp_points[i]; bGPDspoint *next = &temp_points[i + 1]; bGPDspoint *pt_final = &gps->points[i2]; - MDeformVert *dvert_final = &gps->dvert[i2]; /* add a half way point */ interp_v3_v3v3(&pt_final->x, &pt->x, &next->x, 0.5f); @@ -987,8 +991,11 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide) pt_final->uv_fac = interpf(pt->uv_fac, next->uv_fac, 0.5f); pt_final->uv_rot = interpf(pt->uv_rot, next->uv_rot, 0.5f); - dvert_final->totweight = 0; - dvert_final->dw = NULL; + if (gps->dvert != NULL) { + MDeformVert *dvert_final = &gps->dvert[i2]; + dvert_final->totweight = 0; + dvert_final->dw = NULL; + } i2 += 2; } @@ -1211,6 +1218,9 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight) CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { if (gps->flag & GP_STROKE_SELECT) { + /* verify the weight array is created */ + BKE_gpencil_dvert_ensure(gps); + for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; MDeformVert *dvert = &gps->dvert[i]; @@ -1234,6 +1244,9 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob) { for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; + if (gps->dvert == NULL) { + continue; + } MDeformVert *dvert = &gps->dvert[i]; if ((pt->flag & GP_SPOINT_SELECT) && (dvert->totweight > 0)) { @@ -1255,6 +1268,9 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob) { for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; + if (gps->dvert == NULL) { + continue; + } MDeformVert *dvert = &gps->dvert[i]; if (BKE_gpencil_vgroup_use_index(dvert, def_nr) > -1.0f) { @@ -1277,6 +1293,9 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob) { for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; + if (gps->dvert == NULL) { + continue; + } MDeformVert *dvert = &gps->dvert[i]; if (BKE_gpencil_vgroup_use_index(dvert, def_nr) > -1.0f) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 5853fa6e3b3..938b4c45181 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -422,7 +422,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup) if (ruler_item->flag & RULERITEM_USE_ANGLE) { gps->totpoints = 3; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j++) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; @@ -433,7 +432,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup) else { gps->totpoints = 2; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j += 2) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 0475159712b..df8d65449e9 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -338,7 +338,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) if (ruler_item->flag & RULERITEM_USE_ANGLE) { gps->totpoints = 3; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j++) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; @@ -349,7 +348,6 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) else { gps->totpoints = 2; pt = gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); - gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); for (j = 0; j < 3; j += 2) { copy_v3_v3(&pt->x, ruler_item->co[j]); pt->pressure = 1.0f; |