Removal of old transform() <sob> part one.

- added in new transform the (not so useful but yah) old feature that
  does scrollwheel zoom during transform
- had to change transform call arguments for uv-window/sequence/oops to
  match new transform for mouse callback

TODO (for martin?)

- pulldown menu support to call with local axes compliant as for pressing
  it with hotkey
- mirrormenu() still uses old transform stuff...
This commit is contained in:
Ton Roosendaal
2005-04-30 21:19:19 +00:00
parent 413677caff
commit 42ae9128fa
17 changed files with 152 additions and 2006 deletions

View File

@@ -92,8 +92,8 @@ void restore_tob(struct TransOb *tob);
int cylinder_intersect_test(void);
int sphere_intersect_test(void);
int my_clock(void);
void transform(int mode);
void std_rmouse_transform(void (*xf_func)(int));
void std_rmouse_transform(void (*xf_func)(int, int));
void rightmouse_transform(void);
void single_object_users(int flag);
void new_id_matar(struct Material **matar, int totcol);

View File

@@ -40,7 +40,7 @@ void select_backlinked_oops(void);
void select_linked_oops(void);
void set_select_flag_oops(void);
void swap_select_all_oops(void);
void transform_oops(int mode);
void transform_oops(int mode, int context);
void clever_numbuts_oops(void);
#endif

View File

@@ -55,7 +55,7 @@ void seq_snap_menu(void);
void set_filter_seq(void);
void swap_select_seq(void);
void touch_seq_files(void);
void transform_seq(int mode);
void transform_seq(int mode, int context);
void un_meta(void);
/* drawseq.c */

View File

@@ -40,7 +40,7 @@ void mouseco_to_curtile(void);
void mouse_select_sima(void);
void select_swap_tface_uv(void);
void tface_do_clip(void);
void transform_tface_uv(int mode);
void transform_tface_uv(int mode, int context);
void mirrormenu_tface_uv(void);
void mirror_tface_uv(char mirroraxis);
void hide_tface_uv(int swap);

View File

@@ -1790,7 +1790,6 @@ static void view3d_blockhandlers(ScrArea *sa)
void drawview3dspace(ScrArea *sa, void *spacedata)
{
extern void constline_callback(void); // editobject.c helpline
Base *base;
Object *ob;
@@ -1955,7 +1954,6 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
}
if(G.moving) {
constline_callback();
BIF_drawConstraint();
if(G.obedit) BIF_drawPropCircle(); // only editmode has proportional edit
}

View File

