[Bf-committers] Patch for constrain-to-plane

Bill Baxter bf-committers@blender.org
Sun, 25 Jan 2004 22:33:19 -0500


This is a multi-part message in MIME format.
--------------010901080207080906020207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I wrote a patch to allow GKEY and SKEY operations to be constrained to a 
plane rather than just an axis.
I tested it in a CVS checkout from today.

Here's what it adds:
- {G,S}KEY, Ctrl+{X,Y,Z} constrains translations/scales to the plane 
defined by that axis (i.e. X gives you Y-Z plane etc),
- hitting the Ctrl- combo again switches to Local axes, then back to 
unconstrained, just like regular XY
- Both guide lines are drawn, i.e. constrain to X-Y draws X line and Y line.
- Type in of values work too.
- I fixed the TABKEY to highlight the *first* thing when you use it to 
go into typemode.  Currently, like for 'g' mode, if you hit TAB it 
highlights the Dy first, which is odd.
- I also updated the ScaleX header string to indicate active constraints 
(like the Dx Dy Dz header already does)

Thanks to Theeth for pointing me in the right direction.
He also said this was a change that had already been discussed and 
approved.  I hope he wasn't lying!  I just spent a big chunk of my 
afternoon on this!

What more could be done?
- I think typein mode should indicate the current insertion point.  I 
could do that with maybe a little caret indicator?  I think a standard 
cursor would be misleading because it's not really a real edit field.  
But it would be nice to be able to _see_ clearly that you did indeed 
type the decimal point.
- I think there should be better smarts in translating mouse motion for 
GKEY and SKEY modes in the constrained case.  Currently it just projects 
mouse motion onto the constraint axis/plane, but that behaves poorly 
when the axis is nearly perpendicular to the screen.   3DSMAX and those 
guys have a bit more complicated behavior to handle those cases.

Thanks!  I hope you like this patch and put it in!  Please bang on it a 
lot since it is my first attempt to modify Blender (and I just started 
using blender last week....)  So I could have missed some cases of how 
the transform() function gets called.

--bb



--------------010901080207080906020207
Content-Type: text/plain;
 name="plain_constrain_patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="plain_constrain_patch.txt"

