[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44527] trunk/blender/source/blender/bmesh /intern/bmesh_core.c: code cleanup: de-duplicate bmesh face creation code,
Campbell Barton
ideasman42 at gmail.com
Tue Feb 28 20:30:45 CET 2012
Revision: 44527
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44527
Author: campbellbarton
Date: 2012-02-28 19:30:44 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
code cleanup: de-duplicate bmesh face creation code,
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_core.c
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_core.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_core.c 2012-02-28 19:10:53 UTC (rev 44526)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_core.c 2012-02-28 19:30:44 UTC (rev 44527)
@@ -236,6 +236,40 @@
return f2;
}
+/**
+ * only create the face, since this calloc's the length is initialized to 0,
+ * leave adding loops to the caller.
+ */
+BM_INLINE BMFace *bm_face_create__internal(BMesh *bm)
+{
+ BMFace *f;
+
+ f = BLI_mempool_calloc(bm->fpool);
+
+#ifdef USE_DEBUG_INDEX_MEMCHECK
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(f)
+#else
+ BM_elem_index_set(f, -1); /* set_ok_invalid */
+#endif
+
+ bm->elem_index_dirty |= BM_FACE; /* may add to middle of the pool */
+
+ bm->totface++;
+
+ f->head.htype = BM_FACE;
+
+ /* allocate flag */
+ f->oflags = BLI_mempool_calloc(bm->toolflagpool);
+
+ CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
+
+#ifdef USE_BMESH_HOLES
+ f->totbounds = 0;
+#endif
+
+ return f;
+}
+
BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, int nodouble)
{
BMFace *f = NULL;
@@ -257,21 +291,9 @@
BLI_assert(f == NULL);
}
}
-
- f = BLI_mempool_calloc(bm->fpool);
-#ifdef USE_DEBUG_INDEX_MEMCHECK
- DEBUG_MEMCHECK_INDEX_INVALIDATE(f)
-#else
- BM_elem_index_set(f, -1); /* set_ok_invalid */
-#endif
+ f = bm_face_create__internal(bm);
- bm->elem_index_dirty |= BM_FACE; /* may add to middle of the pool */
-
- bm->totface++;
-
- f->head.htype = BM_FACE;
-
startl = lastl = bm_face_boundary_add(bm, f, verts[0], edges[0]);
startl->v = verts[0];
@@ -287,19 +309,10 @@
lastl = l;
}
- /* allocate flag */
- f->oflags = BLI_mempool_calloc(bm->toolflagpool);
-
- CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
-
startl->prev = lastl;
lastl->next = startl;
f->len = len;
-
-#ifdef USE_BMESH_HOLES
- f->totbounds = 0;
-#endif
BM_CHECK_ELEMENT(bm, f);
@@ -1034,40 +1047,20 @@
/* BMESH_TODO - this is only used once, investigate sharing code with BM_face_create
*/
-static BMFace *bm_face_create__internal(BMesh *bm, BMFace *UNUSED(example))
+static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
{
BMFace *f;
#ifdef USE_BMESH_HOLES
BMLoopList *lst;
#endif
- f = BLI_mempool_calloc(bm->fpool);
-#ifdef USE_BMESH_HOLES
- lst = BLI_mempool_calloc(bm->looplistpool);
-#endif
+ f = bm_face_create__internal(bm);
- f->head.htype = BM_FACE;
#ifdef USE_BMESH_HOLES
+ lst = BLI_mempool_calloc(bm->looplistpool);
BLI_addtail(&f->loops, lst);
#endif
-#ifdef USE_DEBUG_INDEX_MEMCHECK
- DEBUG_MEMCHECK_INDEX_INVALIDATE(f)
-#else
- BM_elem_index_set(f, -1); /* set_ok_invalid */
-#endif
-
- bm->elem_index_dirty |= BM_FACE; /* may add to middle of the pool */
-
- bm->totface++;
-
- /* allocate flag */
- f->oflags = BLI_mempool_calloc(bm->toolflagpool);
-
- CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
-
- f->len = 0;
-
#ifdef USE_BMESH_HOLES
f->totbounds = 1;
#endif
@@ -1144,7 +1137,7 @@
/* allocate new edge between v1 and v2 */
e = BM_edge_create(bm, v1, v2, example, FALSE);
- f2 = bm_face_create__internal(bm, f);
+ f2 = bm_face_create__sfme(bm, f);
f1loop = bm_loop_create(bm, v2, e, f, v2loop);
f2loop = bm_loop_create(bm, v1, e, f2, v1loop);
More information about the Bf-blender-cvs
mailing list