diff options
author | Antonioya <blendergit@gmail.com> | 2019-06-12 16:51:51 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-06-12 16:52:03 +0300 |
commit | d788f5231e81ae2be363f877d04ab93ddc396fa6 (patch) | |
tree | 3baba69a6faf8cd45abe0ba7d5719320066e680c /source/blender/blenkernel/intern/gpencil.c | |
parent | 7a50d078fe4125788dfb084cd23a5164070fe69b (diff) |
Fix T65741: Removing a GPencil Object's Material Slot deletes the strokes assigned to it
This was a design decision, but now we have decided to change it using the active material for the strokes using deleted material.
If the material slot is empty a new material is created to keep the strokes visible.
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--; } } } |