Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-16 19:38:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-16 19:38:16 +0400
commitf286061b392112b9a6dff2d6d1a529fbe6a5ed05 (patch)
tree77af7f94e8339e0d7d0a1364a10a8f8aec211fa9
parent300bfd23e4a8bae368d41ccd3b3c2f06a122bd9d (diff)
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).
-rw-r--r--source/blender/bmesh/bmesh.h6
-rw-r--r--source/blender/bmesh/bmesh_class.h13
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c8
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_newcore.c98
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c29
-rw-r--r--source/blender/bmesh/intern/bmesh_structure.h6
7 files changed, 146 insertions, 18 deletions
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index a9936c31b36..1f7e5f15d3a 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -345,7 +345,11 @@ void bmesh_begin_edit(BMesh *bm, int flag);
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.
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 25443051027..50f9247211c 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -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 @@ typedef struct BMLoop {
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*/
+#ifdef USE_BMESH_HOLES
int totbounds; /*total boundaries, is one plus the number of holes in the face*/
ListBase loops;
+#else
+ BMLoop *l_first;
+#endif
float no[3]; /*yes, we do store this here*/
short mat_nr;
} BMFace;
@@ -136,8 +145,10 @@ typedef struct BMesh {
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!
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index d285be460e1..a432049e238 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -66,9 +66,12 @@ static void bmesh_mempool_init(BMesh *bm, const int allocsize[4])
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 @@ void BM_mesh_data_free(BMesh *bm)
/* 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
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 82e1c638e27..21bd24dafde 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -350,7 +350,11 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **nl,
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);
diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c
index aa46a64945d..b77f8146caa 100644
--- a/source/blender/bmesh/intern/bmesh_newcore.c
+++ b/source/blender/bmesh/intern/bmesh_newcore.c
@@ -173,14 +173,20 @@ static BMLoop *bmesh_create_loop(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, con
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;
@@ -309,7 +315,10 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
lastl->next = startl;
f->len = len;
+
+#ifdef USE_BMESH_HOLES
f->totbounds = 0;
+#endif
BM_CHECK_ELEMENT(bm, f);
@@ -400,8 +409,14 @@ int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype)
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 +552,38 @@ void BM_face_verts_kill(BMesh *bm, BMFace *f)
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 +661,19 @@ static int bmesh_loop_length(BMLoop *l)
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 +753,11 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst)
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 +871,10 @@ static int disk_is_flagged(BMVert *v, int flag)
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 +884,6 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
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 +940,15 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
}
} 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 +982,21 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
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 +1045,19 @@ error:
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)
@@ -1011,7 +1075,10 @@ static BMFace *bmesh_addpolylist(BMesh *bm, BMFace *UNUSED(example))
CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
f->len = 0;
+
+#ifdef USE_BMESH_HOLES
f->totbounds = 1;
+#endif
return (BMFace *) f;
}
@@ -1054,14 +1121,20 @@ static BMFace *bmesh_addpolylist(BMesh *bm, BMFace *UNUSED(example))
* 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 +1165,16 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
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 +1203,7 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
if (rl) *rl = f2loop;
+#ifdef USE_BMESH_HOLES
if (holes) {
BLI_movelisttolist(&f2->loops, holes);
}
@@ -1136,6 +1215,7 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
BLI_mempool_free(bm->looplistpool, lst);
}
}
+#endif
BM_CHECK_ELEMENT(bm, e);
BM_CHECK_ELEMENT(bm, f);
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index dbfa9df79d2..096b334e5de 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -101,11 +101,18 @@ BMLoop *BM_face_other_loop(BMEdge *e, BMFace *f, BMVert *v)
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
l_iter = l_first = lst->first;
+#else
+ l_iter = l_first = f->l_first;
+#endif
do {
if (l_iter->v == v) {
return TRUE;
@@ -125,14 +132,26 @@ int BM_vert_in_face(BMFace *f, BMVert *v)
*/
int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len)
{
- BMLoopList *lst;
BMLoop *l_iter, *l_first;
+
+#ifdef USE_BMESH_HOLES
+ BMLoopList *lst;
+#endif
+
int i, count = 0;
for (i = 0; i < len; i++) BMO_elem_flag_enable(bm, varr[i], BM_OVERLAP);
-
- for (lst = f->loops.first; lst; lst = lst->next) {
+
+#ifdef USE_BMESH_HOLES
+ for (lst = f->loops.first; lst; lst = lst->next)
+#endif
+ {
+
+#ifdef USE_BMESH_HOLES
l_iter = l_first = lst->first;
+#else
+ l_iter = l_first = f->l_first;
+#endif
do {
if (BMO_elem_flag_test(bm, l_iter->v, BM_OVERLAP)) {
diff --git a/source/blender/bmesh/intern/bmesh_structure.h b/source/blender/bmesh/intern/bmesh_structure.h
index ab10fb4f062..aff90dcced7 100644
--- a/source/blender/bmesh/intern/bmesh_structure.h
+++ b/source/blender/bmesh/intern/bmesh_structure.h
@@ -91,7 +91,11 @@ int bmesh_ke(struct BMesh *bm, struct BMEdge *e);
int bmesh_kf(struct BMesh *bm, struct BMFace *bply);
struct BMVert *bmesh_semv(struct BMesh *bm, struct BMVert *tv, struct BMEdge *e, struct BMEdge **re);
struct BMFace *bmesh_sfme(struct BMesh *bm, struct BMFace *f, struct BMVert *v1,
- struct BMVert *v2, struct BMLoop **rl, struct ListBase *holes);
+ struct BMVert *v2, struct BMLoop **rl
+#ifdef USE_BMESH_HOLES
+ , ListBase *holes
+#endif
+ );
int bmesh_jekv(struct BMesh *bm, struct BMEdge *ke, struct BMVert *kv);
int bmesh_loop_reverse(struct BMesh *bm, struct BMFace *f);
struct BMFace *bmesh_jfke(struct BMesh *bm, struct BMFace *f1, struct BMFace *f2, struct BMEdge *e);