@@ -4577,23 +4577,6 @@ void calc_trans_verts(void)
}
}
static int test_midtog_proj(short xn, short yn, short *mval)
{
float x,y,z;
/* which movement is the largest? that'll be the one */
xn= (xn-mval[0]);
yn= (yn-mval[1]);
x = fabs(G.vd->persinv[0][0]*xn + G.vd->persinv[1][0]*yn);
y = fabs(G.vd->persinv[0][1]*xn + G.vd->persinv[1][1]*yn);
z = fabs(G.vd->persinv[0][2]*xn + G.vd->persinv[1][2]*yn);
if(x>=y && x>=z) return 0;
else if(y>=x && y>=z) return 1;
else return 2;
}
void apply_keyb_grid(float *val, float fac1, float fac2, float fac3, int invert)
{
/* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
@@ -4837,1926 +4820,8 @@ int my_clock(void)
return (int)ftime;
}
static void view_editmove(unsigned char event)
{
/* Regular: Zoom in */
/* Shift: Scroll up */
/* Ctrl: Scroll right */
/* Alt-Shift: Rotate up */
/* Alt-Ctrl: Rotate right */
switch(event) {
case WHEELUPMOUSE:
if( G.qual & LR_SHIFTKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD2);
G.qual |= LR_SHIFTKEY;
} else {
persptoetsen(PAD2);
}
} else if( G.qual & LR_CTRLKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD4);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD4);
}
} else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADMINUS);
else
persptoetsen(PADPLUSKEY);
break;
case WHEELDOWNMOUSE:
if( G.qual & LR_SHIFTKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD8);
G.qual |= LR_SHIFTKEY;
} else {
persptoetsen(PAD8);
}
} else if( G.qual & LR_CTRLKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD6);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD6);
}
} else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADPLUSKEY);
else
persptoetsen(PADMINUS);
break;
}
}
/* *********************** AXIS CONSTRAINT HELPER LINE *************** */
static void constline(float *center, float *dir, char axis, float axismat[][3])
{
/* extern void make_axis_color(char *col, char *col2, char axis); // drawview.c
*/
float v1[3], v2[3], v3[3];
char col[3], col2[3];
if(G.obedit) mymultmatrix(G.obedit->obmat); // sets opengl viewing
VecCopyf(v3, dir);
VecMulf(v3, G.vd->far);
VecSubf(v2, center, v3);
VecAddf(v1, center, v3);
BIF_GetThemeColor3ubv(TH_GRID, col);
make_axis_color(col, col2, axis);
glColor3ubv(col2);
setlinestyle(0);
glBegin(GL_LINE_STRIP);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
if(axismat) {
float mat[4][4];
Mat4CpyMat3(mat, axismat);
VecAddf(mat[3], mat[3], center);
mymultmatrix(mat);
BIF_ThemeColor(TH_TEXT);
drawaxes(2.0);
}
myloadmatrix(G.vd->viewmat);
}
#define XTRANS 0x01
#define YTRANS 0x02
#define ZTRANS 0x04
#define TRANSLOCAL 0x80
#define XTRANSLOCAL (XTRANS|TRANSLOCAL)
#define YTRANSLOCAL (YTRANS|TRANSLOCAL)
#define ZTRANSLOCAL (ZTRANS|TRANSLOCAL)
/* temporal storage for callback */
struct constline_temp {
int mode, axismode, midtog;
float *centre, *vx, *vy, *vz;
float *imat;
};
static struct constline_temp cnst={0,0}; // init
/* called while transform(), store the relevant values in struct */
static void set_constline_callback(int mode, int axismode, int midtog,
float *centre, float imat[][3], float *vx, float *vy, float *vz)
{
cnst.mode= mode;
cnst.axismode= axismode;
cnst.midtog= midtog;
cnst.centre= centre;
cnst.imat= (float *)imat;
cnst.vx= vx;
cnst.vy= vy;
cnst.vz= vz;
}
/* is called from drawview.c after drawing objects */
void constline_callback(void)
{
TransOb *tob;
int a;
if(cnst.mode==0 || cnst.axismode==0) return; // uninitialized or no helpline
// check further:
if( (cnst.mode == 'C') || (cnst.mode == 'w') || (cnst.mode=='N') ) return;
if( ((cnst.mode=='R')||(cnst.mode=='r')) && (cnst.midtog) ) return;
if(G.obedit) { // only one helpline in editmode
float matone[3][3];
Mat3One(matone);
switch (cnst.axismode) {
case XTRANSLOCAL: constline(cnst.centre, cnst.vx, 'x', matone); break;
case YTRANSLOCAL: constline(cnst.centre, cnst.vy, 'y', matone); break;
case ZTRANSLOCAL: constline(cnst.centre, cnst.vz, 'z', matone); break;
case XTRANS: constline(cnst.centre, cnst.imat, 'x', NULL); break;
case YTRANS: constline(cnst.centre, cnst.imat+3, 'y', NULL); break;
case ZTRANS: constline(cnst.centre, cnst.imat+6, 'z', NULL); break;
}
}
else if(cnst.axismode < TRANSLOCAL) { // for multiple objects one helpline...
switch (cnst.axismode) {
case XTRANS: constline(cnst.centre, cnst.vx, 'x', NULL); break;
case YTRANS: constline(cnst.centre, cnst.vy, 'y', NULL); break;
case ZTRANS: constline(cnst.centre, cnst.vz, 'z', NULL); break;
}
}
else { // unless it's local transform
tob= transmain;
for(a=0; a<tottrans; a++, tob++) {
switch (cnst.axismode) {
case XTRANSLOCAL: constline(tob->loc, tob->axismat[0], 'x', tob->axismat); break;
case YTRANSLOCAL: constline(tob->loc, tob->axismat[1], 'y', tob->axismat); break;
case ZTRANSLOCAL: constline(tob->loc, tob->axismat[2], 'z', tob->axismat); break;
}
}
}
}
/* *********************** END AXIS CONSTRAINT HELPER LINE *************** */
/* *********************** TRANSFORM() *************** */
static char *transform_mode_to_string(int mode)
{
switch(mode) {
case 'g': return("Grab"); break;
case 's': return("Scale"); break;
case 'r': return("Rotate"); break;
case 'G': return("Grab Proportional"); break;
case 'C': return("Scale Proportional"); break;
case 'R': return("Rotate Proportional"); break;
case 'S': return("Shear"); break;
case 'N': return("Shrink/Fatten"); break;
case 'w': return("Warp"); break;
case 'd': return("Duplicate"); break;
case 'n': return("Extrude"); break;
case 'h': return("Extrude"); break;
default: return("Transform");
}
}
/*
'g' 'G' -> Grab / Grab with PET
'n' -> Grab with vert normal (after extrude)
'r' 'R' -> Rotate / Rotate with PET
's' 'C' -> Scale / Scale with PET
'S' -> Shear
't' -> Tilt
'w' -> Warp
'N' -> Shrink/Fatten
*/
void transform(int mode)
{
short canceled = 0;
TransOb *tob;
TransVert *tv;
float *edge_creases=NULL; /* edge transform isnt really supported... */
float vec[3], min[3], max[3], dvec[3], d_dvec[3], dvecp[3], rot0[3], rot1[3], rot2[3], axis[3];
float totmat[3][3], omat[3][3], imat[3][3], mat[3][3], tmat[3][3], phi, dphi;
float persinv[3][3], persmat[3][3], viewinv[4][4], imat4[4][4];
float *curs, dx1, dx2, dy1, dy2, eul[3], quat[4], rot[3], phi0, phi1, deler, rad = 0.0;
float sizefac, size[3], sizelo[3], smat[3][3], xref=1.0, yref=1.0, zref= 1.0;
float si, co, dist=0.0, startcircumfac = 0.0, circumfac, oldval[3];
int axismode=0, time, fast=0, a, midtog=0, firsttime=1, wrong= 0, cameragrab= 0, gridflag;
unsigned short event=0;
short mval[2], breakloop=0, doit, xn, yn, xc, yc, xo, yo = 0, val;
char str[100], *undostr;
int keyflags = 0;
float addvec[3] = {0,0,0}; // for new typing code
short ax = 0, del = 0, typemode = 0; // also for new typing thingy
short pe[3] = {0,0,0}; // again for the same thing. Determines if the period key has been pressed.
short mi[3] = {1,1,1}; // same thing again. Determines whether or not the minus key has been pressed (in order to add or substract new numbers).
short numchange[3] = {0,0,0}; // Determines whether or not one axis recieved changes (mainly for scaling)
float vx[3] = {1,0,0}, vy[3] = {0,1,0}, vz[3] = {0,0,1};
if (mode % 'x' == 0)
axismode = XTRANSLOCAL;
else if (mode % 'X' == 0)
axismode = XTRANS;
else if (mode % 'y' == 0)
axismode = YTRANSLOCAL;
else if (mode % 'Y' == 0)
axismode = YTRANS;
else if (mode % 'z' == 0)
axismode = ZTRANSLOCAL;
else if (mode % 'Z' == 0)
axismode = ZTRANS;
if (mode % 'g' == 0)
mode = 'g';
else if (mode % 'r' == 0)
mode = 'r';
else if (mode % 's' == 0)
mode = 's';
/* used in end of function */
undostr= transform_mode_to_string(mode);
if(G.obedit && (G.f & G_PROPORTIONAL)) {
if(mode=='g') mode= 'G';
if(mode=='r') mode= 'R';
if(mode=='s') mode= 'C';
}
/* from duplicate or extrude routines */
if(mode=='d' || mode=='h') mode= 'g';
/* this can cause floating exception at dec alpha */
d_dvec[0]= d_dvec[1]= d_dvec[2]= 0.0;
dvec[0]= dvec[1]= dvec[2]= 0.0;
if(G.scene->id.lib) return;
if(mode=='t') {
if(G.obedit==0 || G.obedit->type!=OB_CURVE) return;
}
if(mode=='w' && G.obedit==0) return;
/* what data will be involved? */
if(G.obedit) {
if(mode=='N') vertexnormals(0);
/* min en max needed for warp */
if(mode=='G' || mode=='R' || mode=='C') make_trans_verts(min, max, 1);
else make_trans_verts(min, max, 0);
}
else if (G.obpose){
switch (G.obpose->type) {
case OB_ARMATURE:
/* figure out which bones need calculating */
figure_bone_nocalc(G.obpose);
figure_pose_updating();
make_trans_bones((char)mode);
if(mode=='g' && tottrans==0) {
mode= 'r';
make_trans_bones((char)mode);
}
break;
}
}
else {
int opt= 0;
if (mode=='g' || mode=='G') opt= 'g';
else if (mode=='r' || mode=='R') opt= 'r';
else if (mode=='s' || mode=='S') opt= 's';
setbaseflags_for_editing(opt);
figure_pose_updating();
make_trans_objects();
}
if(tottrans==0) {
if(G.obedit==0) clearbaseflags_for_editing();
return;
}
if(G.obedit==0 && mode=='S') return;
if(G.vd->around==V3D_LOCAL) {
if(G.obedit) {
centre[0]= centre[1]= centre[2]= 0.0;
}
}
if(G.vd->around==V3D_CENTROID) {
VECCOPY(centre, centroid);
}
else if(G.vd->around==V3D_CURSOR) {
curs= give_cursor();
VECCOPY(centre, curs);
if(G.obedit) {
VecSubf(centre, centre, G.obedit->obmat[3]);
Mat3CpyMat4(mat, G.obedit->obmat);
Mat3Inv(imat, mat);
Mat3MulVecfl(imat, centre);
}
}
/* Always rotate around object centroid */
if (G.obpose){
VECCOPY (centre, centroid);
}
/* moving: is shown in drawobject() */
if(G.obedit) G.moving= 2;
else G.moving= 1;
areawinset(curarea->win);
/* the persinv is polluted with translation, do not use!! */
Mat3CpyMat4(persmat, G.vd->persmat);
Mat3Inv(persinv, persmat);
VECCOPY(rot0, persinv[0]);
Normalise(rot0);
VECCOPY(rot1, persinv[1]);
Normalise(rot1);
VECCOPY(rot2, persinv[2]);
Normalise(rot2);
/* init vars */
Mat4Invert(viewinv, G.vd->viewmat);
if(transvmain) {
VECCOPY(vec, centre);
Mat4MulVecfl(G.obedit->obmat, vec);
initgrabz(vec[0], vec[1], vec[2]);
project_short_noclip(vec, mval);
}
else {
/* voor panning from cameraview */
if( G.vd->camera==OBACT && G.vd->persp>1) {
/* 6.0 = 6 grid units */
centre[0]+= -6.0*rot2[0];
centre[1]+= -6.0*rot2[1];
centre[2]+= -6.0*rot2[2];
}
initgrabz(centre[0], centre[1], centre[2]);
project_short_noclip(centre, mval);
if( G.vd->camera==OBACT && G.vd->persp>1) {
centre[0]+= 6.0*rot2[0];
centre[1]+= 6.0*rot2[1];
centre[2]+= 6.0*rot2[2];
}
}
VECCOPY(prop_cent, centre);
xc= mval[0];
yc= mval[1];
if(G.obedit) {
Mat3CpyMat4(omat, G.obedit->obmat);
Mat3Inv(imat, omat);
Mat4Invert(imat4, G.obedit->obmat);
}
else if(G.obpose) {
Mat3CpyMat4(omat, G.obpose->obmat);
Mat3Inv(imat, omat);
Mat4Invert(imat4, G.obpose->obmat);
}
else {
if(transmain) {
if(OBACT && G.vd->persp>1 && G.vd->camera==OBACT) {
cameragrab= 1;
xc= curarea->winx/2;
yc= curarea->winy/2;
}
}
}
if((mode=='r' || mode=='s' || mode=='S') && xc==32000) {
error("Centre far out of view");
wrong= 1;
}
if(mode=='w' && G.obedit) {
Mat4MulVecfl(G.obedit->obmat, min);
Mat4MulVecfl(G.vd->viewmat, min);
Mat4MulVecfl(G.obedit->obmat, max);
Mat4MulVecfl(G.vd->viewmat, max);
centre[0]= (min[0]+max[0])/2.0;
centre[1]= (min[1]+max[1])/2.0;
centre[2]= (min[2]+max[2])/2.0;
/* cursor is centre */
curs= give_cursor();
VECCOPY(axis, curs);
Mat4MulVecfl(G.vd->viewmat, axis);
rad= sqrt( (axis[0]-centre[0])*(axis[0]-centre[0])+(axis[1]-centre[1])*(axis[1]-centre[1]) );
dist= max[0]-centre[0];
if(dist==0.0) wrong= 1;
else startcircumfac= (90*rad*M_PI)/(360.0*dist);
}
getmouseco_areawin(mval);
xn=xo= mval[0];
yn=yo= mval[1];
dx1= xc-xn;
dy1= yc-yn;
phi= phi0= phi1= 0.0;
sizefac= sqrt( (float)((yc-yn)*(yc-yn)+(xn-xc)*(xn-xc)) );
if(sizefac<2.0) sizefac= 2.0;
gridflag= U.flag;
while(wrong==0 && breakloop==0) {
getmouseco_areawin(mval);
if(mval[0]!=xo || mval[1]!=yo || firsttime) {
if(firsttime) {
/* not really nice, but who cares! */
oldval[0]= oldval[1]= oldval[2]= MAXFLOAT;
/* proportional precalc */
if(mode=='G' || mode=='R' || mode=='C') {
if(transvmain) {
tv= transvmain;
for(a=0; a<tottrans; a++, tv++) {
set_proportional_weight(tv, min, max);
}
}
}
}
firsttime= 0;
if(mode=='g' || mode=='G' || mode=='n') {
float dot; /* for grab along normal */
char gmode[10] = "";
keyflags |= KEYFLAG_LOC;
if (axismode==XTRANSLOCAL) strcpy(gmode, "Local X: ");
if (axismode==YTRANSLOCAL) strcpy(gmode, "Local Y: ");
if (axismode==ZTRANSLOCAL) strcpy(gmode, "Local Z: ");
if (axismode==XTRANS) strcpy(gmode, "X Axis: ");
if (axismode==YTRANS) strcpy(gmode, "Y Axis: ");
if (axismode==ZTRANS) strcpy(gmode, "Z Axis: ");
if(axismode) {
if(cameragrab) {
dx1= 0.002*(mval[1]-yn)*G.vd->grid;
dvec[0]-= dx1*G.vd->viewinv[2][0];
dvec[1]-= dx1*G.vd->viewinv[2][1];
dvec[2]-= dx1*G.vd->viewinv[2][2];
firsttime= 1; /* so it keeps going */
}
else {
window_to_3d(dvec, mval[0]-xn, mval[1]-yn);
if(axismode & XTRANS) dvec[1]=dvec[2]= 0.0;
if(axismode & YTRANS) dvec[0]=dvec[2]= 0.0;
if(axismode & ZTRANS) dvec[0]=dvec[1]= 0.0;
}
}
else window_to_3d(dvec, mval[0]-xn, mval[1]-yn);
if (typemode){
dvec[0] = addvec[0];
dvec[1] = addvec[1];
dvec[2] = addvec[2];
if(axismode == XTRANS) dvec[1]=dvec[2]= 0.0;
if(axismode == YTRANS) dvec[0]=dvec[2]= 0.0;
if(axismode == ZTRANS) dvec[0]=dvec[1]= 0.0;
}
/* grids */
if(G.qual & LR_SHIFTKEY) {
dvec[0]= 0.1*(dvec[0]-d_dvec[0])+d_dvec[0];
dvec[1]= 0.1*(dvec[1]-d_dvec[1])+d_dvec[1];
dvec[2]= 0.1*(dvec[2]-d_dvec[2])+d_dvec[2];
}
if (mode != 'n') {
apply_keyb_grid(dvec, 0.0, G.vd->grid, 0.1*G.vd->grid, gridflag & USER_AUTOGRABGRID);
apply_keyb_grid(dvec+1, 0.0, G.vd->grid, 0.1*G.vd->grid, gridflag & USER_AUTOGRABGRID);
apply_keyb_grid(dvec+2, 0.0, G.vd->grid, 0.1*G.vd->grid, gridflag & USER_AUTOGRABGRID);
}
if(dvec[0]!=oldval[0] ||dvec[1]!=oldval[1] ||dvec[2]!=oldval[2]) {
VECCOPY(oldval, dvec);
/* speedup for vertices */
if (G.obedit) {
VECCOPY(dvecp, dvec);
if (axismode&TRANSLOCAL && typemode) {
if(axismode==XTRANSLOCAL) dvecp[1]=dvecp[2]=0;
if(axismode==YTRANSLOCAL) dvecp[0]=dvecp[2]=0;
if(axismode==ZTRANSLOCAL) dvecp[0]=dvecp[1]=0;
VECCOPY(dvec, dvecp);
}
else {
Mat3MulVecfl(imat, dvecp);
if(axismode==XTRANSLOCAL) dvecp[1]=dvecp[2]=0;
if(axismode==YTRANSLOCAL) dvecp[0]=dvecp[2]=0;
if(axismode==ZTRANSLOCAL) dvecp[0]=dvecp[1]=0;
if(axismode&TRANSLOCAL){
VECCOPY(dvec, dvecp);
Mat3MulVecfl(omat, dvec);
}
}
}
if(mode=='n') {
if (typemode){
dot = addvec[0];
}
else {
tv= transvmain;
if(tv->nor) {
dot= tv->nor[0]*dvecp[0] + tv->nor[1]*dvecp[1] + tv->nor[2]*dvecp[2];
apply_keyb_grid(&dot, 0.0, G.vd->grid, 0.1*G.vd->grid, gridflag & USER_AUTOGRABGRID);
/* do not change dvec here, for d_dvec (hold shift) to keep working */
}
}
}
/* apply */
tob= transmain;
tv= transvmain;
for(a=0; a<tottrans; a++, tob++, tv++) {
if(transmain) {
VECCOPY(dvecp, dvec);
if(axismode & TRANSLOCAL)
Mat3MulVecfl(tob->axismat, dvecp);
if(transmode==TRANS_TEX) Mat3MulVecfl(tob->obinv, dvecp);
if(tob->flag & TOB_IKA) {
VecAddf(tob->eff, tob->oldeff, dvecp);
}
else
Mat3MulVecfl(tob->parinv, dvecp);
if(tob->flag & TOB_IPO) {
add_ipo_tob_poin(tob->locx, tob->oldloc, dvecp[0]);
add_ipo_tob_poin(tob->locy, tob->oldloc+1, dvecp[1]);
add_ipo_tob_poin(tob->locz, tob->oldloc+2, dvecp[2]);
}
else if(tob->loc) {
VecAddf(tob->loc, tob->oldloc, dvecp);
}
}
else {
if(mode=='G') {
tv->loc[0]= tv->oldloc[0]+tv->fac*dvecp[0];
tv->loc[1]= tv->oldloc[1]+tv->fac*dvecp[1];
tv->loc[2]= tv->oldloc[2]+tv->fac*dvecp[2];
}
else if(mode=='n' && tv->nor) {
//float dot; /* dot product dvec with normal */
//dot= tv->nor[0]*dvecp[0] + tv->nor[1]*dvecp[1] + tv->nor[2]*dvecp[2];
tv->loc[0]= tv->oldloc[0]+dot*tv->nor[0];
tv->loc[1]= tv->oldloc[1]+dot*tv->nor[1];
tv->loc[2]= tv->oldloc[2]+dot*tv->nor[2];
}
else VecAddf(tv->loc, tv->oldloc, dvecp);
}
}
tv= transvmain;
if(mode=='n' && tv->nor) {
if (typemode)
sprintf(str, "D: >%.4f< Along faces normal", dot);
else
sprintf(str, "D: %.4f Along faces normal", dot);
}
else {
if (typemode){
switch (ax){
case 0:
sprintf(str, "%sDx: >%.4f< Dy: %.4f Dz: %.4f", gmode, dvec[0], dvec[1], dvec[2]);
break;
case 1:
sprintf(str, "%sDx: %.4f Dy: >%.4f< Dz: %.4f", gmode, dvec[0], dvec[1], dvec[2]);
break;
case 2:
sprintf(str, "%sDx: %.4f Dy: %.4f Dz: >%.4f<", gmode, dvec[0], dvec[1], dvec[2]);
}
}
else
sprintf(str, "%sDx: %.4f Dy: %.4f Dz: %.4f", gmode, dvec[0], dvec[1], dvec[2]);
}
headerprint(str);
time= my_clock();
if(G.obedit) calc_trans_verts();
special_trans_update(keyflags);
if (cameragrab && midtog)
set_constline_callback(mode, ZTRANSLOCAL, midtog, centre, imat, vx, vy, vz);
else
set_constline_callback(mode, axismode, midtog, centre, imat, vx, vy, vz);
if(fast==0) {
force_draw(0);
time= my_clock()-time;
if(time>50) fast= 1;
}
else {
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
}
}
else if(mode=='r' || mode=='t' || mode=='R') {
int turntable = 0;
doit= 0;
keyflags |= KEYFLAG_ROT;
dx2= xc-mval[0];
dy2= yc-mval[1];
if(midtog && (mode=='r' || mode=='R')) {
turntable = 1;
phi0+= .007*(float)(dy2-dy1);
phi1+= .007*(float)(dx1-dx2);
apply_keyb_grid(&phi0, 0.0, (5.0/180)*M_PI, (1.0/180)*M_PI, gridflag & USER_AUTOROTGRID);
apply_keyb_grid(&phi1, 0.0, (5.0/180)*M_PI, (1.0/180)*M_PI, gridflag & USER_AUTOROTGRID);
if(typemode){
VecRotToMat3(rot0, addvec[1]*M_PI/180.0, smat);
VecRotToMat3(rot1, addvec[2]*M_PI/180.0, totmat);
Mat3MulMat3(mat, smat, totmat);
doit= 1;
}
else if(oldval[0]!=phi0 || oldval[1]!=phi1){
VecRotToMat3(rot0, phi0, smat);
VecRotToMat3(rot1, phi1, totmat);
Mat3MulMat3(mat, smat, totmat);
dx1= dx2;
dy1= dy2;
oldval[0]= phi0;
oldval[1]= phi1;
doit= 1;
}
}
else {
deler= sqrt( (dx1*dx1+dy1*dy1)*(dx2*dx2+dy2*dy2));
if(deler>1.0) {
dphi= (dx1*dx2+dy1*dy2)/deler;
dphi= saacos(dphi);
if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
if(G.qual & LR_SHIFTKEY) phi+= dphi/30.0;
else phi+= dphi;
apply_keyb_grid(&phi, 0.0, (5.0/180)*M_PI, (1.0/180)*M_PI, gridflag & USER_AUTOROTGRID);
if(axismode) {
if(axismode==XTRANS) vec[0]= -1.0; else vec[0]= 0.0;
if(axismode==YTRANS) vec[1]= 1.0; else vec[1]= 0.0;
if(axismode==ZTRANS) vec[2]= -1.0; else vec[2]= 0.0;
if (G.obedit){
if (axismode == XTRANSLOCAL) VECCOPY(vec, G.obedit->obmat[0]);
if (axismode == YTRANSLOCAL) VECCOPY(vec, G.obedit->obmat[1]);
if (axismode == ZTRANSLOCAL) VECCOPY(vec, G.obedit->obmat[2]);
if (axismode & TRANSLOCAL) VecMulf(vec, -1.0);
}
}
if(typemode){
doit= 1;
if(axismode) {
VecRotToMat3(vec, addvec[0]*M_PI/180.0, mat);
}
else VecRotToMat3(rot2, addvec[0]*M_PI/180.0, mat);
}
else if(oldval[2]!=phi) {
dx1= dx2;
dy1= dy2;
oldval[2]= phi;
doit= 1;
if(axismode) {
VecRotToMat3(vec, phi, mat);
}
else VecRotToMat3(rot2, phi, mat);
}
}
}
if(doit) {
/* apply */
tob= transmain;
tv= transvmain;
for(a=0; a<tottrans; a++, tob++, tv++) {
if(transmain) {
/* rotation in three steps:
* 1. editrot correction for parent
* 2. distill from this the euler. Always do this step because MatToEul is pretty weak
* 3. multiply with its own rotation, calculate euler.
*/
if ((G.vd->flag & V3D_ALIGN)==0) {
/* Roll around local axis */
if (mode=='r' || mode=='R'){
if (tob && axismode && (turntable == 0)){
if (axismode == XTRANSLOCAL){
VECCOPY(vec, tob->axismat[0]);
}
if (axismode == YTRANSLOCAL){
VECCOPY(vec, tob->axismat[1]);
}
if (axismode == ZTRANSLOCAL){
VECCOPY(vec, tob->axismat[2]);
}
/* Correct the vector */
if(cameragrab==0) { // because viewmat changes continious then
if ((axismode & TRANSLOCAL) && ((G.vd->viewmat[0][2] * vec[0]+G.vd->viewmat[1][2] * vec[1]+G.vd->viewmat[2][2] * vec[2])>0)){
vec[0]*=-1;
vec[1]*=-1;
vec[2]*=-1;
}
}
if (typemode)
VecRotToMat3(vec, addvec[0] * M_PI / 180.0, mat);
else
VecRotToMat3(vec, phi, mat);
}
}
Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0, 0, 0, 0);
/* 2 */
if( (tob->ob->transflag & OB_QUAT) == 0 && tob->rot){
Mat3ToEul(smat, eul);
EulToMat3(eul, smat);
}
/* 3 */
/* we now work with rot+drot */
if(tob->ob->transflag & OB_QUAT || !tob->rot) {
/* drot+rot TO DO! */
Mat3ToQuat(smat, quat); // Original
QuatMul(tob->quat, quat, tob->oldquat);
if(tob->flag & TOB_IPO) {
if(tob->flag & TOB_IPODROT) {
/* VecSubf(rot, eul, tob->oldrot); */
}
else {
/* VecSubf(rot, eul, tob->olddrot); */
}
/* VecMulf(rot, 9.0/M_PI_2); */
/* VecSubf(rot, rot, tob->oldrot+3); */
/* add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]); */
/* add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]); */
/* add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]); */
}
else {
/* QuatSub(tob->quat, quat, tob->oldquat); */
}
}
else {
VecAddf(eul, tob->oldrot, tob->olddrot);
EulToMat3(eul, tmat);
Mat3MulMat3(totmat, smat, tmat);
Mat3ToEul(totmat, eul);
/* Eul is not allowed to differ too much from old eul.
* This has only been tested for dx && dz
*/
compatible_eul(eul, tob->oldrot);
if(tob->flag & TOB_IPO) {
if(tob->flag & TOB_IPODROT) {
VecSubf(rot, eul, tob->oldrot);
}
else {
VecSubf(rot, eul, tob->olddrot);
}
VecMulf(rot, 9.0/M_PI_2);
VecSubf(rot, rot, tob->oldrot+3);
add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]);
add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]);
add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]);
}
else {
VecSubf(tob->rot, eul, tob->olddrot);
}
/* See if we've moved */
if (!VecCompare (tob->loc, tob->oldloc, 0.01)){
keyflags |= KEYFLAG_LOC;
}
}
}
if(G.vd->around!=V3D_LOCAL && (!G.obpose)) {
float vec[3]; // make local, the other vec stores rot axis
/* translation */
VecSubf(vec, tob->obvec, centre);
Mat3MulVecfl(mat, vec);
VecAddf(vec, vec, centre);
/* vec now is the location where the object has to be */
VecSubf(vec, vec, tob->obvec);
Mat3MulVecfl(tob->parinv, vec);
if(tob->flag & TOB_IPO) {
add_ipo_tob_poin(tob->locx, tob->oldloc, vec[0]);
add_ipo_tob_poin(tob->locy, tob->oldloc+1, vec[1]);
add_ipo_tob_poin(tob->locz, tob->oldloc+2, vec[2]);
}
else if(tob->loc) {
VecAddf(tob->loc, tob->oldloc, vec);
}
}
}
else {
if(mode=='t') {
if(tv->val) *(tv->val)= tv->oldval-phi;
}
else {
if(mode=='R') {
if(midtog) {
if (typemode){
VecRotToMat3(rot0, tv->fac*addvec[1] * M_PI / 180.0, smat);
VecRotToMat3(rot1, tv->fac*addvec[2] * M_PI / 180.0, totmat);
}
else{
VecRotToMat3(rot0, tv->fac*phi0, smat);
VecRotToMat3(rot1, tv->fac*phi1, totmat);
}
Mat3MulMat3(mat, smat, totmat);
}
else {
if (typemode)
VecRotToMat3(rot2, tv->fac*addvec[0] * M_PI / 180.0, mat);
else
VecRotToMat3(rot2, tv->fac*phi, mat);
}
}
Mat3MulMat3(totmat, mat, omat);
Mat3MulMat3(smat, imat, totmat);
VecSubf(vec, tv->oldloc, centre);
Mat3MulVecfl(smat, vec);
VecAddf(tv->loc, vec, centre);
}
}
}
if(midtog){
if (typemode){
if (ax == 1)
sprintf(str, "Rotx: >%.2f< Roty: %.2f", addvec[1], addvec[2]);
if (ax == 2)
sprintf(str, "Rotx: %.2f Roty: >%.2f<", addvec[1], addvec[2]);
}
else
sprintf(str, "Rotx: %.2f Roty: %.2f", 180.0*phi0/M_PI, 180.0*phi1/M_PI);
}
else if(axismode) {
if (typemode){
if(axismode==XTRANS) sprintf(str, "Rot X: >%.2f<", addvec[0]);
else if(axismode==YTRANS) sprintf(str, "Rot Y: >%.2f<", addvec[0]);
else if(axismode==ZTRANS) sprintf(str, "Rot Z: >%.2f<", addvec[0]);
else if(axismode==XTRANSLOCAL) sprintf(str, "Local Rot X: >%.2f<", addvec[0]);
else if(axismode==YTRANSLOCAL) sprintf(str, "Local Rot Y: >%.2f<", addvec[0]);
else if(axismode==ZTRANSLOCAL) sprintf(str, "Local Rot Z: >%.2f<", addvec[0]);
}
else{
if(axismode==XTRANS) sprintf(str, "Rot X: %.2f", 180.0*phi/M_PI);
else if(axismode==YTRANS) sprintf(str, "Rot Y: %.2f", 180.0*phi/M_PI);
else if(axismode==ZTRANS) sprintf(str, "Rot Z: %.2f", 180.0*phi/M_PI);
else if(axismode==XTRANSLOCAL) sprintf(str, "Local Rot X: %.2f", 180.0*phi/M_PI);
else if(axismode==YTRANSLOCAL) sprintf(str, "Local Rot Y: %.2f", 180.0*phi/M_PI);
else if(axismode==ZTRANSLOCAL) sprintf(str, "Local Rot Z: %.2f", 180.0*phi/M_PI);
}
}
else{
if (typemode)
sprintf(str, "Rot: >%.2f<", addvec[0]);
else
sprintf(str, "Rot: %.2f", 180.0*phi/M_PI);
}
headerprint(str);
time= my_clock();
if(G.obedit) calc_trans_verts();
special_trans_update(keyflags);
set_constline_callback(mode, axismode, midtog, centre, imat, vx, vy, vz);
if(fast==0) {
force_draw(0);
time= my_clock()-time;
if(time>50) fast= 1;
}
else {
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
if(tottrans>1 || G.vd->around==V3D_CURSOR) helpline(centre);
else if (G.obpose) helpline (centre);
}
}
else if(mode=='s' || mode=='S' || mode=='C' || mode=='N') {
keyflags |= KEYFLAG_SIZE;
if(mode=='S') {
size[0]= 1.0-(float)(xn-mval[0])*0.005;
size[1]= 1.0-(float)(yn-mval[1])*0.005;
size[2]= 1.0;
}
else size[0]=size[1]=size[2]= (sqrt( (float)((yc-mval[1])*(yc-mval[1])+(mval[0]-xc)*(mval[0]-xc)) ))/sizefac;
if (mode=='s') {
if (typemode){
if (numchange[0]) size[0] = addvec[0]; else size[0] = 1;
if (numchange[1]) size[1] = addvec[1]; else size[1] = 1;
if (numchange[2]) size[2] = addvec[2]; else size[2] = 1;
}
}
else {
if (typemode){
if (numchange[0])
size[0] = size[1] = size[2] = addvec[0];
else
size[0] = size[1] = size[2] = 1;
}
}
if(axismode && mode=='s') {
/* shear has no axismode */
if (!(G.obedit)){
if(axismode==XTRANS) axismode = XTRANSLOCAL;
if(axismode==YTRANS) axismode = YTRANSLOCAL;
if(axismode==ZTRANS) axismode = ZTRANSLOCAL;
}
if(axismode==XTRANS) size[1]=size[2]= 1.0;
if(axismode==YTRANS) size[0]=size[2]= 1.0;
if(axismode==ZTRANS) size[1]=size[0]= 1.0;
if(axismode==XTRANSLOCAL) size[1]=size[2]= 1.0;
if(axismode==YTRANSLOCAL) size[0]=size[2]= 1.0;
if(axismode==ZTRANSLOCAL) size[1]=size[0]= 1.0;
}
/* X en Y flip, there are 2 methods: at |**| removing comments makes flips local
if(transvmain) {
// x flip
val= test_midtog_proj(mval[0]+10, mval[1], mval);
size[val]*= xref;
// y flip
val= test_midtog_proj(mval[0], mval[1]+10, mval);
size[val]*= yref;
} */
/* grid */
apply_keyb_grid(size, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
apply_keyb_grid(size+1, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
apply_keyb_grid(size+2, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
if(transmain) {
size[0]= MINSIZE(size[0], 0.001);
size[1]= MINSIZE(size[1], 0.001);
size[2]= MINSIZE(size[2], 0.001);
}
if(size[0]!=oldval[0] ||size[1]!=oldval[1] ||size[2]!=oldval[2]) {
VECCOPY(oldval, size);
SizeToMat3(size, mat);
/* apply */
tob= transmain;
tv= transvmain;
for(a=0; a<tottrans; a++, tob++, tv++) {
if(transmain) {
/* size local with respect to parent AND own rotation */
/* local wrt parent: */
if ((G.vd->flag & V3D_ALIGN)==0) {
Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0,0 ,0, 0);
/* local wrt own rotation: */
Mat3MulSerie(totmat, tob->obmat, smat, tob->obinv, 0, 0, 0,0 ,0);
/* XXX this can yield garbage in case of inverted sizes (< 0.0)
*/
if(!midtog) {
sizelo[0]= size[0];
sizelo[1]= size[1];
sizelo[2]= size[2];
} else {
/* in this case the previous calculation of the size is wrong */
sizelo[0]= totmat[0][0];
sizelo[1]= totmat[1][1];
sizelo[2]= totmat[2][2];
apply_keyb_grid(sizelo, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
apply_keyb_grid(sizelo+1, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
apply_keyb_grid(sizelo+2, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
}
/* x flip */
/**/ /* sizelo[0]*= xref; */
/* y flip */
/**/ /* sizelo[1]*= yref; */
/* z flip */
/**/ /* sizelo[2]*= zref; */
/* what you see is what you want; not what you get! */
/* correction for delta size */
if(tob->flag & TOB_IPO) {
/* calculate delta size (equal for size and dsize) */
vec[0]= (tob->oldsize[0]+tob->olddsize[0])*(sizelo[0] -1.0);
vec[1]= (tob->oldsize[1]+tob->olddsize[1])*(sizelo[1] -1.0);
vec[2]= (tob->oldsize[2]+tob->olddsize[2])*(sizelo[2] -1.0);
add_ipo_tob_poin(tob->sizex, tob->oldsize+3, vec[0]);
add_ipo_tob_poin(tob->sizey, tob->oldsize+4, vec[1]);
add_ipo_tob_poin(tob->sizez, tob->oldsize+5, vec[2]);
}
else {
tob->size[0]= (tob->oldsize[0]+tob->olddsize[0])*sizelo[0] -tob->olddsize[0];
tob->size[1]= (tob->oldsize[1]+tob->olddsize[1])*sizelo[1] -tob->olddsize[1];
tob->size[2]= (tob->oldsize[2]+tob->olddsize[2])*sizelo[2] -tob->olddsize[2];
}
} else {
sizelo[0]= size[0];
sizelo[1]= size[1];
sizelo[2]= size[2];
}
if(G.vd->around!=V3D_LOCAL && !G.obpose) {
/* translation */
VecSubf(vec, tob->obvec, centre);
Mat3MulVecfl(mat, vec);
VecAddf(vec, vec, centre);
/* vec is the location where the object has to be */
VecSubf(vec, vec, tob->obvec);
Mat3MulVecfl(tob->parinv, vec);
if(tob->flag & TOB_IPO) {
add_ipo_tob_poin(tob->locx, tob->oldloc, vec[0]);
add_ipo_tob_poin(tob->locy, tob->oldloc+1, vec[1]);
add_ipo_tob_poin(tob->locz, tob->oldloc+2, vec[2]);
}
else if(tob->loc) {
if(transmode==TRANS_TEX) ;
else VecAddf(tob->loc, tob->oldloc, vec);
}
}
}
else { /* vertices */
/* for print */
VECCOPY(sizelo, size);
if(mode=='C') {
size[0]= tv->fac*size[0]+ 1.0-tv->fac;;
size[1]= tv->fac*size[1]+ 1.0-tv->fac;;
size[2]= tv->fac*size[2]+ 1.0-tv->fac;;
SizeToMat3(size, mat);
VECCOPY(size, oldval);
}
if(mode=='S') { /* shear */
Mat3One(tmat);
tmat[0][0]= tmat[2][2]= tmat[1][1]= 1.0;
tmat[1][0]= size[0]-1.0;
Mat3MulMat3(totmat, persmat, omat);
Mat3MulMat3(mat, tmat, totmat);
Mat3MulMat3(totmat, persinv, mat);
Mat3MulMat3(smat, imat, totmat);
}
else {
if (axismode & TRANSLOCAL)
Mat3CpyMat3(smat, mat);
else {
Mat3MulMat3(totmat, imat, mat);
Mat3MulMat3(smat, totmat, omat);
}
}
if(mode=='N' && tv->nor!=NULL) {
tv->loc[0]= tv->oldloc[0] + (size[0]-1.0)*tv->nor[0];
tv->loc[1]= tv->oldloc[1] + (size[1]-1.0)*tv->nor[1];
tv->loc[2]= tv->oldloc[2] + (size[2]-1.0)*tv->nor[2];
}
else {
VecSubf(vec, tv->oldloc, centre);
Mat3MulVecfl(smat, vec);
VecAddf(tv->loc, vec, centre);
if(G.obedit->type==OB_MBALL) *(tv->val)= size[0]*tv->oldval;
}
}
}
if(mode=='s') {
if (typemode){
switch (ax){
case 0:
sprintf(str, "Sizex: >%.3f< Sizey: >%.3f< Sizez: >%.3f<", sizelo[0], sizelo[1], sizelo[2]);
break;
case 1:
sprintf(str, "Sizex: >%.3f< Sizey: %.3f Sizez: %.3f", sizelo[0], sizelo[1], sizelo[2]);
break;
case 2:
sprintf(str, "Sizex: %.3f Sizey: >%.3f< Sizez: %.3f", sizelo[0], sizelo[1], sizelo[2]);
break;
case 3:
sprintf(str, "Sizex: %.3f Sizey: %.3f Sizez: >%.3f<", sizelo[0], sizelo[1], sizelo[2]);
}
}
else if (axismode & TRANSLOCAL)
sprintf(str, "Local Sizex: %.3f Sizey: %.3f Sizez: %.3f", sizelo[0], sizelo[1], sizelo[2]);
else
sprintf(str, "Sizex: %.3f Sizey: %.3f Sizez: %.3f", sizelo[0], sizelo[1], sizelo[2]);
}
else if (mode=='S') {
if (typemode)
sprintf(str, "Shear: >%.3f<", sizelo[0]);
else
sprintf(str, "Shear: %.3f", sizelo[0]);
}
else if (mode=='C') {
if (typemode)
sprintf(str, "Size: >%.3f<", sizelo[0]);
else
sprintf(str, "Size: %.3f", sizelo[0]);
}
else if (mode=='N') {
if (typemode)
sprintf(str, "Shrink/Fatten: >%.3f< ", size[0]);
else
sprintf(str, "Shrink/Fatten: %.3f", size[0]);
}
headerprint(str);
time= my_clock();
if(G.obedit) calc_trans_verts();
special_trans_update(keyflags);
set_constline_callback(mode, axismode, midtog, centre, imat, vx, vy, vz);
if(fast==0) {
force_draw(0);
time= my_clock()-time;
if(time>50) fast= 1;
}
else {
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
if(tottrans>1 || G.vd->around==V3D_CURSOR) helpline(centre);
}
}
else if(mode=='w') {
float Dist1;
window_to_3d(dvec, 1, 1);
circumfac= startcircumfac+ 0.05*( mval[1] - yn)*Normalise(dvec);
/* calc angle for print */
dist= max[0]-centre[0];
Dist1 = dist;
phi0= 360*circumfac*dist/(rad*M_PI);
if ((typemode) && (addvec[0])){
phi0 = addvec[0];
}
if((G.qual & LR_CTRLKEY) && (typemode == 0)){
phi0= 5.0*floor(phi0/5.0);
circumfac= (phi0*rad*M_PI)/(360.0*dist);
}
if (typemode && addvec[0])
sprintf(str, "Warp >%3.3f<", addvec[0]);
else
sprintf(str, "Warp %3.3f", phi0);
headerprint(str);
/* each vertex transform individually */
tob= transmain;
tv= transvmain;
for(a=0; a<tottrans; a++, tob++, tv++) {
if(transvmain) {
/* translate point to centre, rotate in such a way that outline==distance */
VECCOPY(vec, tv->oldloc);
Mat4MulVecfl(G.obedit->obmat, vec);
Mat4MulVecfl(G.vd->viewmat, vec);
dist= vec[0]-centre[0];
if ((typemode) && (addvec[0]))
phi0= (dist*addvec[0]*M_PI/(360.0*Dist1)) - 0.5*M_PI;
else
phi0= (circumfac*dist/rad) - 0.5*M_PI;
co= cos(phi0);
si= sin(phi0);
vec[0]= (centre[0]-axis[0]);
vec[1]= (vec[1]-axis[1]);
tv->loc[0]= si*vec[0]+co*vec[1]+axis[0];
tv->loc[1]= co*vec[0]-si*vec[1]+axis[1];
tv->loc[2]= vec[2];
Mat4MulVecfl(viewinv, tv->loc);
Mat4MulVecfl(imat4, tv->loc);
}
}
if(G.obedit) calc_trans_verts();
special_trans_update(keyflags);
if(fast==0) {
time= my_clock();
force_draw(0);
time= my_clock()-time;
if(time>50) fast= 1;
}
else {
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
}
else if(mode=='e') {
/* edge sharpening */
/* only works in edit mode */
if (G.obedit && G.editMesh) {
EditMesh *em = G.editMesh;
EditEdge *ee;
Mesh *me= G.obedit->data;
float mincr=10.0, maxcr= 0.0;
int tot= 0;
/* for esc and calculus */
if(edge_creases==NULL) {
for(ee = em->edges.first; ee; ee= ee->next, tot++);
edge_creases= MEM_mallocN(sizeof(float)*tot, "transform creases");
for(tot= 0, ee = em->edges.first; ee; ee= ee->next, tot++)
edge_creases[tot]= ee->crease;
}
/* this is sufficient to invoke edges added in mesh, but only in editmode */
if(me->medge==NULL) {
me->medge= MEM_callocN(sizeof(MEdge), "fake medge");
me->totedge= 1;
allqueue(REDRAWBUTSEDIT, 0);
}
/* we use input method like scaling, but map effictive range to:
scale 1.0-0.5 : crease no change to full sharp
scale 1.0-2.0 : crease no change to full round */
dist= (sqrt( (float)((yc-mval[1])*(yc-mval[1])+(mval[0]-xc)*(mval[0]-xc)) ))/sizefac;
CLAMP(dist, 0.5, 2.0);
if(dist<1.0) dist= 2.0*(dist-0.5);
for(tot= 0, ee = em->edges.first; ee; ee= ee->next, tot++) {
if(ee->f & SELECT) {
/* this edge is selected */
if(dist<1.0)
ee->crease = (1.0 - dist) + dist*edge_creases[tot];
else
ee->crease = (2.0-dist)*edge_creases[tot];
CLAMP(ee->crease, 0.0, 1.0);
if(mincr>ee->crease) mincr= ee->crease;
if(maxcr<ee->crease) maxcr= ee->crease;
}
}
if(mincr==10.0) wrong= 1;
else {
if(mincr==maxcr) sprintf(str, "Edge sharpness: %.3f", mincr);
else sprintf(str, "Edge sharpness range: %.3f - %.3f", mincr, maxcr);
headerprint(str);
if(G.obedit) calc_trans_verts();
special_trans_update(keyflags);
if(fast==0) {
time= my_clock();
force_draw(0);
time= my_clock()-time;
if(time>50) fast= 1;
}
else {
scrarea_do_windraw(curarea);
screen_swapbuffers();
}
}
}
else {
wrong = 1;
}
}
/* Help line drawing starts here */
}
while( qtest() ) {
float add_num = 0; // numerical value to be added
event= extern_qread(&val);
if(val) {
/* no-numpad option OR typemode remaps padminus */
if (((U.flag & USER_NONUMPAD) || typemode) && event==PADMINUS) event = MINUSKEY;
switch(event) {
case ESCKEY:
case LEFTMOUSE:
case RIGHTMOUSE:
case SPACEKEY:
case PADENTER:
case RETKEY:
breakloop= 1;
break;
case MIDDLEMOUSE:
midtog= ~midtog;
if(midtog) {
int proj;
proj= test_midtog_proj(xn, yn, mval);
if (proj==0)
axismode=XTRANS;
if (proj==1)
axismode=YTRANS;
if (proj==2)
axismode=ZTRANS;
phi0= phi1= 0.0;
if(cameragrab) {
dvec[0]= dvec[1]= dvec[2]= 0.0;
}
if(mode == 'n') mode= 'g';
}
else
axismode = 0;
if ((mode == 'r') || (mode == 'R')){
if (midtog){ax = 1;}
else{ax = 0;}
}
firsttime= 1;
break;
case GKEY:
case RKEY:
case SKEY:
/* Resetting the variables */
addvec[0]=addvec[1]=addvec[2]=0;
ax = del = typemode = 0;
pe[0]=pe[1]=pe[2]=0;
mi[0]=mi[1]=mi[2]=1;
numchange[0]=numchange[1]=numchange[2]=0;
getmouseco_areawin(mval);
xn=xo= mval[0];
yn=xo= mval[1];
dx1= xc-xn;
dy1= yc-yn;
phi= phi0= phi1= 0.0;
sizefac= sqrt( (float)((yc-yn)*(yc-yn)+(xn-xc)*(xn-xc)) );
if(sizefac<2.0) sizefac= 2.0;
if (G.obedit && (G.f & G_PROPORTIONAL)) {
if(event==GKEY) mode= 'G';
else if(event==RKEY) mode= 'R';
else if(event==SKEY && G.qual == LR_ALTKEY) mode= 'N';
else if(event==SKEY && G.qual == LR_CTRLKEY) mode= 'S';
else if(event==SKEY) mode= 'C';
} else {
if(event==GKEY) mode= 'g';
else if(event==RKEY) mode= 'r';
else if(event==SKEY && G.qual==LR_ALTKEY && G.obedit) mode= 'N';
else if(event==SKEY && G.qual==LR_CTRLKEY && G.obedit) mode= 'S';
else if(event==SKEY) mode= 's';
}
firsttime= 1;
tob= transmain;
tv= transvmain;
for(a=0; a<tottrans; a++, tob++, tv++) {
if(transmain) {
restore_tob(tob);
}
else {
VECCOPY(tv->loc, tv->oldloc);
}
}
break;
case XKEY:
if (axismode==XTRANS)
axismode=XTRANSLOCAL;
else if (axismode==XTRANSLOCAL)
axismode=0;
else{
axismode= XTRANS;
}
if (mode == 'g') {
if (axismode & XTRANS)
ax = 0;
} else if (mode == 's') {
if (axismode & XTRANS)
ax = 1;
}
firsttime=1;
break;
case YKEY:
if (axismode==YTRANS)
axismode=YTRANSLOCAL;
else if (axismode==YTRANSLOCAL)
axismode=0;
else{
axismode= YTRANS;
}
if (mode == 'g') {
if (axismode & YTRANS)
ax = 1;
} else if (mode == 's') {
if (axismode & YTRANS)
ax = 2;
}
firsttime=1;
break;
case ZKEY:
if (axismode==ZTRANS)
axismode=ZTRANSLOCAL;
else if (axismode==ZTRANSLOCAL)
axismode=0;
else{
axismode= ZTRANS;
}
if (mode == 'g') {
if (axismode & ZTRANS)
ax = 2;
} else if (mode == 's') {
if (axismode & ZTRANS)
ax = 3;
}
firsttime=1;
break;
case WHEELDOWNMOUSE:
case PADPLUSKEY:
if(G.f & G_PROPORTIONAL) {
prop_size*= 1.1;
firsttime= 1;
}
else {
if(event == WHEELDOWNMOUSE)
view_editmove(event);
else
persptoetsen(PADPLUSKEY);
firsttime= 1;
}
break;
case WHEELUPMOUSE:
case PADMINUS:
if(G.f & G_PROPORTIONAL) {
prop_size*= 0.90909090;
firsttime= 1;
}
else {
if(event == WHEELUPMOUSE)
view_editmove(event);
else
persptoetsen(PADMINUS);
firsttime= 1;
}
break;
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
VECCOPY(d_dvec, dvec);
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
firsttime= 1;
break;
case NKEY:
{
// toggle between typemode = 0 and typemode = 1
typemode *= -1;
typemode += 1;
firsttime = 1;
}
break;
case BACKSPACEKEY:
{
if (typemode){
if (((mode == 's') && (ax == 0)) || (mode == 'N')){
addvec[0]=addvec[1]=addvec[2]=0;
pe[0]=pe[1]=pe[2]=0;
mi[0]=mi[1]=mi[2]=1;
numchange[0]=numchange[1]=numchange[2]=0;
}
else if (del == 1){
addvec[0]=addvec[1]=addvec[2]=0;
pe[0]=pe[1]=pe[2]=0;
mi[0]=mi[1]=mi[2]=1;
numchange[0]=numchange[1]=numchange[2]=0;
del = 0;
}
else if (mode == 's'){
addvec[ax-1]=0;
pe[ax-1]=0;
mi[ax-1]=1;
numchange[ax-1]=0;
del = 1;
}
else if ((mode == 'r') || (mode == 'R')){
phi -= M_PI * addvec[ax] / 180;
addvec[ax] = 0;
pe[ax]=0;
mi[ax]=1;
numchange[ax]=0;
del = 1;
}
else{
addvec[ax] = 0;
pe[ax]=0;
mi[ax]=1;
numchange[ax]=0;
del = 1;
}
}
else{
getmouseco_areawin(mval);
xn=xo= mval[0];
yn=xo= mval[1];
dx1= xc-xn;
dy1= yc-yn;
phi= phi0= phi1= 0.0;
sizefac= sqrt( (float)((yc-yn)*(yc-yn)+(xn-xc)*(xn-xc)) );
if(sizefac<2.0) sizefac= 2.0;
}
firsttime = 1;
break;
}
case PERIODKEY:
case PADPERIOD:
{
typemode = 1;
del = 0;
if (((mode == 's') && (ax == 0)) || (mode == 'N')){
if (pe[0] == 0){pe[0] = 1;}
if (pe[1] == 0){pe[1] = 1;}
if (pe[2] == 0){pe[2] = 1;}
}
else if (mode == 's'){
if (pe[ax-1] == 0){pe[ax-1] = 1;}
}
else{
if (pe[ax] == 0){pe[ax] = 1;}
}
break;
}
case MINUSKEY:
{
del = 0;
if (((mode == 's') && (ax==0)) || (mode == 'N')){
addvec[0]*=-1;
mi[0] *= -1;
addvec[1]*=-1;
mi[1] *= -1;
addvec[2]*=-1;
mi[2] *= -1;
}
else if (mode == 's'){
addvec[ax-1]*=-1;
mi[ax-1] *= -1;
}
else{
addvec[ax]*=-1;
mi[ax] *= -1;
}
firsttime = 1;
break;
}
case TABKEY:
{
typemode = 1;
del = 0;
if ((mode == 'S') || (mode == 'w') || (mode == 'C') || (mode == 'N') || (mode == 'n'))
break;
if ((mode != 'r') && (mode != 'R')){
if (axismode != 0)
break;
ax += 1;
if (mode == 's'){
if (ax == 4){ax=0;}
}
else if (ax == 3){ax=0;}
firsttime = 1;
}
else if (((mode == 'r') || (mode == 'R')) && (midtog)){
ax += 1;
if (ax == 3){ax = 1;}
firsttime = 1;
}
break;
}
case PAD9:
case NINEKEY:
{add_num += 1;}
case PAD8:
case EIGHTKEY:
{add_num += 1;}
case PAD7:
case SEVENKEY:
{add_num += 1;}
case PAD6:
case SIXKEY:
{add_num += 1;}
case PAD5:
case FIVEKEY:
{add_num += 1;}
case PAD4:
case FOURKEY:
{add_num += 1;}
case PAD3:
case THREEKEY:
{add_num += 1;}
case PAD2:
case TWOKEY:
{add_num += 1;}
case PAD1:
case ONEKEY:
{add_num += 1;}
case PAD0:
case ZEROKEY:
{
typemode = 1;
del = 0;
if (mode == 's'){
if (axismode & XTRANS)
ax = 1;
if (axismode & YTRANS)
ax = 2;
if (axismode & ZTRANS)
ax = 3;
if (ax == 0){
if (pe[0]){
int div = 1;
int i;
for (i = 0; i < pe[ax]; i++){div*=10;}
addvec[0] += mi[0] * add_num / div;
pe[0]+=1;
addvec[1] += mi[1] * add_num / div;
pe[1]+=1;
addvec[2] += mi[2] * add_num / div;
pe[2]+=1;
}
else{
addvec[0] *= 10;
addvec[0] += mi[0] * add_num;
addvec[1] *= 10;
addvec[1] += mi[1] * add_num;
addvec[2] *= 10;
addvec[2] += mi[2] * add_num;
}
numchange[0]=numchange[1]=numchange[2]=1;
}
else{
if (pe[ax-1]){
int div = 1;
int i;
for (i = 0; i < pe[ax-1]; i++){div*=10;}
addvec[ax-1] += mi[ax-1] * add_num / div;
pe[ax-1]+=1;
}
else{
addvec[ax-1] *= 10;
addvec[ax-1] += mi[ax-1] * add_num;
}
numchange[ax-1]=1;
}
}
else if (mode == 'N'){
if (pe[0]){
int div = 1;
int i;
for (i = 0; i < pe[ax]; i++){div*=10;}
addvec[0] += mi[0] * add_num / div;
pe[0]+=1;
addvec[1] += mi[1] * add_num / div;
pe[1]+=1;
addvec[2] += mi[2] * add_num / div;
pe[2]+=1;
}
else{
addvec[0] *= 10;
addvec[0] += mi[0] * add_num;
addvec[1] *= 10;
addvec[1] += mi[1] * add_num;
addvec[2] *= 10;
addvec[2] += mi[2] * add_num;
}
numchange[0]=numchange[1]=numchange[2]=1;
}
else if ((mode == 'r') || (mode == 'R')){
if (pe[ax]){
int div = 1;
int i;
for (i = 0; i < pe[ax]; i++){div*=10;}
addvec[ax] += mi[ax] * add_num / div;
pe[ax]+=1;
}
else{
addvec[ax] *= 10;
addvec[ax] += mi[ax] * add_num;
}
numchange[ax]=1;
}
else{
if (axismode & XTRANS)
ax = 0;
if (axismode & YTRANS)
ax = 1;
if (axismode & ZTRANS)
ax = 2;
if (pe[ax]){
int div = 1;
int i;
for (i = 0; i < pe[ax]; i++){div*=10;}
addvec[ax] += mi[ax] * add_num / div;
pe[ax]+=1;
}
else{
addvec[ax] *= 10;
addvec[ax] += mi[ax] * add_num;
}
numchange[ax]=1;
}
firsttime=1;
}
break;
}
arrows_move_cursor(event);
}
if(event==0 || breakloop) break;
}
xo= mval[0];
yo= mval[1];
if( qtest()==0) PIL_sleep_ms(1);
}
G.moving= 0;
if(event==ESCKEY || event==RIGHTMOUSE) {
canceled=1;
if(edge_creases) { // exception case, edges dont fit in Trans structs...
EditEdge *ee;
int tot;
for(tot= 0, ee = G.editMesh->edges.first; ee; ee= ee->next, tot++)
ee->crease= edge_creases[tot];
makeDispList(G.obedit);
}
else {
tv= transvmain;
tob= transmain;
for(a=0; a<tottrans; a++, tob++, tv++) {
if(transmain) {
restore_tob(tob);
}
else {
VECCOPY(tv->loc, tv->oldloc);
if(tv->val) *(tv->val)= tv->oldval;
}
}
if(G.obedit) calc_trans_verts();
}
special_trans_update(keyflags);
}
a= 0;
if(xref<0) a++;
if(yref<0) a++;
if(zref<0) a++;
special_aftertrans_update(mode, a & 1, canceled, keyflags);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSOBJECT, 0);
scrarea_queue_headredraw(curarea);
clearbaseflags_for_editing();
if(transmain) MEM_freeN(transmain);
transmain= NULL;
if(transvmain) MEM_freeN(transvmain);
transvmain= NULL;
if(edge_creases) MEM_freeN(edge_creases);
tottrans= 0;
set_constline_callback(0, 0, 0, NULL, NULL, NULL, NULL, NULL); // disable
/* undo after transform, since it's storing current situations */
/* extrude/duplicate has no own undo-push, so on cancel we still insert it */
if(canceled==0 || strcmp(undostr, "Extrude")==0 || strcmp(undostr, "Duplicate")==0)
BIF_undo_push(undostr);
}
void std_rmouse_transform(void (*xf_func)(int))
void std_rmouse_transform(void (*xf_func)(int, int))
{
short mval[2];
short xo, yo;
@@ -6777,7 +4842,7 @@ void std_rmouse_transform(void (*xf_func)(int))
if(curarea->spacetype==SPACE_VIEW3D)
Transform(TFM_TRANSLATION, CTX_NONE);
else
xf_func('g');
xf_func('g', 0);
while(get_mbut() & mousebut) BIF_wait_for_statechange();
return;
@@ -6797,7 +4862,7 @@ void std_rmouse_transform(void (*xf_func)(int))
void rightmouse_transform(void)
{
std_rmouse_transform(transform);
std_rmouse_transform(Transform);
}

View File

@@ -210,7 +210,7 @@ void deselect_all_area_oops(void) /* all areas */
if(G.soops) G.soops->lockpoin= NULL;
}
void transform_oops(int mode)
void transform_oops(int mode, int context)
{
TransOops *transmain, *tv;
Oops *oops;

View File

@@ -98,8 +98,6 @@ Sequence *last_seq=0;
char last_imagename[FILE_MAXDIR+FILE_MAXFILE]= "/";
char last_sounddir[FILE_MAXDIR+FILE_MAXFILE]= "";
/* void transform_seq(int mode); already in BIF_editseq.h */
#define SEQ_DESEL ~(SELECT+SEQ_LEFTSEL+SEQ_RIGHTSEL)
static int test_overlap_seq(Sequence *);
@@ -678,7 +676,7 @@ static void add_image_strips(char *name)
waitcursor(0);
BIF_undo_push("Add image strip Sequencer");
transform_seq('g');
transform_seq('g', 0);
}
@@ -713,7 +711,7 @@ static void add_movie_strip(char *name)
waitcursor(0);
BIF_undo_push("Add movie strip Sequencer");
transform_seq('g');
transform_seq('g', 0);
}
@@ -742,7 +740,7 @@ static void add_sound_strip(char *name)
waitcursor(0);
BIF_undo_push("Add sound strip Sequencer");
transform_seq('g');
transform_seq('g', 0);
}
#if 0
@@ -960,7 +958,7 @@ static void load_plugin_seq(char *str) /* called from fileselect */
if( test_overlap_seq(last_seq) ) shuffle_seq(last_seq);
BIF_undo_push("Add plugin strip Sequencer");
transform_seq('g');
transform_seq('g', 0);
}
}
@@ -1085,7 +1083,7 @@ void add_sequence(int type)
if(seq->len>0) strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
BIF_undo_push("Add scene strip Sequencer");
transform_seq('g');
transform_seq('g', 0);
}
}
MEM_freeN(str);
@@ -1108,7 +1106,7 @@ void add_sequence(int type)
activate_fileselect(FILE_SPECIAL, "Select Plugin", U.plugseqdir, load_plugin_seq);
}
else {
if( add_seq_effect(event) ) transform_seq('g');
if( add_seq_effect(event) ) transform_seq('g', 0);
}
break;
@@ -1419,7 +1417,7 @@ void add_duplicate_seq(void)
addlisttolist(ed->seqbasep, &new);
BIF_undo_push("Add duplicate Sequencer");
transform_seq('g');
transform_seq('g', 0);
}
int insert_gap(int gap, int cfra)
@@ -1731,7 +1729,7 @@ typedef struct TransSeq {
int startofs, endofs;
} TransSeq;
void transform_seq(int mode)
void transform_seq(int mode, int context)
{
Sequence *seq;
Editing *ed;

View File

@@ -341,7 +341,7 @@ void tface_do_clip(void)
}
void transform_tface_uv(int mode)
void transform_tface_uv(int mode, int context) // 2 args, for callback
{
MFace *mface;
TFace *tface;

View File

@@ -707,8 +707,8 @@ int gesture(void)
if(i) {
if(curarea->spacetype==SPACE_IPO) transform_ipo(i);
else if(curarea->spacetype==SPACE_IMAGE) transform_tface_uv(i);
else if(curarea->spacetype==SPACE_OOPS) transform_oops('g');
else if(curarea->spacetype==SPACE_IMAGE) transform_tface_uv(i, 0);
else if(curarea->spacetype==SPACE_OOPS) transform_oops('g', 0);
else {
if(i=='g') Transform(TFM_TRANSLATION, CTX_NONE);
else if(i=='r') Transform(TFM_ROTATION, CTX_NONE);

View File

@@ -837,13 +837,13 @@ static void do_image_uvs_transformmenu(void *arg, int event)
{
switch(event) {
case 0: /* Grab */
transform_tface_uv('g');
transform_tface_uv('g', 0);
break;
case 1: /* Rotate */
transform_tface_uv('r');
transform_tface_uv('r', 0);
break;
case 2: /* Scale */
transform_tface_uv('s');
transform_tface_uv('s', 0);
break;
}
}

View File

@@ -255,10 +255,10 @@ static void do_oops_blockmenu(void *arg, int event)
switch(event)
{
case 0: /* grab/move */
transform_oops('g');
transform_oops('g', 0);
break;
case 1: /* scale */
transform_oops('s');
transform_oops('s', 0);
break;
}
}

View File

@@ -321,7 +321,7 @@ static void do_seq_editmenu(void *arg, int event)
exit_meta();
break;
case 11: /* grab/move */
transform_seq('g');
transform_seq('g', 0);
break;
case 12: /* Snap to Current Frame */
seq_snap(event);

View File

@@ -66,6 +66,7 @@
#include "BKE_mesh.h"
#include "BKE_image.h"
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BSE_edit.h"
@@ -1134,25 +1135,32 @@ static uiBlock *view3d_edit_snapmenu(void *arg_unused)
void do_view3d_transform_moveaxismenu(void *arg, int event)
{
float mat[3][3];
Mat3One(mat);
switch(event)
{
case 0: /* X Global */
transform('g'*'X');
BIF_setSingleAxisConstraint(mat[0], " X");
Transform(TFM_TRANSLATION, CTX_NONE);
break;
case 1: /* Y Global */
transform('g'*'Y');
BIF_setSingleAxisConstraint(mat[0], " Y");
Transform(TFM_TRANSLATION, CTX_NONE);
break;
case 2: /* Z Global */
transform('g'*'Z');
BIF_setSingleAxisConstraint(mat[0], " Z");
Transform(TFM_TRANSLATION, CTX_NONE);
break;
case 3: /* X Local */
transform('g'*'x');
// transform('g'*'x');
break;
case 4: /* Y Local */
transform('g'*'y');
// transform('g'*'y');
break;
case 5: /* Z Local */
transform('g'*'z');
// transform('g'*'z');
break;
}
allqueue(REDRAWVIEW3D, 0);
@@ -1184,25 +1192,32 @@ static uiBlock *view3d_transform_moveaxismenu(void *arg_unused)
void do_view3d_transform_rotateaxismenu(void *arg, int event)
{
float mat[3][3];
Mat3One(mat);
switch(event)
{
case 0: /* X Global */
transform('r'*'X');
BIF_setSingleAxisConstraint(mat[0], " X");
Transform(TFM_ROTATION, CTX_NONE);
break;
case 1: /* Y Global */
transform('r'*'Y');
BIF_setSingleAxisConstraint(mat[1], " Y");
Transform(TFM_ROTATION, CTX_NONE);
break;
case 2: /* Z Global */
transform('r'*'Z');
BIF_setSingleAxisConstraint(mat[2], " Z");
Transform(TFM_ROTATION, CTX_NONE);
break;
case 3: /* X Local */
transform('r'*'x');
// transform('r'*'x');
break;
case 4: /* Y Local */
transform('r'*'y');
// transform('r'*'y');
break;
case 5: /* Z Local */
transform('r'*'z');
// transform('r'*'z');
break;
}
allqueue(REDRAWVIEW3D, 0);
@@ -1234,25 +1249,32 @@ static uiBlock *view3d_transform_rotateaxismenu(void *arg_unused)
void do_view3d_transform_scaleaxismenu(void *arg, int event)
{
float mat[3][3];
Mat3One(mat);
switch(event)
{
case 0: /* X Global */
transform('s'*'X');
BIF_setSingleAxisConstraint(mat[0], " X");
Transform(TFM_RESIZE, CTX_NONE);
break;
case 1: /* Y Global */
transform('s'*'Y');
BIF_setSingleAxisConstraint(mat[1], " Y");
Transform(TFM_RESIZE, CTX_NONE);
break;
case 2: /* Z Global */
transform('s'*'Z');
BIF_setSingleAxisConstraint(mat[2], " Z");
Transform(TFM_RESIZE, CTX_NONE);
break;
case 3: /* X Local */
transform('s'*'x');
break;
case 4: /* Y Local */
transform('s'*'y');
break;
case 5: /* Z Local */
transform('s'*'z');
break;
}
allqueue(REDRAWVIEW3D, 0);
@@ -1933,7 +1955,7 @@ void do_view3d_edit_mesh_edgesmenu(void *arg, int event)
editmesh_mark_seam(1);
break;
case 9: /* Cease SubSurf */
transform('e');
Transform(TFM_CREASE, CTX_EDGE);
break;
case 10: /* Rotate Edge */
edge_rotate_selected(2);
@@ -2213,13 +2235,13 @@ static void do_view3d_edit_meshmenu(void *arg, int event)
delete_context_selected();
break;
case 9: /* Shrink/Fatten Along Normals */
transform('N');
Transform(TFM_SHRINKFATTEN, CTX_NONE);
break;
case 10: /* Shear */
transform('S');
Transform(TFM_SHEAR, CTX_NONE);
break;
case 11: /* Warp */
transform('w');
Transform(TFM_WARP, CTX_NONE);
break;
case 12: /* proportional edit (toggle) */
if(G.f & G_PROPORTIONAL) G.f &= ~G_PROPORTIONAL;
@@ -2310,7 +2332,7 @@ static void do_view3d_edit_curve_controlpointsmenu(void *arg, int event)
{
switch(event) {
case 0: /* tilt */
transform('t');
Transform(TFM_TILT, CTX_NONE);
break;
case 1: /* clear tilt */
clear_tilt();
@@ -2469,10 +2491,10 @@ static void do_view3d_edit_curvemenu(void *arg, int event)
else G.f |= G_PROPORTIONAL;
break;
case 13: /* Shear */
transform('S');
Transform(TFM_SHEAR, CTX_NONE);
break;
case 14: /* Warp */
transform('w');
Transform(TFM_WARP, CTX_NONE);
break;
}
allqueue(REDRAWVIEW3D, 0);
@@ -2590,10 +2612,10 @@ static void do_view3d_edit_metaballmenu(void *arg, int event)
delete_context_selected();
break;
case 5: /* Shear */
transform('S');
Transform(TFM_SHEAR, CTX_NONE);
break;
case 6: /* Warp */
transform('w');
Transform(TFM_WARP, CTX_NONE);
break;
case 7: /* Transform Properties */
add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, 0);
@@ -2797,10 +2819,10 @@ static void do_view3d_edit_latticemenu(void *arg, int event)
common_insertkey();
break;
case 3: /* Shear */
transform('S');
Transform(TFM_SHEAR, CTX_NONE);
break;
case 4: /* Warp */
transform('w');
Transform(TFM_WARP, CTX_NONE);
break;
case 5: /* proportional edit (toggle) */
if(G.f & G_PROPORTIONAL) G.f &= ~G_PROPORTIONAL;
@@ -2875,10 +2897,10 @@ static void do_view3d_edit_armaturemenu(void *arg, int event)
delete_context_selected();
break;
case 6: /* Shear */
transform('S');
Transform(TFM_SHEAR, CTX_NONE);
break;
case 7: /* Warp */
transform('w');
Transform(TFM_WARP, CTX_NONE);
break;
}
allqueue(REDRAWVIEW3D, 0);

View File

@@ -3384,7 +3384,7 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case GKEY:
if(sseq->mainb) break;
if((G.qual==0))
transform_seq('g');
transform_seq('g', 0);
break;
case MKEY:
if(G.qual==LR_ALTKEY)
@@ -3793,7 +3793,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case GKEY:
if((G.qual==0))
transform_tface_uv('g');
transform_tface_uv('g', 0);
break;
case HKEY:
if(G.qual==LR_ALTKEY)
@@ -3841,11 +3841,11 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case RKEY:
if((G.qual==0))
transform_tface_uv('r');
transform_tface_uv('r', 0);
break;
case SKEY:
if((G.qual==0))
transform_tface_uv('s');
transform_tface_uv('s', 0);
break;
case VKEY:
if((G.qual==0))
@@ -4048,7 +4048,7 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case GKEY:
if((G.qual==0))
transform_oops('g');
transform_oops('g', 0);
break;
case LKEY:
if((G.qual==LR_SHIFTKEY))
@@ -4066,7 +4066,7 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
shuffle_oops();
}
} else if((G.qual==0)) {
transform_oops('s');
transform_oops('s', 0);
}
break;
case PKEY:

View File

@@ -2006,13 +2006,13 @@ static void tb_do_transform(void *arg, int event)
snapmenu();
break;
case 5: /* Shrink/Fatten Along Normals */
transform('N');
Transform(TFM_SHRINKFATTEN, CTX_NONE);
break;
case 6: /* Shear */
Transform(TFM_SHEAR, CTX_NONE);
break;
case 7: /* Warp */
transform('w');
Transform(TFM_WARP, CTX_NONE);
break;
case 8: /* proportional edit (toggle) */
if(G.f & G_PROPORTIONAL) G.f &= ~G_PROPORTIONAL;

View File

@@ -80,6 +80,7 @@
#include "BIF_editmesh.h"
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_toets.h"
#include "BIF_toolbox.h"
#include "BKE_action.h"
@@ -128,6 +129,66 @@ int LastMode = TFM_TRANSLATION;
/* ************************** TRANSFORMATIONS **************************** */
static void view_editmove(unsigned short event)
{
/* Regular: Zoom in */
/* Shift: Scroll up */
/* Ctrl: Scroll right */
/* Alt-Shift: Rotate up */
/* Alt-Ctrl: Rotate right */
switch(event) {
case WHEELUPMOUSE:
if( G.qual & LR_SHIFTKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD2);
G.qual |= LR_SHIFTKEY;
} else {
persptoetsen(PAD2);
}
} else if( G.qual & LR_CTRLKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD4);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD4);
}
} else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADMINUS);
else
persptoetsen(PADPLUSKEY);
break;
case WHEELDOWNMOUSE:
if( G.qual & LR_SHIFTKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD8);
G.qual |= LR_SHIFTKEY;
} else {
persptoetsen(PAD8);
}
} else if( G.qual & LR_CTRLKEY ) {
if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD6);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD6);
}
} else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADPLUSKEY);
else
persptoetsen(PADMINUS);
break;
}
}
void Transform(int mode, int context)
{
int ret_val = 0;
@@ -426,16 +487,18 @@ void Transform(int mode, int context)
if(Trans.flag & T_PROP_EDIT) {
Trans.propsize*= 1.1f;
calculatePropRatio(&Trans);
Trans.redraw= 1;
}
else view_editmove(event);
Trans.redraw= 1;
break;
case WHEELUPMOUSE:
case PADMINUS:
if(Trans.flag & T_PROP_EDIT) {
Trans.propsize*= 0.90909090f;
calculatePropRatio(&Trans);
Trans.redraw= 1;
}
else view_editmove(event);
Trans.redraw= 1;
break;
}
Trans.redraw |= handleNumInput(&(Trans.num), event);