From 666c8b51ca667f2c91600a98745a4f115a82216d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Jun 2013 05:58:51 +0000 Subject: changes to mirror tools - give feedback on how many mirror verts succeed/fail (for select mirror, shape key mirror, weight mirror) ... when a mirror failed it was confusing and not obvious what was going on. - slight change to select mirror, now center vertices will remain selected. - speedup to EDBM_verts_mirror_cache_begin, cache customdata layer offset. --- source/blender/editors/object/object_shapekey.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/object/object_shapekey.c') diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 2008e5ad4f3..af9f7220c26 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -152,10 +152,14 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) return 1; } -static int object_shape_key_mirror(bContext *C, Object *ob) +static bool object_shape_key_mirror(bContext *C, Object *ob, + int *r_totmirr, int *r_totfail) { KeyBlock *kb; Key *key; + int totmirr = 0, totfail = 0; + + *r_totmirr = *r_totfail = 0; key = BKE_key_from_object(ob); if (key == NULL) @@ -182,6 +186,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob) fp1 = ((float *)kb->data) + i1 * 3; fp1[0] = -fp1[0]; tag_elem[i1] = 1; + totmirr++; } else if (i2 != -1) { if (tag_elem[i1] == 0 && tag_elem[i2] == 0) { @@ -195,9 +200,13 @@ static int object_shape_key_mirror(bContext *C, Object *ob) /* flip x axis */ fp1[0] = -fp1[0]; fp2[0] = -fp2[0]; + totmirr++; } tag_elem[i1] = tag_elem[i2] = 1; } + else { + totfail++; + } } mesh_octree_table(ob, NULL, NULL, 'e'); @@ -224,6 +233,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob) i1 = LT_INDEX(lt, u, v, w); fp1 = ((float *)kb->data) + i1 * 3; fp1[0] = -fp1[0]; + totmirr++; } else { i1 = LT_INDEX(lt, u, v, w); @@ -237,6 +247,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob) copy_v3_v3(fp2, tvec); fp1[0] = -fp1[0]; fp2[0] = -fp2[0]; + totmirr++; } } } @@ -246,6 +257,9 @@ static int object_shape_key_mirror(bContext *C, Object *ob) MEM_freeN(tag_elem); } + *r_totmirr = totmirr; + *r_totfail = totfail; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -390,13 +404,16 @@ void OBJECT_OT_shape_key_retime(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op)) +static int shape_key_mirror_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); + int totmirr = 0, totfail = 0; - if (!object_shape_key_mirror(C, ob)) + if (!object_shape_key_mirror(C, ob, &totmirr, &totfail)) return OPERATOR_CANCELLED; + ED_mesh_report_mirror(op, totmirr, totfail); + return OPERATOR_FINISHED; } -- cgit v1.2.3