Mirror now works with all types of data
Fixes the different type of center for Mirror Rename mirrormesh to mirrormenu I'm looking for a hotkey for that. Will talk about it tomorrow during the meeting
This commit is contained in:
@@ -181,7 +181,7 @@ float prop_cent[3];
|
|||||||
|
|
||||||
float centre[3], centroid[3];
|
float centre[3], centroid[3];
|
||||||
|
|
||||||
void mirrormesh(void);
|
void mirrormenu(void);
|
||||||
|
|
||||||
void add_object_draw(int type) /* for toolbox */
|
void add_object_draw(int type) /* for toolbox */
|
||||||
{
|
{
|
||||||
@@ -1597,7 +1597,7 @@ void special_editmenu(void)
|
|||||||
vertexsmooth();
|
vertexsmooth();
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
mirrormesh();
|
mirrormenu();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1608,7 +1608,7 @@ void special_editmenu(void)
|
|||||||
}
|
}
|
||||||
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
|
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
|
||||||
|
|
||||||
nr= pupmenu("Specials%t|Subdivide%x1|Switch Direction%x2");
|
nr= pupmenu("Specials%t|Subdivide%x1|Switch Direction%x2|Mirror%x3");
|
||||||
|
|
||||||
switch(nr) {
|
switch(nr) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -1617,6 +1617,9 @@ void special_editmenu(void)
|
|||||||
case 2:
|
case 2:
|
||||||
switchdirectionNurb2();
|
switchdirectionNurb2();
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
mirrormenu();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6691,62 +6694,49 @@ void make_displists_by_obdata(void *obdata) {
|
|||||||
/* ******************************************************************** */
|
/* ******************************************************************** */
|
||||||
/* Mirror function in Edit Mode */
|
/* Mirror function in Edit Mode */
|
||||||
|
|
||||||
void mirrormesh(){
|
void mirrormenu(){
|
||||||
short mode = 0, axis;
|
short mode = 0, axis, a;
|
||||||
float centre[3] = {0,0,0}, *curs, mat[3][3], imat[3][3];
|
float *curs, mat[3][3], imat[3][3], min[3], max[3];
|
||||||
EditVert *eve;
|
TransVert *tv;
|
||||||
mode=pupmenu("Mirror Axis %t|Global X%x1| Y%x2| Z%x3|Local X%x4| Y%x5| Z%x6|View X%x7| Y%x8| Z%x9|");
|
mode=pupmenu("Mirror Axis %t|Global X%x1| Y%x2| Z%x3|Local X%x4| Y%x5| Z%x6|View X%x7| Y%x8| Z%x9|");
|
||||||
|
|
||||||
if (G.obedit==0) return;
|
if (G.obedit==0) return;
|
||||||
if (mode==0) return;
|
if (mode==0) return;
|
||||||
|
|
||||||
centre[0]= centre[1]= centre[2]= 0.0;
|
make_trans_verts(min, max, 0);
|
||||||
Mat3CpyMat4(mat, G.obedit->obmat);
|
Mat3CpyMat4(mat, G.obedit->obmat);
|
||||||
Mat3Inv(imat, mat);
|
Mat3Inv(imat, mat);
|
||||||
|
|
||||||
|
tv = transvmain;
|
||||||
|
|
||||||
if(G.vd->around==V3D_CENTROID) {
|
if(G.vd->around==V3D_CENTROID) {
|
||||||
int a = 0;
|
VECCOPY(centre, centroid);
|
||||||
eve= G.edve.first;
|
|
||||||
while(eve) {
|
|
||||||
a++;
|
|
||||||
if((eve->h==0) && (eve->f & 1)) {
|
|
||||||
VecAddf(centre, centre, eve->co);
|
|
||||||
}
|
|
||||||
eve= eve->next;
|
|
||||||
}
|
|
||||||
VecMulf(centre, 1.0/a);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(G.vd->around==V3D_CURSOR) {
|
else if(G.vd->around==V3D_CURSOR) {
|
||||||
curs= give_cursor();
|
curs= give_cursor();
|
||||||
VECCOPY(centre, curs);
|
VECCOPY(centre, curs);
|
||||||
|
|
||||||
VecSubf(centre, centre, G.obedit->obmat[3]);
|
|
||||||
Mat3MulVecfl(imat, centre);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VecSubf(centre, centre, G.obedit->obmat[3]);
|
||||||
|
Mat3MulVecfl(imat, centre);
|
||||||
|
|
||||||
if ((mode==1) || (mode==2) || (mode==3)) {
|
if ((mode==1) || (mode==2) || (mode==3)) {
|
||||||
|
|
||||||
axis = mode - 1;
|
axis = mode - 1;
|
||||||
|
|
||||||
eve= G.edve.first;
|
for(a=0; a<tottrans; a++, tv++) {
|
||||||
while(eve) {
|
float vec[3];
|
||||||
if((eve->h==0) && (eve->f & 1)) {
|
vec[0] = tv->loc[0];
|
||||||
float vec[3];
|
vec[1] = tv->loc[1];
|
||||||
vec[0] = eve->co[0];
|
vec[2] = tv->loc[2];
|
||||||
vec[1] = eve->co[1];
|
Mat3MulVecfl(mat, vec);
|
||||||
vec[2] = eve->co[2];
|
vec[axis] -= centre[axis];
|
||||||
Mat3MulVecfl(mat, vec);
|
vec[axis] *= -1;
|
||||||
vec[axis] -= centre[axis];
|
vec[axis] += centre[axis];
|
||||||
vec[axis] *= -1;
|
Mat3MulVecfl(imat, vec);
|
||||||
vec[axis] += centre[axis];
|
tv->loc[0] = vec[0];
|
||||||
Mat3MulVecfl(imat, vec);
|
tv->loc[1] = vec[1];
|
||||||
eve->co[0] = vec[0];
|
tv->loc[2] = vec[2];
|
||||||
eve->co[1] = vec[1];
|
|
||||||
eve->co[2] = vec[2];
|
|
||||||
}
|
|
||||||
eve= eve->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6754,14 +6744,10 @@ void mirrormesh(){
|
|||||||
|
|
||||||
axis = mode - 4;
|
axis = mode - 4;
|
||||||
|
|
||||||
eve= G.edve.first;
|
for(a=0; a<tottrans; a++, tv++) {
|
||||||
while(eve) {
|
tv->loc[axis] -= centre[axis];
|
||||||
if((eve->h==0) && (eve->f & 1)) {
|
tv->loc[axis] *= -1;
|
||||||
eve->co[axis] -= centre[axis];
|
tv->loc[axis] += centre[axis];
|
||||||
eve->co[axis] *= -1;
|
|
||||||
eve->co[axis] += centre[axis];
|
|
||||||
}
|
|
||||||
eve= eve->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6774,28 +6760,33 @@ void mirrormesh(){
|
|||||||
axis = mode - 7;
|
axis = mode - 7;
|
||||||
Mat3MulVecfl(viewmat, centre);
|
Mat3MulVecfl(viewmat, centre);
|
||||||
|
|
||||||
eve= G.edve.first;
|
for(a=0; a<tottrans; a++, tv++) {
|
||||||
while(eve) {
|
float vec[3];
|
||||||
if((eve->h==0) && (eve->f & 1)) {
|
vec[0] = tv->loc[0];
|
||||||
float vec[3];
|
vec[1] = tv->loc[1];
|
||||||
vec[0] = eve->co[0];
|
vec[2] = tv->loc[2];
|
||||||
vec[1] = eve->co[1];
|
Mat3MulVecfl(mat, vec);
|
||||||
vec[2] = eve->co[2];
|
Mat3MulVecfl(viewmat, vec);
|
||||||
Mat3MulVecfl(mat, vec);
|
vec[axis] -= centre[axis];
|
||||||
Mat3MulVecfl(viewmat, vec);
|
vec[axis] *= -1;
|
||||||
vec[axis] -= centre[axis];
|
vec[axis] += centre[axis];
|
||||||
vec[axis] *= -1;
|
Mat3MulVecfl(imat, vec);
|
||||||
vec[axis] += centre[axis];
|
Mat3MulVecfl(iviewmat, vec);
|
||||||
Mat3MulVecfl(imat, vec);
|
tv->loc[0] = vec[0];
|
||||||
Mat3MulVecfl(iviewmat, vec);
|
tv->loc[1] = vec[1];
|
||||||
eve->co[0] = vec[0];
|
tv->loc[2] = vec[2];
|
||||||
eve->co[1] = vec[1];
|
|
||||||
eve->co[2] = vec[2];
|
|
||||||
}
|
|
||||||
eve= eve->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
scrarea_do_windraw(curarea);
|
special_trans_update(0);
|
||||||
screen_swapbuffers();
|
special_aftertrans_update(mode, a & 1, 0, 0);
|
||||||
|
|
||||||
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
|
scrarea_queue_headredraw(curarea);
|
||||||
|
|
||||||
|
clearbaseflags_for_editing();
|
||||||
|
if(transvmain) MEM_freeN(transvmain);
|
||||||
|
transvmain= 0;
|
||||||
|
|
||||||
|
tottrans= 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user