diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index d1a94ca7e6a..3cf1785f3ef 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -545,24 +545,9 @@ DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, float mtx2[4][4], vec[3]; Mat4Invert(mtx2, mmd->mirror_ob->obmat); - Mat4Ortho(mtx2); - Mat4MulMat4(imtx, ob->obmat, mtx2); - Mat4Invert(mtx, imtx); - - /*this math here is probably stupid beyond all reason*/ - VECCOPY(vec, mtx[3]); - VecMulf(vec, -1.0f); - - Mat4One(imtx); - imtx[axis][axis] = -1.0f; - Mat4MulMat4(mtx2, imtx, mtx); - - Mat4One(imtx); - VECCOPY(imtx[3], vec); - Mat4MulMat4(mtx, imtx, mtx2); + Mat4MulMat4(mtx, ob->obmat, mtx2); } else { Mat4One(mtx); - mtx[axis][axis] = -1.0f; } BMO_InitOpf(bm, &op, "mirror geom=%avef mat=%m4 mergedist=%f axis=%d", diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 3b914e769ce..2a97e097b7c 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -402,6 +402,20 @@ BMOpDefine def_translate= { 0, }; +/* + Scale + + Scales vertices by an offset. +*/ +BMOpDefine def_scale= { + "scale", + {{BMOP_OPSLOT_VEC, "vec"}, //scale factor + {BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices + {0, /*null-terminating sentinel*/}}, + bmesh_scale_exec, + 0, +}; + /* Transform @@ -796,6 +810,7 @@ BMOpDefine *opdefines[] = { &def_bmesh_to_mesh, &def_meshreverseuvs, &def_edgenet_prepare, + &def_scale, }; int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*)); diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index b5201ae17d6..abc88b5139a 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -55,5 +55,6 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op); void object_load_bmesh_exec(BMesh *bm, BMOperator *op); void bmesh_reverseuvs_exec(BMesh *bm, BMOperator *op); void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op); +void bmesh_scale_exec(BMesh *bm, BMOperator *op); #endif diff --git a/source/blender/bmesh/operators/mirror.c b/source/blender/bmesh/operators/mirror.c index a4f9f5dd98a..1cde079e61b 100644 --- a/source/blender/bmesh/operators/mirror.c +++ b/source/blender/bmesh/operators/mirror.c @@ -42,6 +42,7 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) { V_DECLARE(emap); float mtx[4][4]; float imtx[4][4]; + float scale[3] = {1.0f, 1.0f, 1.0f}; float dist = BMO_Get_Float(op, "mergedist"); int i, ototvert, ototedge, axis = BMO_Get_Int(op, "axis"); int mirroru = BMO_Get_Int(op, "mirror_u"); @@ -72,7 +73,10 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) { } /*feed old data to transform bmop*/ + scale[axis] = -1.0f; BMO_CallOpf(bm, "transform verts=%fv mat=%m4", ELE_NEW, mtx); + BMO_CallOpf(bm, "scale verts=%fv vec=%v", ELE_NEW, scale); + BMO_CallOpf(bm, "transform verts=%fv mat=%m4", ELE_NEW, imtx); BMO_Init_Op(&weldop, "weldverts"); diff --git a/source/blender/bmesh/operators/utils.c b/source/blender/bmesh/operators/utils.c index c8fb5a2907b..c57d013506b 100644 --- a/source/blender/bmesh/operators/utils.c +++ b/source/blender/bmesh/operators/utils.c @@ -54,10 +54,6 @@ void bmesh_transform_exec(BMesh *bm, BMOperator *op) } } -/*this operator calls the transform operator, which - is a little complex, but makes it easier to make - sure the transform op is working, since initially - only this one will be used.*/ void bmesh_translate_exec(BMesh *bm, BMOperator *op) { float mat[4][4], vec[3]; @@ -70,6 +66,20 @@ void bmesh_translate_exec(BMesh *bm, BMOperator *op) BMO_CallOpf(bm, "transform mat=%m4 verts=%s", mat, op, "verts"); } +void bmesh_scale_exec(BMesh *bm, BMOperator *op) +{ + float mat[3][3], vec[3]; + + BMO_Get_Vec(op, "vec", vec); + + Mat3One(mat); + mat[0][0] = vec[0]; + mat[1][1] = vec[1]; + mat[2][2] = vec[2]; + + BMO_CallOpf(bm, "transform mat=%m3 verts=%s", mat, op, "verts"); +} + void bmesh_rotate_exec(BMesh *bm, BMOperator *op) { float vec[3];