2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Geoffrey Bantle.
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/bmesh/intern/bmesh_mesh.c
26 * BM mesh level functions.
29 #include "MEM_guardedalloc.h"
31 #include "DNA_listBase.h"
32 #include "DNA_object_types.h"
34 #include "BLI_listbase.h"
36 #include "BLI_utildefines.h"
38 #include "BKE_cdderivedmesh.h"
39 #include "BKE_tessmesh.h"
40 #include "BKE_multires.h"
42 #include "intern/bmesh_private.h"
44 /* used as an extern, defined in bmesh.h */
45 BMAllocTemplate bm_mesh_allocsize_default = {512, 1024, 2048, 512};
46 BMAllocTemplate bm_mesh_chunksize_default = {512, 1024, 2048, 512};
48 static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize)
50 bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize->totvert,
51 bm_mesh_chunksize_default.totvert, BLI_MEMPOOL_ALLOW_ITER);
52 bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize->totedge,
53 bm_mesh_chunksize_default.totedge, BLI_MEMPOOL_ALLOW_ITER);
54 bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize->totloop,
55 bm_mesh_chunksize_default.totloop, 0);
56 bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize->totface,
57 bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER);
59 #ifdef USE_BMESH_HOLES
60 bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE);
63 /* allocate one flag pool that we don't get rid of. */
64 bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, 0);
68 * \brief BMesh Make Mesh
70 * Allocates a new BMesh structure.
72 * \return The New bmesh
74 * \note ob is needed by multires
76 BMesh *BM_mesh_create(BMAllocTemplate *allocsize)
78 /* allocate the structure */
79 BMesh *bm = MEM_callocN(sizeof(BMesh), __func__);
81 /* allocate the memory pools for the mesh elements */
82 bm_mempool_init(bm, allocsize);
84 /* allocate one flag pool that we don't get rid of. */
92 * \brief BMesh Free Mesh Data
94 * Frees a BMesh structure.
96 * \note frees mesh, but not actual BMesh struct
98 void BM_mesh_data_free(BMesh *bm)
109 BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
110 CustomData_bmesh_free_block(&(bm->vdata), &(v->head.data));
112 BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
113 CustomData_bmesh_free_block(&(bm->edata), &(e->head.data));
115 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
116 CustomData_bmesh_free_block(&(bm->pdata), &(f->head.data));
117 BM_ITER_ELEM (l, &itersub, f, BM_LOOPS_OF_FACE) {
118 CustomData_bmesh_free_block(&(bm->ldata), &(l->head.data));
122 /* Free custom data pools, This should probably go in CustomData_free? */
123 if (bm->vdata.totlayer) BLI_mempool_destroy(bm->vdata.pool);
124 if (bm->edata.totlayer) BLI_mempool_destroy(bm->edata.pool);
125 if (bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool);
126 if (bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool);
128 /* free custom data */
129 CustomData_free(&bm->vdata, 0);
130 CustomData_free(&bm->edata, 0);
131 CustomData_free(&bm->ldata, 0);
132 CustomData_free(&bm->pdata, 0);
134 /* destroy element pools */
135 BLI_mempool_destroy(bm->vpool);
136 BLI_mempool_destroy(bm->epool);
137 BLI_mempool_destroy(bm->lpool);
138 BLI_mempool_destroy(bm->fpool);
140 /* destroy flag pool */
141 BLI_mempool_destroy(bm->toolflagpool);
143 #ifdef USE_BMESH_HOLES
144 BLI_mempool_destroy(bm->looplistpool);
147 BLI_freelistN(&bm->selected);
153 * \brief BMesh Clear Mesh
155 * Clear all data in bm
157 void BM_mesh_clear(BMesh *bm)
160 BM_mesh_data_free(bm);
161 memset(bm, 0, sizeof(BMesh));
163 /* allocate the memory pools for the mesh elements */
164 bm_mempool_init(bm, &bm_mesh_allocsize_default);
171 * \brief BMesh Free Mesh
173 * Frees a BMesh data and its structure.
175 void BM_mesh_free(BMesh *bm)
177 BM_mesh_data_free(bm);
180 /* keep this out of 'BM_mesh_data_free' because we wan't python
181 * to be able to clear the mesh and maintain access. */
182 extern void bpy_bm_generic_invalidate(void *self);
184 bpy_bm_generic_invalidate(bm->py_handle);
185 bm->py_handle = NULL;
192 * \brief BMesh Compute Normals
194 * Updates the normals of a mesh.
196 void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
209 /* calculate all face normals */
210 BM_ITER_MESH (f, &faces, bm, BM_FACES_OF_MESH) {
211 if (skip_hidden && BM_elem_flag_test(f, BM_ELEM_HIDDEN))
214 if (f->head.flag & BM_NONORMCALC)
218 BM_face_normal_update(f);
221 /* Zero out vertex normals */
222 BM_ITER_MESH (v, &verts, bm, BM_VERTS_OF_MESH) {
223 if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN))
229 /* compute normalized direction vectors for each edge. directions will be
230 * used below for calculating the weights of the face normals on the vertex
233 edgevec = MEM_callocN(sizeof(float) * 3 * bm->totedge, "BM normal computation array");
234 BM_ITER_MESH (e, &edges, bm, BM_EDGES_OF_MESH) {
235 BM_elem_index_set(e, index); /* set_inline */
238 sub_v3_v3v3(edgevec[index], e->v2->co, e->v1->co);
239 normalize_v3(edgevec[index]);
242 /* the edge vector will not be needed when the edge has no radial */
247 bm->elem_index_dirty &= ~BM_EDGE;
249 /* add weighted face normals to vertices */
250 BM_ITER_MESH (f, &faces, bm, BM_FACES_OF_MESH) {
252 if (skip_hidden && BM_elem_flag_test(f, BM_ELEM_HIDDEN))
255 BM_ITER_ELEM (l, &loops, f, BM_LOOPS_OF_FACE) {
256 float *e1diff, *e2diff;
260 /* calculate the dot product of the two edges that
261 * meet at the loop's vertex */
262 e1diff = edgevec[BM_elem_index_get(l->prev->e)];
263 e2diff = edgevec[BM_elem_index_get(l->e)];
264 dotprod = dot_v3v3(e1diff, e2diff);
266 /* edge vectors are calculated from e->v1 to e->v2, so
267 * adjust the dot product if one but not both loops
268 * actually runs from from e->v2 to e->v1 */
269 if ((l->prev->e->v1 == l->prev->v) ^ (l->e->v1 == l->v)) {
273 fac = saacos(-dotprod);
275 /* accumulate weighted face normal into the vertex's normal */
276 madd_v3_v3fl(l->v->no, f->no, fac);
280 /* normalize the accumulated vertex normals */
281 BM_ITER_MESH (v, &verts, bm, BM_VERTS_OF_MESH) {
282 if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN))
285 if (normalize_v3(v->no) == 0.0f) {
286 normalize_v3_v3(v->no, v->co);
293 static void UNUSED_FUNCTION(bm_mdisps_space_set)(Object *ob, BMesh *bm, int from, int to)
295 /* switch multires data out of tangent space */
296 if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
297 BMEditMesh *em = BMEdit_Create(bm, FALSE);
298 DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
302 // int i = 0; // UNUSED
304 multires_set_space(dm, ob, from, to);
306 mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
308 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
311 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
312 MDisps *lmd = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
315 printf("%s: warning - 'lmd->disps' == NULL\n", __func__);
318 if (lmd->disps && lmd->totdisp == mdisps->totdisp) {
319 memcpy(lmd->disps, mdisps->disps, sizeof(float) * 3 * lmd->totdisp);
321 else if (mdisps->disps) {
323 MEM_freeN(lmd->disps);
325 lmd->disps = MEM_dupallocN(mdisps->disps);
326 lmd->totdisp = mdisps->totdisp;
327 lmd->level = mdisps->level;
338 /* setting this to NULL prevents BMEdit_Free from freeing it */
346 * \brief BMesh Begin Edit
348 * Functions for setting up a mesh for editing and cleaning up after
349 * the editing operations are done. These are called by the tools/operator
350 * API for each time a tool is executed.
352 void bmesh_edit_begin(BMesh *UNUSED(bm), int UNUSED(type_flag))
354 /* Most operators seem to be using BMO_OP_FLAG_UNTAN_MULTIRES to change the MDisps to
355 * absolute space during mesh edits. With this enabled, changes to the topology
356 * (loop cuts, edge subdivides, etc) are not reflected in the higher levels of
357 * the mesh at all, which doesn't seem right. Turning off completely for now,
358 * until this is shown to be better for certain types of mesh edits. */
359 #if BMOP_UNTAN_MULTIRES_ENABLED
360 /* switch multires data out of tangent space */
361 if ((type_flag & BMO_OP_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
362 bmesh_mdisps_space_set(bm, MULTIRES_SPACE_TANGENT, MULTIRES_SPACE_ABSOLUTE);
364 /* ensure correct normals, if possible */
365 bmesh_rationalize_normals(bm, 0);
366 BM_mesh_normals_update(bm);
372 * \brief BMesh End Edit
374 void bmesh_edit_end(BMesh *bm, int UNUSED(flag))
376 /* BMO_OP_FLAG_UNTAN_MULTIRES disabled for now, see comment above in bmesh_edit_begin. */
377 #if BMOP_UNTAN_MULTIRES_ENABLED
378 /* switch multires data into tangent space */
379 if ((flag & BMO_OP_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
380 /* set normals to their previous winding */
381 bmesh_rationalize_normals(bm, 1);
382 bmesh_mdisps_space_set(bm, MULTIRES_SPACE_ABSOLUTE, MULTIRES_SPACE_TANGENT);
384 else if (flag & BMO_OP_FLAG_RATIONALIZE_NORMALS) {
385 bmesh_rationalize_normals(bm, 1);
389 /* compute normals, clear temp flags and flush selections */
390 BM_mesh_normals_update(bm, TRUE);
391 BM_mesh_select_mode_flush(bm);
394 void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag)
400 BM_ELEM_INDEX_VALIDATE(bm, "Should Never Fail!", __func__);
403 if (hflag & BM_VERT) {
404 if (bm->elem_index_dirty & BM_VERT) {
406 BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
407 BM_elem_index_set(ele, index); /* set_ok */
410 bm->elem_index_dirty &= ~BM_VERT;
411 BLI_assert(index == bm->totvert);
414 // printf("%s: skipping vert index calc!\n", __func__);
418 if (hflag & BM_EDGE) {
419 if (bm->elem_index_dirty & BM_EDGE) {
421 BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
422 BM_elem_index_set(ele, index); /* set_ok */
425 bm->elem_index_dirty &= ~BM_EDGE;
426 BLI_assert(index == bm->totedge);
429 // printf("%s: skipping edge index calc!\n", __func__);
433 if (hflag & BM_FACE) {
434 if (bm->elem_index_dirty & BM_FACE) {
436 BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
437 BM_elem_index_set(ele, index); /* set_ok */
440 bm->elem_index_dirty &= ~BM_FACE;
441 BLI_assert(index == bm->totface);
444 // printf("%s: skipping face index calc!\n", __func__);
451 * Array checking/setting macros
453 * Currently vert/edge/loop/face index data is being abused, in a few areas of the code.
455 * To avoid correcting them afterwards, set 'bm->elem_index_dirty' however its possible
456 * this flag is set incorrectly which could crash blender.
458 * These functions ensure its correct and are called more often in debug mode.
461 void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func,
462 const char *msg_a, const char *msg_b)
464 const char iter_types[3] = {BM_VERTS_OF_MESH,
468 const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE};
469 const char *type_names[3] = {"vert", "edge", "face"};
474 int is_any_error = 0;
476 for (i = 0; i < 3; i++) {
477 const int is_dirty = (flag_types[i] & bm->elem_index_dirty);
479 int is_error = FALSE;
483 BM_ITER_MESH (ele, &iter, bm, iter_types[i]) {
485 if (BM_elem_index_get(ele) != index) {
486 err_val = BM_elem_index_get(ele);
492 BM_elem_index_set(ele, index); /* set_ok */
496 if ((is_error == TRUE) && (is_dirty == FALSE)) {
499 "Invalid Index: at %s, %s, %s[%d] invalid index %d, '%s', '%s'\n",
500 location, func, type_names[i], err_idx, err_val, msg_a, msg_b);
502 else if ((is_error == FALSE) && (is_dirty == TRUE)) {
504 #if 0 /* mostly annoying */
506 /* dirty may have been incorrectly set */
508 "Invalid Dirty: at %s, %s (%s), dirty flag was set but all index values are correct, '%s', '%s'\n",
509 location, func, type_names[i], msg_a, msg_b);
514 #if 0 /* mostly annoying, even in debug mode */
516 if (is_any_error == 0) {
518 "Valid Index Success: at %s, %s, '%s', '%s'\n",
519 location, func, msg_a, msg_b);
523 (void) is_any_error; /* shut up the compiler */
528 * Return the amount of element of type 'type' in a given bmesh.
530 int BM_mesh_elem_count(BMesh *bm, const char htype)
532 if (htype == BM_VERT) return bm->totvert;
533 else if (htype == BM_EDGE) return bm->totedge;
534 else if (htype == BM_FACE) return bm->totface;
540 * Remaps the vertices, edges and/or faces of the bmesh as indicated by vert/edge/face_idx arrays
541 * (xxx_idx[org_index] = new_index).
543 * A NULL array means no changes.
545 * Note: - Does not mess with indices, just sets elem_index_dirty flag.
546 * - For verts/edges/faces only (as loops must remain "ordered" and "aligned"
547 * on a per-face basis...).
549 * WARNING: Be careful if you keep pointers to affected BM elements, or arrays, when using this func!
551 void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx)
553 /* Mapping old to new pointers. */
554 GHash *vptr_map = NULL, *eptr_map = NULL, *fptr_map = NULL;
561 if (!(vert_idx || edge_idx || face_idx))
566 BMVert **verts_pool, *verts_copy, **vep;
567 int i, totvert = bm->totvert;
570 /* Init the old-to-new vert pointers mapping */
571 vptr_map = BLI_ghash_ptr_new("BM_mesh_remap vert pointers mapping");
573 /* Make a copy of all vertices. */
574 verts_pool = MEM_callocN(sizeof(BMVert *) * totvert, "BM_mesh_remap verts pool");
575 BM_iter_as_array(bm, BM_VERTS_OF_MESH, NULL, (void **)verts_pool, totvert);
576 verts_copy = MEM_mallocN(sizeof(BMVert) * totvert, "BM_mesh_remap verts copy");
577 for (i = totvert, ve = verts_copy + totvert - 1, vep = verts_pool + totvert - 1; i--; ve--, vep--) {
579 /* printf("*vep: %p, verts_pool[%d]: %p\n", *vep, i, verts_pool[i]);*/
582 /* Copy back verts to their new place, and update old2new pointers mapping. */
583 new_idx = vert_idx + totvert - 1;
584 ve = verts_copy + totvert - 1;
585 vep = verts_pool + totvert - 1; /* old, org pointer */
586 for (i = totvert; i--; new_idx--, ve--, vep--) {
587 BMVert *new_vep = verts_pool[*new_idx];
589 /* printf("mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);*/
590 BLI_ghash_insert(vptr_map, (void *)*vep, (void *)new_vep);
592 bm->elem_index_dirty |= BM_VERT;
594 MEM_freeN(verts_pool);
595 MEM_freeN(verts_copy);
598 /* XXX Code not tested yet (though I don't why it would fail)! */
600 BMEdge **edges_pool, *edges_copy, **edp;
601 int i, totedge = bm->totedge;
604 /* Init the old-to-new vert pointers mapping */
605 eptr_map = BLI_ghash_ptr_new("BM_mesh_remap edge pointers mapping");
607 /* Make a copy of all vertices. */
608 edges_pool = MEM_callocN(sizeof(BMEdge *) * totedge, "BM_mesh_remap edges pool");
609 BM_iter_as_array(bm, BM_EDGES_OF_MESH, NULL, (void **)edges_pool, totedge);
610 edges_copy = MEM_mallocN(sizeof(BMEdge) * totedge, "BM_mesh_remap edges copy");
611 for (i = totedge, ed = edges_copy + totedge - 1, edp = edges_pool + totedge - 1; i--; ed--, edp--) {
615 /* Copy back verts to their new place, and update old2new pointers mapping. */
616 new_idx = edge_idx + totedge - 1;
617 ed = edges_copy + totedge - 1;
618 edp = edges_pool + totedge - 1; /* old, org pointer */
619 for (i = totedge; i--; new_idx--, ed--, edp--) {
620 BMEdge *new_edp = edges_pool[*new_idx];
622 BLI_ghash_insert(eptr_map, (void *)*edp, (void *)new_edp);
623 /* printf("mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);*/
625 bm->elem_index_dirty |= BM_EDGE;
627 MEM_freeN(edges_pool);
628 MEM_freeN(edges_copy);
631 /* XXX Code not tested yet (though I don't why it would fail)! */
633 BMFace **faces_pool, *faces_copy, **fap;
634 int i, totface = bm->totface;
637 /* Init the old-to-new vert pointers mapping */
638 fptr_map = BLI_ghash_ptr_new("BM_mesh_remap face pointers mapping");
640 /* Make a copy of all vertices. */
641 faces_pool = MEM_callocN(sizeof(BMFace *) * totface, "BM_mesh_remap faces pool");
642 BM_iter_as_array(bm, BM_FACES_OF_MESH, NULL, (void **)faces_pool, totface);
643 faces_copy = MEM_mallocN(sizeof(BMFace) * totface, "BM_mesh_remap faces copy");
644 for (i = totface, fa = faces_copy + totface - 1, fap = faces_pool + totface - 1; i--; fa--, fap--) {
648 /* Copy back verts to their new place, and update old2new pointers mapping. */
649 new_idx = face_idx + totface - 1;
650 fa = faces_copy + totface - 1;
651 fap = faces_pool + totface - 1; /* old, org pointer */
652 for (i = totface; i--; new_idx--, fa--, fap--) {
653 BMFace *new_fap = faces_pool[*new_idx];
655 BLI_ghash_insert(fptr_map, (void *)*fap, (void *)new_fap);
658 bm->elem_index_dirty |= BM_FACE;
660 MEM_freeN(faces_pool);
661 MEM_freeN(faces_copy);
664 /* And now, fix all vertices/edges/faces/loops pointers! */
665 /* Verts' pointers, only edge pointers... */
667 BM_ITER_MESH (ve, &iter, bm, BM_VERTS_OF_MESH) {
668 /* printf("Vert e: %p -> %p\n", ve->e, BLI_ghash_lookup(eptr_map, (const void*)ve->e));*/
669 ve->e = BLI_ghash_lookup(eptr_map, (const void *)ve->e);
673 /* Edges' pointers, only vert pointers (as we don't mess with loops!), and - ack! - edge pointers,
674 * as we have to handle disklinks... */
675 if (vptr_map || eptr_map) {
676 BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
678 /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, (const void*)ed->v1));*/
679 /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, (const void*)ed->v2));*/
680 ed->v1 = BLI_ghash_lookup(vptr_map, (const void *)ed->v1);
681 ed->v2 = BLI_ghash_lookup(vptr_map, (const void *)ed->v2);
684 /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/
685 /* BLI_ghash_lookup(eptr_map, (const void*)ed->v1_disk_link.prev));*/
686 /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/
687 /* BLI_ghash_lookup(eptr_map, (const void*)ed->v1_disk_link.next));*/
688 /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/
689 /* BLI_ghash_lookup(eptr_map, (const void*)ed->v2_disk_link.prev));*/
690 /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/
691 /* BLI_ghash_lookup(eptr_map, (const void*)ed->v2_disk_link.next));*/
692 ed->v1_disk_link.prev = BLI_ghash_lookup(eptr_map, (const void *)ed->v1_disk_link.prev);
693 ed->v1_disk_link.next = BLI_ghash_lookup(eptr_map, (const void *)ed->v1_disk_link.next);
694 ed->v2_disk_link.prev = BLI_ghash_lookup(eptr_map, (const void *)ed->v2_disk_link.prev);
695 ed->v2_disk_link.next = BLI_ghash_lookup(eptr_map, (const void *)ed->v2_disk_link.next);
700 /* Faces' pointers (loops, in fact), always needed... */
701 BM_ITER_MESH (fa, &iter, bm, BM_FACES_OF_MESH) {
702 BM_ITER_ELEM (lo, &iterl, fa, BM_LOOPS_OF_FACE) {
704 /* printf("Loop v: %p -> %p\n", lo->v, BLI_ghash_lookup(vptr_map, (const void*)lo->v));*/
705 lo->v = BLI_ghash_lookup(vptr_map, (const void *)lo->v);
708 /* printf("Loop e: %p -> %p\n", lo->e, BLI_ghash_lookup(eptr_map, (const void*)lo->e));*/
709 lo->e = BLI_ghash_lookup(eptr_map, (const void *)lo->e);
712 /* printf("Loop f: %p -> %p\n", lo->f, BLI_ghash_lookup(fptr_map, (const void*)lo->f));*/
713 lo->f = BLI_ghash_lookup(fptr_map, (const void *)lo->f);
719 BLI_ghash_free(vptr_map, NULL, NULL);
721 BLI_ghash_free(eptr_map, NULL, NULL);
723 BLI_ghash_free(fptr_map, NULL, NULL);
726 BMVert *BM_vert_at_index(BMesh *bm, const int index)
728 return BLI_mempool_findelem(bm->vpool, index);
731 BMEdge *BM_edge_at_index(BMesh *bm, const int index)
733 return BLI_mempool_findelem(bm->epool, index);
736 BMFace *BM_face_at_index(BMesh *bm, const int index)
738 return BLI_mempool_findelem(bm->fpool, index);