From 5dc3cfc983da11ead73c079096cd21e9592ce612 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Jul 2013 11:15:22 +0000 Subject: fix [#36282] Spin error with non uniform scale add support for passing object matrix to bmesh transform operators. --- source/blender/editors/mesh/editmesh_extrude.c | 33 +++++++++----------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'source/blender/editors/mesh') diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 65c528dbe03..b38f09b1dec 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -713,7 +713,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; BMOperator spinop; - float cent[3], axis[3], imat[3][3]; + float cent[3], axis[3]; float d[3] = {0.0f, 0.0f, 0.0f}; int steps, dupli; float angle; @@ -726,15 +726,10 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) angle = -angle; dupli = RNA_boolean_get(op->ptr, "dupli"); - /* undo object transformation */ - copy_m3_m4(imat, obedit->imat); - sub_v3_v3(cent, obedit->obmat[3]); - mul_m3_v3(imat, cent); - mul_m3_v3(imat, axis); - + /* keep the values in worldspace since we're passing the obmat */ if (!EDBM_op_init(em, &spinop, op, - "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b", - BM_ELEM_SELECT, cent, axis, d, steps, angle, dupli)) + "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 use_duplicate=%b", + BM_ELEM_SELECT, cent, axis, d, steps, angle, obedit->obmat, dupli)) { return OPERATOR_CANCELLED; } @@ -800,8 +795,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) BMVert *eve, *v1, *v2; BMIter iter, eiter; BMOperator spinop; - float dvec[3], nor[3], cent[3], axis[3]; - float imat[3][3]; + float dvec[3], nor[3], cent[3], axis[3], v1_co_global[3], v2_co_global[3]; int steps, turns; int valence; @@ -811,13 +805,6 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); - /* undo object transformation */ - copy_m3_m4(imat, obedit->imat); - sub_v3_v3(cent, obedit->obmat[3]); - mul_m3_v3(imat, cent); - mul_m3_v3(imat, axis); - - /* find two vertices with valence count == 1, more or less is wrong */ v1 = NULL; v2 = NULL; @@ -850,15 +837,17 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) } /* calculate dvec */ - sub_v3_v3v3(dvec, v1->co, v2->co); + mul_v3_m4v3(v1_co_global, obedit->obmat, v1->co); + mul_v3_m4v3(v2_co_global, obedit->obmat, v2->co); + sub_v3_v3v3(dvec, v1_co_global, v2_co_global); mul_v3_fl(dvec, 1.0f / steps); - if (dot_v3v3(nor, dvec) > 0.000f) + if (dot_v3v3(nor, dvec) > 0.0f) negate_v3(dvec); if (!EDBM_op_init(em, &spinop, op, - "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b", - BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), false)) + "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 use_duplicate=%b", + BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), obedit->obmat, false)) { return OPERATOR_CANCELLED; } -- cgit v1.2.3