Index: source/blender/src/editobject.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editobject.c,v
retrieving revision 1.68
diff -r1.68 editobject.c
4303a4304,4306
> #define YZTRANS		(YTRANS|ZTRANS)
> #define XZTRANS		(XTRANS|ZTRANS)
> #define XYTRANS		(XTRANS|YTRANS)
4305,4307c4308,4313
< #define XTRANSLOCAL	(XTRANS|TRANSLOCAL)
< #define YTRANSLOCAL	(YTRANS|TRANSLOCAL)
< #define ZTRANSLOCAL	(ZTRANS|TRANSLOCAL)
---
> #define XTRANSLOCAL		(XTRANS|TRANSLOCAL)
> #define YTRANSLOCAL		(YTRANS|TRANSLOCAL)
> #define ZTRANSLOCAL		(ZTRANS|TRANSLOCAL)
> #define YZTRANSLOCAL	(YZTRANS|TRANSLOCAL)
> #define XZTRANSLOCAL	(XZTRANS|TRANSLOCAL)
> #define XYTRANSLOCAL	(XYTRANS|TRANSLOCAL)
4354a4361,4384
> 		case XYTRANSLOCAL: 
> 			constline(cnst.centre, cnst.vx, 'x', NULL); 
> 			constline(cnst.centre, cnst.vy, 'y', matone);
> 			break;
> 		case YZTRANSLOCAL: 
> 			constline(cnst.centre, cnst.vy, 'y', NULL); 
> 			constline(cnst.centre, cnst.vz, 'z', matone);
> 			break;
> 		case XZTRANSLOCAL: 
> 			constline(cnst.centre, cnst.vx, 'x', NULL); 
> 			constline(cnst.centre, cnst.vz, 'z', matone);
> 			break;
> 		case XYTRANS: 
> 			constline(cnst.centre, cnst.imat,   'x', NULL);
> 			constline(cnst.centre, cnst.imat+3, 'y', NULL);
> 			break;
> 		case YZTRANS: 
> 			constline(cnst.centre, cnst.imat+3, 'y', NULL); 
> 			constline(cnst.centre, cnst.imat+6, 'z', NULL); 
> 			break;
> 		case XZTRANS: 
> 			constline(cnst.centre, cnst.imat,   'x', NULL);
> 			constline(cnst.centre, cnst.imat+6, 'z', NULL); 
> 			break;
4361a4392,4403
> 		case XYTRANS: 
> 			constline(cnst.centre, cnst.vx, 'x', NULL); 
> 			constline(cnst.centre, cnst.vy, 'y', NULL); 
> 			break;
> 		case YZTRANS:
> 			constline(cnst.centre, cnst.vy, 'y', NULL); 
> 			constline(cnst.centre, cnst.vz, 'z', NULL); 
> 			break;
> 		case XZTRANS:
> 			constline(cnst.centre, cnst.vx, 'x', NULL); 
> 			constline(cnst.centre, cnst.vz, 'z', NULL); 
> 			break;
4370a4413,4424
> 			case XYTRANSLOCAL:
> 				constline(tob->loc, tob->axismat[0], 'x', tob->axismat); 
> 				constline(tob->loc, tob->axismat[1], 'y', tob->axismat); 
> 				break;
> 			case YZTRANSLOCAL:
> 				constline(tob->loc, tob->axismat[1], 'y', tob->axismat); 
> 				constline(tob->loc, tob->axismat[2], 'z', tob->axismat); 
> 				break;
> 			case XZTRANSLOCAL:
> 				constline(tob->loc, tob->axismat[0], 'x', tob->axismat); 
> 				constline(tob->loc, tob->axismat[2], 'z', tob->axismat); 
> 				break;
4672c4726
< 				char gmode[10] = "";
---
> 				char gmode[11] = "";
4681a4736,4741
> 				if (axismode==XYTRANSLOCAL) strcpy(gmode, "Local XY: ");
> 				if (axismode==YZTRANSLOCAL) strcpy(gmode, "Local YZ: ");
> 				if (axismode==XZTRANSLOCAL) strcpy(gmode, "Local XZ: ");
> 				if (axismode==XYTRANS) strcpy(gmode, "XY Plane: ");
> 				if (axismode==YZTRANS) strcpy(gmode, "YZ Plane: ");
> 				if (axismode==XZTRANS) strcpy(gmode, "XZ Plane: ");
4693,4695c4753,4760
< 						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;
---
> 						switch (axismode&(XTRANS|YTRANS|ZTRANS)) {
> 						case XTRANS:  dvec[1]=dvec[2]= 0.0; break;
> 						case YTRANS:  dvec[0]=dvec[2]= 0.0; break;
> 						case ZTRANS:  dvec[0]=dvec[1]= 0.0; break;
> 						case XYTRANS: dvec[2] = 0.0; break;
> 						case YZTRANS: dvec[0] = 0.0; break;
> 						case XZTRANS: dvec[1] = 0.0; break;
> 						}
4698a4764
> 				printf("11  vec: %.4f %.4f %.4f\n", dvec[0],dvec[1],dvec[2]);
4706a4773,4775
> 					if(axismode == XYTRANS) dvec[2]= 0.0;
> 					if(axismode == YZTRANS) dvec[0]= 0.0;
> 					if(axismode == XZTRANS) dvec[1]= 0.0;
4728a4798,4800
> 							if(axismode==XYTRANSLOCAL) dvecp[2]=0;
> 							if(axismode==YZTRANSLOCAL) dvecp[0]=0;
> 							if(axismode==XZTRANSLOCAL) dvecp[1]=0;
4735a4808,4810
> 							if(axismode==XYTRANSLOCAL) dvecp[2]=0;
> 							if(axismode==YZTRANSLOCAL) dvecp[0]=0;
> 							if(axismode==XZTRANSLOCAL) dvecp[1]=0;
4782,4791c4857,4863
< 						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]);
< 						}
---
> 						int  l=0;
> 						if (ax==0||axismode&XTRANS) l+=sprintf(str+l,"%sDx: >%.4f<   ",gmode, dvec[0]);
> 						else                        l+=sprintf(str+l,"%sDx: %.4f   ",  gmode, dvec[0]);
> 						if (ax==1||axismode&YTRANS) l+=sprintf(str+l,"Dy: >%.4f<   ",dvec[1]);
> 						else                        l+=sprintf(str+l,"Dy: %.4f   ",  dvec[1]);
> 						if (ax==2||axismode&ZTRANS) l+=sprintf(str+l,"Dz: >%.4f<   ",dvec[2]);
> 						else                        l+=sprintf(str+l,"Dz: %.4f   ",  dvec[2]);
4819a4892
> 				int rotaxismode=axismode&~(XTRANS|YTRANS|ZTRANS);
4824a4898,4905
> 				/* Treat planar constraint modes as rot around the plane normal */
> 				if ((axismode&XYTRANS) == XYTRANS) { rotaxismode |= ZTRANS; }
> 				else if ((axismode&YZTRANS) == YZTRANS) { rotaxismode |= XTRANS; }
> 				else if ((axismode&XZTRANS) == XZTRANS) { rotaxismode |= YTRANS; }
> 				else {
> 					rotaxismode = axismode;
> 				}
> 
4855d4935
< 					
4865,4868c4945,4948
< 						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(rotaxismode) {
> 							if(rotaxismode==XTRANS) vec[0]= -1.0; else vec[0]= 0.0;
> 							if(rotaxismode==YTRANS) vec[1]= 1.0; else vec[1]= 0.0;
> 							if(rotaxismode==ZTRANS) vec[2]= -1.0; else vec[2]= 0.0;
4870,4873c4950,4953
< 								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 (rotaxismode == XTRANSLOCAL) VECCOPY(vec, G.obedit->obmat[0]);
> 								if (rotaxismode == YTRANSLOCAL) VECCOPY(vec, G.obedit->obmat[1]);
> 								if (rotaxismode == ZTRANSLOCAL) VECCOPY(vec, G.obedit->obmat[2]);
> 								if (rotaxismode & TRANSLOCAL) VecMulf(vec, -1.0);
4879c4959
< 							if(axismode) {
---
> 							if(rotaxismode) {
4889c4969
< 							if(axismode) {
---
> 							if(rotaxismode) {
4913,4914c4993,4994
< 								if (tob && axismode && (turntable == 0)){
< 									if (axismode == XTRANSLOCAL){ 
---
> 								if (tob && rotaxismode && (turntable == 0)){
> 									if (rotaxismode == XTRANSLOCAL){ 
4917c4997
< 									if (axismode == YTRANSLOCAL){
---
> 									if (rotaxismode == YTRANSLOCAL){
4920c5000
< 									if (axismode == ZTRANSLOCAL){
---
> 									if (rotaxismode == ZTRANSLOCAL){
4924c5004
< 									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)){
---
> 									if ((rotaxismode & TRANSLOCAL) && ((G.vd->viewmat[0][2] * vec[0]+G.vd->viewmat[1][2] * vec[1]+G.vd->viewmat[2][2] * vec[2])>0)){
5090c5170
< 					else if(axismode) {
---
> 					else if(rotaxismode) {
5092,5097c5172,5177
< 							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]);
---
> 							if(rotaxismode==XTRANS) sprintf(str, "Rot X: >%.2f<", addvec[0]);
> 							else if(rotaxismode==YTRANS) sprintf(str, "Rot Y: >%.2f<", addvec[0]);
> 							else if(rotaxismode==ZTRANS) sprintf(str, "Rot Z: >%.2f<", addvec[0]);
> 							else if(rotaxismode==XTRANSLOCAL) sprintf(str, "Local Rot X: >%.2f<", addvec[0]);
> 							else if(rotaxismode==YTRANSLOCAL) sprintf(str, "Local Rot Y: >%.2f<", addvec[0]);
> 							else if(rotaxismode==ZTRANSLOCAL) sprintf(str, "Local Rot Z: >%.2f<", addvec[0]);
5100,5105c5180,5185
< 							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);
---
> 							if(rotaxismode==XTRANS) sprintf(str, "Rot X: %.2f", 180.0*phi/M_PI);
> 							else if(rotaxismode==YTRANS) sprintf(str, "Rot Y: %.2f", 180.0*phi/M_PI);
> 							else if(rotaxismode==ZTRANS) sprintf(str, "Rot Z: %.2f", 180.0*phi/M_PI);
> 							else if(rotaxismode==XTRANSLOCAL) sprintf(str, "Local Rot X: %.2f", 180.0*phi/M_PI);
> 							else if(rotaxismode==YTRANSLOCAL) sprintf(str, "Local Rot Y: %.2f", 180.0*phi/M_PI);
> 							else if(rotaxismode==ZTRANSLOCAL) sprintf(str, "Local Rot Z: %.2f", 180.0*phi/M_PI);
5121c5201
< 					set_constline_callback(mode, axismode, midtog, centre, imat, vx, vy, vz);
---
> 					set_constline_callback(mode, rotaxismode, midtog, centre, imat, vx, vy, vz);
5157a5238,5240
> 						if(axismode==XYTRANS) axismode = XYTRANSLOCAL;
> 						if(axismode==YZTRANS) axismode = YZTRANSLOCAL;
> 						if(axismode==XZTRANS) axismode = XZTRANSLOCAL;
5161a5245,5247
> 					if(axismode==XYTRANS) size[2]= 1.0;
> 					if(axismode==YZTRANS) size[0]= 1.0;
> 					if(axismode==XZTRANS) size[1]= 1.0;
5164a5251,5253
> 					if(axismode==XYTRANSLOCAL) size[2]= 1.0;
> 					if(axismode==YZTRANSLOCAL) size[0]= 1.0;
> 					if(axismode==XZTRANSLOCAL) size[1]= 1.0;
5321a5411,5425
> 						char gmode[11] = "";
> 
> 						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==XYTRANSLOCAL) strcpy(gmode, "Local XY: ");
> 						if (axismode==YZTRANSLOCAL) strcpy(gmode, "Local YZ: ");
> 						if (axismode==XZTRANSLOCAL) strcpy(gmode, "Local XZ: ");
> 						if (axismode==XYTRANS) strcpy(gmode, "XY Plane: ");
> 						if (axismode==YZTRANS) strcpy(gmode, "YZ Plane: ");
> 						if (axismode==XZTRANS) strcpy(gmode, "XZ Plane: ");
> 						
5323,5335c5427,5433
< 							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]);
< 							}
---
> 							int  l=0;
> 							if (ax==0||ax==1||axismode&XTRANS) l+=sprintf(str+l,"%sSizex: >%.3f<   ",gmode,sizelo[0]);
> 							else                               l+=sprintf(str+l,"%sSizex: %.3f   ",  gmode,sizelo[0]);
> 							if (ax==0||ax==2||axismode&YTRANS) l+=sprintf(str+l,"Sizey: >%.3f<   ",sizelo[1]);
> 							else                               l+=sprintf(str+l,"Sizey: %.3f   ",  sizelo[1]);
> 							if (ax==0||ax==3||axismode&ZTRANS) l+=sprintf(str+l,"Sizez: >%.3f<",   sizelo[2]);
> 							else                               l+=sprintf(str+l,"Sizez: %.3f",     sizelo[2]);
5338c5436,5437
< 							sprintf(str, "Sizex: %.3f   Sizey: %.3f  Sizez: %.3f", sizelo[0], sizelo[1], sizelo[2]);
---
> 							sprintf(str, "%sSizex: %.3f   Sizey: %.3f  Sizez: %.3f", gmode, sizelo[0], sizelo[1], sizelo[2]);
>  
5548,5553c5647,5663
< 					if (axismode==XTRANS)
< 						axismode=XTRANSLOCAL;
< 					else if (axismode==XTRANSLOCAL)
< 						axismode=0;
< 					else{
< 						axismode= XTRANS;
---
> 					if (G.qual & LR_CTRLKEY) {
> 						if (axismode==YZTRANS)
> 							axismode=YZTRANSLOCAL;
> 						else if (axismode==YZTRANSLOCAL)
> 							axismode=0;
> 						else {
> 							axismode= YZTRANS;
> 						}
> 					}
> 					else {
> 						if (axismode==XTRANS)
> 							axismode=XTRANSLOCAL;
> 						else if (axismode==XTRANSLOCAL)
> 							axismode=0;
> 						else{
> 							axismode= XTRANS;
> 						}
5556,5557c5666,5667
<                             if (axismode & XTRANS)
<                                     ax = 0;
---
> 						if (axismode & XTRANS)
> 							ax = 0;
5559,5560c5669,5670
<                             if (axismode & XTRANS)
<                                     ax = 1;
---
> 						if (axismode & XTRANS)
> 							ax = 1;
5566,5571c5676,5692
< 					if (axismode==YTRANS)
< 						axismode=YTRANSLOCAL;
< 					else if (axismode==YTRANSLOCAL)
< 						axismode=0;
< 					else{
< 						axismode= YTRANS;
---
> 					if (G.qual & LR_CTRLKEY) {
> 						if (axismode==XZTRANS)
> 							axismode=XZTRANSLOCAL;
> 						else if (axismode==XZTRANSLOCAL)
> 							axismode=0;
> 						else{
> 							axismode= XZTRANS;
> 						}
> 					}
> 					else {
> 						if (axismode==YTRANS)
> 							axismode=YTRANSLOCAL;
> 						else if (axismode==YTRANSLOCAL)
> 							axismode=0;
> 						else{
> 							axismode= YTRANS;
> 						}
5584,5589c5705,5721
< 					if (axismode==ZTRANS)
< 						axismode=ZTRANSLOCAL;
< 					else if (axismode==ZTRANSLOCAL)
< 						axismode=0;
< 					else{
< 						axismode= ZTRANS;
---
> 					if (G.qual & LR_CTRLKEY) {
> 						if (axismode==XYTRANS)
> 							axismode=XYTRANSLOCAL;
> 						else if (axismode==XYTRANSLOCAL)
> 							axismode=0;
> 						else{
> 							axismode= XYTRANS;
> 						}
> 					}
> 					else {
> 						if (axismode==ZTRANS)
> 							axismode=ZTRANSLOCAL;
> 						else if (axismode==ZTRANSLOCAL)
> 							axismode=0;
> 						else{
> 							axismode= ZTRANS;
> 						}
5662,5665c5794,5805
< 								addvec[ax-1]=0;
< 								pe[ax-1]=0;
< 								mi[ax-1]=1;
< 								numchange[ax-1]=0;
---
> 								if (axismode&XTRANS) {
> 									addvec[0]=pe[0]=numchange[0]=0;
> 									mi[0]=1;
> 								}
> 								if (axismode&YTRANS) {
> 									addvec[1]=pe[1]=numchange[1]=0;
> 									mi[1]=1;
> 								}
> 								if (axismode&ZTRANS) {
> 									addvec[2]=pe[2]=numchange[2]=0;
> 									mi[2]=1;
> 								}
5706,5711c5846,5852
< 						else if (mode == 's'){
< 							if (pe[ax-1] == 0){pe[ax-1] = 1;}
< 						}
< 						else{
< 							if (pe[ax] == 0){pe[ax] = 1;}
< 						}
---
> 						else if (mode=='g') {
> 							if ((axismode&XTRANS) && pe[0] == 0){pe[0] = 1;}
> 							if ((axismode&YTRANS) && pe[1] == 0){pe[1] = 1;}
> 							if ((axismode&ZTRANS) && pe[2] == 0){pe[2] = 1;}
> 						} else {
>                           if (pe[0] == 0) pe[ax] = 1;
>                         }
5725,5727c5866,5869
< 						else if (mode == 's'){
< 							addvec[ax-1]*=-1;
< 							mi[ax-1] *= -1;
---
> 						else if (mode == 's' || mode == 'g' ){
> 							if (axismode&XTRANS) { addvec[0]*=-1; mi[0]*=-1; }
> 							if (axismode&YTRANS) { addvec[1]*=-1; mi[1]*=-1; }
> 							if (axismode&ZTRANS) { addvec[2]*=-1; mi[2]*=-1; }
5737a5880
> 						int was_typemode = typemode;
5742,5745c5885,5888
< 						if ((mode != 'r') && (mode != 'R')){
<                             if (axismode != 0)
<                                     break;
< 							ax += 1;
---
>                         if ((mode != 'r') && (mode != 'R') ) {
> 							if (axismode != 0)
> 								break;
> 							ax += was_typemode; 
5753c5896
< 							ax += 1;
---
> 							ax += was_typemode;
5792,5798c5935,5966
<                             if (axismode & XTRANS)
<                                     ax = 1;
<                             if (axismode & YTRANS)
<                                     ax = 2;
<                             if (axismode & ZTRANS)
<                                     ax = 3;
< 							if (ax == 0){
---
> 							if (typemode&& !axismode && ax!=0) {
> 								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 (axismode&(XTRANS|YTRANS|ZTRANS)) {
> 								for (ax=1;ax<=3;ax++){
> 									if (!(axismode & (XTRANS<<(ax-1)))) continue;
> 									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 {
5820,5833d5987
< 							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;
< 							}
5859c6013
< 							if (pe[ax]){
---
> 							if (pe[ax] ){
5873,5878c6027,6032
<                             if (axismode & XTRANS)
<                                     ax = 0;
<                             if (axismode & YTRANS)
<                                     ax = 1;
<                             if (axismode & ZTRANS)
<                                     ax = 2;
---
> 							if (axismode&(XTRANS|YTRANS|ZTRANS) == XTRANS)
> 								ax = 0;
> 							if (axismode&(XTRANS|YTRANS|ZTRANS) == YTRANS)
> 								ax = 1;
> 							if (axismode&(XTRANS|YTRANS|ZTRANS) == ZTRANS)
> 								ax = 2;

--------------010901080207080906020207--