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:
authorAntonio Vazquez <blendergit@gmail.com>2020-08-12 20:46:15 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-08-12 23:48:14 +0300
commite188a798c64ec538fa598ea50a16d311e517aa85 (patch)
tree46ce7558083862cd32b8fd8799c2634066ee111c /source/blender/blenkernel/intern/gpencil_curve.c
parentcd49c7b5eae0d9cc6942294a1d6002f578c8feb9 (diff)
GPencil: Clean material list when convert a curve
Now the list of materials is cleanup and any duplicated material is removed.
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil_curve.c')
-rw-r--r--source/blender/blenkernel/intern/gpencil_curve.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index d2c9ef0b3bc..429faefd923 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -447,7 +447,6 @@ static void gpencil_convert_spline(Main *bmain,
}
}
/* Cyclic curve, close stroke. */
- // if ((cyclic) && (!do_stroke)) {
if (cyclic) {
BKE_gpencil_stroke_close(gps);
}
@@ -523,8 +522,29 @@ void BKE_gpencil_convert_curve(Main *bmain,
bmain, ob_gp, ob_cu, gpencil_lines, only_stroke, scale_thickness, sample, gpf, nu);
}
+ /* Merge any similar material. */
+ int removed = 0;
+ BKE_gpencil_merge_materials(ob_gp, 0.001f, 0.001f, 0.001f, &removed);
+
+ /* Remove any unused slot. */
+ int actcol = ob_gp->actcol;
+
+ for (int slot = 1; slot <= ob_gp->totcol; slot++) {
+ while (slot <= ob_gp->totcol && !BKE_object_material_slot_used(ob_gp->data, slot)) {
+ ob_gp->actcol = slot;
+ BKE_object_material_slot_remove(bmain, ob_gp);
+
+ if (actcol >= slot) {
+ actcol--;
+ }
+ }
+ }
+
+ ob_gp->actcol = actcol;
+
/* Tag for recalculation */
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob_gp->id, ID_RECALC_GEOMETRY);
}
/** \} */