[Bf-committers] Fix for Bug #760 with Patch

Nathanael Law bf-committers@blender.org
Tue, 16 Dec 2003 23:04:33 -0700


--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I am relatively new to this, so please let me know if I am
doing anything out of order or am posting this to the wrong
place.  Is it better to post bug fixes as follow-ups with
attachments in the bug tracker on GForge?

Attached is a fix for bug 760
(http://projects.blender.org/tracker/index.php?func=detail&aid=760&group_id=9&atid=125).

I have also included aesthetic fixes for revision 1.49.
When I wrote the changes that Martin committed to that
revision, I had odd settings in my editor.  Tabs were
being replaced with two spaces.  This affects only the
code added in 1.49.

If it is more appropriate to use separate diffs for the
bug fix and the aesthetic changes, or if anyone has
other advice for me, please let me know.  I only included
the aesthetic change because they only involved replacing
spaces with tabs, and code was not otherwise altered.

I also welcome comments on the code itself; if I have coded
something outside of standards for Blender, I wish to improve
this.

Thank you,

-- 
 - Nathanael Law <njlaw@blue-shift.ca>
   CTO, BlueShift Innovations Inc.


--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="DefaultSize.diff"

Index: source/blender/src/editobject.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editobject.c,v
retrieving revision 1.49
diff -u -r1.49 editobject.c
--- source/blender/src/editobject.c	17 Dec 2003 04:27:29 -0000	1.49
+++ source/blender/src/editobject.c	17 Dec 2003 05:45:22 -0000
@@ -3979,6 +3979,7 @@
 	int	keyflags = 0;
 
 	float addvec[3] = {0,0,0}; // for new typing code
+	short szchange[3] = {0,0,0}; // for code to use default size of 1.0
 	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).
@@ -4697,10 +4698,13 @@
 				}
 				else size[0]=size[1]=size[2]= (sqrt( (float)((yc-mval[1])*(yc-mval[1])+(mval[0]-xc)*(mval[0]-xc)) ))/sizefac;
 				
-				if (typemode){
-					size[0] = addvec[0];
-					size[1] = addvec[1];
-					size[2] = addvec[2];
+				if (typemode) {
+					if (szchange[0] == 0) size[0] = 1.0;
+					else size[0] = addvec[0];
+					if (szchange[1] == 0) size[1] = 1.0;
+					else size[1] = addvec[1];
+					if (szchange[2] == 0) size[2] = 1.0;
+					else size[2] = addvec[2];
 				}
 
 				if(axismode && mode=='s') {
@@ -5097,13 +5101,13 @@
 					else{
 						axismode= XTRANS;
 					}
-                    if (mode == 'g') {
-                            if (axismode & XTRANS)
-                                    ax = 0;
-                    } else if (mode == 's') {
-                            if (axismode & XTRANS)
-                                    ax = 1;
-                    }
+					if (mode == 'g') {
+						if (axismode & XTRANS)
+							ax = 0;
+					} else if (mode == 's') {
+						if (axismode & XTRANS)
+							ax = 1;
+					}
 					firsttime=1;
 					break;
 					
@@ -5115,13 +5119,13 @@
 					else{
 						axismode= YTRANS;
 					}
-                    if (mode == 'g') {
-                            if (axismode & YTRANS)
-                                    ax = 1;
-                    } else if (mode == 's') {
-                            if (axismode & YTRANS)
-                                    ax = 2;
-                    }
+					if (mode == 'g') {
+						if (axismode & YTRANS)
+							ax = 1;
+					} else if (mode == 's') {
+						if (axismode & YTRANS)
+							ax = 2;
+					}
 					firsttime=1;
 					break;
 					
@@ -5133,13 +5137,13 @@
 					else{
 						axismode= ZTRANS;
 					}
-                    if (mode == 'g') {
-                            if (axismode & ZTRANS)
-                                    ax = 2;
-                    } else if (mode == 's') {
-                            if (axismode & ZTRANS)
-                                    ax = 3;
-                    }
+					if (mode == 'g') {
+						if (axismode & ZTRANS)
+							ax = 2;
+					} else if (mode == 's') {
+						if (axismode & ZTRANS)
+							ax = 3;
+					}
 					firsttime=1;
 					break;
 				case WHEELDOWNMOUSE:
@@ -5194,18 +5198,22 @@
 								addvec[0]=addvec[1]=addvec[2]=0;
 								pe[0]=pe[1]=pe[2]=0;
 								mi[0]=mi[1]=mi[2]=1;
+								szchange[0] = szchange[1] = szchange[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;
 								del = 0;
+								if (mode == 's')
+									szchange[0] = szchange[1] = szchange[2] = 0;
 							}
 							else if (mode == 's'){
 								addvec[ax-1]=0;
 								pe[ax-1]=0;
 								mi[ax-1]=1;
 								del = 1;
+								szchange[ax-1] = 0;
 							}
 							else if ((mode == 'r') || (mode == 'R')){
 								phi -= M_PI * addvec[ax] / 180;
@@ -5280,8 +5288,8 @@
 						if ((mode == 'S') || (mode == 'w') || (mode == 'C') || (mode == 'N'))
 							break;
 						if ((mode != 'r') && (mode != 'R')){
-                            if (axismode != 0)
-                                    break;
+							if (axismode != 0)
+								break;
 							ax += 1;
 							if (mode == 's'){
 								if (ax == 4){ax=0;}
@@ -5328,13 +5336,13 @@
 					{
 						typemode = 1;
 						del = 0;
-						if (mode == 's'){
-                            if (axismode & XTRANS)
-                                    ax = 1;
-                            if (axismode & YTRANS)
-                                    ax = 2;
-                            if (axismode & ZTRANS)
-                                    ax = 3;
+						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;
@@ -5355,6 +5363,7 @@
 									addvec[2] *= 10;
 									addvec[2] += mi[2] * add_num;
 								}
+								szchange[0] = szchange[1] = szchange[2] = 1;
 							}
 							else{
 								if (pe[ax-1]){
@@ -5368,6 +5377,7 @@
 									addvec[ax-1] *= 10;
 									addvec[ax-1] += mi[ax-1] * add_num;
 								}
+								szchange[ax-1] = 1;
 							}
 							
 						}
@@ -5405,13 +5415,13 @@
 								addvec[ax] += mi[ax] * add_num;
 							}
 						}
-						else{
-                            if (axismode & XTRANS)
-                                    ax = 0;
-                            if (axismode & YTRANS)
-                                    ax = 1;
-                            if (axismode & ZTRANS)
-                                    ax = 2;
+						else {
+							if (axismode & XTRANS)
+								ax = 0;
+							if (axismode & YTRANS)
+								ax = 1;
+							if (axismode & ZTRANS)
+								ax = 2;
 							if (pe[ax]){
 								int div = 1;
 								int i;

--sdtB3X0nJg68CQEu--