forked from bartvdbraak/blender
mirror fix attempt 2
This commit is contained in:
parent
7c80ca02bc
commit
6b0679a399
@ -545,24 +545,9 @@ DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
|
|||||||
float mtx2[4][4], vec[3];
|
float mtx2[4][4], vec[3];
|
||||||
|
|
||||||
Mat4Invert(mtx2, mmd->mirror_ob->obmat);
|
Mat4Invert(mtx2, mmd->mirror_ob->obmat);
|
||||||
Mat4Ortho(mtx2);
|
Mat4MulMat4(mtx, ob->obmat, 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);
|
|
||||||
} else {
|
} else {
|
||||||
Mat4One(mtx);
|
Mat4One(mtx);
|
||||||
mtx[axis][axis] = -1.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BMO_InitOpf(bm, &op, "mirror geom=%avef mat=%m4 mergedist=%f axis=%d",
|
BMO_InitOpf(bm, &op, "mirror geom=%avef mat=%m4 mergedist=%f axis=%d",
|
||||||
|
@ -402,6 +402,20 @@ BMOpDefine def_translate= {
|
|||||||
0,
|
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
|
Transform
|
||||||
@ -796,6 +810,7 @@ BMOpDefine *opdefines[] = {
|
|||||||
&def_bmesh_to_mesh,
|
&def_bmesh_to_mesh,
|
||||||
&def_meshreverseuvs,
|
&def_meshreverseuvs,
|
||||||
&def_edgenet_prepare,
|
&def_edgenet_prepare,
|
||||||
|
&def_scale,
|
||||||
};
|
};
|
||||||
|
|
||||||
int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*));
|
int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*));
|
||||||
|
@ -55,5 +55,6 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op);
|
|||||||
void object_load_bmesh_exec(BMesh *bm, BMOperator *op);
|
void object_load_bmesh_exec(BMesh *bm, BMOperator *op);
|
||||||
void bmesh_reverseuvs_exec(BMesh *bm, BMOperator *op);
|
void bmesh_reverseuvs_exec(BMesh *bm, BMOperator *op);
|
||||||
void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op);
|
void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op);
|
||||||
|
void bmesh_scale_exec(BMesh *bm, BMOperator *op);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,6 +42,7 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) {
|
|||||||
V_DECLARE(emap);
|
V_DECLARE(emap);
|
||||||
float mtx[4][4];
|
float mtx[4][4];
|
||||||
float imtx[4][4];
|
float imtx[4][4];
|
||||||
|
float scale[3] = {1.0f, 1.0f, 1.0f};
|
||||||
float dist = BMO_Get_Float(op, "mergedist");
|
float dist = BMO_Get_Float(op, "mergedist");
|
||||||
int i, ototvert, ototedge, axis = BMO_Get_Int(op, "axis");
|
int i, ototvert, ototedge, axis = BMO_Get_Int(op, "axis");
|
||||||
int mirroru = BMO_Get_Int(op, "mirror_u");
|
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*/
|
/*feed old data to transform bmop*/
|
||||||
|
scale[axis] = -1.0f;
|
||||||
BMO_CallOpf(bm, "transform verts=%fv mat=%m4", ELE_NEW, mtx);
|
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");
|
BMO_Init_Op(&weldop, "weldverts");
|
||||||
|
|
||||||
|
@ -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)
|
void bmesh_translate_exec(BMesh *bm, BMOperator *op)
|
||||||
{
|
{
|
||||||
float mat[4][4], vec[3];
|
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");
|
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)
|
void bmesh_rotate_exec(BMesh *bm, BMOperator *op)
|
||||||
{
|
{
|
||||||
float vec[3];
|
float vec[3];
|
||||||
|
Loading…
Reference in New Issue
Block a user