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:34:49 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-08-12 23:48:10 +0300
commitcd49c7b5eae0d9cc6942294a1d6002f578c8feb9 (patch)
treeac709bddb93cc81d8c28f3940c34717479c67fd2 /source/blender/editors/gpencil/gpencil_merge.c
parent01636ed159c7dede57236f7a801d3cfcae0b9750 (diff)
GPencil: Move merge similar materials code to BKE
This is required in other places and need to be shared.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_merge.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index 53dbc1620d0..4839c69b2e3 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -591,35 +591,9 @@ static int gpencil_stroke_merge_material_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- bool changed = BKE_gpencil_merge_materials_table_get(
- ob, hue_threshold, sat_threshold, val_threshold, mat_table);
-
- int removed = BLI_ghash_len(mat_table);
-
- /* Update stroke material index. */
- if (changed) {
- CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- if (ED_gpencil_stroke_can_use(C, gps) == false) {
- continue;
- }
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
- continue;
- }
-
- if (BLI_ghash_haskey(mat_table, POINTER_FROM_INT(gps->mat_nr))) {
- int *idx = BLI_ghash_lookup(mat_table, POINTER_FROM_INT(gps->mat_nr));
- gps->mat_nr = POINTER_AS_INT(idx);
- }
- }
- }
- }
- CTX_DATA_END;
- }
-
- /* Free hash memory. */
- BLI_ghash_free(mat_table, NULL, NULL);
+ int removed;
+ bool changed = BKE_gpencil_merge_materials(
+ ob, hue_threshold, sat_threshold, val_threshold, &removed);
/* notifiers */
if (changed) {