| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2010-03-21 01:14:04 +00:00
										 |  |  |  * $Id$ | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Martin Poirier | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |  #include <math.h>			/* fabs */
 | 
					
						
							|  |  |  | #include <stdio.h>			/* for sprintf		*/
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | #include "BKE_global.h"		/* for G			*/
 | 
					
						
							| 
									
										
										
										
											2011-01-07 19:18:31 +00:00
										 |  |  | 	/* ABS */ | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "transform.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-09 15:40:04 +00:00
										 |  |  | #if 0
 | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | static int updateNDofMotion(NDofInput *n); // return 0 when motion is null
 | 
					
						
							| 
									
										
										
										
											2009-07-09 15:40:04 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | static void resetNDofInput(NDofInput *n); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void initNDofInput(NDofInput *n) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-22 09:30:00 +00:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	n->flag = 0; | 
					
						
							|  |  |  | 	n->axis = 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	resetNDofInput(n); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for(i = 0; i < 3; i++) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		n->factor[i] = 1.0f; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void resetNDofInput(NDofInput *n) | 
					
						
							|  |  |  | {	 | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 	for(i = 0; i < 6; i++) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		n->fval[i] = 0.0f; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2010-10-16 14:32:17 +00:00
										 |  |  | int handleNDofInput(NDofInput *UNUSED(n), wmEvent *UNUSED(event)) | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int retval = 0; | 
					
						
							|  |  |  | 	// TRANSFORM_FIX_ME
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  | 	switch(event) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		case NDOFMOTION: | 
					
						
							|  |  |  | 			if (updateNDofMotion(n) == 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				retval = NDOF_NOMOVE; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				retval = NDOF_REFRESH; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case NDOFBUTTON: | 
					
						
							|  |  |  | 			if (val == 1)  | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				retval = NDOF_CONFIRM; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else if (val == 2)  | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				retval = NDOF_CANCEL; | 
					
						
							|  |  |  | 				resetNDofInput(n); | 
					
						
							|  |  |  | 				n->flag &= ~NDOF_INIT; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | #endif 	
 | 
					
						
							|  |  |  | 	return retval; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int hasNDofInput(NDofInput *n) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return (n->flag & NDOF_INIT) == NDOF_INIT; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void applyNDofInput(NDofInput *n, float *vec) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (hasNDofInput(n)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		int i, j; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		for (i = 0, j = 0; i < 6; i++) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			if (n->axis & (1 << i)) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				vec[j] = n->fval[i] * n->factor[j]; | 
					
						
							|  |  |  | 				j++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-09 15:40:04 +00:00
										 |  |  | // TRANSFORM_FIX_ME
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int updateNDofMotion(NDofInput *n) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-22 09:30:00 +00:00
										 |  |  | 	float fval[7]; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 	int retval = 0; | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	getndof(fval); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (G.vd->ndoffilter) | 
					
						
							|  |  |  | 		filterNDOFvalues(fval); | 
					
						
							| 
									
										
										
										
											2009-07-09 15:40:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | 	for(i = 0; i < 6; i++) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (!retval && fval[i] != 0.0f) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			retval = 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		n->fval[i] += fval[i] / 1024.0f; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	n->flag |= NDOF_INIT; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return retval; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-07-09 15:40:04 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
											
												2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
											
										 
											2008-12-29 01:41:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |