| 
									
										
										
										
											2012-02-19 18:31:04 +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, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Joseph Eagar. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-06 09:21:19 +00:00
										 |  |  | /** \file blender/bmesh/operators/bmo_create.c
 | 
					
						
							|  |  |  |  *  \ingroup bmesh | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_listbase.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "bmesh.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-06 09:21:19 +00:00
										 |  |  | #include "intern/bmesh_operators_private.h" /* own include */
 | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define ELE_NEW		1
 | 
					
						
							|  |  |  | #define ELE_OUT		2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 20:29:53 +00:00
										 |  |  | /* This is what runs when pressing the F key
 | 
					
						
							| 
									
										
										
										
											2012-03-18 07:38:51 +00:00
										 |  |  |  * doing the best thing here isn't always easy create vs dissolve, its nice to support | 
					
						
							| 
									
										
										
										
											2012-03-09 20:29:53 +00:00
										 |  |  |  * but it it _really_ gives issues we might have to not call dissolve. - campbell | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-02-28 09:48:00 +00:00
										 |  |  | void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	BMOperator op2; | 
					
						
							|  |  |  | 	BMOIter oiter; | 
					
						
							|  |  |  | 	BMIter iter; | 
					
						
							|  |  |  | 	BMHeader *h; | 
					
						
							|  |  |  | 	BMVert *v, *verts[4]; | 
					
						
							|  |  |  | 	BMEdge *e; | 
					
						
							|  |  |  | 	BMFace *f; | 
					
						
							|  |  |  | 	int totv = 0, tote = 0, totf = 0, amount; | 
					
						
							| 
									
										
										
										
											2012-11-19 14:58:31 +00:00
										 |  |  | 	const short mat_nr     = BMO_slot_int_get(op->slots_in,  "mat_nr"); | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 	const bool use_smooth  = BMO_slot_bool_get(op->slots_in, "use_smooth"); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* count number of each element type we were passe */ | 
					
						
							| 
									
										
										
										
											2012-11-19 14:58:31 +00:00
										 |  |  | 	BMO_ITER (h, &oiter, op->slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE) { | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 		switch (h->htype) { | 
					
						
							|  |  |  | 			case BM_VERT: totv++; break; | 
					
						
							|  |  |  | 			case BM_EDGE: tote++; break; | 
					
						
							|  |  |  | 			case BM_FACE: totf++; break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BMO_elem_flag_enable(bm, (BMElemF *)h, ELE_NEW); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* --- Support for Special Case ---
 | 
					
						
							|  |  |  | 	 * where there is a contiguous edge ring with one isolated vertex. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * This example shows 2 edges created from 3 verts | 
					
						
							|  |  |  | 	 * with 1 free standing vertex. Dotted lines denote the 2 edges that are created. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * note that this works for any sided shape. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * +--------+ | 
					
						
							|  |  |  | 	 * |        . | 
					
						
							|  |  |  | 	 * |        . | 
					
						
							|  |  |  | 	 * |        . | 
					
						
							|  |  |  | 	 * |        . | 
					
						
							|  |  |  | 	 * +........+ <-- starts out free standing. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-04 12:30:16 +00:00
										 |  |  | 	/* Here we check for consistency and create 2 edges */ | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	if (totf == 0 && totv >= 4 && totv == tote + 2) { | 
					
						
							|  |  |  | 		/* find a free standing vertex and 2 endpoint verts */ | 
					
						
							|  |  |  | 		BMVert *v_free = NULL, *v_a = NULL, *v_b = NULL; | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 		bool ok = true; | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-19 14:58:31 +00:00
										 |  |  | 		BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) { | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			/* count how many flagged edges this vertex uses */ | 
					
						
							|  |  |  | 			int tot_edges = 0; | 
					
						
							| 
									
										
										
										
											2012-04-19 13:47:58 +00:00
										 |  |  | 			BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 				if (BMO_elem_flag_test(bm, e, ELE_NEW)) { | 
					
						
							|  |  |  | 					tot_edges++; | 
					
						
							|  |  |  | 					if (tot_edges > 2) { | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (tot_edges == 0) { | 
					
						
							|  |  |  | 				/* only accept 1 free vert */ | 
					
						
							|  |  |  | 				if (v_free == NULL)  v_free = v; | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 				else                 ok = false;  /* only ever want one of these */ | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else if (tot_edges == 1) { | 
					
						
							|  |  |  | 				if (v_a == NULL)       v_a = v; | 
					
						
							|  |  |  | 				else if (v_b == NULL)  v_b = v; | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 				else                   ok = false;  /* only ever want 2 of these */ | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else if (tot_edges == 2) { | 
					
						
							|  |  |  | 				/* do nothing, regular case */ | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 				ok = false; /* if a vertex has 3+ edge users then cancel - this is only simple cases */ | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 			if (ok == false) { | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 		if (ok == true && v_free && v_a && v_b) { | 
					
						
							| 
									
										
										
										
											2012-11-29 16:26:39 +00:00
										 |  |  | 			e = BM_edge_create(bm, v_free, v_a, NULL, BM_CREATE_NO_DOUBLE); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			BMO_elem_flag_enable(bm, e, ELE_NEW); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-29 16:26:39 +00:00
										 |  |  | 			e = BM_edge_create(bm, v_free, v_b, NULL, BM_CREATE_NO_DOUBLE); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			BMO_elem_flag_enable(bm, e, ELE_NEW); | 
					
						
							| 
									
										
										
										
											2013-03-27 04:41:20 +00:00
										 |  |  | 			tote += 2; | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* --- end special case support, continue as normal --- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-27 07:54:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 	/* EdgeNet Create */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-12 23:56:11 +00:00
										 |  |  | 	/* call edgenet prepare op so additional face creation cases wore */ | 
					
						
							| 
									
										
										
										
											2012-07-21 00:58:02 +00:00
										 |  |  | 	BMO_op_initf(bm, &op2, op->flag, "edgenet_prepare edges=%fe", ELE_NEW); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	BMO_op_exec(bm, &op2); | 
					
						
							| 
									
										
										
										
											2012-11-20 05:50:19 +00:00
										 |  |  | 	BMO_slot_buffer_flag_enable(bm, op2.slots_out, "edges.out", BM_EDGE, ELE_NEW); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	BMO_op_finish(bm, &op2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-21 00:58:02 +00:00
										 |  |  | 	BMO_op_initf(bm, &op2, op->flag, | 
					
						
							| 
									
										
										
										
											2012-04-21 13:58:29 +00:00
										 |  |  | 	             "edgenet_fill edges=%fe use_fill_check=%b mat_nr=%i use_smooth=%b", | 
					
						
							| 
									
										
										
										
											2013-01-14 16:42:43 +00:00
										 |  |  | 	             ELE_NEW, true, mat_nr, use_smooth); | 
					
						
							| 
									
										
										
										
											2012-04-21 13:58:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	BMO_op_exec(bm, &op2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-12 23:56:11 +00:00
										 |  |  | 	/* return if edge net create did something */ | 
					
						
							| 
									
										
										
										
											2012-11-20 05:50:19 +00:00
										 |  |  | 	if (BMO_slot_buffer_count(op2.slots_out, "faces.out")) { | 
					
						
							|  |  |  | 		BMO_slot_copy(&op2, slots_out, "faces.out", | 
					
						
							|  |  |  | 		              op,   slots_out, "faces.out"); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 		BMO_op_finish(bm, &op2); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BMO_op_finish(bm, &op2); | 
					
						
							| 
									
										
										
										
											2013-03-27 07:54:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 	/* Dissolve Face */ | 
					
						
							| 
									
										
										
										
											2012-07-21 00:58:02 +00:00
										 |  |  | 	BMO_op_initf(bm, &op2, op->flag, "dissolve_faces faces=%ff", ELE_NEW); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	BMO_op_exec(bm, &op2); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* if we dissolved anything, then return */ | 
					
						
							| 
									
										
										
										
											2012-11-20 05:50:19 +00:00
										 |  |  | 	if (BMO_slot_buffer_count(op2.slots_out, "region.out")) { | 
					
						
							|  |  |  | 		BMO_slot_copy(&op2, slots_out, "region.out", | 
					
						
							|  |  |  | 		              op,   slots_out,  "faces.out"); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 		BMO_op_finish(bm, &op2); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BMO_op_finish(bm, &op2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-27 07:54:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 	/* Fill EdgeLoop's - fills isolated loops, different from edgenet */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* note: in most cases 'edgenet_fill' will handle this case since in common cases
 | 
					
						
							|  |  |  | 	 * users fill in empty spaces, however its possible to have an edge selection around | 
					
						
							|  |  |  | 	 * existing geometry that makes 'edgenet_fill' fail. */ | 
					
						
							|  |  |  | 	BMO_op_initf(bm, &op2, op->flag, "edgeloop_fill edges=%fe", ELE_NEW); | 
					
						
							|  |  |  | 	BMO_op_exec(bm, &op2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* return if edge loop fill did something */ | 
					
						
							|  |  |  | 	if (BMO_slot_buffer_count(op2.slots_out, "faces.out")) { | 
					
						
							|  |  |  | 		BMO_slot_copy(&op2, slots_out, "faces.out", | 
					
						
							|  |  |  | 		              op,   slots_out, "faces.out"); | 
					
						
							|  |  |  | 		BMO_op_finish(bm, &op2); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BMO_op_finish(bm, &op2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 	/* Continue with ad-hoc fill methods since operators fail,
 | 
					
						
							|  |  |  | 	 * edge, vcloud... may add more */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-12 23:56:11 +00:00
										 |  |  | 	/* now, count how many verts we have */ | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	amount = 0; | 
					
						
							| 
									
										
										
										
											2012-04-19 13:47:58 +00:00
										 |  |  | 	BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 		if (BMO_elem_flag_test(bm, v, ELE_NEW)) { | 
					
						
							|  |  |  | 			verts[amount] = v; | 
					
						
							| 
									
										
										
										
											2012-06-03 17:16:20 +00:00
										 |  |  | 			if (amount == 3) { | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 			amount++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (amount == 2) { | 
					
						
							| 
									
										
										
										
											2012-03-12 23:56:11 +00:00
										 |  |  | 		/* create edge */ | 
					
						
							| 
									
										
										
										
											2012-11-29 16:26:39 +00:00
										 |  |  | 		e = BM_edge_create(bm, verts[0], verts[1], NULL, BM_CREATE_NO_DOUBLE); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 		BMO_elem_flag_enable(bm, e, ELE_OUT); | 
					
						
							| 
									
										
										
										
											2013-03-27 04:41:20 +00:00
										 |  |  | 		tote += 1; | 
					
						
							| 
									
										
										
										
											2012-11-20 05:50:19 +00:00
										 |  |  | 		BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT); | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-14 22:57:15 +00:00
										 |  |  | 	else if (0) { /* nice feature but perhaps it should be a different tool? */ | 
					
						
							| 
									
										
										
										
											2012-02-28 07:19:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-13 02:18:46 +00:00
										 |  |  | 		/* tricky feature for making a line/edge from selection history...
 | 
					
						
							|  |  |  | 		 * | 
					
						
							|  |  |  | 		 * Rather then do nothing, when 5+ verts are selected, check if they are in our history, | 
					
						
							|  |  |  | 		 * when this is so, we can make edges from them, but _not_ a face, | 
					
						
							|  |  |  | 		 * if it is the intention to make a face the user can just hit F again since there will be edges next | 
					
						
							|  |  |  | 		 * time around. | 
					
						
							|  |  |  | 		 * | 
					
						
							|  |  |  | 		 * if all history verts have ELE_NEW flagged and the total number of history verts == totv, | 
					
						
							|  |  |  | 		 * then we know the history contains all verts here and we can continue... | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BMEditSelection *ese; | 
					
						
							|  |  |  | 		int tot_ese_v = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (ese = bm->selected.first; ese; ese = ese->next) { | 
					
						
							|  |  |  | 			if (ese->htype == BM_VERT) { | 
					
						
							|  |  |  | 				if (BMO_elem_flag_test(bm, (BMElemF *)ese->ele, ELE_NEW)) { | 
					
						
							|  |  |  | 					tot_ese_v++; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else { | 
					
						
							|  |  |  | 					/* unflagged vert means we are not in sync */ | 
					
						
							|  |  |  | 					tot_ese_v = -1; | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (tot_ese_v == totv) { | 
					
						
							|  |  |  | 			BMVert *v_prev = NULL; | 
					
						
							|  |  |  | 			/* yes, all select-history verts are accounted for, now make edges */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			for (ese = bm->selected.first; ese; ese = ese->next) { | 
					
						
							|  |  |  | 				if (ese->htype == BM_VERT) { | 
					
						
							|  |  |  | 					v = (BMVert *)ese->ele; | 
					
						
							|  |  |  | 					if (v_prev) { | 
					
						
							| 
									
										
										
										
											2012-11-29 16:26:39 +00:00
										 |  |  | 						e = BM_edge_create(bm, v, v_prev, NULL, BM_CREATE_NO_DOUBLE); | 
					
						
							| 
									
										
										
										
											2012-03-13 02:18:46 +00:00
										 |  |  | 						BMO_elem_flag_enable(bm, e, ELE_OUT); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					v_prev = v; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-11-20 05:50:19 +00:00
										 |  |  | 		BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT); | 
					
						
							| 
									
										
										
										
											2012-03-13 02:18:46 +00:00
										 |  |  | 		/* done creating edges */ | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-16 22:24:56 +00:00
										 |  |  | 	else if (amount > 2) { | 
					
						
							| 
									
										
										
										
											2013-03-27 07:54:11 +00:00
										 |  |  | 		/* TODO, some of these vertes may be connected by edges,
 | 
					
						
							|  |  |  | 		 * this connectivity could be used rather then treating | 
					
						
							|  |  |  | 		 * them as a bunch of isolated verts. */ | 
					
						
							| 
									
										
										
										
											2012-03-14 22:57:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		BMVert **vert_arr = MEM_mallocN(sizeof(BMVert **) * totv, __func__); | 
					
						
							|  |  |  | 		int i = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-19 14:58:31 +00:00
										 |  |  | 		BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) { | 
					
						
							| 
									
										
										
										
											2012-03-14 22:57:15 +00:00
										 |  |  | 			vert_arr[i] = v; | 
					
						
							|  |  |  | 			i++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-29 16:26:39 +00:00
										 |  |  | 		f = BM_face_create_ngon_vcloud(bm, vert_arr, totv, BM_CREATE_NO_DOUBLE); | 
					
						
							| 
									
										
										
										
											2012-03-14 22:57:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (f) { | 
					
						
							|  |  |  | 			BMO_elem_flag_enable(bm, f, ELE_OUT); | 
					
						
							| 
									
										
										
										
											2012-04-09 05:17:07 +00:00
										 |  |  | 			f->mat_nr = mat_nr; | 
					
						
							| 
									
										
										
										
											2012-04-21 13:58:29 +00:00
										 |  |  | 			if (use_smooth) { | 
					
						
							|  |  |  | 				BM_elem_flag_enable(f, BM_ELEM_SMOOTH); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-03-09 14:42:10 +00:00
										 |  |  | 			BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_OUT); | 
					
						
							| 
									
										
										
										
											2012-03-14 22:57:15 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		MEM_freeN(vert_arr); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-27 04:41:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	(void)tote; | 
					
						
							| 
									
										
										
										
											2012-02-19 18:31:04 +00:00
										 |  |  | } |