diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-05-13 15:14:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-05-13 15:14:43 +0400 |
commit | f9642926303ec89679e61076ca9e4b9f0be3afe9 (patch) | |
tree | 8834da5e8743e9572ece0f33b9c3b94b00691a94 /source/blender/editors/object/object_transform.c | |
parent | 305d341ec2c2c5c6485ad6cd719e9472e4bb460d (diff) |
fix geometry to origin in mesh editmode - was broken since bmesh merge.
Diffstat (limited to 'source/blender/editors/object/object_transform.c')
-rw-r--r-- | source/blender/editors/object/object_transform.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 9c58717ec53..16f62f56505 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -653,7 +653,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); Object *tob; - float cursor[3], cent[3], cent_neg[3], centn[3], min[3], max[3]; + float cursor[3], cent[3], cent_neg[3], centn[3]; int centermode = RNA_enum_get(op->ptr, "type"); int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */ @@ -675,14 +675,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) zero_v3(cent); if (obedit) { - INIT_MINMAX(min, max); - if (obedit->type == OB_MESH) { Mesh *me = obedit->data; BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMIter iter; - int total = 0; if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); @@ -690,16 +687,19 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_m4_v3(obedit->imat, cent); } else { - BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - if (around == V3D_CENTROID) { - total++; - add_v3_v3(cent, eve->co); - mul_v3_fl(cent, 1.0f / (float)total); + if (around == V3D_CENTROID) { + const float total_div = 1.0f / (float)em->bm->totvert; + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + madd_v3_v3fl(cent, eve->co, total_div); } - else { + } + else { + float min[3], max[3]; + INIT_MINMAX(min, max); + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { minmax_v3v3_v3(min, max, eve->co); - mid_v3_v3v3(cent, min, max); } + mid_v3_v3v3(cent, min, max); } } @@ -746,8 +746,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_lib_error++; } else { - if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + if (centermode == ORIGIN_TO_CURSOR) { + /* done */ + } else { + float min[3], max[3]; /* only bounds support */ INIT_MINMAX(min, max); BKE_object_minmax_dupli(scene, ob, min, max); |