[Bf-blender-cvs] [e188a798c64] master: GPencil: Clean material list when convert a curve
Antonio Vazquez
noreply at git.blender.org
Wed Aug 12 22:55:58 CEST 2020
Commit: e188a798c64ec538fa598ea50a16d311e517aa85
Author: Antonio Vazquez
Date: Wed Aug 12 19:46:15 2020 +0200
Branches: master
https://developer.blender.org/rBe188a798c64ec538fa598ea50a16d311e517aa85
GPencil: Clean material list when convert a curve
Now the list of materials is cleanup and any duplicated material is removed.
===================================================================
M source/blender/blenkernel/intern/gpencil_curve.c
===================================================================
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);
}
/** \} */
More information about the Bf-blender-cvs
mailing list