[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44154] branches/bmesh/blender/source/ blender/bmesh: ifdef out support for holes in faces.
Campbell Barton
ideasman42 at gmail.com
Thu Feb 16 16:38:22 CET 2012
Revision: 44154
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44154
Author: campbellbarton
Date: 2012-02-16 15:38:16 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------
ifdef out support for holes in faces.
this can be added back easily but currently this cant be saved into DNA and most likly support wont be added soon.
saves memory in editmode: 20 bytes per face or 40 on 64bit systems (5 pointers).
Modified Paths:
--------------
branches/bmesh/blender/source/blender/bmesh/bmesh.h
branches/bmesh/blender/source/blender/bmesh/bmesh_class.h
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_structure.h
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh.h 2012-02-16 15:13:29 UTC (rev 44153)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh.h 2012-02-16 15:38:16 UTC (rev 44154)
@@ -345,7 +345,11 @@
void bmesh_end_edit(BMesh *bm, int flag);
-#define BM_FACE_FIRST_LOOP(p) (((BMLoopList *)((p)->loops.first))->first)
+#ifdef USE_BMESH_HOLES
+# define BM_FACE_FIRST_LOOP(p) (((BMLoopList *)((p)->loops.first))->first)
+#else
+# define BM_FACE_FIRST_LOOP(p) ((p)->l_first)
+#endif
/* size to use for static arrays when dealing with NGons,
* alloc after this limit is reached.
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_class.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_class.h 2012-02-16 15:13:29 UTC (rev 44153)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_class.h 2012-02-16 15:38:16 UTC (rev 44154)
@@ -29,6 +29,9 @@
/* bmesh data structures */
+/* dissable holes for now, these are ifdef'd because they use more memory and cant be saved in DNA currently */
+// define USE_BMESH_HOLES
+
struct BMesh;
struct BMVert;
struct BMEdge;
@@ -97,17 +100,23 @@
struct BMLoop *next, *prev;
} BMLoop;
+#ifdef USE_BMESH_HOLES
/* eventually, this structure will be used for supporting holes in faces */
typedef struct BMLoopList {
struct BMLoopList *next, *prev;
struct BMLoop *first, *last;
} BMLoopList;
+#endif
typedef struct BMFace {
BMHeader head;
int len; /*includes all boundary loops*/
int totbounds; /*total boundaries, is one plus the number of holes in the face*/
+#ifdef USE_BMESH_HOLES
ListBase loops;
+#else
+ BMLoop *l_first;
+#endif
float no[3]; /*yes, we do store this here*/
short mat_nr;
} BMFace;
@@ -136,8 +145,10 @@
CustomData vdata, edata, ldata, pdata;
+#ifdef USE_BMESH_HOLES
struct BLI_mempool *looplistpool;
-
+#endif
+
/* should be copy of scene select mode */
/* stored in BMEditMesh too, this is a bit confusing,
* make sure the're in sync!
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c 2012-02-16 15:13:29 UTC (rev 44153)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c 2012-02-16 15:38:16 UTC (rev 44154)
@@ -66,9 +66,12 @@
bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize[0], allocsize[0], FALSE, TRUE);
bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize[1], allocsize[1], FALSE, TRUE);
bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize[2], allocsize[2], FALSE, FALSE);
- bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE);
bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize[3], allocsize[3], FALSE, TRUE);
+#ifdef USE_BMESH_HOLES
+ bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE);
+#endif
+
/* allocate one flag pool that we dont get rid of. */
bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, FALSE, FALSE);
}
@@ -151,7 +154,10 @@
/* destroy flag pool */
BLI_mempool_destroy(bm->toolflagpool);
+
+#ifdef USE_BMESH_HOLES
BLI_mempool_destroy(bm->looplistpool);
+#endif
/* These tables aren't used yet, so it's not stricly necessary
* to 'end' them (with 'e' param) but if someone tries to start
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c 2012-02-16 15:13:29 UTC (rev 44153)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c 2012-02-16 15:38:16 UTC (rev 44154)
@@ -350,7 +350,11 @@
of = BM_face_copy(bm, f, 0, 0);
}
+#ifdef USE_BMESH_HOLES
nf = bmesh_sfme(bm, f, v1, v2, nl, NULL);
+#else
+ nf = bmesh_sfme(bm, f, v1, v2, nl);
+#endif
if (nf) {
BM_elem_attrs_copy(bm, bm, f, nf);
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2012-02-16 15:13:29 UTC (rev 44153)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2012-02-16 15:38:16 UTC (rev 44154)
@@ -173,14 +173,20 @@
static BMLoop *bm_face_boundry_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge *starte)
{
+#ifdef USE_BMESH_HOLES
BMLoopList *lst = BLI_mempool_calloc(bm->looplistpool);
+#endif
BMLoop *l = bmesh_create_loop(bm, startv, starte, f, NULL);
bmesh_radial_append(starte, l);
+#ifdef USE_BMESH_HOLES
lst->first = lst->last = l;
BLI_addtail(&f->loops, lst);
-
+#else
+ f->l_first = l;
+#endif
+
l->f = f;
return l;
@@ -400,8 +406,14 @@
BMLoop *l_first;
int len = 0;
+#ifdef USE_BMESH_HOLES
if (!f->loops.first)
+#else
+ if (!f->l_first)
+#endif
+ {
err |= (1 << 16);
+ }
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (l_iter->f != f) {
@@ -537,23 +549,38 @@
void BM_face_kill(BMesh *bm, BMFace *f)
{
+#ifdef USE_BMESH_HOLES
BMLoopList *ls, *ls_next;
+#endif
BM_CHECK_ELEMENT(bm, f);
- for (ls = f->loops.first; ls; ls = ls_next) {
+#ifdef USE_BMESH_HOLES
+ for (ls = f->loops.first; ls; ls = ls_next)
+#else
+ if (f->l_first)
+#endif
+ {
BMLoop *l_iter, *l_next, *l_first;
+#ifdef USE_BMESH_HOLES
ls_next = ls->next;
- l_first = l_iter = ls->first;
+ l_iter = l_first = ls->first;
+#else
+ l_iter = l_first = f->l_first;
+#endif
+
do {
l_next = l_iter->next;
bmesh_radial_remove_loop(l_iter, l_iter->e);
bmesh_kill_only_loop(bm, l_iter);
+
} while ((l_iter = l_next) != l_first);
-
+
+#ifdef USE_BMESH_HOLES
BLI_mempool_free(bm->looplistpool, ls);
+#endif
}
bmesh_kill_only_face(bm, f);
@@ -631,9 +658,19 @@
return i;
}
-static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst)
+static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f
+#ifdef USE_BMESH_HOLES
+ , BMLoopList *lst
+#endif
+ )
{
+
+#ifdef USE_BMESH_HOLES
BMLoop *l_first = lst->first;
+#else
+ BMLoop *l_first = f->l_first;
+#endif
+
BMLoop *l_iter, *oldprev, *oldnext;
BMEdge **edar = NULL;
MDisps *md;
@@ -713,7 +750,11 @@
int bmesh_loop_reverse(BMesh *bm, BMFace *f)
{
+#ifdef USE_BMESH_HOLES
return bmesh_loop_reverse_loop(bm, f, f->loops.first);
+#else
+ return bmesh_loop_reverse_loop(bm, f);
+#endif
}
static void bmesh_systag_elements(BMesh *UNUSED(bm), void *veles, int tot, int flag)
@@ -827,7 +868,10 @@
BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
{
BMFace *f, *newf;
+#ifdef USE_BMESH_HOLES
BMLoopList *lst;
+ ListBase holes = {NULL, NULL};
+#endif
BMLoop *l_iter;
BMLoop *l_first;
BMEdge **edges = NULL;
@@ -837,7 +881,6 @@
BLI_array_staticdeclare(deledges, BM_NGON_STACK_SIZE);
BLI_array_staticdeclare(delverts, BM_NGON_STACK_SIZE);
BMVert *v1 = NULL, *v2 = NULL;
- ListBase holes = {NULL, NULL};
const char *err = NULL;
int i, tote = 0;
@@ -894,12 +937,15 @@
}
} while ((l_iter = l_iter->next) != l_first);
+#ifdef USE_BMESH_HOLES
for (lst = f->loops.first; lst; lst = lst->next) {
if (lst == f->loops.first) continue;
BLI_remlink(&f->loops, lst);
BLI_addtail(&holes, lst);
}
+#endif
+
}
/* create region fac */
@@ -933,12 +979,21 @@
BM_elem_attrs_copy(bm, bm, faces[0], newf);
+#ifdef USE_BMESH_HOLES
/* add hole */
BLI_movelisttolist(&newf->loops, &holes);
+#endif
/* update loop face pointer */
- for (lst = newf->loops.first; lst; lst = lst->next) {
+#ifdef USE_BMESH_HOLES
+ for (lst = newf->loops.first; lst; lst = lst->next)
+#endif
+ {
+#ifdef USE_BMESH_HOLES
l_iter = l_first = lst->first;
+#else
+ l_iter = l_first = BM_FACE_FIRST_LOOP(newf);
+#endif
do {
l_iter->f = newf;
} while ((l_iter = l_iter->next) != l_first);
@@ -987,13 +1042,19 @@
static BMFace *bmesh_addpolylist(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->head.htype = BM_FACE;
+#ifdef USE_BMESH_HOLES
BLI_addtail(&f->loops, lst);
+#endif
#ifdef USE_DEBUG_INDEX_MEMCHECK
DEBUG_MEMCHECK_INDEX_INVALIDATE(f)
@@ -1054,14 +1115,20 @@
* A BMFace pointer
*/
BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
- BMLoop **rl, ListBase *holes)
+ BMLoop **rl
+#ifdef USE_BMESH_HOLES
+ , ListBase *holes
+#endif
+ )
{
+#ifdef USE_BMESH_HOLES
+ BMLoopList *lst, *lst2;
+#endif
BMFace *f2;
BMLoop *l_iter, *l_first;
BMLoop *v1loop = NULL, *v2loop = NULL, *f1loop = NULL, *f2loop = NULL;
BMEdge *e;
- BMLoopList *lst, *lst2;
int i, len, f1len, f2len;
/* verify that v1 and v2 are in face */
@@ -1092,11 +1159,16 @@
v1loop->prev = f1loop;
v2loop->prev = f2loop;
+#ifdef USE_BMESH_HOLES
lst = f->loops.first;
lst2 = f2->loops.first;
lst2->first = lst2->last = f2loop;
lst->first = lst->last = f1loop;
+#else
+ f2->l_first = f2loop;
+ f->l_first = f1loop;
+#endif
/* validate both loop */
/* I dont know how many loops are supposed to be in each face at this point! FIXME */
@@ -1125,6 +1197,7 @@
if (rl) *rl = f2loop;
+#ifdef USE_BMESH_HOLES
if (holes) {
BLI_movelisttolist(&f2->loops, holes);
}
@@ -1136,6 +1209,7 @@
BLI_mempool_free(bm->looplistpool, lst);
}
}
+#endif
BM_CHECK_ELEMENT(bm, e);
BM_CHECK_ELEMENT(bm, f);
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c 2012-02-16 15:13:29 UTC (rev 44153)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c 2012-02-16 15:38:16 UTC (rev 44154)
@@ -101,11 +101,18 @@
int BM_vert_in_face(BMFace *f, BMVert *v)
{
- BMLoopList *lst;
BMLoop *l_iter, *l_first;
- for (lst = f->loops.first; lst; lst = lst->next) {
+#ifdef USE_BMESH_HOLES
+ BMLoopList *lst;
+ for (lst = f->loops.first; lst; lst = lst->next)
+#endif
+ {
+#ifdef USE_BMESH_HOLES
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list