forked from bartvdbraak/blender
BMesh: use slightly faster method of stepping over edge-disks
This commit is contained in:
parent
cba3498629
commit
07a5caad5f
@ -311,6 +311,15 @@ typedef bool (*BMElemFilterFunc)(BMElem *, void *user_data);
|
|||||||
# define BM_FACE_FIRST_LOOP(p) ((p)->l_first)
|
# define BM_FACE_FIRST_LOOP(p) ((p)->l_first)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BM_DISK_EDGE_NEXT(e, v) ( \
|
||||||
|
CHECK_TYPE_INLINE(e, BMEdge *), CHECK_TYPE_INLINE(v, BMVert *), \
|
||||||
|
BLI_assert(BM_vert_in_edge(e, v)), \
|
||||||
|
(((&e->v1_disk_link)[v == e->v2]).next))
|
||||||
|
#define BM_DISK_EDGE_PREV(e, v) ( \
|
||||||
|
CHECK_TYPE_INLINE(e, BMEdge *), CHECK_TYPE_INLINE(v, BMVert *), \
|
||||||
|
BLI_assert(BM_vert_in_edge(e, v)), \
|
||||||
|
(((&e->v1_disk_link)[v == e->v2]).prev))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* size to use for stack arrays when dealing with NGons,
|
* size to use for stack arrays when dealing with NGons,
|
||||||
* alloc after this limit is reached.
|
* alloc after this limit is reached.
|
||||||
|
@ -144,8 +144,7 @@ BLI_INLINE bool BM_vert_is_wire_endpoint(const BMVert *v)
|
|||||||
{
|
{
|
||||||
const BMEdge *e = v->e;
|
const BMEdge *e = v->e;
|
||||||
if (e && e->l == NULL) {
|
if (e && e->l == NULL) {
|
||||||
const BMDiskLink *dl = (e->v1 == v) ? &e->v1_disk_link : &e->v2_disk_link;
|
return (BM_DISK_EDGE_NEXT(e, v) == e);
|
||||||
return (dl->next == e);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,17 +130,6 @@ bool bmesh_edge_swapverts(BMEdge *e, BMVert *v_orig, BMVert *v_new)
|
|||||||
* cycle order and all non-manifold conditions are represented trivially.
|
* cycle order and all non-manifold conditions are represented trivially.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BLI_INLINE BMDiskLink *bmesh_disk_edge_link_from_vert(BMEdge *e, BMVert *v)
|
|
||||||
{
|
|
||||||
if (v == e->v1) {
|
|
||||||
return &e->v1_disk_link;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BLI_assert(v == e->v2);
|
|
||||||
return &e->v2_disk_link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void bmesh_disk_edge_append(BMEdge *e, BMVert *v)
|
void bmesh_disk_edge_append(BMEdge *e, BMVert *v)
|
||||||
{
|
{
|
||||||
if (!v->e) {
|
if (!v->e) {
|
||||||
@ -205,28 +194,15 @@ BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2)
|
|||||||
|
|
||||||
int bmesh_disk_count(const BMVert *v)
|
int bmesh_disk_count(const BMVert *v)
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
if (v->e) {
|
if (v->e) {
|
||||||
BMEdge *e_first, *e_iter;
|
BMEdge *e_first, *e_iter;
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
e_iter = e_first = v->e;
|
e_iter = e_first = v->e;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!e_iter) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count >= (1 << 20)) {
|
|
||||||
printf("bmesh error: infinite loop in disk cycle!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
count++;
|
count++;
|
||||||
} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
|
} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
|
||||||
return count;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bmesh_disk_validate(int len, BMEdge *e, BMVert *v)
|
bool bmesh_disk_validate(int len, BMEdge *e, BMVert *v)
|
||||||
|
@ -47,6 +47,8 @@ bool bmesh_loop_validate(BMFace *f);
|
|||||||
/* DISK CYCLE MANAGMENT */
|
/* DISK CYCLE MANAGMENT */
|
||||||
void bmesh_disk_edge_append(BMEdge *e, BMVert *v);
|
void bmesh_disk_edge_append(BMEdge *e, BMVert *v);
|
||||||
void bmesh_disk_edge_remove(BMEdge *e, BMVert *v);
|
void bmesh_disk_edge_remove(BMEdge *e, BMVert *v);
|
||||||
|
BLI_INLINE BMEdge *bmesh_disk_edge_next_safe(const BMEdge *e, const BMVert *v);
|
||||||
|
BLI_INLINE BMEdge *bmesh_disk_edge_prev_safe(const BMEdge *e, const BMVert *v);
|
||||||
BLI_INLINE BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v);
|
BLI_INLINE BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v);
|
||||||
BLI_INLINE BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v);
|
BLI_INLINE BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v);
|
||||||
int bmesh_disk_facevert_count(const BMVert *v);
|
int bmesh_disk_facevert_count(const BMVert *v);
|
||||||
|
@ -27,6 +27,12 @@
|
|||||||
#ifndef __BMESH_STRUCTURE_INLINE_H__
|
#ifndef __BMESH_STRUCTURE_INLINE_H__
|
||||||
#define __BMESH_STRUCTURE_INLINE_H__
|
#define __BMESH_STRUCTURE_INLINE_H__
|
||||||
|
|
||||||
|
BLI_INLINE BMDiskLink *bmesh_disk_edge_link_from_vert(const BMEdge *e, const BMVert *v)
|
||||||
|
{
|
||||||
|
BLI_assert(BM_vert_in_edge(e, v));
|
||||||
|
return (BMDiskLink *)&(&e->v1_disk_link)[v == e->v2];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Next Disk Edge
|
* \brief Next Disk Edge
|
||||||
*
|
*
|
||||||
@ -34,7 +40,7 @@
|
|||||||
*
|
*
|
||||||
* \return Pointer to the next edge in the disk cycle for the vertex v.
|
* \return Pointer to the next edge in the disk cycle for the vertex v.
|
||||||
*/
|
*/
|
||||||
BLI_INLINE BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v)
|
BLI_INLINE BMEdge *bmesh_disk_edge_next_safe(const BMEdge *e, const BMVert *v)
|
||||||
{
|
{
|
||||||
if (v == e->v1)
|
if (v == e->v1)
|
||||||
return e->v1_disk_link.next;
|
return e->v1_disk_link.next;
|
||||||
@ -43,7 +49,7 @@ BLI_INLINE BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_INLINE BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v)
|
BLI_INLINE BMEdge *bmesh_disk_edge_prev_safe(const BMEdge *e, const BMVert *v)
|
||||||
{
|
{
|
||||||
if (v == e->v1)
|
if (v == e->v1)
|
||||||
return e->v1_disk_link.prev;
|
return e->v1_disk_link.prev;
|
||||||
@ -52,4 +58,14 @@ BLI_INLINE BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BLI_INLINE BMEdge *bmesh_disk_edge_next(const BMEdge *e, const BMVert *v)
|
||||||
|
{
|
||||||
|
return BM_DISK_EDGE_NEXT(e, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
BLI_INLINE BMEdge *bmesh_disk_edge_prev(const BMEdge *e, const BMVert *v)
|
||||||
|
{
|
||||||
|
return BM_DISK_EDGE_PREV(e, v);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __BMESH_STRUCTURE_INLINE_H__ */
|
#endif /* __BMESH_STRUCTURE_INLINE_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user