diff options
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 439005ca1b4..8b74400e660 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1640,33 +1640,15 @@ float BKE_gpencil_multiframe_falloff_calc( return value; } -/* remove strokes using a material */ -void BKE_gpencil_material_index_remove(bGPdata *gpd, int index) +/* reassign strokes using a material */ +void BKE_gpencil_material_index_reassign(bGPdata *gpd, int totcol, int index) { - bGPDstroke *gps, *gpsn; - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { - for (gps = gpf->strokes.first; gps; gps = gpsn) { - gpsn = gps->next; - if (gps->mat_nr == index) { - if (gps->points) { - MEM_freeN(gps->points); - } - if (gps->dvert) { - BKE_gpencil_free_stroke_weights(gps); - MEM_freeN(gps->dvert); - } - if (gps->triangles) { - MEM_freeN(gps->triangles); - } - BLI_freelinkN(&gpf->strokes, gps); - } - else { - /* reassign strokes */ - if (gps->mat_nr > index) { - gps->mat_nr--; - } + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + /* reassign strokes */ + if ((gps->mat_nr > index) || (gps->mat_nr > totcol - 1)) { + gps->mat_nr--; } } } |