| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +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: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Blender Foundation, 2002-2008 full recode | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:29:51 +00:00
										 |  |  | /** \file blender/editors/object/object_hook.c
 | 
					
						
							|  |  |  |  *  \ingroup edobj | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-10 20:43:45 +00:00
										 |  |  | #include "BLI_math.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "BLI_listbase.h"
 | 
					
						
							|  |  |  | #include "BLI_string.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_curve_types.h"
 | 
					
						
							|  |  |  | #include "DNA_lattice_types.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-19 22:17:30 +00:00
										 |  |  | #include "DNA_mesh_types.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "DNA_meshdata_types.h"
 | 
					
						
							|  |  |  | #include "DNA_object_types.h"
 | 
					
						
							|  |  |  | #include "DNA_scene_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | #include "BKE_action.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | #include "BKE_context.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "BKE_depsgraph.h"
 | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "BKE_mesh.h"
 | 
					
						
							|  |  |  | #include "BKE_modifier.h"
 | 
					
						
							|  |  |  | #include "BKE_object.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | #include "BKE_report.h"
 | 
					
						
							|  |  |  | #include "BKE_scene.h"
 | 
					
						
							| 
									
										
										
										
											2011-06-30 03:04:39 +00:00
										 |  |  | #include "BKE_deform.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | #include "BKE_tessmesh.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | #include "RNA_define.h"
 | 
					
						
							|  |  |  | #include "RNA_access.h"
 | 
					
						
							| 
									
										
										
											
												* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
  by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
  Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
  /usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
  by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
  bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
											
										 
											2010-03-30 12:15:16 +00:00
										 |  |  | #include "RNA_enum_types.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | #include "ED_curve.h"
 | 
					
						
							|  |  |  | #include "ED_mesh.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | #include "ED_screen.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | #include "UI_resources.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | #include "object_intern.h"
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, float *cent) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 	BMVert *eve; | 
					
						
							|  |  |  | 	BMIter iter; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	int *index, nr, totvert=0; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 	BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { | 
					
						
							| 
									
										
										
										
											2012-02-12 10:51:45 +00:00
										 |  |  | 		if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if(totvert==0) return 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	*indexar= index= MEM_mallocN(4*totvert, "hook indexar"); | 
					
						
							|  |  |  | 	*tot= totvert; | 
					
						
							|  |  |  | 	nr= 0; | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 	zero_v3(cent); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 	BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { | 
					
						
							| 
									
										
										
										
											2012-02-12 10:51:45 +00:00
										 |  |  | 		if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) { | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 			*index= nr; index++; | 
					
						
							| 
									
										
										
										
											2010-04-21 12:27:48 +00:00
										 |  |  | 			add_v3_v3(cent, eve->co); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		nr++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-10 20:43:45 +00:00
										 |  |  | 	mul_v3_fl(cent, 1.0f/(float)totvert); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return totvert; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, float *cent) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 	zero_v3(cent); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	if(obedit->actdef) { | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 		const int defgrp_index= obedit->actdef-1; | 
					
						
							| 
									
										
										
										
											2011-07-25 16:12:54 +00:00
										 |  |  | 		int totvert=0; | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MDeformVert *dvert; | 
					
						
							| 
									
										
										
										
											2011-07-25 16:12:54 +00:00
										 |  |  | 		BMVert *eve; | 
					
						
							|  |  |  | 		BMIter iter; | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		/* find the vertices */ | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 		BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { | 
					
						
							|  |  |  | 			dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			if(dvert) { | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 				if(defvert_find_weight(dvert, defgrp_index) > 0.0f) { | 
					
						
							|  |  |  | 					add_v3_v3(cent, eve->co); | 
					
						
							|  |  |  | 					totvert++; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if(totvert) { | 
					
						
							| 
									
										
										
										
											2011-06-30 02:52:13 +00:00
										 |  |  | 			bDeformGroup *dg = BLI_findlink(&obedit->defbase, defgrp_index); | 
					
						
							|  |  |  | 			BLI_strncpy(name, dg->name, sizeof(dg->name)); | 
					
						
							| 
									
										
										
										
											2009-11-10 20:43:45 +00:00
										 |  |  | 			mul_v3_fl(cent, 1.0f/(float)totvert); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 			return 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | }	 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Mesh *me= ob->data; | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 	BMEditMesh *em= me->edit_btmesh; | 
					
						
							|  |  |  | 	BMVert *eve; | 
					
						
							|  |  |  | 	BMIter iter; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	int index=0, nr=0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (hmd->indexar == NULL) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 	BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		if(nr==hmd->indexar[index]) { | 
					
						
							| 
									
										
										
										
											2012-02-12 10:51:45 +00:00
										 |  |  | 			BM_elem_select_set(em->bm, eve, TRUE); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 			if(index < hmd->totindex-1) index++; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		nr++; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-10 03:03:42 +00:00
										 |  |  | 	EDBM_select_flush(em); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar, float *cent) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BPoint *bp; | 
					
						
							|  |  |  | 	int *index, nr, totvert=0, a; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* count */ | 
					
						
							|  |  |  | 	a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; | 
					
						
							|  |  |  | 	bp= editlatt->def; | 
					
						
							|  |  |  | 	while(a--) { | 
					
						
							|  |  |  | 		if(bp->f1 & SELECT) { | 
					
						
							|  |  |  | 			if(bp->hide==0) totvert++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		bp++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(totvert==0) return 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	*indexar= index= MEM_mallocN(4*totvert, "hook indexar"); | 
					
						
							|  |  |  | 	*tot= totvert; | 
					
						
							|  |  |  | 	nr= 0; | 
					
						
							|  |  |  | 	cent[0]= cent[1]= cent[2]= 0.0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; | 
					
						
							|  |  |  | 	bp= editlatt->def; | 
					
						
							|  |  |  | 	while(a--) { | 
					
						
							|  |  |  | 		if(bp->f1 & SELECT) { | 
					
						
							|  |  |  | 			if(bp->hide==0) { | 
					
						
							|  |  |  | 				*index= nr; index++; | 
					
						
							| 
									
										
										
										
											2010-04-21 12:27:48 +00:00
										 |  |  | 				add_v3_v3(cent, bp->vec); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		bp++; | 
					
						
							|  |  |  | 		nr++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-10 20:43:45 +00:00
										 |  |  | 	mul_v3_fl(cent, 1.0f/(float)totvert); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return totvert; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void select_editlattice_hook(Object *obedit, HookModifierData *hmd) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-10 06:36:42 +00:00
										 |  |  | 	Lattice *lt= obedit->data, *editlt; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	BPoint *bp; | 
					
						
							|  |  |  | 	int index=0, nr=0, a; | 
					
						
							| 
									
										
										
										
											2010-08-10 06:36:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	editlt= lt->editlatt->latt; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	/* count */ | 
					
						
							| 
									
										
										
										
											2010-08-10 06:36:42 +00:00
										 |  |  | 	a= editlt->pntsu*editlt->pntsv*editlt->pntsw; | 
					
						
							|  |  |  | 	bp= editlt->def; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	while(a--) { | 
					
						
							|  |  |  | 		if(hmd->indexar[index]==nr) { | 
					
						
							|  |  |  | 			bp->f1 |= SELECT; | 
					
						
							|  |  |  | 			if(index < hmd->totindex-1) index++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		nr++; | 
					
						
							|  |  |  | 		bp++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, float *cent) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-14 00:37:27 +00:00
										 |  |  | 	ListBase *editnurb= object_editcurve_get(obedit); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	Nurb *nu; | 
					
						
							|  |  |  | 	BPoint *bp; | 
					
						
							|  |  |  | 	BezTriple *bezt; | 
					
						
							|  |  |  | 	int *index, a, nr, totvert=0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for(nu= editnurb->first; nu; nu= nu->next) { | 
					
						
							|  |  |  | 		if(nu->type == CU_BEZIER) { | 
					
						
							|  |  |  | 			bezt= nu->bezt; | 
					
						
							|  |  |  | 			a= nu->pntsu; | 
					
						
							|  |  |  | 			while(a--) { | 
					
						
							|  |  |  | 				if(bezt->f1 & SELECT) totvert++; | 
					
						
							|  |  |  | 				if(bezt->f2 & SELECT) totvert++; | 
					
						
							|  |  |  | 				if(bezt->f3 & SELECT) totvert++; | 
					
						
							|  |  |  | 				bezt++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			bp= nu->bp; | 
					
						
							|  |  |  | 			a= nu->pntsu*nu->pntsv; | 
					
						
							|  |  |  | 			while(a--) { | 
					
						
							|  |  |  | 				if(bp->f1 & SELECT) totvert++; | 
					
						
							|  |  |  | 				bp++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if(totvert==0) return 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	*indexar= index= MEM_mallocN(4*totvert, "hook indexar"); | 
					
						
							|  |  |  | 	*tot= totvert; | 
					
						
							|  |  |  | 	nr= 0; | 
					
						
							|  |  |  | 	cent[0]= cent[1]= cent[2]= 0.0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for(nu= editnurb->first; nu; nu= nu->next) { | 
					
						
							|  |  |  | 		if(nu->type == CU_BEZIER) { | 
					
						
							|  |  |  | 			bezt= nu->bezt; | 
					
						
							|  |  |  | 			a= nu->pntsu; | 
					
						
							|  |  |  | 			while(a--) { | 
					
						
							|  |  |  | 				if(bezt->f1 & SELECT) { | 
					
						
							|  |  |  | 					*index= nr; index++; | 
					
						
							| 
									
										
										
										
											2010-04-21 12:27:48 +00:00
										 |  |  | 					add_v3_v3(cent, bezt->vec[0]); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				if(bezt->f2 & SELECT) { | 
					
						
							|  |  |  | 					*index= nr; index++; | 
					
						
							| 
									
										
										
										
											2010-04-21 12:27:48 +00:00
										 |  |  | 					add_v3_v3(cent, bezt->vec[1]); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				if(bezt->f3 & SELECT) { | 
					
						
							|  |  |  | 					*index= nr; index++; | 
					
						
							| 
									
										
										
										
											2010-04-21 12:27:48 +00:00
										 |  |  | 					add_v3_v3(cent, bezt->vec[2]); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				bezt++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			bp= nu->bp; | 
					
						
							|  |  |  | 			a= nu->pntsu*nu->pntsv; | 
					
						
							|  |  |  | 			while(a--) { | 
					
						
							|  |  |  | 				if(bp->f1 & SELECT) { | 
					
						
							|  |  |  | 					*index= nr; index++; | 
					
						
							| 
									
										
										
										
											2010-04-21 12:27:48 +00:00
										 |  |  | 					add_v3_v3(cent, bp->vec); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				bp++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-10 20:43:45 +00:00
										 |  |  | 	mul_v3_fl(cent, 1.0f/(float)totvert); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return totvert; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-19 08:25:31 +00:00
										 |  |  | static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	*indexar= NULL; | 
					
						
							|  |  |  | 	*tot= 0; | 
					
						
							|  |  |  | 	name[0]= 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	switch(obedit->type) { | 
					
						
							|  |  |  | 		case OB_MESH: | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			Mesh *me= obedit->data; | 
					
						
							| 
									
										
										
										
											2011-09-19 08:25:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 17:15:54 +00:00
										 |  |  | 			BMEditMesh *em; | 
					
						
							| 
									
										
										
										
											2011-09-19 08:25:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 17:15:54 +00:00
										 |  |  | 			EDBM_LoadEditBMesh(scene, obedit); | 
					
						
							|  |  |  | 			EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			em = me->edit_btmesh; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* check selected vertices first */ | 
					
						
							|  |  |  | 			if( return_editmesh_indexar(em, tot, indexar, cent_r)) { | 
					
						
							|  |  |  | 				return 1; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				int ret = return_editmesh_vgroup(obedit, em, name, cent_r); | 
					
						
							|  |  |  | 				return ret; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		case OB_CURVE: | 
					
						
							|  |  |  | 		case OB_SURF: | 
					
						
							|  |  |  | 			return return_editcurve_indexar(obedit, tot, indexar, cent_r); | 
					
						
							|  |  |  | 		case OB_LATTICE: | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			Lattice *lt= obedit->data; | 
					
						
							| 
									
										
										
										
											2010-08-10 06:36:42 +00:00
										 |  |  | 			return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-14 00:37:27 +00:00
										 |  |  | 	ListBase *editnurb= object_editcurve_get(obedit); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	Nurb *nu; | 
					
						
							|  |  |  | 	BPoint *bp; | 
					
						
							|  |  |  | 	BezTriple *bezt; | 
					
						
							|  |  |  | 	int index=0, a, nr=0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for(nu= editnurb->first; nu; nu= nu->next) { | 
					
						
							|  |  |  | 		if(nu->type == CU_BEZIER) { | 
					
						
							|  |  |  | 			bezt= nu->bezt; | 
					
						
							|  |  |  | 			a= nu->pntsu; | 
					
						
							|  |  |  | 			while(a--) { | 
					
						
							|  |  |  | 				if(nr == hmd->indexar[index]) { | 
					
						
							|  |  |  | 					bezt->f1 |= SELECT; | 
					
						
							|  |  |  | 					if(index<hmd->totindex-1) index++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				if(nr == hmd->indexar[index]) { | 
					
						
							|  |  |  | 					bezt->f2 |= SELECT; | 
					
						
							|  |  |  | 					if(index<hmd->totindex-1) index++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				if(nr == hmd->indexar[index]) { | 
					
						
							|  |  |  | 					bezt->f3 |= SELECT; | 
					
						
							|  |  |  | 					if(index<hmd->totindex-1) index++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				bezt++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			bp= nu->bp; | 
					
						
							|  |  |  | 			a= nu->pntsu*nu->pntsv; | 
					
						
							|  |  |  | 			while(a--) { | 
					
						
							|  |  |  | 				if(nr == hmd->indexar[index]) { | 
					
						
							|  |  |  | 					bp->f1 |= SELECT; | 
					
						
							|  |  |  | 					if(index<hmd->totindex-1) index++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				nr++; | 
					
						
							|  |  |  | 				bp++; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | static void object_hook_select(Object *ob, HookModifierData *hmd)  | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-05 10:09:45 +00:00
										 |  |  | 	if (hmd->indexar == NULL) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-01-28 00:45:30 +00:00
										 |  |  | 	if(ob->type==OB_MESH) select_editbmesh_hook(ob, hmd); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd); | 
					
						
							|  |  |  | 	else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd); | 
					
						
							|  |  |  | 	else if(ob->type==OB_SURF) select_editcurve_hook(ob, hmd); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | /* special poll operators for hook operators */ | 
					
						
							|  |  |  | // TODO: check for properties window modifier context too as alternative?
 | 
					
						
							|  |  |  | static int hook_op_edit_poll(bContext *C) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *obedit= CTX_data_edit_object(C); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (obedit) { | 
					
						
							|  |  |  | 		if (ED_operator_editmesh(C)) return 1; | 
					
						
							|  |  |  | 		if (ED_operator_editsurfcurve(C)) return 1; | 
					
						
							|  |  |  | 		if (ED_operator_editlattice(C)) return 1; | 
					
						
							|  |  |  | 		//if (ED_operator_editmball(C)) return 1;
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | static Object *add_hook_object_new(Scene *scene, Object *obedit) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Base *base, *basedit; | 
					
						
							|  |  |  | 	Object *ob; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ob= add_object(scene, OB_EMPTY); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	basedit = object_in_scene(obedit, scene); | 
					
						
							|  |  |  | 	base = object_in_scene(ob, scene); | 
					
						
							|  |  |  | 	base->lay = ob->lay = obedit->lay; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* icky, add_object sets new base as active.
 | 
					
						
							|  |  |  | 	 * so set it back to the original edit object */ | 
					
						
							|  |  |  | 	scene->basact = basedit; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ob; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob, int mode) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ModifierData *md=NULL; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	HookModifierData *hmd = NULL; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	float cent[3]; | 
					
						
							|  |  |  | 	int tot, ok, *indexar; | 
					
						
							| 
									
										
										
										
											2012-01-11 08:51:06 +00:00
										 |  |  | 	char name[MAX_NAME]; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2011-09-19 08:25:31 +00:00
										 |  |  | 	ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	if (!ok) return;	// XXX error("Requires selected vertices or active Vertex Group");
 | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (mode==OBJECT_ADDHOOK_NEWOB && !ob) { | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		ob = add_hook_object_new(scene, obedit); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		/* transform cent to global coords for loc */ | 
					
						
							|  |  |  | 		mul_v3_m4v3(ob->loc, obedit->obmat, cent); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	md = obedit->modifiers.first; | 
					
						
							|  |  |  | 	while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { | 
					
						
							|  |  |  | 		md = md->next; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	hmd = (HookModifierData*) modifier_new(eModifierType_Hook); | 
					
						
							|  |  |  | 	BLI_insertlinkbefore(&obedit->modifiers, md, hmd); | 
					
						
							| 
									
										
										
										
											2009-11-22 12:28:38 +00:00
										 |  |  | 	BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name+2); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	modifier_unique_name(&obedit->modifiers, (ModifierData*)hmd); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	hmd->object= ob; | 
					
						
							|  |  |  | 	hmd->indexar= indexar; | 
					
						
							|  |  |  | 	copy_v3_v3(hmd->cent, cent); | 
					
						
							|  |  |  | 	hmd->totindex= tot; | 
					
						
							| 
									
										
										
										
											2010-11-05 07:35:21 +00:00
										 |  |  | 	BLI_strncpy(hmd->name, name, sizeof(hmd->name)); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* matrix calculus */ | 
					
						
							|  |  |  | 	/* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ | 
					
						
							|  |  |  | 	/*        (parentinv         )                          */ | 
					
						
							|  |  |  | 	where_is_object(scene, ob); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	invert_m4_m4(ob->imat, ob->obmat); | 
					
						
							|  |  |  | 	/* apparently this call goes from right to left... */ | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 	mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, | 
					
						
							|  |  |  | 	             NULL, NULL, NULL, NULL, NULL); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | 	DAG_scene_sort(bmain, scene); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | static int object_add_hook_selob_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | 	Main *bmain= CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	Scene *scene= CTX_data_scene(C); | 
					
						
							|  |  |  | 	Object *obedit = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 	Object *obsel=NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	CTX_DATA_BEGIN(C, Object*, ob, selected_objects) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (ob != obedit) { | 
					
						
							|  |  |  | 			obsel = ob; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	CTX_DATA_END; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!obsel) { | 
					
						
							| 
									
										
										
										
											2011-09-19 12:26:20 +00:00
										 |  |  | 		BKE_report(op->reports, RPT_ERROR, "Can't add hook with no other selected objects"); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | 	add_hook_object(bmain, scene, obedit, obsel, OBJECT_ADDHOOK_SELOB); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-12-17 06:06:30 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_add_selobj(wmOperatorType *ot) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							|  |  |  | 	ot->name= "Hook to Selected Object"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description= "Hook selected vertices to the first selected Object"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->idname= "OBJECT_OT_hook_add_selob"; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	/* api callbacks */ | 
					
						
							|  |  |  | 	ot->exec= object_add_hook_selob_exec; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-15 01:36:14 +00:00
										 |  |  | static int object_add_hook_newob_exec(bContext *C, wmOperator *UNUSED(op)) | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | 	Main *bmain= CTX_data_main(C); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	Scene *scene= CTX_data_scene(C); | 
					
						
							|  |  |  | 	Object *obedit = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-01 12:47:49 +00:00
										 |  |  | 	add_hook_object(bmain, scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); | 
					
						
							| 
									
										
										
										
											2009-12-17 06:06:30 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_add_newobj(wmOperatorType *ot) | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							|  |  |  | 	ot->name= "Hook to New Object"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description= "Hook selected vertices to the first selected Object"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->idname= "OBJECT_OT_hook_add_newob"; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							|  |  |  | 	ot->exec= object_add_hook_newob_exec; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int object_hook_remove_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int num= RNA_enum_get(op->ptr, "modifier"); | 
					
						
							|  |  |  | 	Object *ob=NULL; | 
					
						
							|  |  |  | 	HookModifierData *hmd=NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ob = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 	hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!ob || !hmd) { | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	/* remove functionality */ | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	BLI_remlink(&ob->modifiers, (ModifierData *)hmd); | 
					
						
							|  |  |  | 	modifier_free((ModifierData *)hmd); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-12-05 18:59:23 +00:00
										 |  |  | 	DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | 
					
						
							| 
									
										
										
										
											2009-12-17 06:06:30 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-26 13:38:16 +00:00
										 |  |  | static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | {	 | 
					
						
							|  |  |  | 	Object *ob = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 	EnumPropertyItem tmp = {0, "", 0, "", ""}; | 
					
						
							|  |  |  | 	EnumPropertyItem *item= NULL; | 
					
						
							|  |  |  | 	ModifierData *md = NULL; | 
					
						
							|  |  |  | 	int a, totitem= 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if(!ob) | 
					
						
							| 
									
										
										
											
												* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
  by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
  Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
  /usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
  by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
  bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
											
										 
											2010-03-30 12:15:16 +00:00
										 |  |  | 		return DummyRNA_NULL_items; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	for(a=0, md=ob->modifiers.first; md; md= md->next, a++) { | 
					
						
							|  |  |  | 		if (md->type==eModifierType_Hook) { | 
					
						
							|  |  |  | 			tmp.value= a; | 
					
						
							|  |  |  | 			tmp.icon = ICON_HOOK; | 
					
						
							|  |  |  | 			tmp.identifier= md->name; | 
					
						
							|  |  |  | 			tmp.name= md->name; | 
					
						
							|  |  |  | 			RNA_enum_item_add(&item, &totitem, &tmp); | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	RNA_enum_item_end(&item, &totitem); | 
					
						
							|  |  |  | 	*free= 1; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return item; | 
					
						
							| 
									
										
										
											
												2.5: Object module
* Split object_edit.c into multiple files:
  object_add.c, object_edit.c, object_hook.c, object_relations.c,
  object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
  object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
  * vertex group menu and set active
  * apply location, rotation, scale, visual transform (location is new)
  * make local
  * make vertex parent
  * move to layer
  * convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
  up here...
											
										 
											2009-09-09 11:52:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_remove(wmOperatorType *ot) | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* identifiers */ | 
					
						
							|  |  |  | 	ot->name= "Remove Hook"; | 
					
						
							|  |  |  | 	ot->idname= "OBJECT_OT_hook_remove"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description= "Remove a hook from the active object"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* api callbacks */ | 
					
						
							|  |  |  | 	ot->exec= object_hook_remove_exec; | 
					
						
							|  |  |  | 	ot->invoke= WM_menu_invoke; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2011-12-12 14:54:28 +00:00
										 |  |  | 	/* this operator removes modifier which isn't stored in local undo stack,
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	 * so redoing it from redo panel gives totally weird results  */ | 
					
						
							| 
									
										
										
										
											2011-12-12 14:54:28 +00:00
										 |  |  | 	ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							| 
									
										
										
										
											2011-09-19 12:26:20 +00:00
										 |  |  | 	prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, hook_mod_itemf); | 
					
						
							| 
									
										
										
										
											2010-01-15 22:40:33 +00:00
										 |  |  | 	ot->prop= prop; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | static int object_hook_reset_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); | 
					
						
							|  |  |  | 	int num= RNA_enum_get(op->ptr, "modifier"); | 
					
						
							|  |  |  | 	Object *ob=NULL; | 
					
						
							|  |  |  | 	HookModifierData *hmd=NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (ptr.data) {		/* if modifier context is available, use that */ | 
					
						
							|  |  |  | 		ob = ptr.id.data; | 
					
						
							|  |  |  | 		hmd= ptr.data; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	}  | 
					
						
							|  |  |  | 	else {			/* use the provided property */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		ob = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 		hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!ob || !hmd) { | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* reset functionality */ | 
					
						
							|  |  |  | 	if(hmd->object) { | 
					
						
							|  |  |  | 		bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if(hmd->subtarget[0] && pchan) { | 
					
						
							|  |  |  | 			float imat[4][4], mat[4][4]; | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			/* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ | 
					
						
							| 
									
										
										
											
												Math lib: matrix multiplication order fix for two functions that were
inconsistent with similar functions & math notation:
mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)
For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python
											
										 
											2011-12-16 19:53:12 +00:00
										 |  |  | 			mult_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 			 | 
					
						
							|  |  |  | 			invert_m4_m4(imat, mat); | 
					
						
							|  |  |  | 			mul_serie_m4(hmd->parentinv, imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			invert_m4_m4(hmd->object->imat, hmd->object->obmat); | 
					
						
							|  |  |  | 			mul_serie_m4(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-12-05 18:59:23 +00:00
										 |  |  | 	DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_reset(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->name= "Reset Hook"; | 
					
						
							| 
									
										
										
										
											2010-04-25 15:24:18 +00:00
										 |  |  | 	ot->description= "Recalculate and clear offset transformation"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->idname= "OBJECT_OT_hook_reset"; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* callbacks */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->exec= object_hook_reset_exec; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							| 
									
										
										
										
											2011-09-19 12:26:20 +00:00
										 |  |  | 	prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, hook_mod_itemf); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | static int object_hook_recenter_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); | 
					
						
							|  |  |  | 	int num= RNA_enum_get(op->ptr, "modifier"); | 
					
						
							|  |  |  | 	Object *ob=NULL; | 
					
						
							|  |  |  | 	HookModifierData *hmd=NULL; | 
					
						
							|  |  |  | 	Scene *scene = CTX_data_scene(C); | 
					
						
							|  |  |  | 	float bmat[3][3], imat[3][3]; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (ptr.data) {		/* if modifier context is available, use that */ | 
					
						
							|  |  |  | 		ob = ptr.id.data; | 
					
						
							|  |  |  | 		hmd= ptr.data; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	}  | 
					
						
							|  |  |  | 	else {			/* use the provided property */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		ob = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 		hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!ob || !hmd) { | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* recenter functionality */ | 
					
						
							|  |  |  | 	copy_m3_m4(bmat, ob->obmat); | 
					
						
							|  |  |  | 	invert_m3_m3(imat, bmat); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]); | 
					
						
							|  |  |  | 	mul_m3_v3(imat, hmd->cent); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-12-05 18:59:23 +00:00
										 |  |  | 	DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_recenter(wmOperatorType *ot) | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->name= "Recenter Hook"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description= "Set hook center to cursor position"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->idname= "OBJECT_OT_hook_recenter"; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* callbacks */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->exec= object_hook_recenter_exec; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							| 
									
										
										
										
											2011-09-19 12:26:20 +00:00
										 |  |  | 	prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, hook_mod_itemf); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | static int object_hook_assign_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-21 17:15:54 +00:00
										 |  |  | 	Scene *scene= CTX_data_scene(C); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); | 
					
						
							|  |  |  | 	int num= RNA_enum_get(op->ptr, "modifier"); | 
					
						
							|  |  |  | 	Object *ob=NULL; | 
					
						
							|  |  |  | 	HookModifierData *hmd=NULL; | 
					
						
							|  |  |  | 	float cent[3]; | 
					
						
							| 
									
										
										
										
											2012-01-11 08:51:06 +00:00
										 |  |  | 	char name[MAX_NAME]; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	int *indexar, tot; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (ptr.data) {		/* if modifier context is available, use that */ | 
					
						
							|  |  |  | 		ob = ptr.id.data; | 
					
						
							|  |  |  | 		hmd= ptr.data; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	}  | 
					
						
							|  |  |  | 	else {			/* use the provided property */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		ob = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 		hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!ob || !hmd) { | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* assign functionality */ | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2011-09-21 17:15:54 +00:00
										 |  |  | 	if(!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) { | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if(hmd->indexar) | 
					
						
							|  |  |  | 		MEM_freeN(hmd->indexar); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	copy_v3_v3(hmd->cent, cent); | 
					
						
							|  |  |  | 	hmd->indexar= indexar; | 
					
						
							|  |  |  | 	hmd->totindex= tot; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-12-05 18:59:23 +00:00
										 |  |  | 	DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_assign(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->name= "Assign to Hook"; | 
					
						
							| 
									
										
										
										
											2010-02-10 21:15:44 +00:00
										 |  |  | 	ot->description= "Assign the selected vertices to a hook"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->idname= "OBJECT_OT_hook_assign"; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* callbacks */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->exec= object_hook_assign_exec; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 	/* flags */ | 
					
						
							| 
									
										
										
										
											2011-12-12 14:54:28 +00:00
										 |  |  | 	/* this operator changes data stored in modifier which doesn't get pushed to undo stack,
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	 * so redoing it from redo panel gives totally weird results  */ | 
					
						
							| 
									
										
										
										
											2011-12-12 14:54:28 +00:00
										 |  |  | 	ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							| 
									
										
										
										
											2011-09-19 12:26:20 +00:00
										 |  |  | 	prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, hook_mod_itemf); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int object_hook_select_exec(bContext *C, wmOperator *op) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); | 
					
						
							|  |  |  | 	int num= RNA_enum_get(op->ptr, "modifier"); | 
					
						
							|  |  |  | 	Object *ob=NULL; | 
					
						
							|  |  |  | 	HookModifierData *hmd=NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (ptr.data) {		/* if modifier context is available, use that */ | 
					
						
							|  |  |  | 		ob = ptr.id.data; | 
					
						
							|  |  |  | 		hmd= ptr.data; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	}  | 
					
						
							|  |  |  | 	else {			/* use the provided property */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 		ob = CTX_data_edit_object(C); | 
					
						
							|  |  |  | 		hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!ob || !hmd) { | 
					
						
							|  |  |  | 		BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); | 
					
						
							|  |  |  | 		return OPERATOR_CANCELLED; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* select functionality */ | 
					
						
							|  |  |  | 	object_hook_select(ob, hmd); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return OPERATOR_FINISHED; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | void OBJECT_OT_hook_select(wmOperatorType *ot) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PropertyRNA *prop; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* identifiers */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->name= "Select Hook"; | 
					
						
							| 
									
										
										
										
											2011-10-20 07:56:04 +00:00
										 |  |  | 	ot->description= "Select affected vertices on mesh"; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->idname= "OBJECT_OT_hook_select"; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	/* callbacks */ | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	ot->exec= object_hook_select_exec; | 
					
						
							| 
									
										
										
										
											2009-11-23 02:27:52 +00:00
										 |  |  | 	ot->poll= hook_op_edit_poll; | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/* flags */ | 
					
						
							|  |  |  | 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* properties */ | 
					
						
							| 
									
										
										
										
											2011-09-19 12:26:20 +00:00
										 |  |  | 	prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); | 
					
						
							| 
									
										
										
										
											2009-11-22 06:20:56 +00:00
										 |  |  | 	RNA_def_enum_funcs(prop, hook_mod_itemf); | 
					
						
							| 
									
										
										
										
											2009-11-16 13:59:27 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 |