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:
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/CMakeLists.txt10
-rw-r--r--source/blender/bmesh/bmesh.h4
-rw-r--r--source/blender/bmesh/bmesh_class.h43
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c69
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c20
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.h7
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c44
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h6
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c774
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h141
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h48
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c434
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h5
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c9
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h20
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c57
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h10
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c2209
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c14
-rw-r--r--source/blender/bmesh/operators/bmo_create.c86
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c30
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c159
-rw-r--r--source/blender/bmesh/operators/bmo_edgesplit.c20
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c64
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c64
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c57
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c12
-rw-r--r--source/blender/bmesh/operators/bmo_mesh_conv.c14
-rw-r--r--source/blender/bmesh/operators/bmo_mirror.c23
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c107
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c87
-rw-r--r--source/blender/bmesh/operators/bmo_similar.c30
-rw-r--r--source/blender/bmesh/operators/bmo_slide.c8
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c40
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c65
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.h2
-rw-r--r--source/blender/bmesh/operators/bmo_symmetrize.c20
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c27
-rw-r--r--source/blender/bmesh/operators/bmo_unsubdivide.c6
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c107
-rw-r--r--source/blender/bmesh/operators/bmo_wireframe.c87
-rw-r--r--source/blender/bmesh/tools/BME_bevel.c5
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c1749
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.h32
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate.h (renamed from source/blender/bmesh/intern/bmesh_decimate.h)2
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c (renamed from source/blender/bmesh/intern/bmesh_decimate_collapse.c)5
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_dissolve.c (renamed from source/blender/bmesh/intern/bmesh_decimate_dissolve.c)6
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c (renamed from source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c)2
50 files changed, 3567 insertions, 3293 deletions
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index d7858ebbc0d..2a23658f5d0 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -68,10 +68,6 @@ set(SRC
intern/bmesh_construct.h
intern/bmesh_core.c
intern/bmesh_core.h
- intern/bmesh_decimate_collapse.c
- intern/bmesh_decimate_dissolve.c
- intern/bmesh_decimate_unsubdivide.c
- intern/bmesh_decimate.h
intern/bmesh_inline.h
intern/bmesh_interp.c
intern/bmesh_interp.h
@@ -109,6 +105,12 @@ set(SRC
intern/bmesh_error.h
tools/BME_bevel.c
+ tools/bmesh_bevel.c
+ tools/bmesh_bevel.h
+ tools/bmesh_decimate_collapse.c
+ tools/bmesh_decimate_dissolve.c
+ tools/bmesh_decimate_unsubdivide.c
+ tools/bmesh_decimate.h
bmesh.h
bmesh_class.h
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index a672ec0b6a7..6257aa4bf3e 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -252,7 +252,6 @@ extern "C" {
#include "intern/bmesh_construct.h"
#include "intern/bmesh_core.h"
-#include "intern/bmesh_decimate.h"
#include "intern/bmesh_interp.h"
#include "intern/bmesh_iterators.h"
#include "intern/bmesh_marking.h"
@@ -267,6 +266,9 @@ extern "C" {
#include "intern/bmesh_inline.h"
+#include "tools/bmesh_decimate.h"
+#include "tools/bmesh_bevel.h"
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index cff7da78ef2..f9dbf51a629 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -48,6 +48,8 @@ struct Object;
* hrm. it doesn't but stull works ok, remove the comment above? - campbell.
*/
+// #pragma GCC diagnostic error "-Wpadded"
+
/**
* BMHeader
*
@@ -69,10 +71,19 @@ typedef struct BMHeader {
* this is abused by various tools which set it dirty.
* - For loops this is used for sorting during tessellation. */
- char htype; /* element geometric type (verts/edges/loops/faces) */
- char hflag; /* this would be a CD layer, see below */
+ char htype; /* element geometric type (verts/edges/loops/faces) */
+ char hflag; /* this would be a CD layer, see below */
+
+ /* internal use only!
+ * note,.we are very picky about not bloating this struct
+ * but in this case its padded up to 16 bytes anyway,
+ * so adding a flag here gives no increase in size */
+ char api_flag;
+// char _pad;
} BMHeader;
+BLI_STATIC_ASSERT((sizeof(BMHeader) <= 16), "BMHeader size has grown!");
+
/* note: need some way to specify custom locations for custom data layers. so we can
* make them point directly into structs. and some way to make it only happen to the
* active layer, and properly update when switching active layers.*/
@@ -122,7 +133,10 @@ typedef struct BMLoop {
/* can cast BMFace/BMEdge/BMVert, but NOT BMLoop, since these don't have a flag layer */
typedef struct BMElemF {
BMHeader head;
- struct BMFlagLayer *oflags; /* keep after header, an array of flags, mostly used by the operator stack */
+
+ /* keep directly after header,
+ * optional array of flags, only used by the operator stack */
+ struct BMFlagLayer *oflags;
} BMElemF;
/* can cast anything to this, including BMLoop */
@@ -142,21 +156,24 @@ typedef struct BMFace {
BMHeader head;
struct BMFlagLayer *oflags; /* an array of flags, mostly used by the operator stack */
- 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*/
+ int len; /* includes all boundary loops */
+ float no[3]; /* yes, we do store this here */
short mat_nr;
+// short _pad[3];
} BMFace;
typedef struct BMFlagLayer {
- short f, pflag; /* flags */
+ short f; /* flags */
} BMFlagLayer;
+// #pragma GCC diagnostic ignored "-Wpadded"
+
typedef struct BMesh {
int totvert, totedge, totloop, totface;
int totvertsel, totedgesel, totfacesel;
@@ -166,7 +183,7 @@ typedef struct BMesh {
* valid flags are - BM_VERT | BM_EDGE | BM_FACE.
* BM_LOOP isn't handled so far. */
char elem_index_dirty;
-
+
/*element pools*/
struct BLI_mempool *vpool, *epool, *lpool, *fpool;
@@ -192,7 +209,7 @@ typedef struct BMesh {
int walkers, totflags;
ListBase selected, error_stack;
-
+
BMFace *act_face;
ListBase errorstack;
@@ -243,10 +260,16 @@ enum {
# define BM_FACE_FIRST_LOOP(p) ((p)->l_first)
#endif
-/* size to use for static arrays when dealing with NGons,
+/**
+ * size to use for stack arrays when dealing with NGons,
* alloc after this limit is reached.
* this value is rather arbitrary */
-#define BM_NGON_STACK_SIZE 32
+#define BM_DEFAULT_NGON_STACK_SIZE 32
+/**
+ * size to use for stack arrays dealing with connected mesh data
+ * verts of faces, edges of vert - etc.
+ * often used with #BM_iter_as_arrayN() */
+#define BM_DEFAULT_ITER_STACK_SIZE 16
/* avoid inf loop, this value is arbitrary
* but should not error on valid cases */
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index eae78c6cc25..770196108f0 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -99,7 +99,7 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa
if (nodouble) {
/* check if face exists or overlaps */
- is_overlap = BM_face_exists(bm, verts, len, &f);
+ is_overlap = BM_face_exists(verts, len, &f);
}
/* make new face */
@@ -174,9 +174,9 @@ void BM_face_copy_shared(BMesh *bm, BMFace *f)
BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble)
{
BMEdge **edges2 = NULL;
- BLI_array_staticdeclare(edges2, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(edges2, BM_DEFAULT_NGON_STACK_SIZE);
BMVert **verts = NULL;
- BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE);
BMFace *f = NULL;
BMEdge *e;
BMVert *v, *ev1, *ev2;
@@ -187,8 +187,10 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
* _and_ the old bmesh_mf functions, so its kindof smashed together
* - joeedh */
- if (!len || !v1 || !v2 || !edges || !bm)
+ if (!len || !v1 || !v2 || !edges || !bm) {
+ BLI_assert(0);
return NULL;
+ }
/* put edges in correct order */
for (i = 0; i < len; i++) {
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 0910dd82701..03094873e25 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -76,7 +76,9 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
}
/* allocate flag */
- v->oflags = BLI_mempool_calloc(bm->toolflagpool);
+ if (bm->toolflagpool) {
+ v->oflags = BLI_mempool_calloc(bm->toolflagpool);
+ }
CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
@@ -125,12 +127,14 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example,
e->head.htype = BM_EDGE;
/* allocate flag */
- e->oflags = BLI_mempool_calloc(bm->toolflagpool);
+ if (bm->toolflagpool) {
+ e->oflags = BLI_mempool_calloc(bm->toolflagpool);
+ }
e->v1 = v1;
e->v2 = v2;
- BM_elem_flag_enable(e, BM_ELEM_SMOOTH);
+ BM_elem_flag_enable(e, BM_ELEM_SMOOTH | BM_ELEM_DRAW);
CustomData_bmesh_set_default(&bm->edata, &e->head.data);
@@ -195,8 +199,8 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short co
{
BMVert **verts = NULL;
BMEdge **edges = NULL;
- BLI_array_fixedstack_declare(verts, BM_NGON_STACK_SIZE, f->len, __func__);
- BLI_array_fixedstack_declare(edges, BM_NGON_STACK_SIZE, f->len, __func__);
+ BLI_array_fixedstack_declare(verts, BM_DEFAULT_NGON_STACK_SIZE, f->len, __func__);
+ BLI_array_fixedstack_declare(edges, BM_DEFAULT_NGON_STACK_SIZE, f->len, __func__);
BMLoop *l_iter;
BMLoop *l_first;
BMLoop *l_copy;
@@ -278,7 +282,9 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
f->head.htype = BM_FACE;
/* allocate flag */
- f->oflags = BLI_mempool_calloc(bm->toolflagpool);
+ if (bm->toolflagpool) {
+ f->oflags = BLI_mempool_calloc(bm->toolflagpool);
+ }
CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
@@ -305,7 +311,7 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
if (nodouble) {
/* Check if face already exists */
- overlap = BM_face_exists(bm, verts, len, &f);
+ overlap = BM_face_exists(verts, len, &f);
if (overlap) {
return f;
}
@@ -495,7 +501,9 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v)
if (v->head.data)
CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
- BLI_mempool_free(bm->toolflagpool, v->oflags);
+ if (bm->toolflagpool) {
+ BLI_mempool_free(bm->toolflagpool, v->oflags);
+ }
BLI_mempool_free(bm->vpool, v);
}
@@ -513,7 +521,9 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
if (e->head.data)
CustomData_bmesh_free_block(&bm->edata, &e->head.data);
- BLI_mempool_free(bm->toolflagpool, e->oflags);
+ if (bm->toolflagpool) {
+ BLI_mempool_free(bm->toolflagpool, e->oflags);
+ }
BLI_mempool_free(bm->epool, e);
}
@@ -534,7 +544,9 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f)
if (f->head.data)
CustomData_bmesh_free_block(&bm->pdata, &f->head.data);
- BLI_mempool_free(bm->toolflagpool, f->oflags);
+ if (bm->toolflagpool) {
+ BLI_mempool_free(bm->toolflagpool, f->oflags);
+ }
BLI_mempool_free(bm->fpool, f);
}
@@ -558,7 +570,7 @@ static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
void BM_face_edges_kill(BMesh *bm, BMFace *f)
{
BMEdge **edges = NULL;
- BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(edges, BM_DEFAULT_NGON_STACK_SIZE);
BMLoop *l_iter;
BMLoop *l_first;
int i;
@@ -582,7 +594,7 @@ void BM_face_edges_kill(BMesh *bm, BMFace *f)
void BM_face_verts_kill(BMesh *bm, BMFace *f)
{
BMVert **verts = NULL;
- BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE);
BMLoop *l_iter;
BMLoop *l_first;
int i;
@@ -734,7 +746,7 @@ static int bm_loop_reverse_loop(BMesh *bm, BMFace *f
const int do_disps = CustomData_has_layer(&bm->ldata, CD_MDISPS);
BMLoop *l_iter, *oldprev, *oldnext;
BMEdge **edar = NULL;
- BLI_array_fixedstack_declare(edar, BM_NGON_STACK_SIZE, len, __func__);
+ BLI_array_fixedstack_declare(edar, BM_DEFAULT_NGON_STACK_SIZE, len, __func__);
int i, j, edok;
for (i = 0, l_iter = l_first; i < len; i++, l_iter = l_iter->next) {
@@ -937,9 +949,9 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
BMEdge **edges = NULL;
BMEdge **deledges = NULL;
BMVert **delverts = NULL;
- BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
- BLI_array_staticdeclare(deledges, BM_NGON_STACK_SIZE);
- BLI_array_staticdeclare(delverts, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(edges, BM_DEFAULT_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(deledges, BM_DEFAULT_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(delverts, BM_DEFAULT_NGON_STACK_SIZE);
BMVert *v1 = NULL, *v2 = NULL;
const char *err = NULL;
int i, tote = 0;
@@ -1587,7 +1599,7 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_dou
if (LIKELY(radlen)) {
BMLoop **loops = NULL;
- BLI_array_fixedstack_declare(loops, BM_NGON_STACK_SIZE, radlen, __func__);
+ BLI_array_fixedstack_declare(loops, BM_DEFAULT_NGON_STACK_SIZE, radlen, __func__);
killoop = ke->l;
@@ -1773,14 +1785,18 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
bmesh_disk_edge_remove(f1loop->e, f1loop->e->v2);
/* deallocate edge and its two loops as well as f2 */
- BLI_mempool_free(bm->toolflagpool, f1loop->e->oflags);
+ if (bm->toolflagpool) {
+ BLI_mempool_free(bm->toolflagpool, f1loop->e->oflags);
+ }
BLI_mempool_free(bm->epool, f1loop->e);
bm->totedge--;
BLI_mempool_free(bm->lpool, f1loop);
bm->totloop--;
BLI_mempool_free(bm->lpool, f2loop);
bm->totloop--;
- BLI_mempool_free(bm->toolflagpool, f2->oflags);
+ if (bm->toolflagpool) {
+ BLI_mempool_free(bm->toolflagpool, f2->oflags);
+ }
BLI_mempool_free(bm->fpool, f2);
bm->totface--;
/* account for both above */
@@ -1808,23 +1824,28 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
*/
int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target)
{
- BMEdge *e;
-
+ void *loops_stack[BM_DEFAULT_ITER_STACK_SIZE];
BMLoop **loops;
int i, loops_tot;
+ BMEdge *e;
+
/* verts already spliced */
if (v == v_target) {
return FALSE;
}
/* we can't modify the vert while iterating so first allocate an array of loops */
- loops = BM_iter_as_arrayN(bm, BM_LOOPS_OF_VERT, v, &loops_tot);
- if (loops) {
+ loops = BM_iter_as_arrayN(bm, BM_LOOPS_OF_VERT, v, &loops_tot,
+ loops_stack, BM_DEFAULT_ITER_STACK_SIZE);
+
+ if (LIKELY(loops != NULL)) {
for (i = 0; i < loops_tot; i++) {
loops[i]->v = v_target;
}
- MEM_freeN(loops);
+ if (loops != (BMLoop **)loops_stack) {
+ MEM_freeN(loops);
+ }
}
/* move all the edges from v's disk to vtarget's disk */
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 508b3b8fcdf..caf9f3c70d5 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -174,9 +174,9 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source)
void **blocks = NULL;
float (*cos)[3] = NULL, *w = NULL;
- BLI_array_fixedstack_declare(cos, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(w, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(blocks, BM_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(cos, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(w, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(blocks, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
int i;
BM_elem_attrs_copy(bm, bm, source, target);
@@ -613,10 +613,10 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
void **vblocks = NULL;
float (*cos)[3] = NULL, co[3], *w = NULL;
float cent[3] = {0.0f, 0.0f, 0.0f};
- BLI_array_fixedstack_declare(cos, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(w, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(blocks, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(vblocks, BM_NGON_STACK_SIZE, do_vertex ? source->len : 0, __func__);
+ BLI_array_fixedstack_declare(cos, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(w, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(blocks, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(vblocks, BM_DEFAULT_NGON_STACK_SIZE, do_vertex ? source->len : 0, __func__);
int i, ax, ay;
BM_elem_attrs_copy(bm, bm, source, target->f);
@@ -689,9 +689,9 @@ void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source)
void **blocks = NULL;
float (*cos)[3] = NULL, *w = NULL;
float cent[3] = {0.0f, 0.0f, 0.0f};
- BLI_array_fixedstack_declare(cos, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(w, BM_NGON_STACK_SIZE, source->len, __func__);
- BLI_array_fixedstack_declare(blocks, BM_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(cos, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(w, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
+ BLI_array_fixedstack_declare(blocks, BM_DEFAULT_NGON_STACK_SIZE, source->len, __func__);
int i;
i = 0;
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index 1cb95d94e9b..c3f33eb95e1 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -116,10 +116,14 @@ int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, cons
*
* Caller needs to free the array.
*/
-void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len)
+void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len,
+ /* optional args to avoid an alloc (normally stack array) */
+ void **stack_array, int stack_array_size)
{
BMIter iter;
+ BLI_assert(stack_array_size == 0 || (stack_array_size && stack_array));
+
/* we can't rely on coun't being set */
switch (itype) {
case BM_VERTS_OF_MESH:
@@ -137,7 +141,9 @@ void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len)
if (BM_iter_init(&iter, bm, itype, data) && iter.count > 0) {
BMElem *ele;
- BMElem **array = MEM_mallocN(sizeof(ele) * iter.count, __func__);
+ BMElem **array = iter.count > stack_array_size ?
+ MEM_mallocN(sizeof(ele) * iter.count, __func__) :
+ stack_array;
int i = 0;
*r_len = iter.count; /* set before iterating */
diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h
index 3c42b3d610c..7291bca6356 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.h
+++ b/source/blender/bmesh/intern/bmesh_iterators.h
@@ -107,14 +107,14 @@ typedef struct BMIter {
BMesh *bm;
void (*begin)(struct BMIter *iter);
void *(*step)(struct BMIter *iter);
- /*
+#if 0
union {
void *p;
int i;
long l;
float f;
} filter;
- */
+#endif
int count; /* note, only some iterators set this, don't rely on it */
char itype;
} BMIter;
@@ -125,7 +125,8 @@ __attribute__((warn_unused_result))
#endif
;
int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, const int len);
-void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len)
+void *BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len,
+ void **stack_array, int stack_array_size)
#ifdef __GNUC__
__attribute__((warn_unused_result))
#endif
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index d3e3bcd3556..ba5e7569c31 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -59,9 +59,45 @@ static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize)
#ifdef USE_BMESH_HOLES
bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), 512, 512, 0);
#endif
+}
- /* allocate one flag pool that we don't get rid of. */
- bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, 0);
+void BM_mesh_elem_toolflags_ensure(BMesh *bm)
+{
+ if (bm->toolflagpool == NULL) {
+ const int totflagpool_size = max_ii(512, bm->totvert + bm->totedge + bm->totface);
+ BLI_mempool *toolflagpool;
+
+ BMIter iter;
+ BMElemF *ele;
+ const char iter_types[3] = {BM_VERTS_OF_MESH,
+ BM_EDGES_OF_MESH,
+ BM_FACES_OF_MESH};
+
+ int i;
+
+ BLI_assert(bm->totflags == 0);
+
+ /* allocate one flag pool that we don't get rid of. */
+ toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), totflagpool_size, 512, 0);
+
+
+ for (i = 0; i < 3; i++) {
+ BM_ITER_MESH (ele, &iter, bm, iter_types[i]) {
+ ele->oflags = BLI_mempool_calloc(toolflagpool);
+ }
+ }
+
+ bm->toolflagpool = toolflagpool;
+ bm->totflags = 1;
+ }
+}
+
+void BM_mesh_elem_toolflags_clear(BMesh *bm)
+{
+ if (bm->toolflagpool) {
+ BLI_mempool_destroy(bm->toolflagpool);
+ bm->toolflagpool = NULL;
+ }
}
/**
@@ -83,7 +119,7 @@ BMesh *BM_mesh_create(BMAllocTemplate *allocsize)
/* allocate one flag pool that we don't get rid of. */
bm->stackdepth = 1;
- bm->totflags = 1;
+ bm->totflags = 0;
CustomData_reset(&bm->vdata);
CustomData_reset(&bm->edata);
@@ -143,7 +179,7 @@ void BM_mesh_data_free(BMesh *bm)
BLI_mempool_destroy(bm->fpool);
/* destroy flag pool */
- BLI_mempool_destroy(bm->toolflagpool);
+ BM_mesh_elem_toolflags_clear(bm);
#ifdef USE_BMESH_HOLES
BLI_mempool_destroy(bm->looplistpool);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index 8b6ef9aa3e0..b592f863cd1 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -29,6 +29,8 @@
struct BMAllocTemplate;
+void BM_mesh_elem_toolflags_ensure(BMesh *bm);
+void BM_mesh_elem_toolflags_clear(BMesh *bm);
BMesh *BM_mesh_create(struct BMAllocTemplate *allocsize);
void BM_mesh_free(BMesh *bm);
@@ -58,4 +60,8 @@ typedef struct BMAllocTemplate {
extern BMAllocTemplate bm_mesh_allocsize_default;
extern BMAllocTemplate bm_mesh_chunksize_default;
+enum {
+ BM_MESH_CREATE_USE_TOOLFLAGS = (1 << 0)
+};
+
#endif /* __BMESH_MESH_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 398e6bbedcf..ec07eb5d9f7 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -47,9 +47,9 @@
* "in" (e.g. edgefacein). for three-type slots, use geom.
*
* for output slots, for single-type geometry slots, use the type name plus "out",
- * (e.g. vertout), for double-type slots, use the two type names plus "out",
- * (e.g. vertfaceout), for three-type slots, use geom. note that you can also
- * use more esohteric names (e.g. skirtout) so long as the comment next to the
+ * (e.g. verts.out), for double-type slots, use the two type names plus "out",
+ * (e.g. vertfaces.out), for three-type slots, use geom. note that you can also
+ * use more esohteric names (e.g. geom_skirt.out) so long as the comment next to the
* slot definition tells you what types of elements are in it.
*
*/
@@ -82,7 +82,7 @@
* would be extracted from comments
* next to them, e.g.
*
- * {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, boundary region
+ * {BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, //output slot, boundary region
*
* the doc generator would automatically detect the presence of "output slot"
* and flag the slot as an output. the same happens for "input slot". also
@@ -99,16 +99,18 @@
*/
static BMOpDefine bmo_smooth_vert_def = {
"smooth_vert",
- {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, /* set vertices close to the x axis before the operation to 0 */
- {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, /* set vertices close to the y axis before the operation to 0 */
- {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, /* set vertices close to the z axis before the operation to 0 */
- {BMO_OP_SLOT_FLT, "clipdist"}, /* clipping threshod for the above three slots */
- {BMO_OP_SLOT_BOOL, "use_axis_x"}, /* smooth vertices along X axis */
- {BMO_OP_SLOT_BOOL, "use_axis_y"}, /* smooth vertices along Y axis */
- {BMO_OP_SLOT_BOOL, "use_axis_z"}, /* smooth vertices along Z axis */
- {0} /* null-terminating sentinel */,
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
+ {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, /* set vertices close to the x axis before the operation to 0 */
+ {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, /* set vertices close to the y axis before the operation to 0 */
+ {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, /* set vertices close to the z axis before the operation to 0 */
+ {BMO_OP_SLOT_FLT, "clip_dist"}, /* clipping threshod for the above three slots */
+ {BMO_OP_SLOT_BOOL, "use_axis_x"}, /* smooth vertices along X axis */
+ {BMO_OP_SLOT_BOOL, "use_axis_y"}, /* smooth vertices along Y axis */
+ {BMO_OP_SLOT_BOOL, "use_axis_z"}, /* smooth vertices along Z axis */
+ {0},
},
+ {{0}}, /* no output */
bmo_smooth_vert_exec,
0
};
@@ -117,18 +119,20 @@ static BMOpDefine bmo_smooth_vert_def = {
* Vertext Smooth Laplacian
* Smooths vertices by using Laplacian smoothing propose by.
* Desbrun, et al. Implicit Fairing of Irregular Meshes using Diffusion and Curvature Flow
-*/
+ */
static BMOpDefine bmo_smooth_laplacian_vert_def = {
"smooth_laplacian_vert",
- {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices
- {BMO_OP_SLOT_FLT, "lambda"}, //lambda param
- {BMO_OP_SLOT_FLT, "lambda_border"}, //lambda param in border
- {BMO_OP_SLOT_BOOL, "use_x"}, //Smooth object along X axis
- {BMO_OP_SLOT_BOOL, "use_y"}, //Smooth object along Y axis
- {BMO_OP_SLOT_BOOL, "use_z"}, //Smooth object along Z axis
- {BMO_OP_SLOT_BOOL, "volume_preservation"}, //Apply volume preservation after smooth
- {0} /* null-terminating sentinel */,
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
+ {BMO_OP_SLOT_FLT, "lambda"}, /* lambda param */
+ {BMO_OP_SLOT_FLT, "lambda_border"}, /* lambda param in border */
+ {BMO_OP_SLOT_BOOL, "use_x"}, /* Smooth object along X axis */
+ {BMO_OP_SLOT_BOOL, "use_y"}, /* Smooth object along Y axis */
+ {BMO_OP_SLOT_BOOL, "use_z"}, /* Smooth object along Z axis */
+ {BMO_OP_SLOT_BOOL, "preserve_volume"}, /* Apply volume preservation after smooth */
+ {0},
},
+ {{0}}, /* no output */
bmo_smooth_laplacian_vert_exec,
0
};
@@ -141,10 +145,12 @@ static BMOpDefine bmo_smooth_laplacian_vert_def = {
static BMOpDefine bmo_recalc_face_normals_def = {
"recalc_face_normals",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"},
- {BMO_OP_SLOT_BOOL, "do_flip"}, /* internal flag, used by bmesh_rationalize_normals */
- {0} /* null-terminating sentinel */,
+ {BMO_OP_SLOT_BOOL, "use_flip"}, /* internal flag, used by bmesh_rationalize_normals */
+ {0},
},
+ {{0}}, /* no output */
bmo_recalc_face_normals_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -154,18 +160,22 @@ static BMOpDefine bmo_recalc_face_normals_def = {
*
* used to implement the select more/less tools.
* this puts some geometry surrounding regions of
- * geometry in geom into geomout.
+ * geometry in geom into geom.out.
*
- * if usefaces is 0 then geomout spits out verts and edges,
+ * if usefaces is 0 then geom.out spits out verts and edges,
* otherwise it spits out faces.
*/
static BMOpDefine bmo_region_extend_def = {
"region_extend",
- {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output slot, computed boundary geometry. */
- {BMO_OP_SLOT_BOOL, "constrict"}, /* find boundary inside the regions, not outside. */
- {BMO_OP_SLOT_BOOL, "use_faces"}, /* extend from faces instead of edges */
- {0} /* null-terminating sentinel */,
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */
+ {BMO_OP_SLOT_BOOL, "use_constrict"}, /* find boundary inside the regions, not outside. */
+ {BMO_OP_SLOT_BOOL, "use_faces"}, /* extend from faces instead of edges */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* output slot, computed boundary geometry. */
+ {0},
},
bmo_region_extend_exec,
0
@@ -179,10 +189,14 @@ static BMOpDefine bmo_region_extend_def = {
*/
static BMOpDefine bmo_rotate_edges_def = {
"rotate_edges",
- {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly spun edges */
- {BMO_OP_SLOT_BOOL, "ccw"}, /* rotate edge counter-clockwise if true, othewise clockwise */
- {0} /* null-terminating sentinel */,
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
+ {BMO_OP_SLOT_BOOL, "use_ccw"}, /* rotate edge counter-clockwise if true, othewise clockwise */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* newly spun edges */
+ {0},
},
bmo_rotate_edges_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
@@ -196,9 +210,11 @@ static BMOpDefine bmo_rotate_edges_def = {
*/
static BMOpDefine bmo_reverse_faces_def = {
"reverse_faces",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {0} /* null-terminating sentinel */,
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
+ {0},
},
+ {{0}}, /* no output */
bmo_reverse_faces_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -211,10 +227,14 @@ static BMOpDefine bmo_reverse_faces_def = {
*/
static BMOpDefine bmo_bisect_edges_def = {
"bisect_edges",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_INT, "numcuts"}, /* number of cuts */
- {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, /* newly created vertices and edges */
- {0} /* null-terminating sentinel */,
+ {BMO_OP_SLOT_INT, "cuts"}, /* number of cuts */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom_split.out"}, /* newly created vertices and edges */
+ {0},
},
bmo_bisect_edges_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
@@ -224,20 +244,25 @@ static BMOpDefine bmo_bisect_edges_def = {
* Mirror
*
* Mirrors geometry along an axis. The resulting geometry is welded on using
- * mergedist. Pairs of original/mirrored vertices are welded using the mergedist
+ * merge_dist. Pairs of original/mirrored vertices are welded using the merge_dist
* parameter (which defines the minimum distance for welding to happen).
*/
static BMOpDefine bmo_mirror_def = {
"mirror",
- {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */
- {BMO_OP_SLOT_FLT, "mergedist"}, /* maximum distance for merging. does no merging if 0. */
- {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* output geometry, mirrored */
- {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */
+ {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */
+ {BMO_OP_SLOT_FLT, "merge_dist"}, /* maximum distance for merging. does no merging if 0. */
+ {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */
{BMO_OP_SLOT_BOOL, "mirror_u"}, /* mirror UVs across the u axis */
{BMO_OP_SLOT_BOOL, "mirror_v"}, /* mirror UVs across the v axis */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* output geometry, mirrored */
+ {0},
+ },
bmo_mirror_exec,
0,
};
@@ -253,11 +278,16 @@ static BMOpDefine bmo_mirror_def = {
*/
static BMOpDefine bmo_find_doubles_def = {
"find_doubles",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
{BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, /* list of verts to keep */
{BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */
- {BMO_OP_SLOT_MAPPING, "targetmapout"},
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_MAPPING, "targetmap.out"},
+ {0},
+ },
bmo_find_doubles_exec,
0,
};
@@ -270,9 +300,12 @@ static BMOpDefine bmo_find_doubles_def = {
*/
static BMOpDefine bmo_remove_doubles_def = {
"remove_doubles",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */
{BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_remove_doubles_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -286,9 +319,12 @@ static BMOpDefine bmo_remove_doubles_def = {
*/
static BMOpDefine bmo_automerge_def = {
"automerge",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */
{BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_automerge_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -300,8 +336,11 @@ static BMOpDefine bmo_automerge_def = {
*/
static BMOpDefine bmo_collapse_def = {
"collapse",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_collapse_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -314,9 +353,12 @@ static BMOpDefine bmo_collapse_def = {
*/
static BMOpDefine bmo_pointmerge_facedata_def = {
"pointmerge_facedata",
- {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */
- {BMO_OP_SLOT_ELEMENT_BUF, "snapv"}, /* snap verte */
- {0, /* null-terminating sentinel */}},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
+ {BMO_OP_SLOT_ELEMENT_BUF, "snapv"}, /* snap vertex */
+ {0},
+ },
+ {{0}}, /* no output */
bmo_pointmerge_facedata_exec,
0,
};
@@ -330,8 +372,11 @@ static BMOpDefine bmo_pointmerge_facedata_def = {
*/
static BMOpDefine bmo_average_vert_facedata_def = {
"average_vert_facedata",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_average_vert_facedata_exec,
0,
};
@@ -343,9 +388,12 @@ static BMOpDefine bmo_average_vert_facedata_def = {
*/
static BMOpDefine bmo_pointmerge_def = {
"pointmerge",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */
{BMO_OP_SLOT_VEC, "merge_co"},
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_pointmerge_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -357,8 +405,11 @@ static BMOpDefine bmo_pointmerge_def = {
*/
static BMOpDefine bmo_collapse_uvs_def = {
"collapse_uvs",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_collapse_uvs_exec,
0,
};
@@ -372,8 +423,11 @@ static BMOpDefine bmo_collapse_uvs_def = {
*/
static BMOpDefine bmo_weld_verts_def = {
"weld_verts",
+ /* slots_in */
{{BMO_OP_SLOT_MAPPING, "targetmap"}, /* maps welded vertices to verts they should weld to */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_weld_verts_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -386,9 +440,14 @@ static BMOpDefine bmo_weld_verts_def = {
*/
static BMOpDefine bmo_create_vert_def = {
"create_vert",
+ /* slots_in */
{{BMO_OP_SLOT_VEC, "co"}, /* the coordinate of the new vert */
- {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, /* the new vert */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "vert.out"}, /* the new vert */
+ {0},
+ },
bmo_create_vert_exec,
0,
};
@@ -401,14 +460,19 @@ static BMOpDefine bmo_create_vert_def = {
*/
static BMOpDefine bmo_join_triangles_def = {
"join_triangles",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input geometry. */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* joined faces */
{BMO_OP_SLOT_BOOL, "cmp_sharp"},
{BMO_OP_SLOT_BOOL, "cmp_uvs"},
{BMO_OP_SLOT_BOOL, "cmp_vcols"},
{BMO_OP_SLOT_BOOL, "cmp_materials"},
{BMO_OP_SLOT_FLT, "limit"},
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* joined faces */
+ {0},
+ },
bmo_join_triangles_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -426,13 +490,18 @@ static BMOpDefine bmo_join_triangles_def = {
*/
static BMOpDefine bmo_contextual_create_def = {
"contextual_create",
- {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* newly-made face(s) */
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry. */
+ {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
+ {BMO_OP_SLOT_BOOL, "use_smooth"}, /* smooth to use */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* newly-made face(s) */
/* note, this is for stand-alone edges only, not edges which are apart of newly created faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly-made edge(s) */
- {BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
- {BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */
- {0, /* null-terminating sentinel */}},
+ {BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* newly-made edge(s) */
+ {0},
+ },
bmo_contextual_create_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -442,27 +511,37 @@ static BMOpDefine bmo_contextual_create_def = {
*/
static BMOpDefine bmo_bridge_loops_def = {
"bridge_loops",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */
{BMO_OP_SLOT_BOOL, "use_merge"},
{BMO_OP_SLOT_FLT, "merge_factor"},
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* new faces */
+ {0},
+ },
bmo_bridge_loops_exec,
0,
};
static BMOpDefine bmo_edgenet_fill_def = {
"edgenet_fill",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edge */
{BMO_OP_SLOT_MAPPING, "restrict"}, /* restricts edges to groups. maps edges to integer */
{BMO_OP_SLOT_BOOL, "use_restrict"},
{BMO_OP_SLOT_BOOL, "use_fill_check"},
- {BMO_OP_SLOT_ELEMENT_BUF, "excludefaces"}, /* list of faces to ignore for manifold check */
- {BMO_OP_SLOT_MAPPING, "faceout_groupmap"}, /* maps new faces to the group numbers they came fro */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* new face */
+ {BMO_OP_SLOT_ELEMENT_BUF, "exclude_faces"}, /* list of faces to ignore for manifold check */
{BMO_OP_SLOT_INT, "mat_nr"}, /* material to use */
{BMO_OP_SLOT_BOOL, "use_smooth"}, /* material to use */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_MAPPING, "face_groupmap.out"}, /* maps new faces to the group numbers they came from */
+ {BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* new face */
+ {0},
+ },
bmo_edgenet_fill_exec,
0,
};
@@ -479,9 +558,14 @@ static BMOpDefine bmo_edgenet_fill_def = {
*/
static BMOpDefine bmo_edgenet_prepare_def = {
"edgenet_prepare",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* new edges */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* new edges */
+ {0},
+ },
bmo_edgenet_prepare,
0,
};
@@ -494,10 +578,13 @@ static BMOpDefine bmo_edgenet_prepare_def = {
*/
static BMOpDefine bmo_rotate_def = {
"rotate",
+ /* slots_in */
{{BMO_OP_SLOT_VEC, "cent"}, /* center of rotation */
{BMO_OP_SLOT_MAT, "mat"}, /* matrix defining rotation */
{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_rotate_exec,
0,
};
@@ -510,9 +597,12 @@ static BMOpDefine bmo_rotate_def = {
*/
static BMOpDefine bmo_translate_def = {
"translate",
+ /* slots_in */
{{BMO_OP_SLOT_VEC, "vec"}, /* translation offset */
{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_translate_exec,
0,
};
@@ -524,9 +614,12 @@ static BMOpDefine bmo_translate_def = {
*/
static BMOpDefine bmo_scale_def = {
"scale",
+ /* slots_in */
{{BMO_OP_SLOT_VEC, "vec"}, /* scale factor */
{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_scale_exec,
0,
};
@@ -540,9 +633,12 @@ static BMOpDefine bmo_scale_def = {
*/
static BMOpDefine bmo_transform_def = {
"transform",
+ /* slots_in */
{{BMO_OP_SLOT_MAT, "mat"}, /* transform matrix */
{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_transform_exec,
0,
};
@@ -555,9 +651,12 @@ static BMOpDefine bmo_transform_def = {
*/
static BMOpDefine bmo_object_load_bmesh_def = {
"object_load_bmesh",
+ /* slots_in */
{{BMO_OP_SLOT_PTR, "scene"},
{BMO_OP_SLOT_PTR, "object"},
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_object_load_bmesh_exec,
0,
};
@@ -570,10 +669,13 @@ static BMOpDefine bmo_object_load_bmesh_def = {
*/
static BMOpDefine bmo_bmesh_to_mesh_def = {
"bmesh_to_mesh",
+ /* slots_in */
{{BMO_OP_SLOT_PTR, "mesh"}, /* pointer to a mesh structure to fill in */
{BMO_OP_SLOT_PTR, "object"}, /* pointer to an object structure */
- {BMO_OP_SLOT_BOOL, "notessellation"}, /* don't calculate mfaces */
- {0, /* null-terminating sentinel */}},
+ {BMO_OP_SLOT_BOOL, "skip_tessface"}, /* don't calculate mfaces */
+ {0},
+ },
+ {{0}}, /* no output */
bmo_bmesh_to_mesh_exec,
0,
};
@@ -586,10 +688,13 @@ static BMOpDefine bmo_bmesh_to_mesh_def = {
*/
static BMOpDefine bmo_mesh_to_bmesh_def = {
"mesh_to_bmesh",
+ /* slots_in */
{{BMO_OP_SLOT_PTR, "mesh"}, /* pointer to a Mesh structure */
{BMO_OP_SLOT_PTR, "object"}, /* pointer to an Object structure */
- {BMO_OP_SLOT_BOOL, "set_shapekey"}, /* load active shapekey coordinates into verts */
- {0, /* null-terminating sentinel */}},
+ {BMO_OP_SLOT_BOOL, "use_shapekey"}, /* load active shapekey coordinates into verts */
+ {0},
+ },
+ {{0}}, /* no output */
bmo_mesh_to_bmesh_exec,
0
};
@@ -601,10 +706,15 @@ static BMOpDefine bmo_mesh_to_bmesh_def = {
*/
static BMOpDefine bmo_extrude_discrete_faces_def = {
"extrude_discrete_faces",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, /* output skirt geometry, faces and edges */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom_skirt.out"}, /* output skirt geometry, faces and edges */
+ {0},
+ },
bmo_extrude_discrete_faces_exec,
0
};
@@ -617,9 +727,14 @@ static BMOpDefine bmo_extrude_discrete_faces_def = {
*/
static BMOpDefine bmo_extrude_edge_only_def = {
"extrude_edge_only",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input vertices */
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output geometry */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* output geometry */
+ {0},
+ },
bmo_extrude_edge_only_exec,
0
};
@@ -631,125 +746,171 @@ static BMOpDefine bmo_extrude_edge_only_def = {
*/
static BMOpDefine bmo_extrude_vert_indiv_def = {
"extrude_vert_indiv",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output wire edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* output wire edges */
+ {BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output vertices */
+ {0},
+ },
bmo_extrude_vert_indiv_exec,
0
};
static BMOpDefine bmo_connect_verts_def = {
"connect_verts",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"},
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"},
+ {0},
+ },
bmo_connect_verts_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_extrude_face_region_def = {
"extrude_face_region",
- {{BMO_OP_SLOT_ELEMENT_BUF, "edgefacein"},
- {BMO_OP_SLOT_MAPPING, "exclude"},
- {BMO_OP_SLOT_BOOL, "alwayskeeporig"},
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* edges and faces */
+ {BMO_OP_SLOT_MAPPING, "edges_exclude"},
+ {BMO_OP_SLOT_BOOL, "use_keep_orig"}, /* keep original geometry */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"},
+ {0},
+ },
bmo_extrude_face_region_exec,
0
};
static BMOpDefine bmo_dissolve_verts_def = {
"dissolve_verts",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_dissolve_verts_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_dissolve_edges_def = {
"dissolve_edges",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
- {BMO_OP_SLOT_ELEMENT_BUF, "regionout"},
{BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "region.out"},
+ {0},
+ },
bmo_dissolve_edges_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_dissolve_edge_loop_def = {
"dissolve_edge_loop",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
- {BMO_OP_SLOT_ELEMENT_BUF, "regionout"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "region.out"},
+ {0},
+ },
bmo_dissolve_edgeloop_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_dissolve_faces_def = {
"dissolve_faces",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"},
- {BMO_OP_SLOT_ELEMENT_BUF, "regionout"},
{BMO_OP_SLOT_BOOL, "use_verts"}, /* dissolve verts left between only 2 edges. */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "region.out"},
+ {0},
+ },
bmo_dissolve_faces_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_dissolve_limit_def = {
"dissolve_limit",
+ /* slots_in */
{{BMO_OP_SLOT_FLT, "angle_limit"}, /* total rotation angle (degrees) */
{BMO_OP_SLOT_BOOL, "use_dissolve_boundaries"},
{BMO_OP_SLOT_ELEMENT_BUF, "verts"},
{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_dissolve_limit_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_triangulate_def = {
"triangulate",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"},
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"},
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"},
- {BMO_OP_SLOT_MAPPING, "facemap"},
{BMO_OP_SLOT_BOOL, "use_beauty"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "faces.out"},
+ {BMO_OP_SLOT_MAPPING, "facemap.out"},
+ {0},
+ },
bmo_triangulate_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_unsubdivide_def = {
"unsubdivide",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
{BMO_OP_SLOT_INT, "iterations"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_unsubdivide_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
static BMOpDefine bmo_subdivide_edges_def = {
"subdivide_edges",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
{BMO_OP_SLOT_FLT, "smooth"},
{BMO_OP_SLOT_FLT, "fractal"},
{BMO_OP_SLOT_FLT, "along_normal"},
- {BMO_OP_SLOT_INT, "numcuts"},
+ {BMO_OP_SLOT_INT, "cuts"},
{BMO_OP_SLOT_INT, "seed"},
{BMO_OP_SLOT_MAPPING, "custompatterns"},
{BMO_OP_SLOT_MAPPING, "edgepercents"},
- /* these next three can have multiple types of elements in them */
- {BMO_OP_SLOT_ELEMENT_BUF, "outinner"},
- {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"},
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* contains all output geometr */
-
- {BMO_OP_SLOT_INT, "quadcornertype"}, /* quad corner type, see bmesh_operators.h */
+ {BMO_OP_SLOT_INT, "quad_corner_type"}, /* quad corner type, see bmesh_operators.h */
{BMO_OP_SLOT_BOOL, "use_gridfill"}, /* fill in fully-selected faces with a grid */
{BMO_OP_SLOT_BOOL, "use_singleedge"}, /* tessellate the case of one edge selected in a quad or triangle */
{BMO_OP_SLOT_BOOL, "use_sphere"}, /* for making new primitives only */
-
- {0} /* null-terminating sentinel */,
+ {0},
+ },
+ /* slots_out */
+ {/* these next three can have multiple types of elements in them */
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom_inner.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom_split.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* contains all output geometr */
+ {0},
},
bmo_subdivide_edges_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
@@ -757,38 +918,51 @@ static BMOpDefine bmo_subdivide_edges_def = {
static BMOpDefine bmo_delete_def = {
"delete",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"},
{BMO_OP_SLOT_INT, "context"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ {{0}}, /* no output */
bmo_delete_exec,
0
};
static BMOpDefine bmo_duplicate_def = {
"duplicate",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"},
- {BMO_OP_SLOT_ELEMENT_BUF, "origout"},
- {BMO_OP_SLOT_ELEMENT_BUF, "newout"},
+ {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom_orig.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom.out"},
/* facemap maps from source faces to dupe
* faces, and from dupe faces to source faces */
- {BMO_OP_SLOT_MAPPING, "facemap"},
- {BMO_OP_SLOT_MAPPING, "boundarymap"},
- {BMO_OP_SLOT_MAPPING, "isovertmap"},
- {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */
- {0} /* null-terminating sentinel */},
+ {BMO_OP_SLOT_MAPPING, "facemap.out"},
+ {BMO_OP_SLOT_MAPPING, "boundarymap.out"},
+ {BMO_OP_SLOT_MAPPING, "isovertmap.out"},
+ {0},
+ },
bmo_duplicate_exec,
0
};
static BMOpDefine bmo_split_def = {
"split",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"},
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},
- {BMO_OP_SLOT_MAPPING, "boundarymap"},
- {BMO_OP_SLOT_MAPPING, "isovertmap"},
- {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */
- {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */
- {0} /* null-terminating sentinel */},
+ {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current one */
+ {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"},
+ {BMO_OP_SLOT_MAPPING, "boundarymap.out"},
+ {BMO_OP_SLOT_MAPPING, "isovertmap.out"},
+ {0},
+ },
bmo_split_exec,
0
};
@@ -801,15 +975,20 @@ static BMOpDefine bmo_split_def = {
*/
static BMOpDefine bmo_spin_def = {
"spin",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"},
- {BMO_OP_SLOT_ELEMENT_BUF, "lastout"}, /* result of last step */
- {BMO_OP_SLOT_VEC, "cent"}, /* rotation center */
- {BMO_OP_SLOT_VEC, "axis"}, /* rotation axis */
- {BMO_OP_SLOT_VEC, "dvec"}, /* translation delta per step */
- {BMO_OP_SLOT_FLT, "ang"}, /* total rotation angle (degrees) */
- {BMO_OP_SLOT_INT, "steps"}, /* number of steps */
- {BMO_OP_SLOT_BOOL, "do_dupli"}, /* duplicate or extrude? */
- {0} /* null-terminating sentinel */},
+ {BMO_OP_SLOT_VEC, "cent"}, /* rotation center */
+ {BMO_OP_SLOT_VEC, "axis"}, /* rotation axis */
+ {BMO_OP_SLOT_VEC, "dvec"}, /* translation delta per step */
+ {BMO_OP_SLOT_FLT, "angle"}, /* total rotation angle (degrees) */
+ {BMO_OP_SLOT_INT, "steps"}, /* number of steps */
+ {BMO_OP_SLOT_BOOL, "use_duplicate"}, /* duplicate or extrude? */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom_last.out"}, /* result of last step */
+ {0},
+ },
bmo_spin_exec,
0
};
@@ -822,12 +1001,17 @@ static BMOpDefine bmo_spin_def = {
*/
static BMOpDefine bmo_similar_faces_def = {
"similar_faces",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
{BMO_OP_SLOT_INT, "type"}, /* type of selection */
{BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
{BMO_OP_SLOT_INT, "compare"}, /* comparison method */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */
+ {0},
+ },
bmo_similar_faces_exec,
0
};
@@ -839,12 +1023,17 @@ static BMOpDefine bmo_similar_faces_def = {
*/
static BMOpDefine bmo_similar_edges_def = {
"similar_edges",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */
{BMO_OP_SLOT_INT, "type"}, /* type of selection */
{BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
{BMO_OP_SLOT_INT, "compare"}, /* comparison method */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* output edges */
+ {0},
+ },
bmo_similar_edges_exec,
0
};
@@ -856,12 +1045,17 @@ static BMOpDefine bmo_similar_edges_def = {
*/
static BMOpDefine bmo_similar_verts_def = {
"similar_verts",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */
- {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */
{BMO_OP_SLOT_INT, "type"}, /* type of selection */
{BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */
{BMO_OP_SLOT_INT, "compare"}, /* comparison method */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output vertices */
+ {0},
+ },
bmo_similar_verts_exec,
0
};
@@ -872,9 +1066,13 @@ static BMOpDefine bmo_similar_verts_def = {
*/
static BMOpDefine bmo_rotate_uvs_def = {
"rotate_uvs",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_INT, "dir"}, /* direction */
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
+ {BMO_OP_SLOT_BOOL, "use_ccw"}, /* rotate counter-clockwise if true, othewise clockwise */
+ {0},
+ },
+ /* slots_out */
+ {{0}}, /* no output */
bmo_rotate_uvs_exec,
0
};
@@ -885,8 +1083,11 @@ static BMOpDefine bmo_rotate_uvs_def = {
*/
static BMOpDefine bmo_reverse_uvs_def = {
"reverse_uvs",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
+ {0},
+ },
+ {{0}}, /* no output */
bmo_reverse_uvs_exec,
0
};
@@ -897,9 +1098,12 @@ static BMOpDefine bmo_reverse_uvs_def = {
*/
static BMOpDefine bmo_rotate_colors_def = {
"rotate_colors",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_INT, "dir"}, /* direction */
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
+ {BMO_OP_SLOT_BOOL, "use_ccw"}, /* rotate counter-clockwise if true, othewise clockwise */
+ {0},
+ },
+ {{0}}, /* no output */
bmo_rotate_colors_exec,
0
};
@@ -910,8 +1114,11 @@ static BMOpDefine bmo_rotate_colors_def = {
*/
static BMOpDefine bmo_reverse_colors_def = {
"reverse_colors",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
+ {0},
+ },
+ {{0}}, /* no output */
bmo_reverse_colors_exec,
0
};
@@ -923,11 +1130,16 @@ static BMOpDefine bmo_reverse_colors_def = {
*/
static BMOpDefine bmo_shortest_path_def = {
"shortest_path",
- {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */
- {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */
- {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */
- {BMO_OP_SLOT_INT, "type"}, /* type of selection */
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */
+ {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */
+ {BMO_OP_SLOT_INT, "type"}, /* type of selection */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output vertices */
+ {0},
+ },
bmo_shortest_path_exec,
0
};
@@ -939,12 +1151,17 @@ static BMOpDefine bmo_shortest_path_def = {
*/
static BMOpDefine bmo_split_edges_def = {
"split_edges",
- {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* old output disconnected edges */
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
/* needed for vertex rip so we can rip only half an edge at a boundary wich would otherwise split off */
- {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */
+ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */
{BMO_OP_SLOT_BOOL, "use_verts"}, /* use 'verts' for splitting, else just find verts to split from edges */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges.out"}, /* old output disconnected edges */
+ {0},
+ },
bmo_split_edges_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
@@ -956,12 +1173,17 @@ static BMOpDefine bmo_split_edges_def = {
*/
static BMOpDefine bmo_create_grid_def = {
"create_grid",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_INT, "xsegments"}, /* number of x segments */
- {BMO_OP_SLOT_INT, "ysegments"}, /* number of y segments */
- {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
- {0, /* null-terminating sentinel */}},
+ /* slots_in */
+ {{BMO_OP_SLOT_INT, "x_segments"}, /* number of x segments */
+ {BMO_OP_SLOT_INT, "y_segments"}, /* number of y segments */
+ {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */
+ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_grid_exec,
0,
};
@@ -973,12 +1195,17 @@ static BMOpDefine bmo_create_grid_def = {
*/
static BMOpDefine bmo_create_uvsphere_def = {
"create_uvsphere",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_INT, "segments"}, /* number of u segments */
- {BMO_OP_SLOT_INT, "revolutions"}, /* number of v segment */
+ /* slots_in */
+ {{BMO_OP_SLOT_INT, "u_segments"}, /* number of u segments */
+ {BMO_OP_SLOT_INT, "v_segments"}, /* number of v segment */
{BMO_OP_SLOT_FLT, "diameter"}, /* diameter */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */
- {0, /* null-terminating sentinel */}},
+ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_uvsphere_exec,
0,
};
@@ -990,11 +1217,16 @@ static BMOpDefine bmo_create_uvsphere_def = {
*/
static BMOpDefine bmo_create_icosphere_def = {
"create_icosphere",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */
+ /* slots_in */
+ {{BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */
{BMO_OP_SLOT_FLT, "diameter"}, /* diameter */
{BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
- {0, /* null-terminating sentinel */}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_icosphere_exec,
0,
};
@@ -1006,9 +1238,14 @@ static BMOpDefine bmo_create_icosphere_def = {
*/
static BMOpDefine bmo_create_monkey_def = {
"create_monkey",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */
- {0, /* null-terminating sentinel */}},
+ /* slots_in */
+ {{BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_monkey_exec,
0,
};
@@ -1020,15 +1257,20 @@ static BMOpDefine bmo_create_monkey_def = {
*/
static BMOpDefine bmo_create_cone_def = {
"create_cone",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */
- {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */
+ /* slots_in */
+ {{BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */
+ {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */
{BMO_OP_SLOT_INT, "segments"},
- {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */
- {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */
- {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */
- {0, /* null-terminating sentinel */}},
+ {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */
+ {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */
+ {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */
+ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_cone_exec,
0,
};
@@ -1038,13 +1280,18 @@ static BMOpDefine bmo_create_cone_def = {
*/
static BMOpDefine bmo_create_circle_def = {
"create_circle",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */
- {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */
+ /* slots_in */
+ {{BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */
+ {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */
{BMO_OP_SLOT_INT, "segments"},
- {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */
- {0, /* null-terminating sentinel */}},
+ {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */
+ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_circle_exec,
0,
};
@@ -1056,15 +1303,19 @@ static BMOpDefine bmo_create_circle_def = {
*/
static BMOpDefine bmo_create_cube_def = {
"create_cube",
- {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */
- {BMO_OP_SLOT_FLT, "size"}, /* size of the cube */
- {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */
- {0, /* null-terminating sentinel */}},
+ /* slots_in */
+ {{BMO_OP_SLOT_FLT, "size"}, /* size of the cube */
+ {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"}, /* output verts */
+ {0},
+ },
bmo_create_cube_exec,
0,
};
-#define NEW_BEVEL 1
/*
* Bevel
*
@@ -1072,12 +1323,17 @@ static BMOpDefine bmo_create_cube_def = {
*/
static BMOpDefine bmo_bevel_def = {
"bevel",
-#ifdef NEW_BEVEL
- {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */
- {BMO_OP_SLOT_FLT, "offset"}, /* amount to offset beveled edge */
- {BMO_OP_SLOT_INT, "segments"}, /* number of segments in bevel */
- {0} /* null-terminating sentinel */},
-#else
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */
+ {BMO_OP_SLOT_FLT, "offset"}, /* amount to offset beveled edge */
+ {BMO_OP_SLOT_INT, "segments"}, /* number of segments in bevel */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */
+ {0},
+ },
+#if 0 /* old bevel*/
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */
{BMO_OP_SLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */
{BMO_OP_SLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */
@@ -1087,7 +1343,8 @@ static BMOpDefine bmo_bevel_def = {
* modifier uses this. We could do this as another float setting */
{BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */
{BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand beveled edge */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
#endif
bmo_bevel_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
@@ -1100,10 +1357,15 @@ static BMOpDefine bmo_bevel_def = {
*/
static BMOpDefine bmo_beautify_fill_def = {
"beautify_fill",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
{BMO_OP_SLOT_ELEMENT_BUF, "constrain_edges"}, /* edges that can't be flipped */
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new flipped faces and edges */
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* new flipped faces and edges */
+ {0},
+ },
bmo_beautify_fill_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
@@ -1115,9 +1377,14 @@ static BMOpDefine bmo_beautify_fill_def = {
*/
static BMOpDefine bmo_triangle_fill_def = {
"triangle_fill",
- {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* new faces and edges */
- {0} /* null-terminating sentinel */},
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"}, /* new faces and edges */
+ {0},
+ },
bmo_triangle_fill_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
@@ -1129,10 +1396,15 @@ static BMOpDefine bmo_triangle_fill_def = {
*/
static BMOpDefine bmo_solidify_def = {
"solidify",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "geom"},
{BMO_OP_SLOT_FLT, "thickness"},
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},
- {0}},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"},
+ {0},
+ },
bmo_solidify_face_region_exec,
0
};
@@ -1144,15 +1416,20 @@ static BMOpDefine bmo_solidify_def = {
*/
static BMOpDefine bmo_inset_def = {
"inset",
- {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
+ /* slots_in */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
{BMO_OP_SLOT_BOOL, "use_boundary"},
{BMO_OP_SLOT_BOOL, "use_even_offset"},
{BMO_OP_SLOT_BOOL, "use_relative_offset"},
{BMO_OP_SLOT_FLT, "thickness"},
{BMO_OP_SLOT_FLT, "depth"},
{BMO_OP_SLOT_BOOL, "use_outset"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */
+ {0},
+ },
bmo_inset_exec,
0
};
@@ -1164,15 +1441,20 @@ static BMOpDefine bmo_inset_def = {
*/
static BMOpDefine bmo_wireframe_def = {
"wireframe",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */
- {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */
{BMO_OP_SLOT_BOOL, "use_boundary"},
{BMO_OP_SLOT_BOOL, "use_even_offset"},
{BMO_OP_SLOT_BOOL, "use_crease"},
{BMO_OP_SLOT_FLT, "thickness"},
{BMO_OP_SLOT_BOOL, "use_relative_offset"},
{BMO_OP_SLOT_FLT, "depth"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "faces.out"}, /* output faces */
+ {0},
+ },
bmo_wireframe_exec,
0
};
@@ -1184,11 +1466,16 @@ static BMOpDefine bmo_wireframe_def = {
*/
static BMOpDefine bmo_slide_vert_def = {
"slide_vert",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "vert"},
{BMO_OP_SLOT_ELEMENT_BUF, "edge"},
- {BMO_OP_SLOT_ELEMENT_BUF, "vertout"},
{BMO_OP_SLOT_FLT, "distance_t"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "verts.out"},
+ {0},
+ },
bmo_slide_vert_exec,
BMO_OP_FLAG_UNTAN_MULTIRES
};
@@ -1202,7 +1489,7 @@ static BMOpDefine bmo_slide_vert_def = {
* If 'use_existing_faces' is true, the hull will not output triangles
* that are covered by a pre-existing face.
*
- * All hull vertices, faces, and edges are added to 'geomout'. Any
+ * All hull vertices, faces, and edges are added to 'geom.out'. Any
* input elements that end up inside the hull (i.e. are not used by an
* output face) are added to the 'interior_geom' slot. The
* 'unused_geom' slot will contain all interior geometry that is
@@ -1211,15 +1498,18 @@ static BMOpDefine bmo_slide_vert_def = {
*/
static BMOpDefine bmo_convex_hull_def = {
"convex_hull",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "input"},
{BMO_OP_SLOT_BOOL, "use_existing_faces"},
-
- /* Outputs */
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},
- {BMO_OP_SLOT_ELEMENT_BUF, "interior_geom"},
- {BMO_OP_SLOT_ELEMENT_BUF, "unused_geom"},
- {BMO_OP_SLOT_ELEMENT_BUF, "holes_geom"},
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom_interior.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom_unused.out"},
+ {BMO_OP_SLOT_ELEMENT_BUF, "geom_holes.out"},
+ {0},
+ },
bmo_convex_hull_exec,
0
};
@@ -1233,17 +1523,19 @@ static BMOpDefine bmo_convex_hull_def = {
* the "direction" slot. The edges and faces that cross the plane of
* symmetry are split as needed to enforce symmetry.
*
- * All new vertices, edges, and faces are added to the "geomout" slot.
+ * All new vertices, edges, and faces are added to the "geom.out" slot.
*/
static BMOpDefine bmo_symmetrize_def = {
"symmetrize",
+ /* slots_in */
{{BMO_OP_SLOT_ELEMENT_BUF, "input"},
{BMO_OP_SLOT_INT, "direction"},
-
- /* Outputs */
- {BMO_OP_SLOT_ELEMENT_BUF, "geomout"},
-
- {0} /* null-terminating sentinel */},
+ {0},
+ },
+ /* slots_out */
+ {{BMO_OP_SLOT_ELEMENT_BUF, "geom.out"},
+ {0},
+ },
bmo_symmetrize_exec,
0
};
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 671cfbbc55e..b87e023e63a 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -116,30 +116,45 @@ enum {
* for when your defining an operator with BMOpDefine.*/
typedef struct BMOpSlot {
+ const char *slot_name; /* pointer to BMOpDefine.slot_args */
int slot_type;
int len;
- int flag;
- int index; /* index within slot array */
+// int flag; /* UNUSED */
+// int index; /* index within slot array */ /* UNUSED */
union {
int i;
float f;
void *p;
float vec[3];
- void *buf;
+ void **buf;
GHash *ghash;
} data;
} BMOpSlot;
-#define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */
+/* mainly for use outside bmesh internal code */
+#define BMO_SLOT_AS_BOOL(slot) ((slot)->data.i)
+#define BMO_SLOT_AS_INT(slot) ((slot)->data.i)
+#define BMO_SLOT_AS_FLOAT(slot) ((slot)->data.f)
+#define BMO_SLOT_AS_VECTOR(slot) ((slot)->data.vec)
+#define BMO_SLOT_AS_MATRIX(slot ) ((float (*)[4])((slot)->data.p))
+#define BMO_SLOT_AS_BUFFER(slot ) ((slot)->data.buf)
+#define BMO_SLOT_AS_GHASH(slot ) ((slot)->data.ghash)
+
+#define BMO_ASSERT_SLOT_IN_OP(slot, op) \
+ BLI_assert(((slot >= (op)->slots_in) && (slot < &(op)->slots_in[BMO_OP_MAX_SLOTS])) || \
+ ((slot >= (op)->slots_out) && (slot < &(op)->slots_out[BMO_OP_MAX_SLOTS])))
+
+/* way more than probably needed, compiler complains if limit hit */
+#define BMO_OP_MAX_SLOTS 16
typedef struct BMOperator {
+ struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS];
+ struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS];
+ void (*exec)(BMesh *bm, struct BMOperator *op);
+ struct MemArena *arena;
int type;
- int slot_type;
int type_flag;
int flag; /* runtime options */
- struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS];
- void (*exec)(BMesh *bm, struct BMOperator *op);
- struct MemArena *arena;
} BMOperator;
enum {
@@ -156,8 +171,9 @@ typedef struct BMOSlotType {
} BMOSlotType;
typedef struct BMOpDefine {
- const char *name;
- BMOSlotType slot_types[BMO_OP_MAX_SLOTS];
+ const char *opname;
+ BMOSlotType slot_types_in[BMO_OP_MAX_SLOTS];
+ BMOSlotType slot_types_out[BMO_OP_MAX_SLOTS];
void (*exec)(BMesh *bm, BMOperator *op);
int type_flag;
} BMOpDefine;
@@ -245,15 +261,22 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, ...
int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *fmt, va_list vlist);
/* test whether a named slot exists */
-int BMO_slot_exists(BMOperator *op, const char *slot_name);
+int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier);
/* get a pointer to a slot. this may be removed layer on from the public API. */
-BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name);
+BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier);
/* copies the data of a slot from one operator to another. src and dst are the
* source/destination slot codes, respectively. */
-void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op,
- const char *src, const char *dst);
+#define BMO_slot_copy(op_src, slots_src, slot_name_src, \
+ op_dst, slots_dst, slot_name_dst) \
+ _bmo_slot_copy((op_src)->slots_src, slot_name_src, \
+ (op_dst)->slots_dst, slot_name_dst, \
+ (op_dst)->arena)
+
+void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src,
+ BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst,
+ struct MemArena *arena_dst);
/* del "context" slot values, used for operator too */
enum {
@@ -279,13 +302,13 @@ typedef enum {
void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag);
void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag);
-void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f);
-float BMO_slot_float_get(BMOperator *op, const char *slot_name);
-void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i);
-int BMO_slot_int_get(BMOperator *op, const char *slot_name);
-void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i);
-int BMO_slot_bool_get(BMOperator *op, const char *slot_name);
-void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len);
+void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float f);
+float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i);
+int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i);
+int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len);
/* don't pass in arrays that are supposed to map to elements this way.
@@ -293,69 +316,81 @@ void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len);
* so, e.g. passing in list of floats per element in another slot is bad.
* passing in, e.g. pointer to an editmesh for the conversion operator is fine
* though. */
-void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p);
-void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name);
-void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]);
-void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]);
+void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *p);
+void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float vec[3]);
+void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_vec[3]);
/* only supports square mats */
/* size must be 3 or 4; this api is meant only for transformation matrices.
* note that internally the matrix is stored in 4x4 form, and it's safe to
* call whichever BMO_Get_MatXXX function you want. */
-void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size);
-void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]);
-void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]);
+void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size);
+void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4]);
+void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[3][3]);
void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, const short oflag);
/* copies the values from another slot to the end of the output slot */
-void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot,
- BMOperator *other_op, const char *other_op_slot);
+#define BMO_slot_buffer_append(op_src, slots_src, slot_name_src, \
+ op_dst, slots_dst, slot_name_dst) \
+ _bmo_slot_buffer_append((op_src)->slots_src, slot_name_src, \
+ (op_dst)->slots_dst, slot_name_dst, \
+ (op_dst)->arena)
+void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst,
+ BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src,
+ struct MemArena *arena_dst);
/* puts every element of type 'type' (which is a bitmask) with tool
* flag 'flag', into a slot. */
-void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag);
/* puts every element of type 'type' (which is a bitmask) without tool
* flag 'flag', into a slot. */
-void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag);
/* tool-flags all elements inside an element slot array with flag flag. */
-void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_flag_enable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag);
/* clears tool-flag flag from all elements inside a slot array. */
-void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_flag_disable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag);
/* tool-flags all elements inside an element slot array with flag flag. */
-void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_hflag_enable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag, const char do_flush);
/* clears tool-flag flag from all elements inside a slot array. */
-void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_hflag_disable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag, const char do_flush);
/* puts every element of type 'type' (which is a bitmask) with header
* flag 'flag', into a slot. note: ignores hidden elements
* (e.g. elements with header flag BM_ELEM_HIDDEN set).*/
void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op,
- const char *slot_name,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag);
/* puts every element of type 'type' (which is a bitmask) without
* header flag 'flag', into a slot. note: ignores hidden elements
* (e.g. elements with header flag BM_ELEM_HIDDEN set).*/
void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op,
- const char *slot_name,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag);
/* counts number of elements inside a slot array. */
-int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slot_name);
-int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name);
+int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
+int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
-void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name,
- void *element, void *data, int len);
+void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element, void *data, int len);
/* Counts the number of edges with tool flag toolflag around
*/
@@ -363,13 +398,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag);
/* flags all elements in a mapping. note that the mapping must only have
* bmesh elements in it.*/
-void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name,
- const char hflag, const short oflag);
+void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
+ const char *slot_name, const char hflag, const short oflag);
-void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len);
+void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
+ const char *slot_name, const int len);
-void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name,
- const char htype);
+void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
+ const char *slot_name, const char htype);
/* this part of the API is used to iterate over element buffer or
* mapping slots.
@@ -412,10 +448,11 @@ typedef struct BMOIter {
char restrictmask; /* bitwise '&' with BMHeader.htype */
} BMOIter;
-void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name);
+void *BMO_slot_buffer_elem_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
-void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op,
- const char *slot_name, const char restrictmask);
+void *BMO_iter_new(BMOIter *iter,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
+ const char restrictmask);
void *BMO_iter_step(BMOIter *iter);
/* returns a pointer to the key value when iterating over mappings.
@@ -428,8 +465,8 @@ void *BMO_iter_map_value_p(BMOIter *iter);
/* use this for float mappings */
float BMO_iter_map_value_f(BMOIter *iter);
-#define BMO_ITER(ele, iter, bm, op, slot_name, restrict) \
- for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = BMO_iter_step(iter))
+#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag) \
+ for (ele = BMO_iter_new(iter, slot_args, slot_name, restrict_flag); ele; ele = BMO_iter_step(iter))
/******************* Inlined Functions********************/
typedef void (*opexec)(BMesh *bm, BMOperator *op);
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index 16c2b8b0505..b405ecc1841 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -69,16 +69,16 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor
oflags[bm->stackdepth - 1].f ^= oflag;
}
-BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slot_name,
+BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot,
void *element, int val)
{
- BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(int));
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(int));
}
-BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slot_name,
+BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot,
void *element, float val)
{
- BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(float));
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(float));
}
@@ -87,62 +87,62 @@ BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char
* do NOT use these for non-operator-api-allocated memory! instead
* use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */
-BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slot_name,
- void *element, void *val)
+BLI_INLINE void BMO_slot_map_ptr_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element, void *val)
{
- BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(void *));
+ BMO_slot_map_insert(op, slot, element, &val, sizeof(void *));
}
-BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element)
+BLI_INLINE int BMO_slot_map_contains(BMOpSlot *slot, const void *element)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
/* sanity check */
- if (!slot->data.ghash) return 0;
+ if (UNLIKELY(slot->data.ghash == NULL)) {
+ return 0;
+ }
return BLI_ghash_haskey(slot->data.ghash, element);
}
-BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name,
- void *element)
+BLI_INLINE void *BMO_slot_map_data_get(BMOpSlot *slot, const void *element)
{
BMOElemMapping *mapping;
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
/* sanity check */
- if (!slot->data.ghash) return NULL;
+ if (UNLIKELY(slot->data.ghash == NULL)) {
+ return NULL;
+ }
mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
- if (!mapping) return NULL;
+ if (!mapping) {
+ return NULL;
+ }
return mapping + 1;
}
-BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slot_name,
- void *element)
+BLI_INLINE float BMO_slot_map_float_get(BMOpSlot *slot, const void *element)
{
- float *val = (float *) BMO_slot_map_data_get(bm, op, slot_name, element);
+ float *val = (float *) BMO_slot_map_data_get(slot, element);
if (val) return *val;
return 0.0f;
}
-BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slot_name,
- void *element)
+BLI_INLINE int BMO_slot_map_int_get(BMOpSlot *slot, const void *element)
{
- int *val = (int *) BMO_slot_map_data_get(bm, op, slot_name, element);
+ int *val = (int *) BMO_slot_map_data_get(slot, element);
if (val) return *val;
return 0;
}
-BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slot_name,
- void *element)
+BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element)
{
- void **val = (void **) BMO_slot_map_data_get(bm, op, slot_name, element);
+ void **val = (void **) BMO_slot_map_data_get(slot, element);
if (val) return *val;
return NULL;
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 9d1054dc042..157837a13c0 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -45,8 +45,8 @@
static void bmo_flag_layer_alloc(BMesh *bm);
static void bmo_flag_layer_free(BMesh *bm);
static void bmo_flag_layer_clear(BMesh *bm);
-static int bmo_name_to_slotcode(BMOpDefine *def, const char *name);
-static int bmo_name_to_slotcode_check(BMOpDefine *def, const char *name);
+static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier);
+static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier);
static int bmo_opname_to_opcode(const char *opname);
static const char *bmo_error_messages[] = {
@@ -80,7 +80,7 @@ const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = {
};
/* Dummy slot so there is something to return when slot name lookup fails */
-static BMOpSlot BMOpEmptySlot = {0};
+// static BMOpSlot BMOpEmptySlot = {0};
void BMO_op_flag_enable(BMesh *UNUSED(bm), BMOperator *op, const int op_flag)
{
@@ -101,6 +101,8 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op))
{
bm->stackdepth++;
+ BLI_assert(bm->totflags > 0);
+
/* add flag layer, if appropriate */
if (bm->stackdepth > 1)
bmo_flag_layer_alloc(bm);
@@ -123,6 +125,18 @@ void BMO_pop(BMesh *bm)
bm->stackdepth--;
}
+
+/* use for both slot_types_in and slot_types_out */
+static void bmo_op_slots_init(BMOSlotType *slot_types, BMOpSlot *slot_args)
+{
+ unsigned int i;
+ for (i = 0; slot_types[i].type; i++) {
+ slot_args[i].slot_name = slot_types[i].name;
+ slot_args[i].slot_type = slot_types[i].type;
+ // slot_args[i].index = i; // UNUSED
+ }
+}
+
/**
* \brief BMESH OPSTACK INIT OP
*
@@ -130,7 +144,7 @@ void BMO_pop(BMesh *bm)
*/
void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname)
{
- int i, opcode = bmo_opname_to_opcode(opname);
+ int opcode = bmo_opname_to_opcode(opname);
#ifdef DEBUG
BM_ELEM_INDEX_VALIDATE(bm, "pre bmo", opname);
@@ -148,10 +162,8 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname)
op->flag = flag;
/* initialize the operator slot types */
- for (i = 0; opdefines[opcode]->slot_types[i].type; i++) {
- op->slot_args[i].slot_type = opdefines[opcode]->slot_types[i].type;
- op->slot_args[i].index = i;
- }
+ bmo_op_slots_init(opdefines[opcode]->slot_types_in, op->slots_in);
+ bmo_op_slots_init(opdefines[opcode]->slot_types_out, op->slots_out);
/* callback */
op->exec = opdefines[opcode]->exec;
@@ -172,7 +184,9 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const int flag, const char *opname)
*/
void BMO_op_exec(BMesh *bm, BMOperator *op)
{
-
+ /* allocate tool flags on demand */
+ BM_mesh_elem_toolflags_ensure(bm);
+
BMO_push(bm, op);
if (bm->stackdepth == 2)
@@ -185,6 +199,20 @@ void BMO_op_exec(BMesh *bm, BMOperator *op)
BMO_pop(bm);
}
+static void bmo_op_slots_free(BMOSlotType *slot_types, BMOpSlot *slot_args)
+{
+ BMOpSlot *slot;
+ unsigned int i;
+ for (i = 0; slot_types[i].type; i++) {
+ slot = &slot_args[i];
+ if (slot->slot_type == BMO_OP_SLOT_MAPPING) {
+ if (slot->data.ghash) {
+ BLI_ghash_free(slot->data.ghash, NULL, NULL);
+ }
+ }
+ }
+}
+
/**
* \brief BMESH OPSTACK FINISH OP
*
@@ -192,21 +220,13 @@ void BMO_op_exec(BMesh *bm, BMOperator *op)
*/
void BMO_op_finish(BMesh *bm, BMOperator *op)
{
- BMOpSlot *slot;
- int i;
-
- for (i = 0; opdefines[op->type]->slot_types[i].type; i++) {
- slot = &op->slot_args[i];
- if (slot->slot_type == BMO_OP_SLOT_MAPPING) {
- if (slot->data.ghash)
- BLI_ghash_free(slot->data.ghash, NULL, NULL);
- }
- }
+ bmo_op_slots_free(opdefines[op->type]->slot_types_in, op->slots_in);
+ bmo_op_slots_free(opdefines[op->type]->slot_types_out, op->slots_out);
BLI_memarena_free(op->arena);
#ifdef DEBUG
- BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->name);
+ BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->opname);
#else
(void)bm;
#endif
@@ -217,9 +237,9 @@ void BMO_op_finish(BMesh *bm, BMOperator *op)
*
* \return Success if the slot if found.
*/
-int BMO_slot_exists(BMOperator *op, const char *slot_name)
+int BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
{
- int slot_code = bmo_name_to_slotcode(opdefines[op->type], slot_name);
+ int slot_code = bmo_name_to_slotcode(slot_args, identifier);
return (slot_code >= 0);
}
@@ -228,73 +248,78 @@ int BMO_slot_exists(BMOperator *op, const char *slot_name)
*
* Returns a pointer to the slot of type 'slot_code'
*/
-BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name)
+BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
{
- int slot_code = bmo_name_to_slotcode_check(opdefines[op->type], slot_name);
+ int slot_code = bmo_name_to_slotcode_check(slot_args, identifier);
- if (slot_code < 0) {
- return &BMOpEmptySlot;
+ if (UNLIKELY(slot_code < 0)) {
+ //return &BMOpEmptySlot;
+ BLI_assert(0);
+ NULL; /* better crash */
}
- return &(op->slot_args[slot_code]);
+ return &slot_args[slot_code];
}
/**
* \brief BMESH OPSTACK COPY SLOT
*
+ * define used.
* Copies data from one slot to another.
*/
-void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, const char *dst)
+void _bmo_slot_copy(BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src,
+ BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst,
+ struct MemArena *arena_dst)
{
- BMOpSlot *source_slot = BMO_slot_get(source_op, src);
- BMOpSlot *dest_slot = BMO_slot_get(dest_op, dst);
+ BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src);
+ BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst);
- if (source_slot == dest_slot)
+ if (slot_src == slot_dst)
return;
- if (source_slot->slot_type != dest_slot->slot_type) {
- /* possibly assert here? */
+ BLI_assert(slot_src->slot_type == slot_dst->slot_type);
+ if (slot_src->slot_type != slot_dst->slot_type) {
return;
}
- if (dest_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) {
+ if (slot_dst->slot_type == BMO_OP_SLOT_ELEMENT_BUF) {
/* do buffer copy */
- dest_slot->data.buf = NULL;
- dest_slot->len = source_slot->len;
- if (dest_slot->len) {
- const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slot_type] * dest_slot->len;
- dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, slot_alloc_size);
- memcpy(dest_slot->data.buf, source_slot->data.buf, slot_alloc_size);
+ slot_dst->data.buf = NULL;
+ slot_dst->len = slot_src->len;
+ if (slot_dst->len) {
+ const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type] * slot_dst->len;
+ slot_dst->data.buf = BLI_memarena_alloc(arena_dst, slot_alloc_size);
+ memcpy(slot_dst->data.buf, slot_src->data.buf, slot_alloc_size);
}
}
- else if (dest_slot->slot_type == BMO_OP_SLOT_MAPPING) {
+ else if (slot_dst->slot_type == BMO_OP_SLOT_MAPPING) {
GHashIterator it;
BMOElemMapping *srcmap, *dstmap;
/* sanity check */
- if (!source_slot->data.ghash) {
+ if (!slot_src->data.ghash) {
return;
}
- if (!dest_slot->data.ghash) {
- dest_slot->data.ghash = BLI_ghash_ptr_new("bmesh operator 2");
+ if (!slot_dst->data.ghash) {
+ slot_dst->data.ghash = BLI_ghash_ptr_new("bmesh operator 2");
}
- BLI_ghashIterator_init(&it, source_slot->data.ghash);
- for ( ; (srcmap = BLI_ghashIterator_getValue(&it));
- BLI_ghashIterator_step(&it))
+ for (BLI_ghashIterator_init(&it, slot_src->data.ghash);
+ (srcmap = BLI_ghashIterator_getValue(&it));
+ BLI_ghashIterator_step(&it))
{
- dstmap = BLI_memarena_alloc(dest_op->arena, sizeof(*dstmap) + srcmap->len);
+ dstmap = BLI_memarena_alloc(arena_dst, sizeof(*dstmap) + srcmap->len);
dstmap->element = srcmap->element;
dstmap->len = srcmap->len;
memcpy(dstmap + 1, srcmap + 1, srcmap->len);
- BLI_ghash_insert(dest_slot->data.ghash, dstmap->element, dstmap);
+ BLI_ghash_insert(slot_dst->data.ghash, dstmap->element, dstmap);
}
}
else {
- dest_slot->data = source_slot->data;
+ slot_dst->data = slot_src->data;
}
}
@@ -304,9 +329,9 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src,
* Sets the value of a slot depending on it's type
*/
-void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f)
+void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float f)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT);
if (!(slot->slot_type == BMO_OP_SLOT_FLT))
return;
@@ -314,9 +339,9 @@ void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f)
slot->data.f = f;
}
-void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i)
+void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_INT);
if (!(slot->slot_type == BMO_OP_SLOT_INT))
return;
@@ -324,9 +349,9 @@ void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i)
slot->data.i = i;
}
-void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i)
+void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int i)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL);
if (!(slot->slot_type == BMO_OP_SLOT_BOOL))
return;
@@ -335,9 +360,9 @@ void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i)
}
/* only supports square mats */
-void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size)
+void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT);
if (!(slot->slot_type == BMO_OP_SLOT_MAT))
return;
@@ -358,39 +383,39 @@ void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, i
}
}
-void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4])
+void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[4][4])
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT);
if (!(slot->slot_type == BMO_OP_SLOT_MAT))
return;
if (slot->data.p) {
- copy_m4_m4(r_mat, (float (*)[4])slot->data.p);
+ copy_m4_m4(r_mat, BMO_SLOT_AS_MATRIX(slot));
}
else {
unit_m4(r_mat);
}
}
-void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3])
+void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_mat[3][3])
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT);
if (!(slot->slot_type == BMO_OP_SLOT_MAT))
return;
if (slot->data.p) {
- copy_m3_m4(r_mat, slot->data.p);
+ copy_m3_m4(r_mat, BMO_SLOT_AS_MATRIX(slot));
}
else {
unit_m3(r_mat);
}
}
-void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p)
+void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, void *p)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR);
if (!(slot->slot_type == BMO_OP_SLOT_PTR))
return;
@@ -398,9 +423,9 @@ void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p)
slot->data.p = p;
}
-void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3])
+void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float vec[3])
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC);
if (!(slot->slot_type == BMO_OP_SLOT_VEC))
return;
@@ -409,9 +434,9 @@ void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3])
}
-float BMO_slot_float_get(BMOperator *op, const char *slot_name)
+float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT);
if (!(slot->slot_type == BMO_OP_SLOT_FLT))
return 0.0f;
@@ -419,9 +444,9 @@ float BMO_slot_float_get(BMOperator *op, const char *slot_name)
return slot->data.f;
}
-int BMO_slot_int_get(BMOperator *op, const char *slot_name)
+int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_INT);
if (!(slot->slot_type == BMO_OP_SLOT_INT))
return 0;
@@ -429,9 +454,9 @@ int BMO_slot_int_get(BMOperator *op, const char *slot_name)
return slot->data.i;
}
-int BMO_slot_bool_get(BMOperator *op, const char *slot_name)
+int BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL);
if (!(slot->slot_type == BMO_OP_SLOT_BOOL))
return 0;
@@ -440,23 +465,23 @@ int BMO_slot_bool_get(BMOperator *op, const char *slot_name)
}
/* if you want a copy of the elem buffer */
-void *BMO_slot_as_arrayN(BMOperator *op, const char *slot_name, int *len)
+void *BMO_slot_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int *len)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
void *ret;
/* could add support for mapping type */
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
- ret = MEM_mallocN(sizeof(void *) * slot->len, __func__);
- memcpy(ret, slot->data.buf, sizeof(void *) * slot->len);
+ ret = MEM_mallocN(sizeof(void **) * slot->len, __func__);
+ memcpy(ret, slot->data.buf, sizeof(void **) * slot->len);
*len = slot->len;
return ret;
}
-void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name)
+void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR);
if (!(slot->slot_type == BMO_OP_SLOT_PTR))
return NULL;
@@ -464,9 +489,9 @@ void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name)
return slot->data.p;
}
-void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3])
+void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, float r_vec[3])
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC);
if (!(slot->slot_type == BMO_OP_SLOT_VEC))
return;
@@ -542,9 +567,9 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty
}
}
-int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name)
+int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
/* check if its actually a buffer */
@@ -554,9 +579,9 @@ int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_na
return slot->len;
}
-int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name)
+int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
/* check if its actually a buffer */
@@ -569,12 +594,12 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name)
/* inserts a key/value mapping into a mapping slot. note that it copies the
* value, it doesn't store a reference to it. */
-void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name,
- void *element, void *data, int len)
+void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot,
+ const void *element, void *data, int len)
{
BMOElemMapping *mapping;
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
+ BMO_ASSERT_SLOT_IN_OP(slot, op);
mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len);
@@ -586,7 +611,7 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_nam
slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash");
}
- BLI_ghash_insert(slot->data.ghash, element, mapping);
+ BLI_ghash_insert(slot->data.ghash, (void *)element, mapping);
}
#if 0
@@ -632,11 +657,11 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd)
}
#endif
-void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag)
{
GHashIterator it;
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BMElemF *ele_f;
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
@@ -652,18 +677,22 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name,
}
}
-void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len)
+void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const int len)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
- BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
/* check if its actually a buffer */
if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
return NULL;
slot->len = len;
- if (len)
+ if (len) {
slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len);
+ }
+ else {
+ slot->data.buf = NULL;
+ }
+
return slot->data.buf;
}
@@ -672,9 +701,10 @@ void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len
*
* Copies all elements of a certain type into an operator slot.
*/
-void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, const char htype)
+void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
+ const char *slot_name, const char htype)
{
- BMOpSlot *output = BMO_slot_get(op, slot_name);
+ BMOpSlot *output = BMO_slot_get(slot_args, slot_name);
int totelement = 0, i = 0;
if (htype & BM_VERT) totelement += bm->totvert;
@@ -685,27 +715,27 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name,
BMIter iter;
BMHeader *ele;
- BMO_slot_buffer_alloc(op, slot_name, totelement);
+ BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement);
/* TODO - collapse these loops into one */
if (htype & BM_VERT) {
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
- ((BMHeader **)output->data.p)[i] = ele;
+ output->data.buf[i] = ele;
i++;
}
}
if (htype & BM_EDGE) {
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
- ((BMHeader **)output->data.p)[i] = ele;
+ output->data.buf[i] = ele;
i++;
}
}
if (htype & BM_FACE) {
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
- ((BMHeader **)output->data.p)[i] = ele;
+ output->data.buf[i] = ele;
i++;
}
}
@@ -718,11 +748,11 @@ void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name,
* Copies elements of a certain type, which have a certain header flag
* enabled/disabled into a slot for an operator.
*/
-static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slot_name,
+static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag,
const short test_for_enabled)
{
- BMOpSlot *output = BMO_slot_get(op, slot_name);
+ BMOpSlot *output = BMO_slot_get(slot_args, slot_name);
int totelement = 0, i = 0;
const int respecthide = (op->flag & BMO_FLAG_RESPECT_HIDE) != 0;
@@ -737,7 +767,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
BMIter iter;
BMElem *ele;
- BMO_slot_buffer_alloc(op, slot_name, totelement);
+ BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement);
/* TODO - collapse these loops into one */
@@ -746,7 +776,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) &&
BM_elem_flag_test_bool(ele, hflag) == test_for_enabled)
{
- ((BMElem **)output->data.p)[i] = ele;
+ output->data.buf[i] = ele;
i++;
}
}
@@ -757,7 +787,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) &&
BM_elem_flag_test_bool(ele, hflag) == test_for_enabled)
{
- ((BMElem **)output->data.p)[i] = ele;
+ output->data.buf[i] = ele;
i++;
}
}
@@ -768,7 +798,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) &&
BM_elem_flag_test_bool(ele, hflag) == test_for_enabled)
{
- ((BMElem **)output->data.p)[i] = ele;
+ output->data.buf[i] = ele;
i++;
}
}
@@ -779,46 +809,51 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
}
}
-void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag)
{
- bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, TRUE);
+ bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, TRUE);
}
-void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag)
{
- bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, FALSE);
+ bmo_slot_buffer_from_hflag(bm, op, slot_args, slot_name, htype, hflag, FALSE);
}
/**
* Copies the values from another slot to the end of the output slot.
*/
-void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name,
- BMOperator *other_op, const char *other_slot_name)
+void _bmo_slot_buffer_append(BMOpSlot slot_args_dst[BMO_OP_MAX_SLOTS], const char *slot_name_dst,
+ BMOpSlot slot_args_src[BMO_OP_MAX_SLOTS], const char *slot_name_src,
+ struct MemArena *arena_dst)
{
- BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name);
- BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name);
+ BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst);
+ BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src);
- BLI_assert(output_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF &&
- other_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
+ BLI_assert(slot_dst->slot_type == BMO_OP_SLOT_ELEMENT_BUF &&
+ slot_src->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
- if (output_slot->len == 0) {
+ if (slot_dst->len == 0) {
/* output slot is empty, copy rather than append */
- BMO_slot_copy(other_op, output_op, other_slot_name, output_slot_name);
+ _bmo_slot_copy(slot_args_src, slot_name_src,
+ slot_args_dst, slot_name_dst,
+ arena_dst);
}
- else if (other_slot->len != 0) {
- int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slot_type];
- int alloc_size = elem_size * (output_slot->len + other_slot->len);
+ else if (slot_src->len != 0) {
+ int elem_size = BMO_OPSLOT_TYPEINFO[slot_dst->slot_type];
+ int alloc_size = elem_size * (slot_dst->len + slot_src->len);
/* allocate new buffer */
- void *buf = BLI_memarena_alloc(output_op->arena, alloc_size);
+ void *buf = BLI_memarena_alloc(arena_dst, alloc_size);
/* copy slot data */
- memcpy(buf, output_slot->data.buf, elem_size * output_slot->len);
- memcpy(((char *)buf) + elem_size * output_slot->len, other_slot->data.buf, elem_size * other_slot->len);
+ memcpy(buf, slot_dst->data.buf, elem_size * slot_dst->len);
+ memcpy(((char *)buf) + elem_size * slot_dst->len, slot_src->data.buf, elem_size * slot_src->len);
- output_slot->data.buf = buf;
- output_slot->len += other_slot->len;
+ slot_dst->data.buf = buf;
+ slot_dst->len += slot_src->len;
}
}
@@ -828,13 +863,15 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name,
* Copies elements of a certain type, which have a certain flag set
* into an output slot for an operator.
*/
-static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slot_name,
+static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag,
const short test_for_enabled)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
int totelement, i = 0;
+ BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args);
BLI_assert(ELEM(TRUE, FALSE, test_for_enabled));
if (test_for_enabled)
@@ -849,9 +886,9 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo
BMHeader *ele;
BMHeader **ele_array;
- BMO_slot_buffer_alloc(op, slot_name, totelement);
+ BMO_slot_buffer_alloc(op, slot_args, slot_name, totelement);
- ele_array = (BMHeader **)slot->data.p;
+ ele_array = (BMHeader **)slot->data.buf;
/* TODO - collapse these loops into one */
@@ -887,16 +924,18 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo
}
}
-void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag)
{
- bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, TRUE);
+ bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, TRUE);
}
-void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag)
{
- bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, FALSE);
+ bmo_slot_buffer_from_flag(bm, op, slot_args, slot_name, htype, oflag, FALSE);
}
/**
@@ -905,11 +944,12 @@ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *s
* Header Flags elements in a slots buffer, automatically
* using the selection API where appropriate.
*/
-void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_hflag_enable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag, const char do_flush)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
- BMElem **data = slot->data.p;
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
+ BMElem **data = (BMElem **)slot->data.buf;
int i;
const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT));
const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN));
@@ -938,11 +978,12 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_na
* Removes flags from elements in a slots buffer, automatically
* using the selection API where appropriate.
*/
-void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_hflag_disable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const char hflag, const char do_flush)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
- BMElem **data = slot->data.p;
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
+ BMElem **data = (BMElem **)slot->data.buf;
int i;
const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT));
const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN));
@@ -989,10 +1030,11 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag)
*
* Flags elements in a slots buffer
*/
-void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_flag_enable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BMHeader **data = slot->data.p;
int i;
@@ -1011,11 +1053,12 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_nam
*
* Removes flags from elements in a slots buffer
*/
-void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name,
+void BMO_slot_buffer_flag_disable(BMesh *bm,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
const char htype, const short oflag)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
- BMHeader **data = slot->data.p;
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
+ BMHeader **data = (BMHeader **)slot->data.buf;
int i;
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
@@ -1056,7 +1099,9 @@ static void bmo_flag_layer_alloc(BMesh *bm)
/* store memcpy size for reuse */
const size_t old_totflags_size = (bm->totflags * sizeof(BMFlagLayer));
-
+
+ BLI_assert(oldpool != NULL);
+
bm->totflags++;
/* allocate new flag poo */
@@ -1068,18 +1113,21 @@ static void bmo_flag_layer_alloc(BMesh *bm)
ele->oflags = BLI_mempool_calloc(newpool);
memcpy(ele->oflags, oldflags, old_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
+ BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
}
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
memcpy(ele->oflags, oldflags, old_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
+ BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
}
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
memcpy(ele->oflags, oldflags, old_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
+ BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
}
bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE);
@@ -1113,18 +1161,21 @@ static void bmo_flag_layer_free(BMesh *bm)
ele->oflags = BLI_mempool_calloc(newpool);
memcpy(ele->oflags, oldflags, new_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
+ BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
}
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
memcpy(ele->oflags, oldflags, new_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
+ BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
}
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
oldflags = ele->oflags;
ele->oflags = BLI_mempool_calloc(newpool);
memcpy(ele->oflags, oldflags, new_totflags_size);
BM_elem_index_set(ele, i); /* set_inline */
+ BM_ELEM_API_FLAG_CLEAR((BMElemF *)ele);
}
bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE);
@@ -1159,14 +1210,14 @@ static void bmo_flag_layer_clear(BMesh *bm)
bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE);
}
-void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name)
+void *BMO_slot_buffer_elem_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF)
return NULL;
- return slot->data.buf ? *(void **)slot->data.buf : NULL;
+ return slot->data.buf ? *slot->data.buf : NULL;
}
/**
@@ -1175,10 +1226,11 @@ void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name)
* \param restrictmask restricts the iteration to certain element types
* (e.g. combination of BM_VERT, BM_EDGE, BM_FACE), if iterating
* over an element buffer (not a mapping). */
-void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op,
- const char *slot_name, const char restrictmask)
+void *BMO_iter_new(BMOIter *iter,
+ BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name,
+ const char restrictmask)
{
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
memset(iter, 0, sizeof(BMOIter));
@@ -1207,13 +1259,13 @@ void *BMO_iter_step(BMOIter *iter)
return NULL;
}
- h = ((void **)iter->slot->data.buf)[iter->cur++];
+ h = iter->slot->data.buf[iter->cur++];
while (!(iter->restrictmask & h->htype)) {
if (iter->cur >= iter->slot->len) {
return NULL;
}
- h = ((void **)iter->slot->data.buf)[iter->cur++];
+ h = iter->slot->data.buf[iter->cur++];
}
return h;
@@ -1312,24 +1364,26 @@ int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op)
#define NEXT_CHAR(fmt) ((fmt)[0] != 0 ? (fmt)[1] : 0)
-static int bmo_name_to_slotcode(BMOpDefine *def, const char *name)
+static int bmo_name_to_slotcode(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
{
- int i;
+ int i = 0;
- for (i = 0; def->slot_types[i].type; i++) {
- if (!strncmp(name, def->slot_types[i].name, MAX_SLOTNAME)) {
+ while (slot_args->slot_name) {
+ if (strncmp(identifier, slot_args->slot_name, MAX_SLOTNAME) == 0) {
return i;
}
+ slot_args++;
+ i++;
}
return -1;
}
-static int bmo_name_to_slotcode_check(BMOpDefine *def, const char *name)
+static int bmo_name_to_slotcode_check(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
{
- int i = bmo_name_to_slotcode(def, name);
+ int i = bmo_name_to_slotcode(slot_args, identifier);
if (i < 0) {
- fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, name);
+ fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, identifier);
}
return i;
@@ -1340,12 +1394,12 @@ static int bmo_opname_to_opcode(const char *opname)
int i;
for (i = 0; i < bmesh_total_ops; i++) {
- if (!strcmp(opname, opdefines[i]->name)) {
+ if (!strcmp(opname, opdefines[i]->opname)) {
return i;
}
}
- fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname);
+ fprintf(stderr, "%s: could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname);
return -1;
}
@@ -1355,6 +1409,8 @@ static int bmo_opname_to_opcode(const char *opname)
* i - int
* b - boolean (same as int but 1/0 only)
* f - float
+ * s - slot_in
+ * S - slot_out
* hv - header flagged verts (hflag)
* he - header flagged edges (hflag)
* hf - header flagged faces (hflag)
@@ -1368,7 +1424,7 @@ static int bmo_opname_to_opcode(const char *opname)
int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, va_list vlist)
{
- BMOpDefine *def;
+// BMOpDefine *def;
char *opname, *ofmt, *fmt;
char slot_name[64] = {0};
int i /*, n = strlen(fmt) */, stop /*, slot_code = -1 */, type, state;
@@ -1407,7 +1463,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v
}
BMO_op_init(bm, op, flag, opname);
- def = opdefines[i];
+// def = opdefines[i];
i = 0;
state = 1; /* 0: not inside slot_code name, 1: inside slot_code name */
@@ -1430,7 +1486,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v
fmt[i] = 0;
- if (bmo_name_to_slotcode_check(def, fmt) < 0) {
+ if (bmo_name_to_slotcode_check(op->slots_in, fmt) < 0) {
GOTO_ERROR("name to slot code check failed");
}
@@ -1456,47 +1512,57 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v
else if (c == '4') size = 4;
else GOTO_ERROR("matrix size was not 3 or 4");
- BMO_slot_mat_set(op, slot_name, va_arg(vlist, void *), size);
+ BMO_slot_mat_set(op, op->slots_in, slot_name, va_arg(vlist, void *), size);
state = 1;
break;
}
case 'v':
{
- BMO_slot_vec_set(op, slot_name, va_arg(vlist, float *));
+ BMO_slot_vec_set(op->slots_in, slot_name, va_arg(vlist, float *));
state = 1;
break;
}
case 'e':
{
BMHeader *ele = va_arg(vlist, void *);
- BMOpSlot *slot = BMO_slot_get(op, slot_name);
+ BMOpSlot *slot = BMO_slot_get(op->slots_in, slot_name);
slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4);
slot->len = 1;
- *((void **)slot->data.buf) = ele;
+ *slot->data.buf = ele;
state = 1;
break;
}
case 's':
+ case 'S':
{
- BMOperator *op2 = va_arg(vlist, void *);
- const char *slot_name2 = va_arg(vlist, char *);
+ BMOperator *op_other = va_arg(vlist, void *);
+ const char *slot_name_other = va_arg(vlist, char *);
- BMO_slot_copy(op2, op, slot_name2, slot_name);
+ if (*fmt == 's') {
+ BLI_assert(bmo_name_to_slotcode_check(op_other->slots_in, slot_name_other) != -1);
+ BMO_slot_copy(op_other, slots_in, slot_name_other,
+ op, slots_in, slot_name);
+ }
+ else {
+ BLI_assert(bmo_name_to_slotcode_check(op_other->slots_out, slot_name_other) != -1);
+ BMO_slot_copy(op_other, slots_out, slot_name_other,
+ op, slots_in, slot_name);
+ }
state = 1;
break;
}
case 'i':
- BMO_slot_int_set(op, slot_name, va_arg(vlist, int));
+ BMO_slot_int_set(op->slots_in, slot_name, va_arg(vlist, int));
state = 1;
break;
case 'b':
- BMO_slot_bool_set(op, slot_name, va_arg(vlist, int));
+ BMO_slot_bool_set(op->slots_in, slot_name, va_arg(vlist, int));
state = 1;
break;
case 'p':
- BMO_slot_ptr_set(op, slot_name, va_arg(vlist, void *));
+ BMO_slot_ptr_set(op->slots_in, slot_name, va_arg(vlist, void *));
state = 1;
break;
case 'f':
@@ -1507,7 +1573,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v
type = *fmt;
if (NEXT_CHAR(fmt) == ' ' || NEXT_CHAR(fmt) == '\0') {
- BMO_slot_float_set(op, slot_name, va_arg(vlist, double));
+ BMO_slot_float_set(op->slots_in, slot_name, va_arg(vlist, double));
}
else {
htype = 0;
@@ -1529,19 +1595,19 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, v
}
if (type == 'h') {
- BMO_slot_buffer_from_enabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int));
+ BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int));
}
else if (type == 'H') {
- BMO_slot_buffer_from_disabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int));
+ BMO_slot_buffer_from_disabled_hflag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int));
}
else if (type == 'a') {
- BMO_slot_buffer_from_all(bm, op, slot_name, htype);
+ BMO_slot_buffer_from_all(bm, op, op->slots_in, slot_name, htype);
}
else if (type == 'f') {
- BMO_slot_buffer_from_enabled_flag(bm, op, slot_name, htype, va_arg(vlist, int));
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int));
}
else if (type == 'F') {
- BMO_slot_buffer_from_disabled_flag(bm, op, slot_name, htype, va_arg(vlist, int));
+ BMO_slot_buffer_from_disabled_flag(bm, op, op->slots_in, slot_name, htype, va_arg(vlist, int));
}
}
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 14da93302b9..b74d97c9bb5 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -88,11 +88,6 @@ enum {
OPUVC_AXIS_Y
};
-enum {
- DIRECTION_CW = 1,
- DIRECTION_CCW
-};
-
/* vertex path selection values */
enum {
VPATH_SELECT_EDGE_LENGTH = 0,
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 98edceb30a2..2e0471863d4 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -162,7 +162,7 @@ float BM_face_calc_area(BMFace *f)
float area;
int i;
- BLI_array_fixedstack_declare(verts, BM_NGON_STACK_SIZE, f->len, __func__);
+ BLI_array_fixedstack_declare(verts, BM_DEFAULT_NGON_STACK_SIZE, f->len, __func__);
BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
copy_v3_v3(verts[i], l->v->co);
@@ -677,6 +677,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, floa
BMLoop *l_first;
const float cos_threshold = 0.9f;
+ const float bias = 1.0f + 1e-6f;
if (f->len == 4) {
BMLoop *larr[4];
@@ -691,7 +692,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int use_beauty, floa
/* pick 0/1 based on best lenth */
/* XXX Can't only rely on such test, also must check we do not get (too much) degenerated triangles!!! */
i = (((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) >
- len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty);
+ len_squared_v3v3(larr[1]->v->co, larr[3]->v->co) * bias)) != use_beauty);
i4 = (i + 3) % 4;
/* Check produced tris aren’t too flat/narrow...
* Probably not the best test, but is quite efficient and should at least avoid null-area faces! */
@@ -965,8 +966,8 @@ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len)
float fac1 = 1.0000001f, fac2 = 0.9f; //9999f; //0.999f;
int i, j, a = 0, clen;
- BLI_array_fixedstack_declare(projverts, BM_NGON_STACK_SIZE, f->len, "projvertsb");
- BLI_array_fixedstack_declare(edgeverts, BM_NGON_STACK_SIZE * 2, len * 2, "edgevertsb");
+ BLI_array_fixedstack_declare(projverts, BM_DEFAULT_NGON_STACK_SIZE, f->len, "projvertsb");
+ BLI_array_fixedstack_declare(edgeverts, BM_DEFAULT_NGON_STACK_SIZE * 2, len * 2, "edgevertsb");
i = 0;
l = BM_iter_new(&iter, bm, BM_LOOPS_OF_FACE, f);
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index b3fe3676ab8..850e81ba3ac 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -56,15 +56,21 @@ int bmesh_elem_check(void *element, const char htype);
int bmesh_radial_length(BMLoop *l);
int bmesh_disk_count(BMVert *v);
-/* NOTE: ensure different parts of the API do not conflict
+/**
+ * Internal BMHeader.api_flag
+ * \note Ensure different parts of the API do not conflict
* on using these internal flags!*/
-#define _FLAG_JF 1 /* join faces */
-#define _FLAG_MF 2 /* make face */
-#define _FLAG_MV 2 /* make face, vertex */
+enum {
+ _FLAG_JF = (1 << 0), /* join faces */
+ _FLAG_MF = (1 << 1), /* make face */
+ _FLAG_MV = (1 << 1), /* make face, vertex */
+ _FLAG_OVERLAP = (1 << 2) /* general overlap flag */
+};
-#define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->oflags[0].pflag |= (f))
-#define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f))
-#define BM_ELEM_API_FLAG_TEST(element, f) ((element)->oflags[0].pflag & (f))
+#define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->head.api_flag |= (f))
+#define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->head.api_flag &= ~(f))
+#define BM_ELEM_API_FLAG_TEST(element, f) ((element)->head.api_flag & (f))
+#define BM_ELEM_API_FLAG_CLEAR(element) ((element)->head.api_flag = 0)
void calc_poly_plane(float (*verts)[3], const int nverts);
void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts);
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 1e1d7d1becb..ec2e90591cc 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -39,8 +39,6 @@
#include "bmesh.h"
#include "intern/bmesh_private.h"
-#define BM_OVERLAP (1 << 13)
-
/**
* Returns whether or not a given vertex is
* is part of a given edge.
@@ -240,7 +238,7 @@ int BM_vert_in_face(BMFace *f, BMVert *v)
* Compares the number of vertices in an array
* that appear in a given face
*/
-int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len)
+int BM_verts_in_face(BMFace *f, BMVert **varr, int len)
{
BMLoop *l_iter, *l_first;
@@ -251,7 +249,7 @@ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len)
int i, count = 0;
for (i = 0; i < len; i++) {
- BMO_elem_flag_enable(bm, varr[i], BM_OVERLAP);
+ BM_ELEM_API_FLAG_ENABLE(varr[i], _FLAG_OVERLAP);
}
#ifdef USE_BMESH_HOLES
@@ -266,14 +264,16 @@ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len)
#endif
do {
- if (BMO_elem_flag_test(bm, l_iter->v, BM_OVERLAP)) {
+ if (BM_ELEM_API_FLAG_TEST(l_iter->v, _FLAG_OVERLAP)) {
count++;
}
} while ((l_iter = l_iter->next) != l_first);
}
- for (i = 0; i < len; i++) BMO_elem_flag_disable(bm, varr[i], BM_OVERLAP);
+ for (i = 0; i < len; i++) {
+ BM_ELEM_API_FLAG_DISABLE(varr[i], _FLAG_OVERLAP);
+ }
return count;
}
@@ -1217,7 +1217,7 @@ BMEdge *BM_edge_find_double(BMEdge *e)
* \returns TRUE for overlap
*
*/
-int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlapface)
+int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface)
{
BMIter viter;
BMFace *f;
@@ -1225,7 +1225,7 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap
for (i = 0; i < len; i++) {
BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
- amount = BM_verts_in_face(bm, f, varr, len);
+ amount = BM_verts_in_face(f, varr, len);
if (amount >= len) {
if (r_overlapface) {
*r_overlapface = f;
@@ -1247,7 +1247,7 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap
* there is a face with exactly those vertices
* (and only those vertices).
*/
-int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface)
+int BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
{
BMIter viter;
BMFace *f;
@@ -1255,7 +1255,7 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface)
for (i = 0; i < len; i++) {
BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
- amount = BM_verts_in_face(bm, f, varr, len);
+ amount = BM_verts_in_face(f, varr, len);
if (amount == len && amount == f->len) {
if (r_existface) {
*r_existface = f;
@@ -1393,7 +1393,7 @@ int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len)
int BM_face_exists_multi_edge(BMEdge **earr, int len)
{
BMVert **varr;
- BLI_array_fixedstack_declare(varr, BM_NGON_STACK_SIZE, len, __func__);
+ BLI_array_fixedstack_declare(varr, BM_DEFAULT_NGON_STACK_SIZE, len, __func__);
int ok;
int i, i_next;
@@ -1419,3 +1419,38 @@ int BM_face_exists_multi_edge(BMEdge **earr, int len)
return ok;
}
+
+/* convenience functions for checking flags */
+int BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag)
+{
+ return (BM_elem_flag_test(e->v1, hflag) ||
+ BM_elem_flag_test(e->v2, hflag));
+}
+
+int BM_face_is_any_vert_flag_test(BMFace *f, const char hflag)
+{
+ BMLoop *l_iter;
+ BMLoop *l_first;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ if (BM_elem_flag_test(l_iter->v, hflag)) {
+ return TRUE;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+ return FALSE;
+}
+
+int BM_face_is_any_edge_flag_test(BMFace *f, const char hflag)
+{
+ BMLoop *l_iter;
+ BMLoop *l_first;
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ if (BM_elem_flag_test(l_iter->e, hflag)) {
+ return TRUE;
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+ return FALSE;
+}
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 579a1397b0c..d97faebf021 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -28,7 +28,7 @@
*/
int BM_vert_in_face(BMFace *f, BMVert *v);
-int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len);
+int BM_verts_in_face(BMFace *f, BMVert **varr, int len);
int BM_edge_in_face(BMFace *f, BMEdge *e);
int BM_edge_in_loop(BMEdge *e, BMLoop *l);
@@ -77,9 +77,9 @@ BMLoop *BM_face_find_longest_loop(BMFace *f);
BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2);
BMEdge *BM_edge_find_double(BMEdge *e);
-int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);
+int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_existface);
-int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);
+int BM_face_exists(BMVert **varr, int len, BMFace **r_existface);
int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len);
int BM_face_exists_multi_edge(BMEdge **earr, int len);
@@ -100,4 +100,8 @@ void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2);
void BM_edge_ordered_verts_ex(BMEdge *edge, BMVert **r_v1, BMVert **r_v2,
BMLoop *edge_loop);
+int BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag);
+int BM_face_is_any_vert_flag_test(BMFace *f, const char hflag);
+int BM_face_is_any_edge_flag_test(BMFace *f, const char hflag);
+
#endif /* __BMESH_QUERIES_H__ */
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 7df5aa8fe9c..126d0f46119 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor(s): Joseph Eagar, Aleksandr Mokhov, Howard Trickey
+ * Contributor(s):
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -24,2211 +24,38 @@
* \ingroup bmesh
*/
-#include "MEM_guardedalloc.h"
-
-#include "BLI_listbase.h"
-#include "BLI_array.h"
-#include "BLI_math.h"
-#include "BLI_smallhash.h"
-
-#include "BKE_customdata.h"
+#include "BLI_utildefines.h"
#include "bmesh.h"
#include "intern/bmesh_operators_private.h" /* own include */
-#define NEW_BEVEL 1
-
-#ifdef NEW_BEVEL
-#define BEVEL_FLAG 1
-#define EDGE_SELECTED 2
-
-#define BEVEL_EPSILON 1e-6
-
-/* Constructed vertex, sometimes later instantiated as BMVert */
-typedef struct NewVert {
- float co[3];
- BMVert *v;
-} NewVert;
-
-struct BoundVert;
-
-/* Data for one end of an edge involved in a bevel */
-typedef struct EdgeHalf {
- struct EdgeHalf *next, *prev; /* in CCW order */
- BMEdge *e; /* original mesh edge */
- int isbev; /* is this edge beveled? */
- int isrev; /* is e->v2 the vertex at this end? */
- int seg; /* how many segments for the bevel */
- float offset; /* offset for this edge */
- BMFace *fprev; /* face between this edge and previous, if any */
- BMFace *fnext; /* face between this edge and next, if any */
- struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */
- struct BoundVert *rightv; /* right boundary vert, if beveled */
-} EdgeHalf;
-
-/* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
-typedef struct BoundVert {
- struct BoundVert *next, *prev; /* in CCW order */
- int index; /* used for vmesh indexing */
- NewVert nv;
- EdgeHalf *efirst; /* first of edges attached here: in CCW order */
- EdgeHalf *elast;
- EdgeHalf *ebev; /* beveled edge whose left side is attached here, if any */
-} BoundVert;
-
-/* Mesh structure replacing a vertex */
-typedef struct VMesh {
- enum {
- M_NONE, /* no polygon mesh needed */
- M_POLY, /* a simple polygon */
- M_ADJ, /* "adjacent edges" mesh pattern */
- M_CROSS, /* "cross edges" mesh pattern */
- } mesh_kind;
- int count; /* number of vertices in the boundary */
- int seg; /* common # of segments for segmented edges */
- BoundVert *boundstart; /* start of boundary double-linked list */
- NewVert *mesh; /* allocated array - size and structure depends on kind */
-} VMesh;
-
-/* Data for a vertex involved in a bevel */
-typedef struct BevVert {
- struct BevVert *next, *prev;
- BMVert *v; /* original mesh vertex */
- int edgecount; /* total number of edges around the vertex */
- int selcount; /* number of selected edges around the vertex */
- EdgeHalf *edges; /* array of size edgecount; CCW order from vertex normal side */
- VMesh *vmesh; /* mesh structure for replacing vertex */
-} BevVert;
-
-/*
- * Bevel parameters and state
- */
-typedef struct BevelParams {
- ListBase vertList; /* list of BevVert for each vertex involved in bevel */
- float offset; /* blender units to offset each side of a beveled edge */
- int seg; /* number of segments in beveled edge profile */
-
- BMOperator *op;
-} BevelParams;
-
-/* Make a new BoundVert of the given kind, insert it at the end of the circular linked
- * list with entry point bv->boundstart, and return it. */
-static BoundVert *add_new_bound_vert(VMesh *vm, float co[3])
-{
- BoundVert *ans = (BoundVert *) MEM_callocN(sizeof(BoundVert), "BoundVert");
- copy_v3_v3(ans->nv.co, co);
- if (!vm->boundstart) {
- ans->index = 0;
- vm->boundstart = ans;
- ans->next = ans->prev = ans;
- }
- else {
- BoundVert *tail = vm->boundstart->prev;
- ans->index = tail->index + 1;
- ans->prev = tail;
- ans->next = vm->boundstart;
- tail->next = ans;
- vm->boundstart->prev = ans;
- }
- vm->count++;
- return ans;
-}
-
-/* Mesh verts are indexed (i, j, k) where
- * i = boundvert index (0 <= i < nv)
- * j = ring index (0 <= j <= ns2)
- * k = segment index (0 <= k <= ns)
- * Not all of these are used, and some will share BMVerts */
-static NewVert *mesh_vert(VMesh *vm, int i, int j, int k)
-{
- int nj = (vm->seg / 2) + 1;
- int nk = vm->seg + 1;
-
- return &vm->mesh[i * nk * nj + j * nk + k];
-}
-
-static void create_mesh_bmvert(BMesh *bm, VMesh *vm, int i, int j, int k, BMVert *eg)
-{
- NewVert *nv = mesh_vert(vm, i, j, k);
- nv->v = BM_vert_create(bm, nv->co, eg);
-}
-
-static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto,
- int ifrom, int jfrom, int kfrom)
-{
- NewVert *nvto, *nvfrom;
-
- nvto = mesh_vert(vm, ito, jto, kto);
- nvfrom = mesh_vert(vm, ifrom, jfrom, kfrom);
- nvto->v = nvfrom->v;
- copy_v3_v3(nvto->co, nvfrom->co);
-}
-
-/* find the EdgeHalf in bv's array that has edge bme */
-static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
-{
- int i;
-
- for (i = 0; i < bv->edgecount; i++) {
- if (bv->edges[i].e == bme)
- return &bv->edges[i];
- }
- return NULL;
-}
-
-/* Return the next EdgeHalf after from_e that is beveled.
- * If from_e is NULL, find the first beveled edge. */
-static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
-{
- EdgeHalf *e;
-
- if (from_e == NULL)
- from_e = &bv->edges[bv->edgecount - 1];
- e = from_e;
- do {
- if (e->isbev)
- return e;
- e = e->next;
- } while (e != from_e);
- return NULL;
-}
-
-/* find the BevVert corresponding to BMVert bmv */
-static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
-{
- BevVert *bv;
-
- for (bv = bp->vertList.first; bv; bv = bv->next) {
- if (bv->v == bmv)
- return bv;
- }
- return NULL;
-}
-
-/* Return a good respresentative face (for materials, etc.) for faces
- * created around/near BoundVert v */
-static BMFace *boundvert_rep_face(BoundVert *v)
-{
- BMFace *fans = NULL;
- BMFace *firstf = NULL;
- BMEdge *e1, *e2;
- BMFace *f1, *f2;
- BMIter iter1, iter2;
-
- BLI_assert(v->efirst != NULL && v->elast != NULL);
- e1 = v->efirst->e;
- e2 = v->elast->e;
- BM_ITER_ELEM (f1, &iter1, e1, BM_FACES_OF_EDGE) {
- if (!firstf)
- firstf = f1;
- BM_ITER_ELEM (f2, &iter2, e2, BM_FACES_OF_EDGE) {
- if (f1 == f2) {
- fans = f1;
- break;
- }
- }
- }
- if (!fans)
- fans = firstf;
-
- return fans;
-}
-
-/* Make ngon from verts alone.
- * Make sure to properly copy face attributes and do custom data interpolation from
- * example face, facerep. */
-static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, int totv, BMFace *facerep)
-{
- BMIter iter;
- BMLoop *l;
- BMFace *f;
-
- if (totv == 3) {
- f = BM_face_create_quad_tri(bm,
- vert_arr[0], vert_arr[1], vert_arr[2], NULL, facerep, 0);
- }
- else if (totv == 4) {
- f = BM_face_create_quad_tri(bm,
- vert_arr[0], vert_arr[1], vert_arr[2], vert_arr[3], facerep, 0);
- }
- else {
- int i;
- BMEdge *e;
- BMEdge **ee = NULL;
- BLI_array_staticdeclare(ee, 30);
-
- for (i = 0; i < totv; i++) {
- e = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, TRUE);
- BLI_array_append(ee, e);
- }
- f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, FALSE);
- BLI_array_free(ee);
- }
- if (facerep && f) {
- int has_mdisps = CustomData_has_layer(&bm->ldata, CD_MDISPS);
- BM_elem_attrs_copy(bm, bm, facerep, f);
- BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
- BM_loop_interp_from_face(bm, l, facerep, TRUE, TRUE);
- if (has_mdisps)
- BM_loop_interp_multires(bm, l, facerep);
- }
- }
- return f;
-}
-
-static BMFace *bev_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
- BMFace *facerep)
-{
- BMVert *varr[4];
-
- varr[0] = v1;
- varr[1] = v2;
- varr[2] = v3;
- varr[3] = v4;
- return bev_create_ngon(bm, varr, v4 ? 4 : 3, facerep);
-}
-
-/*
- * Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
- * e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
- * the bevel vertex, e1 precedes e2 in CCW order.
- * If on_right is true, offset edge is on right of both edges, where e1 enters v and
- * e2 leave it. If on_right is false, then the offset edge is on the left.
- * When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2),
- * but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
- * lead to different offsets) then meeting point can be found be intersecting offset lines.
- */
-static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
- int on_right, float meetco[3])
-{
- float dir1[3], dir2[3], norm_v[3], norm_perp1[3], norm_perp2[3],
- off1a[3], off1b[3], off2a[3], off2b[3], isect2[3];
-
- /* get direction vectors for two offset lines */
- sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
- sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
-
- /* get normal to plane where meet point should be */
- cross_v3_v3v3(norm_v, dir2, dir1);
- normalize_v3(norm_v);
- if (!on_right)
- negate_v3(norm_v);
- if (is_zero_v3(norm_v)) {
- /* special case: e1 and e2 are parallel; put offset point perp to both, from v.
- * need to find a suitable plane.
- * if offsets are different, we're out of luck: just use e1->offset */
- if (f)
- copy_v3_v3(norm_v, f->no);
- else
- copy_v3_v3(norm_v, v->no);
- cross_v3_v3v3(norm_perp1, dir1, norm_v);
- normalize_v3(norm_perp1);
- copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset);
- copy_v3_v3(meetco, off1a);
- }
- else {
- /* get vectors perp to each edge, perp to norm_v, and pointing into face */
- if (f) {
- copy_v3_v3(norm_v, f->no);
- normalize_v3(norm_v);
- }
- cross_v3_v3v3(norm_perp1, dir1, norm_v);
- cross_v3_v3v3(norm_perp2, dir2, norm_v);
- normalize_v3(norm_perp1);
- normalize_v3(norm_perp2);
-
- /* get points that are offset distances from each line, then another point on each line */
- copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset);
- add_v3_v3v3(off1b, off1a, dir1);
- copy_v3_v3(off2a, v->co);
- madd_v3_v3fl(off2a, norm_perp2, e2->offset);
- add_v3_v3v3(off2b, off2a, dir2);
-
- /* intersect the lines; by construction they should be on the same plane and not parallel */
- if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
- BLI_assert(!"offset_meet failure");
- copy_v3_v3(meetco, off1a); /* just to do something */
- }
- }
-}
-
-/* Like offset_meet, but here f1 and f2 must not be NULL and give the
- * planes in which to run the offset lines. They may not meet exactly,
- * but the line intersection routine will find the closest approach point. */
-static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v,
- BMFace *f1, BMFace *f2, float meetco[3])
-{
- float dir1[3], dir2[3], norm_perp1[3], norm_perp2[3],
- off1a[3], off1b[3], off2a[3], off2b[3], isect2[3];
-
- BLI_assert(f1 != NULL && f2 != NULL);
-
- /* get direction vectors for two offset lines */
- sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
- sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
-
- /* get directions into offset planes */
- cross_v3_v3v3(norm_perp1, dir1, f1->no);
- normalize_v3(norm_perp1);
- cross_v3_v3v3(norm_perp2, dir2, f2->no);
- normalize_v3(norm_perp2);
-
- /* get points that are offset distances from each line, then another point on each line */
- copy_v3_v3(off1a, v->co);
- madd_v3_v3fl(off1a, norm_perp1, e1->offset);
- add_v3_v3v3(off1b, off1a, dir1);
- copy_v3_v3(off2a, v->co);
- madd_v3_v3fl(off2a, norm_perp2, e2->offset);
- add_v3_v3v3(off2b, off2a, dir2);
-
- /* intersect the lines; by construction they should be on the same plane and not parallel */
- if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
- BLI_assert(!"offset_meet failure");
- copy_v3_v3(meetco, off1a); /* just to do something */
- }
-}
-
-/* Offset by e->offset in plane with normal plane_no, on left if left==TRUE,
- * else on right. If no is NULL, choose an arbitrary plane different
- * from eh's direction. */
-static void offset_in_plane(EdgeHalf *e, float plane_no[3], int left, float r[3])
-{
- float dir[3], no[3];
- BMVert *v;
-
- v = e->isrev ? e->e->v1 : e->e->v2;
-
- sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co);
- normalize_v3(dir);
- if (plane_no) {
- copy_v3_v3(no, plane_no);
- }
- else {
- zero_v3(no);
- if (fabs(dir[0]) < fabs(dir[1]))
- no[0] = 1.0f;
- else
- no[1] = 1.0f;
- }
- if (left)
- cross_v3_v3v3(r, no, dir);
- else
- cross_v3_v3v3(r, dir, no);
- normalize_v3(r);
- mul_v3_fl(r, e->offset);
-}
-
-/* Calculate coordinates of a point a distance d from v on e->e and return it in slideco */
-static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
-{
- float dir[3], len;
-
- sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
- len = len_v3(dir);
- normalize_v3(dir);
- if (d > len)
- d = len - (float)(50 * BEVEL_EPSILON);
- copy_v3_v3(slideco, v->co);
- madd_v3_v3fl(slideco, dir, -d);
-}
-
-/* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */
-static void project_to_edge(BMEdge *e, float co_a[3], float co_b[3], float projco[3])
-{
- float otherco[3];
-
- if (!isect_line_line_v3(e->v1->co, e->v2->co, co_a, co_b,
- projco, otherco)) {
- BLI_assert(!"project meet failure");
- copy_v3_v3(projco, e->v1->co);
- }
-}
-
-
-/* return 1 if a and b are in CCW order on the normal side of f,
- * and -1 if they are reversed, and 0 if there is no shared face f */
-static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
-{
- BMLoop *la, *lb;
-
- if (!f)
- return 0;
- la = BM_face_edge_share_loop(f, a);
- lb = BM_face_edge_share_loop(f, b);
- if (!la || !lb)
- return 0;
- return lb->next == la ? 1 : -1;
-}
-
-/*
- * calculation of points on the round profile
- * r - result, coordinate of point on round profile
- * method:
- * Inscribe a circle in angle va - v -vb
- * such that it touches the arms at offset from v.
- * Rotate the center-va segment by (i/n) of the
- * angle va - center -vb, and put the endpoint
- * of that segment in r.
- */
-static void get_point_on_round_profile(float r[3], float offset, int i, int count,
- float va[3], float v[3], float vb[3])
-{
- float vva[3], vvb[3], angle, center[3], rv[3], axis[3], co[3];
-
- sub_v3_v3v3(vva, va, v);
- sub_v3_v3v3(vvb, vb, v);
- normalize_v3(vva);
- normalize_v3(vvb);
- angle = angle_v3v3(vva, vvb);
-
- add_v3_v3v3(center, vva, vvb);
- normalize_v3(center);
- mul_v3_fl(center, offset * (1.0f / cosf(0.5f * angle)));
- add_v3_v3(center, v); /* coordinates of the center of the inscribed circle */
-
-
- sub_v3_v3v3(rv, va, center); /* radius vector */
-
-
- sub_v3_v3v3(co, v, center);
- cross_v3_v3v3(axis, rv, co); /* calculate axis */
-
- sub_v3_v3v3(vva, va, center);
- sub_v3_v3v3(vvb, vb, center);
- angle = angle_v3v3(vva, vvb);
-
- rotate_v3_v3v3fl(co, rv, axis, angle * (float)(i) / (float)(count));
-
- add_v3_v3(co, center);
- copy_v3_v3(r, co);
-}
-
-/*
- * Find the point (i/n) of the way around the round profile for e,
- * where start point is va, midarc point is vmid, and end point is vb.
- * Return the answer in profileco.
- * Method:
- * Adjust va and vb (along edge direction) so that they are perpendicular
- * to edge at v, then use get_point_on_round_profile, then project
- * back onto original va - vmid - vb plane.
- * If va, vmid, and vb are all on the same plane, just interpolate between va and vb.
- */
-static void get_point_on_round_edge(EdgeHalf *e, int i,
- float va[3], float vmid[3], float vb[3], float profileco[3])
-{
- float vva[3], vvb[3], point[3], dir[3], vaadj[3], vbadj[3], p2[3], pn[3];
- int n = e->seg;
-
- sub_v3_v3v3(vva, va, vmid);
- sub_v3_v3v3(vvb, vb, vmid);
- if (e->isrev)
- sub_v3_v3v3(dir, e->e->v1->co, e->e->v2->co);
- else
- sub_v3_v3v3(dir, e->e->v2->co, e->e->v1->co);
- normalize_v3(dir);
- if (fabsf(angle_v3v3(vva, vvb) - (float)M_PI) > (float)BEVEL_EPSILON) {
- copy_v3_v3(vaadj, va);
- madd_v3_v3fl(vaadj, dir, -len_v3(vva) * cosf(angle_v3v3(vva, dir)));
- copy_v3_v3(vbadj, vb);
- madd_v3_v3fl(vbadj, dir, -len_v3(vvb) * cosf(angle_v3v3(vvb, dir)));
-
- get_point_on_round_profile(point, e->offset, i, n, vaadj, vmid, vbadj);
-
- add_v3_v3v3(p2, profileco, dir);
- cross_v3_v3v3(pn, vva, vvb);
- if (!isect_line_plane_v3(profileco, point, p2, vmid, pn, 0)) {
- BLI_assert(!"bevel: unexpected non-intersection");
- copy_v3_v3(profileco, point);
- }
- }
- else {
- /* planar case */
- interp_v3_v3v3(profileco, va, vb, (float) i / (float) n);
- }
-}
-
-static void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
-{
- v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
- v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
- v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
-}
-
-/* Make a circular list of BoundVerts for bv, each of which has the coordinates
- * of a vertex on the the boundary of the beveled vertex bv->v.
- * Also decide on the mesh pattern that will be used inside the boundary.
- * Doesn't make the actual BMVerts */
-static void build_boundary(BevVert *bv)
-{
- EdgeHalf *efirst, *e;
- BoundVert *v;
- VMesh *vm;
- float co[3], *no;
- float lastd;
-
- e = efirst = next_bev(bv, NULL);
- vm = bv->vmesh;
-
- BLI_assert(bv->edgecount >= 2); /* since bevel edges incident to 2 faces */
-
- if (bv->edgecount == 2 && bv->selcount == 1) {
- /* special case: beveled edge meets non-beveled one at valence 2 vert */
- no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
- offset_in_plane(e, no, TRUE, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = v->elast = v->ebev = e;
- e->leftv = v;
- no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
- offset_in_plane(e, no, FALSE, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = v->elast = e;
- e->rightv = v;
- /* make artifical extra point along unbeveled edge, and form triangle */
- slide_dist(e->next, bv->v, e->offset, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = v->elast = e->next;
- vm->mesh_kind = M_POLY;
- return;
- }
-
- lastd = e->offset;
- vm->boundstart = NULL;
- do {
- if (e->isbev) {
- /* handle only left side of beveled edge e here: next iteration should do right side */
- if (e->prev->isbev) {
- BLI_assert(e->prev != e); /* see: wire edge special case */
- offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = e->prev;
- v->elast = v->ebev = e;
- e->leftv = v;
- e->prev->rightv = v;
- }
- else {
- /* e->prev is not beveled */
- if (e->prev->prev->isbev) {
- BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */
- /* find meet point between e->prev->prev and e and attach e->prev there */
- /* TODO: fix case when one or both faces in following are NULL */
- offset_in_two_planes(e->prev->prev, e, bv->v,
- e->prev->prev->fnext, e->fprev, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = e->prev->prev;
- v->elast = v->ebev = e;
- e->leftv = v;
- e->prev->leftv = v;
- e->prev->prev->rightv = v;
- }
- else {
- /* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */
- offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = e->prev;
- v->elast = v->ebev = e;
- e->leftv = v;
- e->prev->leftv = v;
- }
- }
- lastd = len_v3v3(bv->v->co, v->nv.co);
- }
- else {
- /* e is not beveled */
- if (e->next->isbev) {
- /* next iteration will place e between beveled previous and next edges */
- e = e->next;
- continue;
- }
- if (e->prev->isbev) {
- /* on-edge meet between e->prev and e */
- offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = e->prev;
- v->elast = e;
- e->leftv = v;
- e->prev->rightv = v;
- }
- else {
- /* None of e->prev, e, e->next are beveled.
- * could either leave alone or add slide points to make
- * one polygon around bv->v. For now, we choose latter.
- * Could slide to make an even bevel plane but for now will
- * just use last distance a meet point moved from bv->v. */
- slide_dist(e, bv->v, lastd, co);
- v = add_new_bound_vert(vm, co);
- v->efirst = v->elast = e;
- e->leftv = v;
- }
- }
- e = e->next;
- } while (e != efirst);
-
- BLI_assert(vm->count >= 2);
- if (vm->count == 2 && bv->edgecount == 3)
- vm->mesh_kind = M_NONE;
- else if (efirst->seg == 1 || bv->selcount < 3)
- vm->mesh_kind = M_POLY;
- else
- vm->mesh_kind = M_ADJ;
- /* TODO: if vm->count == 4 and bv->selcount == 4, use M_CROSS pattern */
-}
-
-/*
- * Given that the boundary is built and the boundary BMVerts have been made,
- * calculate the positions of the interior mesh points for the M_ADJ pattern,
- * then make the BMVerts and the new faces. */
-static void bevel_build_rings(BMesh *bm, BevVert *bv)
-{
- int k, ring, i, n, ns, ns2, nn;
- VMesh *vm = bv->vmesh;
- BoundVert *v, *vprev, *vnext;
- NewVert *nv, *nvprev, *nvnext;
- BMVert *bmv, *bmv1, *bmv2, *bmv3, *bmv4;
- BMFace *f;
- float co[3], coa[3], cob[3], midco[3];
-
- n = vm->count;
- ns = vm->seg;
- ns2 = ns / 2;
- BLI_assert(n > 2 && ns > 1);
-
- /* Make initial rings, going between points on neighbors */
- for (ring = 1; ring <= ns2; ring++) {
- v = vm->boundstart;
- do {
- i = v->index;
- if (v->ebev) {
- /* get points coords of points a and b, on outer rings
- * of prev and next edges, k away from this edge */
- vprev = v->prev;
- vnext = v->next;
-
- if (vprev->ebev)
- nvprev = mesh_vert(vm, vprev->index, 0, ns - ring);
- else
- nvprev = mesh_vert(vm, vprev->index, 0, ns);
- copy_v3_v3(coa, nvprev->co);
- nv = mesh_vert(vm, i, ring, 0);
- copy_v3_v3(nv->co, coa);
- nv->v = nvprev->v;
-
- if (vnext->ebev)
- nvnext = mesh_vert(vm, vnext->index, 0, ring);
- else
- nvnext = mesh_vert(vm, vnext->index, 0, 0);
- copy_v3_v3(cob, nvnext->co);
- nv = mesh_vert(vm, i, ring, ns);
- copy_v3_v3(nv->co, cob);
- nv->v = nvnext->v;
-
- /* TODO: better calculation of new midarc point? */
- project_to_edge(v->ebev->e, coa, cob, midco);
-
- for (k = 1; k < ns; k++) {
- get_point_on_round_edge(v->ebev, k, coa, midco, cob, co);
- copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co);
- }
- }
- v = v->next;
- } while (v != vm->boundstart);
- }
-
- /* Now make sure cross points of rings share coordinates and vertices */
- v = vm->boundstart;
- do {
- i = v->index;
- if (v->ebev) {
- vprev = v->prev;
- vnext = v->next;
- if (vprev->ebev) {
- for (ring = 1; ring <= ns2; ring++) {
- for (k = 1; k <= ns2; k++) {
- if (ns % 2 == 0 && (k == ns2 || ring == ns2))
- continue; /* center line is special case: do after the rest are done */
- nv = mesh_vert(vm, i, ring, k);
- nvprev = mesh_vert(vm, vprev->index, k, ns - ring);
- mid_v3_v3v3(co, nv->co, nvprev->co);
- copy_v3_v3(nv->co, co);
- BLI_assert(nv->v == NULL && nvprev->v == NULL);
- create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
- copy_mesh_vert(vm, vprev->index, k, ns - ring, i, ring, k);
- }
- }
- if (!vprev->prev->ebev) {
- for (ring = 1; ring <= ns2; ring++) {
- for (k = 1; k <= ns2; k++) {
- if (ns % 2 == 0 && (k == ns2 || ring == ns2))
- continue;
- create_mesh_bmvert(bm, vm, vprev->index, ring, k, bv->v);
- }
- }
- }
- if (!vnext->ebev) {
- for (ring = 1; ring <= ns2; ring++) {
- for (k = ns - ns2; k < ns; k++) {
- if (ns % 2 == 0 && (k == ns2 || ring == ns2))
- continue;
- create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
- }
- }
- }
- }
- }
- v = v->next;
- } while (v != vm->boundstart);
-
- if (ns % 2 == 0) {
- /* do special case center lines */
- v = vm->boundstart;
- do {
- i = v->index;
- if (v->ebev) {
- vprev = v->prev;
- vnext = v->next;
- for (k = 1; k < ns2; k++) {
- nv = mesh_vert(vm, i, k, ns2);
- if (vprev->ebev)
- nvprev = mesh_vert(vm, vprev->index, ns2, ns - k);
- if (vnext->ebev)
- nvnext = mesh_vert(vm, vnext->index, ns2, k);
- if (vprev->ebev && vnext->ebev) {
- mid_v3_v3v3v3(co, nvprev->co, nv->co, nvnext->co);
- copy_v3_v3(nv->co, co);
- create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
- copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
- copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
-
- }
- else if (vprev->ebev) {
- mid_v3_v3v3(co, nvprev->co, nv->co);
- copy_v3_v3(nv->co, co);
- create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
- copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
- }
- else if (vnext->ebev) {
- mid_v3_v3v3(co, nv->co, nvnext->co);
- copy_v3_v3(nv->co, co);
- create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
- copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
- }
- }
- }
- v = v->next;
- } while (v != vm->boundstart);
-
- /* center point need to be average of all centers of rings */
- /* TODO: this is wrong if not all verts have ebev: could have
- * several disconnected sections of mesh. */
- zero_v3(midco);
- nn = 0;
- v = vm->boundstart;
- do {
- i = v->index;
- if (v->ebev) {
- nv = mesh_vert(vm, i, ns2, ns2);
- add_v3_v3(midco, nv->co);
- nn++;
- }
- v = v->next;
- } while (v != vm->boundstart);
- mul_v3_fl(midco, 1.0f / nn);
- bmv = BM_vert_create(bm, midco, NULL);
- v = vm->boundstart;
- do {
- i = v->index;
- if (v->ebev) {
- nv = mesh_vert(vm, i, ns2, ns2);
- copy_v3_v3(nv->co, midco);
- nv->v = bmv;
- }
- v = v->next;
- } while (v != vm->boundstart);
- }
-
- /* Make the ring quads */
- for (ring = 0; ring < ns2; ring++) {
- v = vm->boundstart;
- do {
- i = v->index;
- f = boundvert_rep_face(v);
- if (v->ebev && (v->prev->ebev || v->next->ebev)) {
- for (k = 0; k < ns2 + (ns % 2); k++) {
- bmv1 = mesh_vert(vm, i, ring, k)->v;
- bmv2 = mesh_vert(vm, i, ring, k + 1)->v;
- bmv3 = mesh_vert(vm, i, ring + 1, k + 1)->v;
- bmv4 = mesh_vert(vm, i, ring + 1, k)->v;
- BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
- if (bmv3 == bmv4 || bmv1 == bmv4)
- bmv4 = NULL;
- bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f);
- }
- }
- else if (v->prev->ebev && v->prev->prev->ebev) {
- /* finish off a sequence of beveled edges */
- i = v->prev->index;
- f = boundvert_rep_face(v->prev);
- for (k = ns2 + (ns % 2); k < ns; k++) {
- bmv1 = mesh_vert(vm, i, ring + 1, k)->v;
- bmv2 = mesh_vert(vm, i, ring, k)->v;
- bmv3 = mesh_vert(vm, i, ring, k + 1)->v;
- BLI_assert(bmv1 && bmv2 && bmv3);
- bev_create_quad_tri(bm, bmv1, bmv2, bmv3, NULL, f);
- }
- }
- v = v->next;
- } while (v != vm->boundstart);
- }
-
- /* Make center ngon if odd number of segments and fully beveled */
- if (ns % 2 == 1 && vm->count == bv->selcount) {
- BMVert **vv = NULL;
- BLI_array_declare(vv);
-
- v = vm->boundstart;
- do {
- i = v->index;
- BLI_assert(v->ebev);
- BLI_array_append(vv, mesh_vert(vm, i, ns2, ns2)->v);
- v = v->next;
- } while (v != vm->boundstart);
- f = boundvert_rep_face(vm->boundstart);
- bev_create_ngon(bm, vv, BLI_array_count(vv), f);
-
- BLI_array_free(vv);
- }
-
- /* Make 'rest-of-vmesh' polygon if not fully beveled */
- if (vm->count > bv->selcount) {
- int j;
- BMVert **vv = NULL;
- BLI_array_declare(vv);
-
- v = vm->boundstart;
- f = boundvert_rep_face(v);
- j = 0;
- do {
- i = v->index;
- if (v->ebev) {
- if (!v->prev->ebev) {
- for (k = 0; k < ns2; k++) {
- bmv1 = mesh_vert(vm, i, ns2, k)->v;
- if (!(j > 0 && bmv1 == vv[j - 1])) {
- BLI_array_append(vv, bmv1);
- j++;
- }
- }
- }
- bmv1 = mesh_vert(vm, i, ns2, ns2)->v;
- if (!(j > 0 && bmv1 == vv[j - 1])) {
- BLI_array_append(vv, bmv1);
- j++;
- }
- if (!v->next->ebev) {
- for (k = ns - ns2; k < ns; k++) {
- bmv1 = mesh_vert(vm, i, ns2, k)->v;
- if (!(j > 0 && bmv1 == vv[j - 1])) {
- BLI_array_append(vv, bmv1);
- j++;
- }
- }
- }
- }
- else {
- BLI_array_append(vv, mesh_vert(vm, i, 0, 0)->v);
- j++;
- }
- v = v->next;
- } while (v != vm->boundstart);
- if (vv[0] == vv[j - 1])
- j--;
- bev_create_ngon(bm, vv, j, f);
-
- BLI_array_free(vv);
- }
-}
-
-static void bevel_build_poly(BMesh *bm, BevVert *bv)
-{
- int n, k;
- VMesh *vm = bv->vmesh;
- BoundVert *v;
- BMVert **vv = NULL;
- BLI_array_declare(vv);
-
- v = vm->boundstart;
- n = 0;
- do {
- /* accumulate vertices for vertex ngon */
- BLI_array_append(vv, v->nv.v);
- n++;
- if (v->ebev && v->ebev->seg > 1) {
- for (k = 1; k < v->ebev->seg; k++) {
- BLI_array_append(vv, mesh_vert(vm, v->index, 0, k)->v);
- n++;
- }
- }
- v = v->next;
- } while (v != vm->boundstart);
- if (n > 2)
- bev_create_ngon(bm, vv, n, boundvert_rep_face(v));
- BLI_array_free(vv);
-}
-
-/* Given that the boundary is built, now make the actual BMVerts
- * for the boundary and the interior of the vertex mesh. */
-static void build_vmesh(BMesh *bm, BevVert *bv)
-{
- VMesh *vm = bv->vmesh;
- BoundVert *v, *weld1, *weld2;
- int n, ns, ns2, i, k, weld;
- float *va, *vb, co[3], midco[3];
-
- n = vm->count;
- ns = vm->seg;
- ns2 = ns / 2;
-
- vm->mesh = (NewVert *)MEM_callocN(n * (ns2 + 1) * (ns + 1) * sizeof(NewVert), "NewVert");
-
- /* special case: two beveled ends welded together */
- weld = (bv->selcount == 2) && (vm->count == 2);
- weld1 = weld2 = NULL; /* will hold two BoundVerts involved in weld */
-
- /* make (i, 0, 0) mesh verts for all i */
- v = vm->boundstart;
- do {
- i = v->index;
- copy_v3_v3(mesh_vert(vm, i, 0, 0)->co, v->nv.co);
- create_mesh_bmvert(bm, vm, i, 0, 0, bv->v);
- v->nv.v = mesh_vert(vm, i, 0, 0)->v;
- if (weld && v->ebev) {
- if (!weld1)
- weld1 = v;
- else
- weld2 = v;
- }
- v = v->next;
- } while (v != vm->boundstart);
-
- /* copy other ends to (i, 0, ns) for all i, and fill in profiles for beveled edges */
- v = vm->boundstart;
- do {
- i = v->index;
- copy_mesh_vert(vm, i, 0, ns, v->next->index, 0, 0);
- if (v->ebev) {
- va = mesh_vert(vm, i, 0, 0)->co;
- vb = mesh_vert(vm, i, 0, ns)->co;
- project_to_edge(v->ebev->e, va, vb, midco);
- for (k = 1; k < ns; k++) {
- get_point_on_round_edge(v->ebev, k, va, midco, vb, co);
- copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
- if (!weld)
- create_mesh_bmvert(bm, vm, i, 0, k, bv->v);
- }
- }
- v = v->next;
- } while (v != vm->boundstart);
-
- if (weld) {
- for (k = 1; k < ns; k++) {
- mid_v3_v3v3(co, mesh_vert(vm, weld1->index, 0, k)->co,
- mesh_vert(vm, weld2->index, 0, ns - k)->co);
- copy_v3_v3(mesh_vert(vm, weld1->index, 0, k)->co, co);
- create_mesh_bmvert(bm, vm, weld1->index, 0, k, bv->v);
- }
- for (k = 1; k < ns; k++)
- copy_mesh_vert(vm, weld2->index, 0, ns - k, weld1->index, 0, k);
- }
-
- if (vm->mesh_kind == M_ADJ)
- bevel_build_rings(bm, bv);
- else if (vm->mesh_kind == M_POLY)
- bevel_build_poly(bm, bv);
-}
-
-/*
- * Construction around the vertex
- */
-static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMOperator *op, BMVert *v)
-{
-
- BMOIter siter;
- BMEdge *bme;
- BevVert *bv;
- BMEdge *bme2, *unflagged_bme;
- BMFace *f;
- BMIter iter, iter2;
- EdgeHalf *e;
- int i, ntot, found_shared_face, ccw_test_sum;
- int nsel = 0;
-
- /* Gather input selected edges.
- * Only bevel selected edges that have exactly two incident faces. */
- BMO_ITER (bme, &siter, bm, op, "geom", BM_EDGE) {
- if ((bme->v1 == v) || (BM_edge_other_vert(bme, bme->v1) == v)) {
- if (BM_edge_face_count(bme) == 2) {
- BMO_elem_flag_enable(bm, bme, EDGE_SELECTED);
- nsel++;
- }
- }
- }
-
- if (nsel == 0)
- return;
-
- ntot = BM_vert_edge_count(v);
- bv = (BevVert *)MEM_callocN(sizeof(BevVert), "BevVert");
- bv->v = v;
- bv->edgecount = ntot;
- bv->selcount = nsel;
- bv->edges = (EdgeHalf *)MEM_callocN(ntot * sizeof(EdgeHalf), "EdgeHalf");
- bv->vmesh = (VMesh *)MEM_callocN(sizeof(VMesh), "VMesh");
- bv->vmesh->seg = bp->seg;
- BLI_addtail(&bp->vertList, bv);
-
- /* add edges to bv->edges in order that keeps adjacent edges sharing
- * a face, if possible */
- i = 0;
- bme = v->e;
- BMO_elem_flag_enable(bm, bme, BEVEL_FLAG);
- e = &bv->edges[0];
- e->e = bme;
- for (i = 0; i < ntot; i++) {
- if (i > 0) {
- /* find an unflagged edge bme2 that shares a face f with previous bme */
- found_shared_face = 0;
- unflagged_bme = NULL;
- BM_ITER_ELEM (bme2, &iter, v, BM_EDGES_OF_VERT) {
- if (BMO_elem_flag_test(bm, bme2, BEVEL_FLAG))
- continue;
- if (!unflagged_bme)
- unflagged_bme = bme2;
- BM_ITER_ELEM (f, &iter2, bme2, BM_FACES_OF_EDGE) {
- if (BM_face_edge_share_loop(f, bme)) {
- found_shared_face = 1;
- break;
- }
- }
- if (found_shared_face)
- break;
- }
- e = &bv->edges[i];
- if (found_shared_face) {
- e->e = bme2;
- e->fprev = f;
- bv->edges[i - 1].fnext = f;
- }
- else {
- e->e = unflagged_bme;
- }
- }
- bme = e->e;
- BMO_elem_flag_enable(bm, bme, BEVEL_FLAG);
- if (BMO_elem_flag_test(bm, bme, EDGE_SELECTED)) {
- e->isbev = 1;
- e->seg = bp->seg;
- }
- else {
- e->isbev = 0;
- e->seg = 0;
- }
- e->isrev = (bme->v2 == v);
- e->offset = e->isbev ? bp->offset : 0.0f;
- }
- /* find wrap-around shared face */
- BM_ITER_ELEM (f, &iter2, bme, BM_FACES_OF_EDGE) {
- if (BM_face_edge_share_loop(f, bv->edges[0].e)) {
- if (bv->edges[0].fnext == f)
- continue; /* if two shared faces, want the other one now */
- bv->edges[ntot - 1].fnext = f;
- bv->edges[0].fprev = f;
- break;
- }
- }
-
- /* remove BEVEL_FLAG now that we are finished with it*/
- for (i = 0; i < ntot; i++)
- BMO_elem_flag_disable(bm, bv->edges[i].e, BEVEL_FLAG);
-
- /* if edge array doesn't go CCW around vertex from average normal side,
- * reverse the array, being careful to reverse face pointers too */
- if (ntot > 1) {
- ccw_test_sum = 0;
- for (i = 0; i < ntot; i++)
- ccw_test_sum += bev_ccw_test(bv->edges[i].e, bv->edges[(i + 1) % ntot].e,
- bv->edges[i].fnext);
- if (ccw_test_sum < 0) {
- for (i = 0; i <= (ntot / 2) - 1; i++) {
- SWAP(EdgeHalf, bv->edges[i], bv->edges[ntot - i - 1]);
- SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
- SWAP(BMFace *, bv->edges[ntot - i - 1].fprev, bv->edges[ntot - i - 1].fnext);
- }
- if (ntot % 2 == 1) {
- i = ntot / 2;
- SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
- }
- }
- }
-
- for (i = 0; i < ntot; i++) {
- e = &bv->edges[i];
- e->next = &bv->edges[(i + 1) % ntot];
- e->prev = &bv->edges[(i + ntot - 1) % ntot];
- }
-
- build_boundary(bv);
- build_vmesh(bm, bv);
-}
-
-/* Face f has at least one beveled vertex. Rebuild f */
-static void rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
-{
- BMIter liter;
- BMLoop *l, *lprev;
- BevVert *bv;
- BoundVert *v, *vstart, *vend;
- EdgeHalf *e, *eprev;
- VMesh *vm;
- int i, k;
- BMVert *bmv;
- BMVert **vv = NULL;
- BLI_array_declare(vv);
-
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- bv = find_bevvert(bp, l->v);
- if (bv) {
- lprev = l->prev;
- e = find_edge_half(bv, l->e);
- eprev = find_edge_half(bv, lprev->e);
- BLI_assert(e != NULL && eprev != NULL);
- vstart = eprev->leftv;
- if (e->isbev)
- vend = e->rightv;
- else
- vend = e->leftv;
- v = vstart;
- vm = bv->vmesh;
- BLI_array_append(vv, v->nv.v);
- while (v != vend) {
- if (vm->mesh_kind == M_NONE && v->ebev && v->ebev->seg > 1 && v->ebev != e && v->ebev != eprev) {
- /* case of 3rd face opposite a beveled edge, with no vmesh */
- i = v->index;
- e = v->ebev;
- for (k = 1; k < e->seg; k++) {
- bmv = mesh_vert(vm, i, 0, k)->v;
- BLI_array_append(vv, bmv);
- }
- }
- v = v->prev;
- BLI_array_append(vv, v->nv.v);
- }
- }
- else {
- BLI_array_append(vv, l->v);
- }
- }
- bev_create_ngon(bm, vv, BLI_array_count(vv), f);
- BLI_array_free(vv);
-}
-
-/* All polygons touching v need rebuilding because beveling v has made new vertices */
-static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert *v)
-{
- BMFace *f;
- BMIter iter;
-
- /* TODO: don't iterate through all faces, but just local geometry around v */
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- BMLoop *l = f->l_first;
- do {
- if (l->v == v) {
- rebuild_polygon(bm, bp, f);
- BM_face_kill(bm, f);
- }
- l = l->next;
- } while (l != f->l_first);
- }
-}
-
-
-
-/*
- * Build the polygons along the selected Edge
- */
-static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
-{
- BevVert *bv1, *bv2;
- BMVert *bmv1, *bmv2, *bmv3, *bmv4, *bmv1i, *bmv2i, *bmv3i, *bmv4i;
- VMesh *vm1, *vm2;
- EdgeHalf *e1, *e2;
- BMFace *f1, *f2, *f;
- int k, nseg, i1, i2;
-
- if (BM_edge_face_count(bme) != 2)
- return;
-
- bv1 = find_bevvert(bp, bme->v1);
- bv2 = find_bevvert(bp, bme->v2);
-
- BLI_assert(bv1 && bv2);
-
- e1 = find_edge_half(bv1, bme);
- e2 = find_edge_half(bv2, bme);
-
- BLI_assert(e1 && e2);
-
- /* v4 v3
- * \ /
- * e->v1 - e->v2
- * / \
- * v1 v2 */
-
- nseg = e1->seg;
- BLI_assert(nseg > 0 && nseg == e2->seg);
-
- bmv1 = e1->leftv->nv.v;
- bmv4 = e1->rightv->nv.v;
- bmv2 = e2->rightv->nv.v;
- bmv3 = e2->leftv->nv.v;
-
- BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
-
- f1 = boundvert_rep_face(e1->leftv);
- f2 = boundvert_rep_face(e1->rightv);
-
- if (nseg == 1) {
- bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f1);
- }
- else {
- i1 = e1->leftv->index;
- i2 = e2->leftv->index;
- vm1 = bv1->vmesh;
- vm2 = bv2->vmesh;
- bmv1i = bmv1;
- bmv2i = bmv2;
- for (k = 1; k <= nseg; k++) {
- bmv4i = mesh_vert(vm1, i1, 0, k)->v;
- bmv3i = mesh_vert(vm2, i2, 0, nseg - k)->v;
- f = (k <= nseg / 2 + (nseg % 2)) ? f1 : f2;
- bev_create_quad_tri(bm, bmv1i, bmv2i, bmv3i, bmv4i, f);
- bmv1i = bmv4i;
- bmv2i = bmv3i;
- }
- }
-}
-
-
-static void free_bevel_params(BevelParams *bp)
-{
- BevVert *bv;
- VMesh *vm;
- BoundVert *v, *vnext;
-
- for (bv = bp->vertList.first; bv; bv = bv->next) {
- MEM_freeN(bv->edges);
- vm = bv->vmesh;
- v = vm->boundstart;
- if (v) {
- do {
- vnext = v->next;
- MEM_freeN(v);
- v = vnext;
- } while (v != vm->boundstart);
- }
- if (vm->mesh)
- MEM_freeN(vm->mesh);
- MEM_freeN(vm);
- }
- BLI_freelistN(&bp->vertList);
-}
-
void bmo_bevel_exec(BMesh *bm, BMOperator *op)
{
- BMOIter siter;
- BMVert *v;
- BMEdge *e;
- BevelParams bp;
-
- bp.offset = BMO_slot_float_get(op, "offset");
- bp.op = op;
- bp.seg = BMO_slot_int_get(op, "segments");
-
- if (bp.offset > 0) {
- bp.vertList.first = bp.vertList.last = NULL;
-
- /* The analysis of the input vertices and execution additional constructions */
- BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
- bevel_vert_construct(bm, &bp, op, v);
- }
- /* Build polygons for edges */
- BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) {
- bevel_build_edge_polygons(bm, &bp, e);
- }
-
- BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
- bevel_rebuild_existing_polygons(bm, &bp, v);
- }
-
- BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
- if (find_bevvert(&bp, v))
- BM_vert_kill(bm, v);
- }
- free_bevel_params(&bp);
- }
-
-}
-
-#else
-#define BEVEL_FLAG 1
-#define BEVEL_DEL 2
-#define FACE_NEW 4
-#define EDGE_OLD 8
-#define FACE_OLD 16
-#define VERT_OLD 32
-#define FACE_SPAN 64
-#define FACE_HOLE 128
-
-typedef struct LoopTag {
- BMVert *newv;
-} LoopTag;
-
-typedef struct EdgeTag {
- BMVert *newv1, *newv2;
-} EdgeTag;
-
-static void calc_corner_co(BMLoop *l, const float fac, float r_co[3],
- const short do_dist, const short do_even)
-{
- float no[3], l_vec_prev[3], l_vec_next[3], l_co_prev[3], l_co[3], l_co_next[3], co_ofs[3];
- int is_concave;
-
- /* first get the prev/next verts */
- if (l->f->len > 2) {
- copy_v3_v3(l_co_prev, l->prev->v->co);
- copy_v3_v3(l_co, l->v->co);
- copy_v3_v3(l_co_next, l->next->v->co);
-
- /* calculate normal */
- sub_v3_v3v3(l_vec_prev, l_co_prev, l_co);
- sub_v3_v3v3(l_vec_next, l_co_next, l_co);
-
- cross_v3_v3v3(no, l_vec_prev, l_vec_next);
- is_concave = dot_v3v3(no, l->f->no) > 0.0f;
- }
- else {
- BMIter iter;
- BMLoop *l2;
- float up[3] = {0.0f, 0.0f, 1.0f};
-
- copy_v3_v3(l_co_prev, l->prev->v->co);
- copy_v3_v3(l_co, l->v->co);
-
- BM_ITER_ELEM (l2, &iter, l->v, BM_LOOPS_OF_VERT) {
- if (l2->f != l->f) {
- copy_v3_v3(l_co_next, BM_edge_other_vert(l2->e, l2->next->v)->co);
- break;
- }
- }
-
- sub_v3_v3v3(l_vec_prev, l_co_prev, l_co);
- sub_v3_v3v3(l_vec_next, l_co_next, l_co);
-
- cross_v3_v3v3(no, l_vec_prev, l_vec_next);
- if (dot_v3v3(no, no) == 0.0f) {
- no[0] = no[1] = 0.0f; no[2] = -1.0f;
- }
-
- is_concave = dot_v3v3(no, up) < 0.0f;
- }
-
-
- /* now calculate the new location */
- if (do_dist) { /* treat 'fac' as distance */
-
- normalize_v3(l_vec_prev);
- normalize_v3(l_vec_next);
-
- add_v3_v3v3(co_ofs, l_vec_prev, l_vec_next);
- if (UNLIKELY(normalize_v3(co_ofs) == 0.0f)) { /* edges form a straight line */
- cross_v3_v3v3(co_ofs, l_vec_prev, l->f->no);
- }
+ const float offset = BMO_slot_float_get(op->slots_in, "offset");
+ const int seg = BMO_slot_int_get(op->slots_in, "segments");
- if (do_even) {
- negate_v3(l_vec_next);
- mul_v3_fl(co_ofs, fac * shell_angle_to_dist(0.5f * angle_normalized_v3v3(l_vec_prev, l_vec_next)));
- /* negate_v3(l_vec_next); */ /* no need unless we use again */
- }
- else {
- mul_v3_fl(co_ofs, fac);
- }
- }
- else { /* treat as 'fac' as a factor (0 - 1) */
-
- /* not strictly necessary, balance vectors
- * so the longer edge doesn't skew the result,
- * gives nicer, move even output.
- *
- * Use the minimum rather then the middle value so skinny faces don't flip along the short axis */
- float min_fac = min_ff(normalize_v3(l_vec_prev), normalize_v3(l_vec_next));
- float angle;
-
- if (do_even) {
- negate_v3(l_vec_next);
- angle = angle_normalized_v3v3(l_vec_prev, l_vec_next);
- negate_v3(l_vec_next); /* no need unless we use again */
- }
- else {
- angle = 0.0f;
- }
-
- mul_v3_fl(l_vec_prev, min_fac);
- mul_v3_fl(l_vec_next, min_fac);
-
- add_v3_v3v3(co_ofs, l_vec_prev, l_vec_next);
-
- if (UNLIKELY(is_zero_v3(co_ofs))) {
- cross_v3_v3v3(co_ofs, l_vec_prev, l->f->no);
- normalize_v3(co_ofs);
- mul_v3_fl(co_ofs, min_fac);
- }
-
- /* done */
- if (do_even) {
- mul_v3_fl(co_ofs, (fac * 0.5f) * shell_angle_to_dist(0.5f * angle));
- }
- else {
- mul_v3_fl(co_ofs, fac * 0.5f);
- }
- }
-
- /* apply delta vec */
- if (is_concave)
- negate_v3(co_ofs);
-
- add_v3_v3v3(r_co, co_ofs, l->v->co);
-}
-
-
-#define ETAG_SET(e, v, nv) ( \
- (v) == (e)->v1 ? \
- (etags[BM_elem_index_get((e))].newv1 = (nv)) : \
- (etags[BM_elem_index_get((e))].newv2 = (nv)) \
- )
-
-#define ETAG_GET(e, v) ( \
- (v) == (e)->v1 ? \
- (etags[BM_elem_index_get((e))].newv1) : \
- (etags[BM_elem_index_get((e))].newv2) \
- )
-
-void bmo_bevel_exec(BMesh *bm, BMOperator *op)
-{
- BMOIter siter;
- BMIter iter;
- BMEdge *e;
- BMVert *v;
- BMFace **faces = NULL, *f;
- LoopTag *tags = NULL, *tag;
- EdgeTag *etags = NULL;
- BMVert **verts = NULL;
- BMEdge **edges = NULL;
- BLI_array_declare(faces);
- BLI_array_declare(tags);
- BLI_array_declare(etags);
- BLI_array_declare(verts);
- BLI_array_declare(edges);
- SmallHash hash;
- float fac = BMO_slot_float_get(op, "percent");
- const short do_even = BMO_slot_bool_get(op, "use_even");
- const short do_dist = BMO_slot_bool_get(op, "use_dist");
- int i, li, has_elens, HasMDisps = CustomData_has_layer(&bm->ldata, CD_MDISPS);
-
- has_elens = CustomData_has_layer(&bm->edata, CD_PROP_FLT) && BMO_slot_bool_get(op, "use_lengths");
- if (has_elens) {
- li = BMO_slot_int_get(op, "lengthlayer");
- }
-
- BLI_smallhash_init(&hash);
-
- BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) {
- BMO_elem_flag_enable(bm, e, BEVEL_FLAG | BEVEL_DEL);
- BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG | BEVEL_DEL);
- BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG | BEVEL_DEL);
-
- if (BM_edge_face_count(e) < 2) {
- BMO_elem_flag_disable(bm, e, BEVEL_DEL);
- BMO_elem_flag_disable(bm, e->v1, BEVEL_DEL);
- BMO_elem_flag_disable(bm, e->v2, BEVEL_DEL);
- }
-#if 0
- if (BM_edge_face_count(e) == 0) {
- BMVert *verts[2] = {e->v1, e->v2};
- BMEdge *edges[2] = {e, BM_edge_create(bm, e->v1, e->v2, e, 0)};
-
- BMO_elem_flag_enable(bm, edges[1], BEVEL_FLAG);
- BM_face_create(bm, verts, edges, 2, FALSE);
- }
-#endif
- }
-
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- BMO_elem_flag_enable(bm, v, VERT_OLD);
- }
-
-#if 0
- /* a bit of cleaner code that, alas, doens't work. */
- /* build edge tag */
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BMO_elem_flag_test(bm, e->v1, BEVEL_FLAG) || BMO_elem_flag_test(bm, e->v2, BEVEL_FLAG)) {
- BMIter liter;
- BMLoop *l;
-
- if (!BMO_elem_flag_test(bm, e, EDGE_OLD)) {
- BM_elem_index_set(e, BLI_array_count(etags)); /* set_dirty! */
- BLI_array_grow_one(etags);
-
- BMO_elem_flag_enable(bm, e, EDGE_OLD);
- }
-
- BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
- BMLoop *l2;
- BMIter liter2;
-
- if (BMO_elem_flag_test(bm, l->f, BEVEL_FLAG))
- continue;
-
- BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) {
- BM_elem_index_set(l2, BLI_array_count(tags)); /* set_loop */
- BLI_array_grow_one(tags);
-
- if (!BMO_elem_flag_test(bm, l2->e, EDGE_OLD)) {
- BM_elem_index_set(l2->e, BLI_array_count(etags)); /* set_dirty! */
- BLI_array_grow_one(etags);
-
- BMO_elem_flag_enable(bm, l2->e, EDGE_OLD);
- }
- }
-
- BMO_elem_flag_enable(bm, l->f, BEVEL_FLAG);
- BLI_array_append(faces, l->f);
- }
- }
- else {
- BM_elem_index_set(e, -1); /* set_dirty! */
- }
- }
-#endif
-
- /* create and assign looptag structure */
- BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) {
- BMLoop *l;
- BMIter liter;
-
- BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG | BEVEL_DEL);
- BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG | BEVEL_DEL);
-
- if (BM_edge_face_count(e) < 2) {
- BMO_elem_flag_disable(bm, e, BEVEL_DEL);
- BMO_elem_flag_disable(bm, e->v1, BEVEL_DEL);
- BMO_elem_flag_disable(bm, e->v2, BEVEL_DEL);
- }
-
- if (!BLI_smallhash_haskey(&hash, (intptr_t)e)) {
- BLI_array_grow_one(etags);
- BM_elem_index_set(e, BLI_array_count(etags) - 1); /* set_dirty! */
- BLI_smallhash_insert(&hash, (intptr_t)e, NULL);
- BMO_elem_flag_enable(bm, e, EDGE_OLD);
- }
-
- /* find all faces surrounding e->v1 and, e->v2 */
- for (i = 0; i < 2; i++) {
- BM_ITER_ELEM (l, &liter, i ? e->v2 : e->v1, BM_LOOPS_OF_VERT) {
- BMLoop *l2;
- BMIter liter2;
-
- /* see if we've already processed this loop's fac */
- if (BLI_smallhash_haskey(&hash, (intptr_t)l->f))
- continue;
-
- /* create tags for all loops in l-> */
- BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) {
- BLI_array_grow_one(tags);
- BM_elem_index_set(l2, BLI_array_count(tags) - 1); /* set_loop */
-
- if (!BLI_smallhash_haskey(&hash, (intptr_t)l2->e)) {
- BLI_array_grow_one(etags);
- BM_elem_index_set(l2->e, BLI_array_count(etags) - 1); /* set_dirty! */
- BLI_smallhash_insert(&hash, (intptr_t)l2->e, NULL);
- BMO_elem_flag_enable(bm, l2->e, EDGE_OLD);
- }
- }
-
- BLI_smallhash_insert(&hash, (intptr_t)l->f, NULL);
- BMO_elem_flag_enable(bm, l->f, BEVEL_FLAG);
- BLI_array_append(faces, l->f);
- }
- }
- }
-
- bm->elem_index_dirty |= BM_EDGE;
-
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- BMIter eiter;
-
- if (!BMO_elem_flag_test(bm, v, BEVEL_FLAG))
- continue;
-
- BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
- if (!BMO_elem_flag_test(bm, e, BEVEL_FLAG) && !ETAG_GET(e, v)) {
- BMVert *v2;
- float co[3];
-
- v2 = BM_edge_other_vert(e, v);
- sub_v3_v3v3(co, v2->co, v->co);
- if (has_elens) {
- float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, e->head.data, CD_PROP_FLT, li);
-
- normalize_v3(co);
- mul_v3_fl(co, elen);
- }
-
- mul_v3_fl(co, fac);
- add_v3_v3(co, v->co);
-
- v2 = BM_vert_create(bm, co, v);
- ETAG_SET(e, v, v2);
- }
- }
- }
-
- for (i = 0; i < BLI_array_count(faces); i++) {
- BMLoop *l;
- BMIter liter;
-
- BMO_elem_flag_enable(bm, faces[i], FACE_OLD);
-
- BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) {
- float co[3];
-
- if (BMO_elem_flag_test(bm, l->e, BEVEL_FLAG)) {
- if (BMO_elem_flag_test(bm, l->prev->e, BEVEL_FLAG)) {
- tag = tags + BM_elem_index_get(l);
- calc_corner_co(l, fac, co, do_dist, do_even);
- tag->newv = BM_vert_create(bm, co, l->v);
- }
- else {
- tag = tags + BM_elem_index_get(l);
- tag->newv = ETAG_GET(l->prev->e, l->v);
-
- if (!tag->newv) {
- sub_v3_v3v3(co, l->prev->v->co, l->v->co);
- if (has_elens) {
- float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data,
- CD_PROP_FLT, li);
-
- normalize_v3(co);
- mul_v3_fl(co, elen);
- }
-
- mul_v3_fl(co, fac);
- add_v3_v3(co, l->v->co);
-
- tag->newv = BM_vert_create(bm, co, l->v);
-
- ETAG_SET(l->prev->e, l->v, tag->newv);
- }
- }
- }
- else if (BMO_elem_flag_test(bm, l->v, BEVEL_FLAG)) {
- tag = tags + BM_elem_index_get(l);
- tag->newv = ETAG_GET(l->e, l->v);
-
- if (!tag->newv) {
- sub_v3_v3v3(co, l->next->v->co, l->v->co);
- if (has_elens) {
- float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, l->e->head.data, CD_PROP_FLT, li);
-
- normalize_v3(co);
- mul_v3_fl(co, elen);
- }
-
- mul_v3_fl(co, fac);
- add_v3_v3(co, l->v->co);
-
- tag = tags + BM_elem_index_get(l);
- tag->newv = BM_vert_create(bm, co, l->v);
-
- ETAG_SET(l->e, l->v, tag->newv);
- }
- }
- else {
- tag = tags + BM_elem_index_get(l);
- tag->newv = l->v;
- BMO_elem_flag_disable(bm, l->v, BEVEL_DEL);
- }
- }
- }
-
- /* create new faces inset from original face */
- for (i = 0; i < BLI_array_count(faces); i++) {
- BMLoop *l;
- BMIter liter;
- BMFace *f;
- BMVert *lastv = NULL, *firstv = NULL;
-
- BMO_elem_flag_enable(bm, faces[i], BEVEL_DEL);
-
- BLI_array_empty(verts);
- BLI_array_empty(edges);
-
- BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) {
- BMVert *v2;
-
- tag = tags + BM_elem_index_get(l);
- BLI_array_append(verts, tag->newv);
-
- if (!firstv)
- firstv = tag->newv;
-
- if (lastv) {
- e = BM_edge_create(bm, lastv, tag->newv, l->e, TRUE);
- BM_elem_attrs_copy(bm, bm, l->prev->e, e);
- BLI_array_append(edges, e);
- }
- lastv = tag->newv;
-
- v2 = ETAG_GET(l->e, l->next->v);
-
- tag = &tags[BM_elem_index_get(l->next)];
- if (!BMO_elem_flag_test(bm, l->e, BEVEL_FLAG) && v2 && v2 != tag->newv) {
- BLI_array_append(verts, v2);
-
- e = BM_edge_create(bm, lastv, v2, l->e, TRUE);
- BM_elem_attrs_copy(bm, bm, l->e, e);
-
- BLI_array_append(edges, e);
- lastv = v2;
- }
- }
-
- e = BM_edge_create(bm, firstv, lastv, BM_FACE_FIRST_LOOP(faces[i])->e, TRUE);
- if (BM_FACE_FIRST_LOOP(faces[i])->prev->e != e) {
- BM_elem_attrs_copy(bm, bm, BM_FACE_FIRST_LOOP(faces[i])->prev->e, e);
- }
- BLI_array_append(edges, e);
-
- f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), FALSE);
- if (UNLIKELY(f == NULL)) {
- printf("%s: could not make face!\n", __func__);
- continue;
- }
-
- BMO_elem_flag_enable(bm, f, FACE_NEW);
- }
-
- for (i = 0; i < BLI_array_count(faces); i++) {
- BMLoop *l;
- BMIter liter;
- int j;
-
- /* create quad spans between split edge */
- BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) {
- BMVert *v1 = NULL, *v2 = NULL, *v3 = NULL, *v4 = NULL;
-
- if (!BMO_elem_flag_test(bm, l->e, BEVEL_FLAG))
- continue;
-
- v1 = tags[BM_elem_index_get(l)].newv;
- v2 = tags[BM_elem_index_get(l->next)].newv;
- if (l->radial_next != l) {
- v3 = tags[BM_elem_index_get(l->radial_next)].newv;
- if (l->radial_next->next->v == l->next->v) {
- v4 = v3;
- v3 = tags[BM_elem_index_get(l->radial_next->next)].newv;
- }
- else {
- v4 = tags[BM_elem_index_get(l->radial_next->next)].newv;
- }
- }
- else {
- /* the loop is on a boundar */
- v3 = l->next->v;
- v4 = l->v;
-
- for (j = 0; j < 2; j++) {
- BMIter eiter;
- BMVert *v = j ? v4 : v3;
-
- BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
- if (!BM_vert_in_edge(e, v3) || !BM_vert_in_edge(e, v4))
- continue;
-
- if (!BMO_elem_flag_test(bm, e, BEVEL_FLAG) && BMO_elem_flag_test(bm, e, EDGE_OLD)) {
- BMVert *vv;
-
- vv = ETAG_GET(e, v);
- if (!vv || BMO_elem_flag_test(bm, vv, BEVEL_FLAG))
- continue;
-
- if (j) {
- v1 = vv;
- }
- else {
- v2 = vv;
- }
- break;
- }
- }
- }
-
- BMO_elem_flag_disable(bm, v3, BEVEL_DEL);
- BMO_elem_flag_disable(bm, v4, BEVEL_DEL);
- }
-
- if (v1 != v2 && v2 != v3 && v3 != v4) {
- BMIter liter2;
- BMLoop *l2, *l3;
- BMEdge *e1, *e2;
- float d1, d2, *d3;
-
- f = BM_face_create_quad_tri(bm, v4, v3, v2, v1, l->f, TRUE);
-
- e1 = BM_edge_exists(v4, v3);
- e2 = BM_edge_exists(v2, v1);
- BM_elem_attrs_copy(bm, bm, l->e, e1);
- BM_elem_attrs_copy(bm, bm, l->e, e2);
-
- /* set edge lengths of cross edges as the average of the cross edges they're based o */
- if (has_elens) {
- /* angle happens not to be used. why? - not sure it just isn't - campbell.
- * leave this in in case we need to use it later */
-#if 0
- float ang;
-#endif
- e1 = BM_edge_exists(v1, v4);
- e2 = BM_edge_exists(v2, v3);
-
- if (l->radial_next->v == l->v) {
- l2 = l->radial_next->prev;
- l3 = l->radial_next->next;
- }
- else {
- l2 = l->radial_next->next;
- l3 = l->radial_next->prev;
- }
-
- d3 = CustomData_bmesh_get_n(&bm->edata, e1->head.data, CD_PROP_FLT, li);
- d1 = *(float *)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, CD_PROP_FLT, li);
- d2 = *(float *)CustomData_bmesh_get_n(&bm->edata, l2->e->head.data, CD_PROP_FLT, li);
-#if 0
- ang = angle_v3v3v3(l->prev->v->co, l->v->co, BM_edge_other_vert(l2->e, l->v)->co);
-#endif
- *d3 = (d1 + d2) * 0.5f;
-
- d3 = CustomData_bmesh_get_n(&bm->edata, e2->head.data, CD_PROP_FLT, li);
- d1 = *(float *)CustomData_bmesh_get_n(&bm->edata, l->next->e->head.data, CD_PROP_FLT, li);
- d2 = *(float *)CustomData_bmesh_get_n(&bm->edata, l3->e->head.data, CD_PROP_FLT, li);
-#if 0
- ang = angle_v3v3v3(BM_edge_other_vert(l->next->e, l->next->v)->co, l->next->v->co,
- BM_edge_other_vert(l3->e, l->next->v)->co);
-#endif
- *d3 = (d1 + d2) * 0.5f;
- }
-
- if (UNLIKELY(f == NULL)) {
- fprintf(stderr, "%s: face index out of range! (bmesh internal error)\n", __func__);
- continue;
- }
-
- BMO_elem_flag_enable(bm, f, FACE_NEW | FACE_SPAN);
-
- /* un-tag edges in f for deletio */
- BM_ITER_ELEM (l2, &liter2, f, BM_LOOPS_OF_FACE) {
- BMO_elem_flag_disable(bm, l2->e, BEVEL_DEL);
- }
- }
- else {
- f = NULL;
- }
- }
- }
-
- /* fill in holes at vertices */
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- BMIter eiter;
- BMVert *vv, *vstart = NULL, *lastv = NULL;
- SmallHash tmphash;
- int rad, insorig = 0, err = 0;
+ if (offset > 0) {
+ BMOIter siter;
+ BMEdge *e;
+ BMVert *v;
- BLI_smallhash_init(&tmphash);
+ /* first flush 'geom' into flags, this makes it possible to check connected data,
+ * BM_FACE is cleared so we can put newly created faces into a bmesh slot. */
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE);
- if (!BMO_elem_flag_test(bm, v, BEVEL_FLAG))
- continue;
-
- BLI_array_empty(verts);
- BLI_array_empty(edges);
-
- BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
- BMIter liter;
- BMVert *v1 = NULL, *v2 = NULL;
- BMLoop *l;
-
- if (BM_edge_face_count(e) < 2)
- insorig = 1;
-
- if (BM_elem_index_get(e) == -1)
- continue;
-
- rad = 0;
- BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
- if (!BMO_elem_flag_test(bm, l->f, FACE_OLD))
- continue;
-
- rad++;
-
- tag = tags + BM_elem_index_get((l->v == v) ? l : l->next);
-
- if (!v1)
- v1 = tag->newv;
- else if (!v2)
- v2 = tag->newv;
- }
-
- if (rad < 2)
- insorig = 1;
-
- if (!v1)
- v1 = ETAG_GET(e, v);
- if (!v2 || v1 == v2)
- v2 = ETAG_GET(e, v);
-
- if (v1) {
- if (!BLI_smallhash_haskey(&tmphash, (intptr_t)v1)) {
- BLI_array_append(verts, v1);
- BLI_smallhash_insert(&tmphash, (intptr_t)v1, NULL);
- }
-
- if (v2 && v1 != v2 && !BLI_smallhash_haskey(&tmphash, (intptr_t)v2)) {
- BLI_array_append(verts, v2);
- BLI_smallhash_insert(&tmphash, (intptr_t)v2, NULL);
- }
- }
- }
-
- if (!BLI_array_count(verts))
- continue;
-
- if (insorig) {
- BLI_array_append(verts, v);
- BLI_smallhash_insert(&tmphash, (intptr_t)v, NULL);
+ BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) {
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
}
-
- /* find edges that exist between vertices in verts. this is basically
- * a topological walk of the edges connecting them */
- vstart = vstart ? vstart : verts[0];
- vv = vstart;
- do {
- BM_ITER_ELEM (e, &eiter, vv, BM_EDGES_OF_VERT) {
- BMVert *vv2 = BM_edge_other_vert(e, vv);
-
- if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) {
- /* if we've go over the same vert twice, break out of outer loop */
- if (BLI_smallhash_lookup(&tmphash, (intptr_t)vv2) != NULL) {
- e = NULL;
- err = 1;
- break;
- }
-
- /* use self pointer as ta */
- BLI_smallhash_remove(&tmphash, (intptr_t)vv2);
- BLI_smallhash_insert(&tmphash, (intptr_t)vv2, vv2);
-
- lastv = vv;
- BLI_array_append(edges, e);
- vv = vv2;
- break;
- }
- }
- if (e == NULL) {
- break;
- }
- } while (vv != vstart);
-
- if (err) {
- continue;
- }
-
- /* there may not be a complete loop of edges, so start again and make
- * final edge afterwards. in this case, the previous loop worked to
- * find one of the two edges at the extremes. */
- if (vv != vstart) {
- /* undo previous taggin */
- for (i = 0; i < BLI_array_count(verts); i++) {
- BLI_smallhash_remove(&tmphash, (intptr_t)verts[i]);
- BLI_smallhash_insert(&tmphash, (intptr_t)verts[i], NULL);
- }
-
- vstart = vv;
- lastv = NULL;
- BLI_array_empty(edges);
- do {
- BM_ITER_ELEM (e, &eiter, vv, BM_EDGES_OF_VERT) {
- BMVert *vv2 = BM_edge_other_vert(e, vv);
-
- if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) {
- /* if we've go over the same vert twice, break out of outer loo */
- if (BLI_smallhash_lookup(&tmphash, (intptr_t)vv2) != NULL) {
- e = NULL;
- err = 1;
- break;
- }
-
- /* use self pointer as ta */
- BLI_smallhash_remove(&tmphash, (intptr_t)vv2);
- BLI_smallhash_insert(&tmphash, (intptr_t)vv2, vv2);
-
- lastv = vv;
- BLI_array_append(edges, e);
- vv = vv2;
- break;
- }
- }
- if (e == NULL)
- break;
- } while (vv != vstart);
-
- if (!err) {
- e = BM_edge_create(bm, vv, vstart, NULL, TRUE);
- BLI_array_append(edges, e);
- }
- }
-
- if (err)
- continue;
-
- if (BLI_array_count(edges) >= 3) {
- BMFace *f;
-
- if (BM_face_exists(bm, verts, BLI_array_count(verts), &f))
- continue;
-
- f = BM_face_create_ngon(bm, lastv, vstart, edges, BLI_array_count(edges), FALSE);
- if (UNLIKELY(f == NULL)) {
- fprintf(stderr, "%s: in bevel vert fill! (bmesh internal error)\n", __func__);
- }
- else {
- BMO_elem_flag_enable(bm, f, FACE_NEW | FACE_HOLE);
+ BMO_ITER (e, &siter, op->slots_in, "geom", BM_EDGE) {
+ if (BM_edge_is_manifold(e)) {
+ BM_elem_flag_enable(e, BM_ELEM_TAG);
}
}
- BLI_smallhash_release(&tmphash);
- }
-
- /* copy over customdat */
- for (i = 0; i < BLI_array_count(faces); i++) {
- BMLoop *l;
- BMIter liter;
- BMFace *f = faces[i];
-
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- BMLoop *l2;
- BMIter liter2;
-
- tag = tags + BM_elem_index_get(l);
- if (!tag->newv)
- continue;
-
- BM_ITER_ELEM (l2, &liter2, tag->newv, BM_LOOPS_OF_VERT) {
- if (!BMO_elem_flag_test(bm, l2->f, FACE_NEW) || (l2->v != tag->newv && l2->v != l->v))
- continue;
-
- if (tag->newv != l->v || HasMDisps) {
- BM_elem_attrs_copy(bm, bm, l->f, l2->f);
- BM_loop_interp_from_face(bm, l2, l->f, TRUE, TRUE);
- }
- else {
- BM_elem_attrs_copy(bm, bm, l->f, l2->f);
- BM_elem_attrs_copy(bm, bm, l, l2);
- }
-
- if (HasMDisps) {
- BMLoop *l3;
- BMIter liter3;
-
- BM_ITER_ELEM (l3, &liter3, l2->f, BM_LOOPS_OF_FACE) {
- BM_loop_interp_multires(bm, l3, l->f);
- }
- }
- }
- }
- }
-
- /* handle vertices along boundary edge */
- BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BMO_elem_flag_test(bm, v, VERT_OLD) &&
- BMO_elem_flag_test(bm, v, BEVEL_FLAG) &&
- !BMO_elem_flag_test(bm, v, BEVEL_DEL))
- {
- BMLoop *l;
- BMLoop *lorig = NULL;
- BMIter liter;
-
- BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
- // BMIter liter2;
- // BMLoop *l2 = l->v == v ? l : l->next, *l3;
-
- if (BMO_elem_flag_test(bm, l->f, FACE_OLD)) {
- lorig = l;
- break;
- }
- }
-
- if (!lorig)
- continue;
-
- BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
- BMLoop *l2 = l->v == v ? l : l->next;
-
- BM_elem_attrs_copy(bm, bm, lorig->f, l2->f);
- BM_elem_attrs_copy(bm, bm, lorig, l2);
- }
- }
- }
-#if 0
- /* clean up any remaining 2-edged face */
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (f->len == 2) {
- BMFace *faces[2] = {f, BM_FACE_FIRST_LOOP(f)->radial_next->f};
-
- if (faces[0] == faces[1])
- BM_face_kill(bm, f);
- else
- BM_faces_join(bm, faces, 2);
- }
- }
-#endif
- BMO_op_callf(bm, op->flag, "delete geom=%fv context=%i", BEVEL_DEL, DEL_VERTS);
+ BM_mesh_bevel(bm, offset, seg);
- /* clean up any edges that might not get properly delete */
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BMO_elem_flag_test(bm, e, EDGE_OLD) && !e->l)
- BMO_elem_flag_enable(bm, e, BEVEL_DEL);
+ BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
}
-
- BMO_op_callf(bm, op->flag, "delete geom=%fe context=%i", BEVEL_DEL, DEL_EDGES);
- BMO_op_callf(bm, op->flag, "delete geom=%ff context=%i", BEVEL_DEL, DEL_FACES);
-
- BLI_smallhash_release(&hash);
- BLI_array_free(tags);
- BLI_array_free(etags);
- BLI_array_free(verts);
- BLI_array_free(edges);
- BLI_array_free(faces);
-
- BMO_slot_buffer_from_enabled_flag(bm, op, "face_spans", BM_FACE, FACE_SPAN);
- BMO_slot_buffer_from_enabled_flag(bm, op, "face_holes", BM_FACE, FACE_HOLE);
}
-#endif /* NEW_BEVEL */
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index ebd848ff8b2..b7bb57bb19d 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -52,7 +52,7 @@ void bmo_connect_verts_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(verts_pair);
int i;
- BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_INPUT);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_INPUT);
for (f = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); f; f = BM_iter_step(&iter)) {
BLI_array_empty(loops_split);
@@ -117,7 +117,7 @@ void bmo_connect_verts_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_OUT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT);
BLI_array_free(loops_split);
BLI_array_free(verts_pair);
@@ -219,12 +219,12 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
int c = 0, cl1 = 0, cl2 = 0;
/* merge-bridge support */
- const int use_merge = BMO_slot_bool_get(op, "use_merge");
- const float merge_factor = BMO_slot_float_get(op, "merge_factor");
+ const int use_merge = BMO_slot_bool_get(op->slots_in, "use_merge");
+ const float merge_factor = BMO_slot_float_get(op->slots_in, "merge_factor");
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (!BMO_elem_flag_test(bm, e, EDGE_DONE)) {
BMVert *v, *ov;
/* BMEdge *e2, *e3, *oe = e; */ /* UNUSED */
@@ -523,7 +523,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_OUT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_OUT);
cleanup:
BLI_array_free(ee1);
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index 093f567d995..987aa8cdf99 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -168,7 +168,7 @@ static void rotsys_reverse(BMEdge *UNUSED(e), BMVert *v, EdgeData *edata, VertDa
BMEdge **edges = NULL;
BMEdge *e_first;
BMEdge *e;
- BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(edges, BM_DEFAULT_NGON_STACK_SIZE);
int i, totedge;
e = e_first = vdata[BM_elem_index_get(v)].e;
@@ -359,10 +359,10 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
BMIter iter;
BMEdge *e;
BMEdge **edges = NULL;
- BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(edges, BM_DEFAULT_NGON_STACK_SIZE);
BMVert *v;
/* BMVert **verts = NULL; */
- /* BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE); */ /* UNUSE */
+ /* BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE); */ /* UNUSE */
int i;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
@@ -741,7 +741,10 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E
BMVert *startv;
BMVert *endv;
EPathNode *node;
- int i, use_restrict = BMO_slot_bool_get(op, "use_restrict");
+ int i;
+ const int use_restrict = BMO_slot_bool_get(op->slots_in, "use_restrict");
+ BMOpSlot *slot_restrict = BMO_slot_get(op->slots_in, "restrict");
+
startv = edata[BM_elem_index_get(edge)].ftag ? edge->v2 : edge->v1;
endv = edata[BM_elem_index_get(edge)].ftag ? edge->v1 : edge->v2;
@@ -769,7 +772,7 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E
verts[i] = node->v;
}
- if (BM_face_exists(bm, verts, i, &f)) {
+ if (BM_face_exists(verts, i, &f)) {
if (!BMO_elem_flag_test(bm, f, FACE_IGNORE)) {
BLI_ghash_remove(gh, endv, NULL, NULL);
continue;
@@ -806,12 +809,13 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E
continue;
}
- if (use_restrict && BMO_slot_map_contains(bm, op, "restrict", e)) {
- int group = BMO_slot_map_int_get(bm, op, "restrict", e);
-
- if (!(group & path->group)) {
- v2 = NULL;
- continue;
+ if (use_restrict) {
+ int *group = (int *)BMO_slot_map_data_get(slot_restrict, e);
+ if (group) {
+ if (!(*group & path->group)) {
+ v2 = NULL;
+ continue;
+ }
}
}
@@ -895,12 +899,14 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
BMEdge **edges = NULL;
PathBase *pathbase;
BLI_array_declare(edges);
- int use_restrict = BMO_slot_bool_get(op, "use_restrict");
- int use_fill_check = BMO_slot_bool_get(op, "use_fill_check");
- const short mat_nr = BMO_slot_int_get(op, "mat_nr");
- const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
+ int use_restrict = BMO_slot_bool_get(op->slots_in, "use_restrict");
+ int use_fill_check = BMO_slot_bool_get(op->slots_in, "use_fill_check");
+ const short mat_nr = BMO_slot_int_get(op->slots_in, "mat_nr");
+ const short use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth");
int i, j, group = 0;
unsigned int winding[2]; /* accumulte winding directions for each edge which has a face */
+ BMOpSlot *slot_restrict = BMO_slot_get(op->slots_in, "restrict");
+ BMOpSlot *slot_face_groupmap_out = BMO_slot_get(op->slots_out, "face_groupmap.out");
if (!bm->totvert || !bm->totedge)
return;
@@ -910,8 +916,8 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
edata = MEM_callocN(sizeof(EdgeData) * bm->totedge, "EdgeData");
vdata = MEM_callocN(sizeof(VertData) * bm->totvert, "VertData");
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
- BMO_slot_buffer_flag_enable(bm, op, "excludefaces", BM_FACE, FACE_IGNORE);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "exclude_faces", BM_FACE, FACE_IGNORE);
BM_mesh_elem_index_ensure(bm, BM_VERT);
@@ -932,14 +938,14 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
bm->elem_index_dirty &= ~BM_EDGE;
init_rotsys(bm, edata, vdata);
-
+
while (1) {
edge = NULL;
group = 0;
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
/* if restrict is on, only start on faces in the restrict map */
- if (use_restrict && !BMO_slot_map_contains(bm, op, "restrict", e))
+ if (use_restrict && !BMO_slot_map_contains(slot_restrict, e))
continue;
if (edata[BM_elem_index_get(e)].tag < 2) {
@@ -948,7 +954,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
if (use_restrict) {
int i = 0, j = 0, gi = 0;
- group = BMO_slot_map_int_get(bm, op, "restrict", e);
+ group = BMO_slot_map_int_get(slot_restrict, e);
for (i = 0; i < 30; i++) {
if (group & (1 << i)) {
@@ -1055,7 +1061,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
}
if (use_restrict) {
- BMO_slot_map_int_insert(bm, op, "faceout_groupmap", f, path->group);
+ BMO_slot_map_int_insert(op, slot_face_groupmap_out, f, path->group);
}
}
}
@@ -1063,7 +1069,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
edge_free_path(pathbase, path);
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_NEW);
BLI_array_free(edges);
BLI_array_free(verts);
@@ -1103,11 +1109,11 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
int ok = 1;
int i, count;
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
/* validate that each edge has at most one other tagged edge in the
* disk cycle around each of it's vertices */
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
for (i = 0; i < 2; i++) {
count = BMO_vert_edge_flags_count(bm, i ? e->v2 : e->v1, EDGE_MARK);
if (count > 2) {
@@ -1129,7 +1135,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
/* find connected loops within the input edge */
count = 0;
while (1) {
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (!BMO_elem_flag_test(bm, e, EDGE_VIS)) {
if (BMO_vert_edge_flags_count(bm, e->v1, EDGE_MARK) == 1 ||
BMO_vert_edge_flags_count(bm, e->v2, EDGE_MARK) == 1)
@@ -1260,7 +1266,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_NEW);
BLI_array_free(edges1);
BLI_array_free(edges2);
@@ -1280,11 +1286,11 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
BMFace *f;
int totv = 0, tote = 0, totf = 0, amount;
- const short mat_nr = BMO_slot_int_get(op, "mat_nr");
- const short use_smooth = BMO_slot_bool_get(op, "use_smooth");
+ const short mat_nr = BMO_slot_int_get(op->slots_in, "mat_nr");
+ const short use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth");
/* count number of each element type we were passe */
- BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT | BM_EDGE | BM_FACE) {
+ BMO_ITER (h, &oiter, op->slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE) {
switch (h->htype) {
case BM_VERT: totv++; break;
case BM_EDGE: tote++; break;
@@ -1318,7 +1324,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
int ok = TRUE;
- BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) {
+ BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) {
/* count how many flagged edges this vertex uses */
int tot_edges = 0;
BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
@@ -1366,7 +1372,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
/* call edgenet prepare op so additional face creation cases wore */
BMO_op_initf(bm, &op2, op->flag, "edgenet_prepare edges=%fe", ELE_NEW);
BMO_op_exec(bm, &op2);
- BMO_slot_buffer_flag_enable(bm, &op2, "edgeout", BM_EDGE, ELE_NEW);
+ BMO_slot_buffer_flag_enable(bm, op2.slots_out, "edges.out", BM_EDGE, ELE_NEW);
BMO_op_finish(bm, &op2);
BMO_op_initf(bm, &op2, op->flag,
@@ -1376,8 +1382,9 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
BMO_op_exec(bm, &op2);
/* return if edge net create did something */
- if (BMO_slot_buffer_count(bm, &op2, "faceout")) {
- BMO_slot_copy(&op2, op, "faceout", "faceout");
+ if (BMO_slot_buffer_count(op2.slots_out, "faces.out")) {
+ BMO_slot_copy(&op2, slots_out, "faces.out",
+ op, slots_out, "faces.out");
BMO_op_finish(bm, &op2);
return;
}
@@ -1389,8 +1396,9 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
BMO_op_exec(bm, &op2);
/* if we dissolved anything, then return */
- if (BMO_slot_buffer_count(bm, &op2, "regionout")) {
- BMO_slot_copy(&op2, op, "regionout", "faceout");
+ if (BMO_slot_buffer_count(op2.slots_out, "region.out")) {
+ BMO_slot_copy(&op2, slots_out, "region.out",
+ op, slots_out, "faces.out");
BMO_op_finish(bm, &op2);
return;
}
@@ -1414,7 +1422,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
/* create edge */
e = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE);
BMO_elem_flag_enable(bm, e, ELE_OUT);
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_OUT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
}
else if (0) { /* nice feature but perhaps it should be a different tool? */
@@ -1460,7 +1468,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
}
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, ELE_OUT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
/* done creating edges */
}
else if (amount > 2) {
@@ -1470,7 +1478,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
BMVert **vert_arr = MEM_mallocN(sizeof(BMVert **) * totv, __func__);
int i = 0;
- BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) {
+ BMO_ITER (v, &oiter, op->slots_in, "geom", BM_VERT) {
vert_arr[i] = v;
i++;
}
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 9addb1b1657..7c3bcd60daa 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -85,7 +85,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BMWalker regwalker;
int i;
- int use_verts = BMO_slot_bool_get(op, "use_verts");
+ int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts");
if (use_verts) {
/* tag verts that start out with only 2 edges,
@@ -98,10 +98,10 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_flag_enable(bm, op, "faces", BM_FACE, FACE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_MARK);
/* collect region */
- BMO_ITER (f, &oiter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
if (!BMO_elem_flag_test(bm, f, FACE_MARK)) {
continue;
@@ -184,7 +184,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
goto cleanup;
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "regionout", BM_FACE, FACE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "region.out", BM_FACE, FACE_NEW);
cleanup:
/* free/cleanup */
@@ -208,7 +208,7 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op)
int i;
- BMO_ITER (e, &oiter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &oiter, op->slots_in, "edges", BM_EDGE) {
if (BM_edge_face_pair(e, &fa, &fb)) {
BMO_elem_flag_enable(bm, e->v1, VERT_MARK);
BMO_elem_flag_enable(bm, e->v2, VERT_MARK);
@@ -237,7 +237,7 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op)
//BMO_op_initf(bm, &fop, "dissolve_faces faces=%ff", FACE_MARK);
//BMO_op_exec(bm, &fop);
- //BMO_slot_copy(op, &fop, "regionout", "regionout");
+ //BMO_slot_copy(op, &fop, "region.out", "region.out");
//BMO_op_finish(bm, &fop);
}
@@ -254,7 +254,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
BMIter viter;
BMVert *v;
- int use_verts = BMO_slot_bool_get(op, "use_verts");
+ int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts");
if (use_verts) {
BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
@@ -262,7 +262,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_ITER (e, &eiter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &eiter, op->slots_in, "edges", BM_EDGE) {
BMFace *fa, *fb;
if (BM_edge_face_pair(e, &fa, &fb)) {
@@ -338,7 +338,7 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op)
BMFace *f;
/* int i; */
- BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_MARK);
for (v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v = BM_iter_step(&iter)) {
if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
@@ -479,13 +479,13 @@ void dummy_exec(BMesh *bm, BMOperator *op)
/* Limited Dissolve */
void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
{
- BMOpSlot *einput = BMO_slot_get(op, "edges");
- BMOpSlot *vinput = BMO_slot_get(op, "verts");
+ BMOpSlot *einput = BMO_slot_get(op->slots_in, "edges");
+ BMOpSlot *vinput = BMO_slot_get(op->slots_in, "verts");
const float angle_max = (float)M_PI / 2.0f;
- const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op, "angle_limit"));
- const int do_dissolve_boundaries = BMO_slot_bool_get(op, "use_dissolve_boundaries");
+ const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op->slots_in, "angle_limit"));
+ const int do_dissolve_boundaries = BMO_slot_bool_get(op->slots_in, "use_dissolve_boundaries");
BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
- vinput->data.p, vinput->len,
- einput->data.p, einput->len);
+ (BMVert **)BMO_SLOT_AS_BUFFER(vinput), vinput->len,
+ (BMEdge **)BMO_SLOT_AS_BUFFER(einput), einput->len);
}
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index 32270007a0b..c4f6c821320 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -68,7 +68,9 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar
*
* Copy an existing edge from one bmesh to another.
*/
-static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh,
+static BMEdge *copy_edge(BMOperator *op,
+ BMOpSlot *slot_boundarymap_out,
+ BMesh *source_mesh,
BMEdge *source_edge, BMesh *target_mesh,
GHash *vhash, GHash *ehash)
{
@@ -102,7 +104,7 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh,
if (rlen < 2) {
/* not sure what non-manifold cases of greater then three
* radial should do. */
- BMO_slot_map_ptr_insert(source_mesh, op, "boundarymap",
+ BMO_slot_map_ptr_insert(op, slot_boundarymap_out,
source_edge, target_edge);
}
@@ -124,7 +126,9 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh,
* Copy an existing face from one bmesh to another.
*/
-static BMFace *copy_face(BMOperator *op, BMesh *source_mesh,
+static BMFace *copy_face(BMOperator *op,
+ BMOpSlot *slot_facemap_out,
+ BMesh *source_mesh,
BMFace *source_face, BMesh *target_mesh,
BMVert **vtar, BMEdge **edar, GHash *vhash, GHash *ehash)
{
@@ -151,11 +155,11 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh,
vtar[i] = BLI_ghash_lookup(vhash, source_loop->v);
edar[i] = BLI_ghash_lookup(ehash, source_loop->e);
}
-
+
/* create new face */
target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, FALSE);
- BMO_slot_map_ptr_insert(source_mesh, op, "facemap", source_face, target_face);
- BMO_slot_map_ptr_insert(source_mesh, op, "facemap", target_face, source_face);
+ BMO_slot_map_ptr_insert(op, slot_facemap_out, source_face, target_face);
+ BMO_slot_map_ptr_insert(op, slot_facemap_out, target_face, source_face);
BM_elem_attrs_copy(source_mesh, target_mesh, source_face, target_face);
@@ -181,7 +185,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh,
* Internal Copy function.
*/
-static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
+static void bmo_mesh_copy(BMOperator *op, BMesh *bm_src, BMesh *bm_dst)
{
BMVert *v = NULL, *v2;
@@ -196,22 +200,26 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
BMIter viter, eiter, fiter;
GHash *vhash, *ehash;
+ BMOpSlot *slot_boundarymap_out = BMO_slot_get(op->slots_out, "boundarymap.out");
+ BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "facemap.out");
+ BMOpSlot *slot_isovertmap_out = BMO_slot_get(op->slots_out, "isovertmap.out");
+
/* initialize pointer hashes */
vhash = BLI_ghash_ptr_new("bmesh dupeops v");
ehash = BLI_ghash_ptr_new("bmesh dupeops e");
/* duplicate flagged vertices */
- BM_ITER_MESH (v, &viter, source, BM_VERTS_OF_MESH) {
- if (BMO_elem_flag_test(source, v, DUPE_INPUT) &&
- !BMO_elem_flag_test(source, v, DUPE_DONE))
+ BM_ITER_MESH (v, &viter, bm_src, BM_VERTS_OF_MESH) {
+ if (BMO_elem_flag_test(bm_src, v, DUPE_INPUT) &&
+ !BMO_elem_flag_test(bm_src, v, DUPE_DONE))
{
BMIter iter;
int isolated = 1;
- v2 = copy_vertex(source, v, target, vhash);
+ v2 = copy_vertex(bm_src, v, bm_dst, vhash);
BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) {
- if (BMO_elem_flag_test(source, f, DUPE_INPUT)) {
+ if (BMO_elem_flag_test(bm_src, f, DUPE_INPUT)) {
isolated = 0;
break;
}
@@ -219,7 +227,7 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
if (isolated) {
BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
- if (BMO_elem_flag_test(source, e, DUPE_INPUT)) {
+ if (BMO_elem_flag_test(bm_src, e, DUPE_INPUT)) {
isolated = 0;
break;
}
@@ -227,49 +235,49 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
}
if (isolated) {
- BMO_slot_map_ptr_insert(source, op, "isovertmap", v, v2);
+ BMO_slot_map_ptr_insert(op, slot_isovertmap_out, v, v2);
}
- BMO_elem_flag_enable(source, v, DUPE_DONE);
+ BMO_elem_flag_enable(bm_src, v, DUPE_DONE);
}
}
/* now we dupe all the edges */
- BM_ITER_MESH (e, &eiter, source, BM_EDGES_OF_MESH) {
- if (BMO_elem_flag_test(source, e, DUPE_INPUT) &&
- !BMO_elem_flag_test(source, e, DUPE_DONE))
+ BM_ITER_MESH (e, &eiter, bm_src, BM_EDGES_OF_MESH) {
+ if (BMO_elem_flag_test(bm_src, e, DUPE_INPUT) &&
+ !BMO_elem_flag_test(bm_src, e, DUPE_DONE))
{
/* make sure that verts are copied */
- if (!BMO_elem_flag_test(source, e->v1, DUPE_DONE)) {
- copy_vertex(source, e->v1, target, vhash);
- BMO_elem_flag_enable(source, e->v1, DUPE_DONE);
+ if (!BMO_elem_flag_test(bm_src, e->v1, DUPE_DONE)) {
+ copy_vertex(bm_src, e->v1, bm_dst, vhash);
+ BMO_elem_flag_enable(bm_src, e->v1, DUPE_DONE);
}
- if (!BMO_elem_flag_test(source, e->v2, DUPE_DONE)) {
- copy_vertex(source, e->v2, target, vhash);
- BMO_elem_flag_enable(source, e->v2, DUPE_DONE);
+ if (!BMO_elem_flag_test(bm_src, e->v2, DUPE_DONE)) {
+ copy_vertex(bm_src, e->v2, bm_dst, vhash);
+ BMO_elem_flag_enable(bm_src, e->v2, DUPE_DONE);
}
/* now copy the actual edge */
- copy_edge(op, source, e, target, vhash, ehash);
- BMO_elem_flag_enable(source, e, DUPE_DONE);
+ copy_edge(op, slot_boundarymap_out, bm_src, e, bm_dst, vhash, ehash);
+ BMO_elem_flag_enable(bm_src, e, DUPE_DONE);
}
}
/* first we dupe all flagged faces and their elements from source */
- BM_ITER_MESH (f, &fiter, source, BM_FACES_OF_MESH) {
- if (BMO_elem_flag_test(source, f, DUPE_INPUT)) {
+ BM_ITER_MESH (f, &fiter, bm_src, BM_FACES_OF_MESH) {
+ if (BMO_elem_flag_test(bm_src, f, DUPE_INPUT)) {
/* vertex pass */
BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) {
- if (!BMO_elem_flag_test(source, v, DUPE_DONE)) {
- copy_vertex(source, v, target, vhash);
- BMO_elem_flag_enable(source, v, DUPE_DONE);
+ if (!BMO_elem_flag_test(bm_src, v, DUPE_DONE)) {
+ copy_vertex(bm_src, v, bm_dst, vhash);
+ BMO_elem_flag_enable(bm_src, v, DUPE_DONE);
}
}
/* edge pass */
BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) {
- if (!BMO_elem_flag_test(source, e, DUPE_DONE)) {
- copy_edge(op, source, e, target, vhash, ehash);
- BMO_elem_flag_enable(source, e, DUPE_DONE);
+ if (!BMO_elem_flag_test(bm_src, e, DUPE_DONE)) {
+ copy_edge(op, slot_boundarymap_out, bm_src, e, bm_dst, vhash, ehash);
+ BMO_elem_flag_enable(bm_src, e, DUPE_DONE);
}
}
@@ -280,8 +288,8 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
BLI_array_grow_items(vtar, f->len);
BLI_array_grow_items(edar, f->len);
- copy_face(op, source, f, target, vtar, edar, vhash, ehash);
- BMO_elem_flag_enable(source, f, DUPE_DONE);
+ copy_face(op, slot_facemap_out, bm_src, f, bm_dst, vtar, edar, vhash, ehash);
+ BMO_elem_flag_enable(bm_src, f, DUPE_DONE);
}
}
@@ -317,23 +325,24 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
void bmo_duplicate_exec(BMesh *bm, BMOperator *op)
{
BMOperator *dupeop = op;
- BMesh *bm2 = BMO_slot_ptr_get(op, "dest");
+ BMesh *bm2 = BMO_slot_ptr_get(op->slots_in, "dest");
if (!bm2)
bm2 = bm;
/* flag input */
- BMO_slot_buffer_flag_enable(bm, dupeop, "geom", BM_ALL, DUPE_INPUT);
+ BMO_slot_buffer_flag_enable(bm, dupeop->slots_in, "geom", BM_ALL, DUPE_INPUT);
/* use the internal copy function */
- BKE_mesh_copy(dupeop, bm, bm2);
+ bmo_mesh_copy(dupeop, bm, bm2);
/* Output */
/* First copy the input buffers to output buffers - original data */
- BMO_slot_copy(dupeop, dupeop, "geom", "origout");
+ BMO_slot_copy(dupeop, slots_in, "geom",
+ dupeop, slots_out, "geom_orig.out");
/* Now alloc the new output buffers */
- BMO_slot_buffer_from_enabled_flag(bm, dupeop, "newout", BM_ALL, DUPE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, dupeop, dupeop->slots_out, "geom.out", BM_ALL, DUPE_NEW);
}
#if 0 /* UNUSED */
@@ -378,16 +387,17 @@ void bmo_split_exec(BMesh *bm, BMOperator *op)
BMOperator *splitop = op;
BMOperator dupeop;
BMOperator delop;
- const short use_only_faces = BMO_slot_bool_get(op, "use_only_faces");
+ const short use_only_faces = BMO_slot_bool_get(op->slots_in, "use_only_faces");
/* initialize our sub-operator */
BMO_op_init(bm, &dupeop, op->flag, "duplicate");
BMO_op_init(bm, &delop, op->flag, "delete");
- BMO_slot_copy(splitop, &dupeop, "geom", "geom");
+ BMO_slot_copy(splitop, slots_in, "geom",
+ &dupeop, slots_in, "geom");
BMO_op_exec(bm, &dupeop);
- BMO_slot_buffer_flag_enable(bm, splitop, "geom", BM_ALL, SPLIT_INPUT);
+ BMO_slot_buffer_flag_enable(bm, splitop->slots_in, "geom", BM_ALL, SPLIT_INPUT);
if (use_only_faces) {
BMVert *v;
@@ -427,16 +437,22 @@ void bmo_split_exec(BMesh *bm, BMOperator *op)
}
/* connect outputs of dupe to delete, exluding keep geometry */
- BMO_slot_int_set(&delop, "context", DEL_FACES);
- BMO_slot_buffer_from_enabled_flag(bm, &delop, "geom", BM_ALL, SPLIT_INPUT);
+ BMO_slot_int_set(delop.slots_in, "context", DEL_FACES);
+ BMO_slot_buffer_from_enabled_flag(bm, &delop, delop.slots_in, "geom", BM_ALL, SPLIT_INPUT);
BMO_op_exec(bm, &delop);
/* now we make our outputs by copying the dupe output */
- BMO_slot_copy(&dupeop, splitop, "newout", "geomout");
- BMO_slot_copy(&dupeop, splitop, "boundarymap", "boundarymap");
- BMO_slot_copy(&dupeop, splitop, "isovertmap", "isovertmap");
-
+ BMO_slot_copy(&dupeop, slots_out, "geom.out",
+ splitop, slots_out, "geom.out");
+
+ BMO_slot_copy(&dupeop, slots_out, "boundarymap.out",
+ splitop, slots_out, "boundarymap.out");
+
+ BMO_slot_copy(&dupeop, slots_out, "isovertmap.out",
+ splitop, slots_out, "isovertmap.out");
+
+
/* cleanup */
BMO_op_finish(bm, &delop);
BMO_op_finish(bm, &dupeop);
@@ -450,9 +466,9 @@ void bmo_delete_exec(BMesh *bm, BMOperator *op)
BMOperator *delop = op;
/* Mark Buffer */
- BMO_slot_buffer_flag_enable(bm, delop, "geom", BM_ALL, DEL_INPUT);
+ BMO_slot_buffer_flag_enable(bm, delop->slots_in, "geom", BM_ALL, DEL_INPUT);
- BMO_remove_tagged_context(bm, DEL_INPUT, BMO_slot_int_get(op, "context"));
+ BMO_remove_tagged_context(bm, DEL_INPUT, BMO_slot_int_get(op->slots_in, "context"));
#undef DEL_INPUT
}
@@ -473,44 +489,47 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
float phi;
int steps, do_dupli, a, usedvec;
- BMO_slot_vec_get(op, "cent", cent);
- BMO_slot_vec_get(op, "axis", axis);
+ BMO_slot_vec_get(op->slots_in, "cent", cent);
+ BMO_slot_vec_get(op->slots_in, "axis", axis);
normalize_v3(axis);
- BMO_slot_vec_get(op, "dvec", dvec);
+ BMO_slot_vec_get(op->slots_in, "dvec", dvec);
usedvec = !is_zero_v3(dvec);
- steps = BMO_slot_int_get(op, "steps");
- phi = BMO_slot_float_get(op, "ang") * DEG2RADF(1.0f) / steps;
- do_dupli = BMO_slot_bool_get(op, "do_dupli");
+ steps = BMO_slot_int_get(op->slots_in, "steps");
+ phi = BMO_slot_float_get(op->slots_in, "angle") * DEG2RADF(1.0f) / steps;
+ do_dupli = BMO_slot_bool_get(op->slots_in, "use_duplicate");
axis_angle_to_mat3(rmat, axis, phi);
- BMO_slot_copy(op, op, "geom", "lastout");
+ BMO_slot_copy(op, slots_in, "geom",
+ op, slots_out, "geom_last.out");
for (a = 0; a < steps; a++) {
if (do_dupli) {
- BMO_op_initf(bm, &dupop, op->flag, "duplicate geom=%s", op, "lastout");
+ BMO_op_initf(bm, &dupop, op->flag, "duplicate geom=%S", op, "geom_last.out");
BMO_op_exec(bm, &dupop);
BMO_op_callf(bm, op->flag,
- "rotate cent=%v mat=%m3 verts=%s",
- cent, rmat, &dupop, "newout");
- BMO_slot_copy(&dupop, op, "newout", "lastout");
+ "rotate cent=%v mat=%m3 verts=%S",
+ cent, rmat, &dupop, "geom.out");
+ BMO_slot_copy(&dupop, slots_out, "geom.out",
+ op, slots_out, "geom_last.out");
BMO_op_finish(bm, &dupop);
}
else {
- BMO_op_initf(bm, &extop, op->flag, "extrude_face_region edgefacein=%s",
- op, "lastout");
+ BMO_op_initf(bm, &extop, op->flag, "extrude_face_region geom=%S",
+ op, "geom_last.out");
BMO_op_exec(bm, &extop);
BMO_op_callf(bm, op->flag,
- "rotate cent=%v mat=%m3 verts=%s",
- cent, rmat, &extop, "geomout");
- BMO_slot_copy(&extop, op, "geomout", "lastout");
+ "rotate cent=%v mat=%m3 verts=%S",
+ cent, rmat, &extop, "geom.out");
+ BMO_slot_copy(&extop, slots_out, "geom.out",
+ op, slots_out, "geom_last.out");
BMO_op_finish(bm, &extop);
}
if (usedvec) {
mul_m3_v3(rmat, dvec);
BMO_op_callf(bm, op->flag,
- "translate vec=%v verts=%s",
- dvec, op, "lastout");
+ "translate vec=%v verts=%S",
+ dvec, op, "geom_last.out");
}
}
}
diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c
index 1f6689ed06c..9e9e4b8c962 100644
--- a/source/blender/bmesh/operators/bmo_edgesplit.c
+++ b/source/blender/bmesh/operators/bmo_edgesplit.c
@@ -81,14 +81,14 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op)
/* single marked edges unconnected to any other marked edges
* are illegal, go through and unmark them */
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
/* lame, but we don't want the count to exceed 255,
* so just count to 2, its all we need */
unsigned char *vt;
vt = &vtouch[BM_elem_index_get(e->v1)]; if (*vt < 2) (*vt)++;
vt = &vtouch[BM_elem_index_get(e->v2)]; if (*vt < 2) (*vt)++;
}
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (vtouch[BM_elem_index_get(e->v1)] == 1 &&
vtouch[BM_elem_index_get(e->v2)] == 1)
{
@@ -104,13 +104,13 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
{
BMOIter siter;
BMEdge *e;
- const int use_verts = BMO_slot_bool_get(op, "use_verts");
+ const int use_verts = BMO_slot_bool_get(op->slots_in, "use_verts");
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_SEAM);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_SEAM);
if (use_verts) {
/* this slows down the operation but its ok because the modifier doesn't use */
- BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_SEAM);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_SEAM);
/* prevent one edge having both verts unflagged
* we could alternately disable these edges, either way its a corner case.
@@ -118,7 +118,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
* This is needed so we don't split off the edge but then none of its verts which
* would leave a duplicate edge.
*/
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (UNLIKELY((BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE &&
(BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE))))
{
@@ -130,7 +130,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
bm_edgesplit_validate_seams(bm, op);
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) {
/* this flag gets copied so we can be sure duplicate edges get it too (important) */
BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG);
@@ -146,7 +146,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
}
if (use_verts) {
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE) {
BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
}
@@ -156,7 +156,7 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) {
if (BM_elem_flag_test(e->v1, BM_ELEM_TAG)) {
BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
@@ -169,5 +169,5 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_hflag(bm, op, "edgeout", BM_EDGE, BM_ELEM_INTERNAL_TAG);
+ BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_INTERNAL_TAG);
}
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 627351ead11..6a9d9c1e48b 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -60,7 +60,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(edges);
int i;
- BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
BLI_array_empty(edges);
BLI_array_grow_items(edges, f->len);
@@ -122,7 +122,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
BMO_op_callf(bm, op->flag,
"delete geom=%ff context=%i",
EXT_DEL, DEL_ONLYFACES);
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, EXT_KEEP);
}
/**
@@ -181,7 +181,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
BMFace *f;
BMEdge *e, *e_new;
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
BMO_elem_flag_enable(bm, e, EXT_INPUT);
BMO_elem_flag_enable(bm, e->v1, EXT_INPUT);
BMO_elem_flag_enable(bm, e->v2, EXT_INPUT);
@@ -193,12 +193,12 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
/* disable root flag on all new skin nodes */
if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
BMVert *v;
- BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) {
+ BMO_ITER(v, &siter, dupeop.slots_out, "geom.out", BM_VERT) {
bm_extrude_disable_skin_root(bm, v);
}
}
- for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) {
+ for (e = BMO_iter_new(&siter, dupeop.slots_out, "boundarymap.out", 0); e; e = BMO_iter_step(&siter)) {
BMVert *f_verts[4];
e_new = *(BMEdge **)BMO_iter_map_value(&siter);
@@ -230,7 +230,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
BMO_op_finish(bm, &dupeop);
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, EXT_KEEP);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, EXT_KEEP);
}
void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
@@ -240,7 +240,7 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
const int has_vskin = CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN);
- for (v = BMO_iter_new(&siter, bm, op, "verts", BM_VERT); v; v = BMO_iter_step(&siter)) {
+ for (v = BMO_iter_new(&siter, op->slots_in, "verts", BM_VERT); v; v = BMO_iter_step(&siter)) {
dupev = BM_vert_create(bm, v->co, v);
if (has_vskin)
bm_extrude_disable_skin_root(bm, v);
@@ -251,8 +251,8 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_enable(bm, dupev, EXT_KEEP);
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, EXT_KEEP);
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EXT_KEEP);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, EXT_KEEP);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EXT_KEEP);
}
void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
@@ -264,15 +264,17 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
BMVert *v, *v2;
BMFace *f;
int found, fwd, delorig = FALSE;
+ BMOpSlot *slot_facemap_out;
+ BMOpSlot *slot_edges_exclude;
/* initialize our sub-operators */
BMO_op_init(bm, &dupeop, op->flag, "duplicate");
- BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE | BM_FACE, EXT_INPUT);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_EDGE | BM_FACE, EXT_INPUT);
/* if one flagged face is bordered by an un-flagged face, then we delete
* original geometry unless caller explicitly asked to keep it. */
- if (!BMO_slot_bool_get(op, "alwayskeeporig")) {
+ if (!BMO_slot_bool_get(op->slots_in, "use_keep_orig")) {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
int edge_face_tot;
@@ -339,18 +341,21 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
EXT_DEL, DEL_ONLYTAGGED);
}
- BMO_slot_copy(op, &dupeop, "edgefacein", "geom");
+ BMO_slot_copy(op, slots_in, "geom",
+ &dupeop, slots_in, "geom");
BMO_op_exec(bm, &dupeop);
/* disable root flag on all new skin nodes */
if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) {
- BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) {
+ BMO_ITER(v, &siter, dupeop.slots_out, "geom.out", BM_VERT) {
bm_extrude_disable_skin_root(bm, v);
}
}
- if (bm->act_face && BMO_elem_flag_test(bm, bm->act_face, EXT_INPUT))
- bm->act_face = BMO_slot_map_ptr_get(bm, &dupeop, "facemap", bm->act_face);
+ slot_facemap_out = BMO_slot_get(dupeop.slots_out, "facemap.out");
+ if (bm->act_face && BMO_elem_flag_test(bm, bm->act_face, EXT_INPUT)) {
+ bm->act_face = BMO_slot_map_ptr_get(slot_facemap_out, bm->act_face);
+ }
if (delorig) {
BMO_op_exec(bm, &delop);
@@ -365,13 +370,15 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_copy(&dupeop, op, "newout", "geomout");
+ BMO_slot_copy(&dupeop, slots_out, "geom.out",
+ op, slots_out, "geom.out");
- for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) {
+ slot_edges_exclude = BMO_slot_get(op->slots_in, "edges_exclude");
+ for (e = BMO_iter_new(&siter, dupeop.slots_out, "boundarymap.out", 0); e; e = BMO_iter_step(&siter)) {
BMVert *f_verts[4];
/* this should always be wire, so this is mainly a speedup to avoid map lookup */
- if (BM_edge_is_wire(e) && BMO_slot_map_contains(bm, op, "exclude", e)) {
+ if (BM_edge_is_wire(e) && BMO_slot_map_contains(slot_edges_exclude, e)) {
BMVert *v1 = e->v1, *v2 = e->v2;
/* The original edge was excluded,
@@ -421,7 +428,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
}
/* link isolated vert */
- for (v = BMO_iter_new(&siter, bm, &dupeop, "isovertmap", 0); v; v = BMO_iter_step(&siter)) {
+ for (v = BMO_iter_new(&siter, dupeop.slots_out, "isovertmap.out", 0); v; v = BMO_iter_step(&siter)) {
v2 = *((void **)BMO_iter_map_value(&siter));
BM_edge_create(bm, v, v2, v->e, TRUE);
}
@@ -595,10 +602,10 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
/* array for passing verts to angle_poly_v3 */
float **verts = NULL;
- BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(verts, BM_DEFAULT_NGON_STACK_SIZE);
/* array for receiving angles from angle_poly_v3 */
float *face_angles = NULL;
- BLI_array_staticdeclare(face_angles, BM_NGON_STACK_SIZE);
+ BLI_array_staticdeclare(face_angles, BM_DEFAULT_NGON_STACK_SIZE);
BM_mesh_elem_index_ensure(bm, BM_VERT);
@@ -647,25 +654,28 @@ void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op)
BMOperator reverseop;
float thickness;
- thickness = BMO_slot_float_get(op, "thickness");
+ thickness = BMO_slot_float_get(op->slots_in, "thickness");
/* Flip original faces (so the shell is extruded inward) */
BMO_op_init(bm, &reverseop, op->flag, "reverse_faces");
- BMO_slot_copy(op, &reverseop, "geom", "faces");
+ BMO_slot_copy(op, slots_in, "geom",
+ &reverseop, slots_in, "faces");
BMO_op_exec(bm, &reverseop);
BMO_op_finish(bm, &reverseop);
/* Extrude the region */
- BMO_op_initf(bm, &extrudeop, op->flag, "extrude_face_region alwayskeeporig=%b", TRUE);
- BMO_slot_copy(op, &extrudeop, "geom", "edgefacein");
+ BMO_op_initf(bm, &extrudeop, op->flag, "extrude_face_region use_keep_orig=%b", TRUE);
+ BMO_slot_copy(op, slots_in, "geom",
+ &extrudeop, slots_in, "geom");
BMO_op_exec(bm, &extrudeop);
/* Push the verts of the extruded faces inward to create thickness */
- BMO_slot_buffer_flag_enable(bm, &extrudeop, "geomout", BM_FACE, FACE_MARK);
+ BMO_slot_buffer_flag_enable(bm, extrudeop.slots_out, "geom.out", BM_FACE, FACE_MARK);
calc_solidify_normals(bm);
solidify_add_thickness(bm, thickness);
- BMO_slot_copy(&extrudeop, op, "geomout", "geomout");
+ BMO_slot_copy(&extrudeop, slots_out, "geom.out",
+ op, slots_out, "geom.out");
BMO_op_finish(bm, &extrudeop);
}
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index b9c9398fbfa..117f65ae4ea 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -119,7 +119,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
};
BMFace *f, *example = NULL;
- if (BM_face_exists(bm, t->v, 3, &f)) {
+ if (BM_face_exists(t->v, 3, &f)) {
/* If the operator is run with "use_existing_faces"
* disabled, but an output face in the hull is the
* same as a face in the existing mesh, it should not
@@ -139,17 +139,17 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
f = BM_face_create_quad_tri_v(bm, t->v, 3, example, TRUE);
BM_face_copy_shared(bm, f);
}
- /* Mark face for 'geomout' slot and select */
+ /* Mark face for 'geom.out' slot and select */
BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM);
BM_face_select_set(bm, f, TRUE);
- /* Mark edges for 'geomout' slot */
+ /* Mark edges for 'geom.out' slot */
for (i = 0; i < 3; i++) {
BMO_elem_flag_enable(bm, edges[i], HULL_FLAG_OUTPUT_GEOM);
}
}
else {
- /* Mark input edges for 'geomout' slot */
+ /* Mark input edges for 'geom.out' slot */
for (i = 0; i < 3; i++) {
const int next = (i == 2 ? 0 : i + 1);
BMEdge *e = BM_edge_exists(t->v[i], t->v[next]);
@@ -161,7 +161,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
}
}
- /* Mark verts for 'geomout' slot */
+ /* Mark verts for 'geom.out' slot */
for (i = 0; i < 3; i++) {
BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM);
}
@@ -304,14 +304,14 @@ static void hull_mark_interior_elements(BMesh *bm, BMOperator *op,
BMOIter oiter;
/* Check for interior edges too */
- BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
+ BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) {
if (!hull_final_edges_lookup(final_edges, e->v1, e->v2))
BMO_elem_flag_enable(bm, e, HULL_FLAG_INTERIOR_ELE);
}
/* Mark all input faces as interior, some may be unmarked in
* hull_remove_overlapping() */
- BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) {
+ BMO_ITER (f, &oiter, op->slots_in, "input", BM_FACE) {
BMO_elem_flag_enable(bm, f, HULL_FLAG_INTERIOR_ELE);
}
}
@@ -328,7 +328,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op)
* interior (i.e. were already part of the input, but not part of
* the hull), but that aren't also used by elements outside the
* input set */
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) {
if (BMO_elem_flag_test(bm, v, HULL_FLAG_INTERIOR_ELE)) {
int del = TRUE;
@@ -351,7 +351,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op)
}
}
- BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
+ BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) {
if (BMO_elem_flag_test(bm, e, HULL_FLAG_INTERIOR_ELE)) {
int del = TRUE;
@@ -367,7 +367,7 @@ static void hull_tag_unused(BMesh *bm, BMOperator *op)
}
}
- BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) {
+ BMO_ITER (f, &oiter, op->slots_in, "input", BM_FACE) {
if (BMO_elem_flag_test(bm, f, HULL_FLAG_INTERIOR_ELE))
BMO_elem_flag_enable(bm, f, HULL_FLAG_DEL);
}
@@ -382,10 +382,10 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op)
/* Unmark any hole faces if they are isolated or part of a
* border */
- BMO_ITER (f, &oiter, bm, op, "input", BM_FACE) {
+ BMO_ITER (f, &oiter, op->slots_in, "input", BM_FACE) {
if (BMO_elem_flag_test(bm, f, HULL_FLAG_HOLE)) {
BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) {
- if (BM_edge_face_count(e) == 1) {
+ if (BM_edge_is_boundary(e)) {
BMO_elem_flag_disable(bm, f, HULL_FLAG_HOLE);
break;
}
@@ -395,7 +395,7 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op)
/* Mark edges too if all adjacent faces are holes and the edge is
* not already isolated */
- BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) {
+ BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) {
int hole = TRUE;
int any_faces = FALSE;
@@ -412,20 +412,20 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op)
}
}
-static int hull_input_vert_count(BMesh *bm, BMOperator *op)
+static int hull_input_vert_count(BMOperator *op)
{
BMOIter oiter;
BMVert *v;
int count = 0;
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) {
count++;
}
return count;
}
-static BMVert **hull_input_verts_copy(BMesh *bm, BMOperator *op,
+static BMVert **hull_input_verts_copy(BMOperator *op,
const int num_input_verts)
{
BMOIter oiter;
@@ -434,7 +434,7 @@ static BMVert **hull_input_verts_copy(BMesh *bm, BMOperator *op,
num_input_verts, AT);
int i = 0;
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) {
input_verts[i++] = v;
}
@@ -492,9 +492,9 @@ static void hull_from_bullet(BMesh *bm, BMOperator *op,
plConvexHull hull;
int i, count = 0;
- const int num_input_verts = hull_input_vert_count(bm, op);
+ const int num_input_verts = hull_input_vert_count(op);
- input_verts = hull_input_verts_copy(bm, op, num_input_verts);
+ input_verts = hull_input_verts_copy(op, num_input_verts);
coords = hull_verts_for_bullet(input_verts, num_input_verts);
hull = plConvexHullCompute(coords, num_input_verts);
@@ -535,13 +535,13 @@ static void hull_from_bullet(BMesh *bm, BMOperator *op,
}
/* Check that there are at least three vertices in the input */
-static int hull_num_input_verts_is_ok(BMesh *bm, BMOperator *op)
+static int hull_num_input_verts_is_ok(BMOperator *op)
{
BMOIter oiter;
BMVert *v;
int partial_num_verts = 0;
- BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) {
+ BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) {
partial_num_verts++;
if (partial_num_verts >= 3)
break;
@@ -559,14 +559,14 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
GHash *hull_triangles;
/* Verify that at least three verts in the input */
- if (!hull_num_input_verts_is_ok(bm, op)) {
+ if (!hull_num_input_verts_is_ok(op)) {
BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED,
"Requires at least three vertices");
return;
}
/* Tag input elements */
- BMO_ITER (ele, &oiter, bm, op, "input", BM_ALL) {
+ BMO_ITER (ele, &oiter, op->slots_in, "input", BM_ALL) {
BMO_elem_flag_enable(bm, ele, HULL_FLAG_INPUT);
/* Mark all vertices as interior to begin with */
@@ -584,7 +584,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
hull_mark_interior_elements(bm, op, final_edges);
/* Remove hull triangles covered by an existing face */
- if (BMO_slot_bool_get(op, "use_existing_faces")) {
+ if (BMO_slot_bool_get(op->slots_in, "use_existing_faces")) {
hull_remove_overlapping(bm, hull_triangles, final_edges);
hull_tag_holes(bm, op);
@@ -603,23 +603,23 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
/* Output slot of input elements that ended up inside the hull
* rather than part of it */
- BMO_slot_buffer_from_enabled_flag(bm, op, "interior_geom", BM_ALL,
- HULL_FLAG_INTERIOR_ELE);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_interior.out",
+ BM_ALL, HULL_FLAG_INTERIOR_ELE);
/* Output slot of input elements that ended up inside the hull and
* are are unused by other geometry. */
- BMO_slot_buffer_from_enabled_flag(bm, op, "unused_geom", BM_ALL,
- HULL_FLAG_DEL);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_unused.out",
+ BM_ALL, HULL_FLAG_DEL);
/* Output slot of faces and edges that were in the input and on
* the hull (useful for cases like bridging where you want to
* delete some input geometry) */
- BMO_slot_buffer_from_enabled_flag(bm, op, "holes_geom", BM_ALL,
- HULL_FLAG_HOLE);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_holes.out",
+ BM_ALL, HULL_FLAG_HOLE);
/* Output slot of all hull vertices, faces, and edges */
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL,
- HULL_FLAG_OUTPUT_GEOM);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out",
+ BM_ALL, HULL_FLAG_OUTPUT_GEOM);
}
#endif /* WITH_BULLET */
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 132d7050b31..9abf129a529 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -92,13 +92,13 @@ static BMLoop *bm_edge_is_mixed_face_tag(BMLoop *l)
void bmo_inset_exec(BMesh *bm, BMOperator *op)
{
- const int use_outset = BMO_slot_bool_get(op, "use_outset");
- const int use_boundary = BMO_slot_bool_get(op, "use_boundary") && (use_outset == FALSE);
- const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset");
+ const int use_outset = BMO_slot_bool_get(op->slots_in, "use_outset");
+ const int use_boundary = BMO_slot_bool_get(op->slots_in, "use_boundary") && (use_outset == FALSE);
+ const int use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
const int use_even_boundry = use_even_offset; /* could make own option */
- const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset");
- const float thickness = BMO_slot_float_get(op, "thickness");
- const float depth = BMO_slot_float_get(op, "depth");
+ const int use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset");
+ const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
+ const float depth = BMO_slot_float_get(op->slots_in, "depth");
int edge_info_len = 0;
@@ -113,11 +113,11 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
if (use_outset == FALSE) {
BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE);
- BMO_slot_buffer_hflag_enable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE);
+ BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, FALSE);
}
else {
BM_mesh_elem_hflag_enable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE);
- BMO_slot_buffer_hflag_disable(bm, op, "faces", BM_FACE, BM_ELEM_TAG, FALSE);
+ BMO_slot_buffer_hflag_disable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, FALSE);
}
/* first count all inset edges we will split */
@@ -477,11 +477,48 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
/* copy for loop data, otherwise UV's and vcols are no good.
* tiny speedup here we could be more clever and copy from known adjacent data
* also - we could attempt to interpolate the loop data, this would be much slower but more useful too */
+#if 0
+ /* don't use this because face boundaries have no adjacent loops and won't be filled in.
+ * instead copy from the opposite side with the code below */
BM_face_copy_shared(bm, f);
+#else
+ {
+ /* 2 inner loops on the edge between the new face and the original */
+ BMLoop *l_a;
+ BMLoop *l_b;
+ BMLoop *l_a_other;
+ BMLoop *l_b_other;
+
+ l_a = BM_FACE_FIRST_LOOP(f);
+ l_b = l_a->next;
+
+ /* we know this side has a radial_next because of the order of created verts in the quad */
+ l_a_other = BM_edge_other_loop(l_a->e, l_a);
+ l_b_other = BM_edge_other_loop(l_a->e, l_b);
+ BM_elem_attrs_copy(bm, bm, l_a_other, l_a);
+ BM_elem_attrs_copy(bm, bm, l_b_other, l_b);
+
+ /* step around to the opposite side of the quad - warning, this may have no other edges! */
+ l_a = l_a->next->next;
+ l_b = l_a->next;
+ if (!BM_edge_is_boundary(l_a->e)) {
+ /* same as above */
+ l_a_other = BM_edge_other_loop(l_a->e, l_a);
+ l_b_other = BM_edge_other_loop(l_a->e, l_b);
+ BM_elem_attrs_copy(bm, bm, l_a_other, l_a);
+ BM_elem_attrs_copy(bm, bm, l_b_other, l_b);
+ }
+ else { /* boundary edges have no useful data to copy from, use opposite side of face */
+ /* swap a<->b intentionally */
+ BM_elem_attrs_copy(bm, bm, l_a_other, l_b);
+ BM_elem_attrs_copy(bm, bm, l_b_other, l_a);
+ }
+ }
+#endif
}
/* we could flag new edges/verts too, is it useful? */
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, ELE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_NEW);
/* cheap feature to add depth to the inset */
if (depth != 0.0f) {
@@ -514,7 +551,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE);
/* tag face verts */
- BMO_ITER (f, &oiter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) {
BM_elem_flag_enable(v, BM_ELEM_TAG);
}
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 3dbc0d0a5eb..1e18a83a0a0 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -204,16 +204,16 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
BLI_array_declare(jedges);
JoinEdge *jedges = NULL;
- int do_sharp = BMO_slot_bool_get(op, "cmp_sharp");
- int do_uv = BMO_slot_bool_get(op, "cmp_uvs");
+ int do_sharp = BMO_slot_bool_get(op->slots_in, "cmp_sharp");
+ int do_uv = BMO_slot_bool_get(op->slots_in, "cmp_uvs");
int do_tf = do_uv; /* texture face, make make its own option eventually */
- int do_vcol = BMO_slot_bool_get(op, "cmp_vcols");
- int do_mat = BMO_slot_bool_get(op, "cmp_materials");
- float limit = BMO_slot_float_get(op, "limit");
+ int do_vcol = BMO_slot_bool_get(op->slots_in, "cmp_vcols");
+ int do_mat = BMO_slot_bool_get(op->slots_in, "cmp_materials");
+ float limit = BMO_slot_float_get(op->slots_in, "limit");
int i, totedge;
/* flag all edges of all input face */
- BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
BMO_elem_flag_enable(bm, f, FACE_INPUT);
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
BMO_elem_flag_enable(bm, l->e, EDGE_MARK);
diff --git a/source/blender/bmesh/operators/bmo_mesh_conv.c b/source/blender/bmesh/operators/bmo_mesh_conv.c
index c4b988ae82d..4b897a24c8a 100644
--- a/source/blender/bmesh/operators/bmo_mesh_conv.c
+++ b/source/blender/bmesh/operators/bmo_mesh_conv.c
@@ -53,9 +53,9 @@
void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op)
{
- Object *ob = BMO_slot_ptr_get(op, "object");
- Mesh *me = BMO_slot_ptr_get(op, "mesh");
- int set_key = BMO_slot_bool_get(op, "set_shapekey");
+ Object *ob = BMO_slot_ptr_get(op->slots_in, "object");
+ Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh");
+ int set_key = BMO_slot_bool_get(op->slots_in, "use_shapekey");
BM_mesh_bm_from_me(bm, me, set_key, ob->shapenr);
@@ -66,20 +66,20 @@ void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op)
void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op)
{
- Object *ob = BMO_slot_ptr_get(op, "object");
+ Object *ob = BMO_slot_ptr_get(op->slots_in, "object");
/* Scene *scene = BMO_slot_ptr_get(op, "scene"); */
Mesh *me = ob->data;
BMO_op_callf(bm, op->flag,
- "bmesh_to_mesh mesh=%p object=%p notessellation=%b",
+ "bmesh_to_mesh mesh=%p object=%p skip_tessface=%b",
me, ob, TRUE);
}
void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op)
{
- Mesh *me = BMO_slot_ptr_get(op, "mesh");
+ Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh");
/* Object *ob = BMO_slot_ptr_get(op, "object"); */
- int dotess = !BMO_slot_bool_get(op, "notessellation");
+ int dotess = !BMO_slot_bool_get(op->slots_in, "skip_tessface");
BM_mesh_bm_to_me(bm, me, dotess);
}
diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c
index 937601712b0..01bce976ec0 100644
--- a/source/blender/bmesh/operators/bmo_mirror.c
+++ b/source/blender/bmesh/operators/bmo_mirror.c
@@ -50,27 +50,28 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
float mtx[4][4];
float imtx[4][4];
float scale[3] = {1.0f, 1.0f, 1.0f};
- float dist = BMO_slot_float_get(op, "mergedist");
+ float dist = BMO_slot_float_get(op->slots_in, "merge_dist");
int i, ototvert /*, ototedge */;
- int axis = BMO_slot_int_get(op, "axis");
- int mirroru = BMO_slot_bool_get(op, "mirror_u");
- int mirrorv = BMO_slot_bool_get(op, "mirror_v");
+ int axis = BMO_slot_int_get(op->slots_in, "axis");
+ int mirroru = BMO_slot_bool_get(op->slots_in, "mirror_u");
+ int mirrorv = BMO_slot_bool_get(op->slots_in, "mirror_v");
+ BMOpSlot *slot_targetmap;
ototvert = bm->totvert;
/* ototedge = bm->totedge; */ /* UNUSED */
- BMO_slot_mat4_get(op, "mat", mtx);
+ BMO_slot_mat4_get(op->slots_in, "mat", mtx);
invert_m4_m4(imtx, mtx);
BMO_op_initf(bm, &dupeop, op->flag, "duplicate geom=%s", op, "geom");
BMO_op_exec(bm, &dupeop);
- BMO_slot_buffer_flag_enable(bm, &dupeop, "newout", BM_ALL, ELE_NEW);
+ BMO_slot_buffer_flag_enable(bm, dupeop.slots_out, "geom.out", BM_ALL, ELE_NEW);
/* create old -> new mappin */
i = 0;
/* v2 = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); */ /* UNUSED */
- BMO_ITER (v, &siter, bm, &dupeop, "newout", BM_VERT) {
+ BMO_ITER (v, &siter, dupeop.slots_out, "geom.out", BM_VERT) {
BLI_array_grow_one(vmap);
vmap[i] = v;
/* v2 = BM_iter_step(&iter); */ /* UNUSED */
@@ -86,10 +87,12 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
+ slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
+
v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
for (i = 0; i < ototvert; i++) {
if (fabsf(v->co[axis]) <= dist) {
- BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", vmap[i], v);
+ BMO_slot_map_ptr_insert(&weldop, slot_targetmap, vmap[i], v);
}
v = BM_iter_step(&iter);
}
@@ -101,7 +104,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
int totlayer;
BMIter liter;
- BMO_ITER (f, &siter, bm, &dupeop, "newout", BM_FACE) {
+ BMO_ITER (f, &siter, dupeop.slots_out, "geom.out", BM_FACE) {
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
totlayer = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
for (i = 0; i < totlayer; i++) {
@@ -120,7 +123,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
BMO_op_finish(bm, &weldop);
BMO_op_finish(bm, &dupeop);
- BMO_slot_buffer_from_enabled_flag(bm, op, "newout", BM_ALL, ELE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, ELE_NEW);
BLI_array_free(vmap);
BLI_array_free(emap);
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index d7b163cb760..71f63bbaf28 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -227,16 +227,17 @@ static signed char monkeyf[250][4] = {
void bmo_create_grid_exec(BMesh *bm, BMOperator *op)
{
+ const float dia = BMO_slot_float_get(op->slots_in, "size");
+ const int tot = max_ii(2, BMO_slot_int_get(op->slots_in, "x_segments"));
+ const int seg = max_ii(2, BMO_slot_int_get(op->slots_in, "y_segments"));
+
BMOperator bmop, prevop;
BMVert *eve, *preveve;
BMEdge *e;
- float vec[3], mat[4][4], phi, phid, dia = BMO_slot_float_get(op, "size");
- int a, tot = BMO_slot_int_get(op, "xsegments"), seg = BMO_slot_int_get(op, "ysegments");
-
- if (tot < 2) tot = 2;
- if (seg < 2) seg = 2;
+ float vec[3], mat[4][4], phi, phid;
+ int a;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
/* one segment first: the X axis */
phi = 1.0f;
@@ -267,39 +268,43 @@ void bmo_create_grid_exec(BMesh *bm, BMOperator *op)
for (a = 0; a < seg - 1; a++) {
if (a) {
- BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%s", &prevop, "geomout");
+ BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%S", &prevop, "geom.out");
BMO_op_exec(bm, &bmop);
BMO_op_finish(bm, &prevop);
- BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK);
}
else {
BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%fe", EDGE_ORIG);
BMO_op_exec(bm, &bmop);
- BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK);
}
- BMO_op_callf(bm, op->flag, "translate vec=%v verts=%s", vec, &bmop, "geomout");
+ BMO_op_callf(bm, op->flag, "translate vec=%v verts=%S", vec, &bmop, "geom.out");
prevop = bmop;
}
if (a)
BMO_op_finish(bm, &bmop);
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
{
+ const float dia = BMO_slot_float_get(op->slots_in, "diameter");
+ const int seg = BMO_slot_int_get(op->slots_in, "u_segments");
+ const int tot = BMO_slot_int_get(op->slots_in, "v_segments");
+
BMOperator bmop, prevop;
BMVert *eve, *preveve;
BMEdge *e;
BMIter iter;
float vec[3], mat[4][4], cmat[3][3], phi, q[4];
- float phid, dia = BMO_slot_float_get(op, "diameter");
- int a, seg = BMO_slot_int_get(op, "segments"), tot = BMO_slot_int_get(op, "revolutions");
+ float phid;
+ int a;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
phid = 2.0f * (float)M_PI / tot;
/* phi = 0.25f * (float)M_PI; */ /* UNUSED */
@@ -333,7 +338,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
for (a = 0; a < seg; a++) {
if (a) {
- BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%s", &prevop, "geomout");
+ BMO_op_initf(bm, &bmop, op->flag, "extrude_edge_only edges=%S", &prevop, "geom.out");
BMO_op_exec(bm, &bmop);
BMO_op_finish(bm, &prevop);
}
@@ -342,8 +347,8 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
BMO_op_exec(bm, &bmop);
}
- BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK);
- BMO_op_callf(bm, op->flag, "rotate cent=%v mat=%m3 verts=%s", vec, cmat, &bmop, "geomout");
+ BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK);
+ BMO_op_callf(bm, op->flag, "rotate cent=%v mat=%m3 verts=%S", vec, cmat, &bmop, "geom.out");
prevop = bmop;
}
@@ -375,30 +380,33 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
{
+ const float dia = BMO_slot_float_get(op->slots_in, "diameter");
+ const float dia_div = dia / 200.0f;
+ const int subdiv = BMO_slot_int_get(op->slots_in, "subdivisions");
+
BMVert *eva[12];
BMVert *v;
BMIter liter;
BMIter viter;
BMLoop *l;
float vec[3], mat[4][4] /* , phi, phid */;
- float dia = BMO_slot_float_get(op, "diameter");
- int a, subdiv = BMO_slot_int_get(op, "subdivisions");
+ int a;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
/* phid = 2.0f * (float)M_PI / subdiv; */ /* UNUSED */
/* phi = 0.25f * (float)M_PI; */ /* UNUSED */
- dia /= 200.0f;
+
for (a = 0; a < 12; a++) {
- vec[0] = dia * icovert[a][0];
- vec[1] = dia * icovert[a][1];
- vec[2] = dia * icovert[a][2];
+ vec[0] = dia_div * icovert[a][0];
+ vec[1] = dia_div * icovert[a][1];
+ vec[2] = dia_div * icovert[a][2];
eva[a] = BM_vert_create(bm, vec, NULL);
BMO_elem_flag_enable(bm, eva[a], VERT_MARK);
@@ -421,22 +429,20 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_enable(bm, eftemp, FACE_MARK);
}
- dia *= 200.0f;
-
if (subdiv > 1) {
BMOperator bmop;
BMO_op_initf(bm, &bmop, op->flag,
"subdivide_edges edges=%fe "
"smooth=%f "
- "numcuts=%i "
+ "cuts=%i "
"use_gridfill=%b use_sphere=%b",
EDGE_MARK, dia, (1 << (subdiv - 1)) - 1,
TRUE, TRUE);
BMO_op_exec(bm, &bmop);
- BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_VERT, VERT_MARK);
- BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_EDGE, EDGE_MARK);
BMO_op_finish(bm, &bmop);
}
@@ -447,7 +453,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
void bmo_create_monkey_exec(BMesh *bm, BMOperator *op)
@@ -457,7 +463,7 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op)
float mat[4][4];
int i;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
for (i = 0; i < monkeynv; i++) {
float v[3];
@@ -494,24 +500,25 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op)
MEM_freeN(tv);
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
{
+ const float dia = BMO_slot_float_get(op->slots_in, "diameter");
+ const int segs = BMO_slot_int_get(op->slots_in, "segments");
+ const int cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends");
+ const int cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris");
+
BMVert *v1, *lastv1 = NULL, *cent1, *firstv1 = NULL;
float vec[3], mat[4][4], phi, phid;
- float dia = BMO_slot_float_get(op, "diameter");
- int segs = BMO_slot_int_get(op, "segments");
- int cap_ends = BMO_slot_bool_get(op, "cap_ends");
- int cap_tris = BMO_slot_bool_get(op, "cap_tris");
int a;
if (!segs)
return;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
phid = 2.0f * (float)M_PI / segs;
phi = 0;
@@ -566,25 +573,25 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
BMO_op_callf(bm, op->flag, "dissolve_faces faces=%ff", FACE_NEW);
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
{
BMVert *v1, *v2, *lastv1 = NULL, *lastv2 = NULL, *cent1, *cent2, *firstv1, *firstv2;
float vec[3], mat[4][4], phi, phid;
- float dia1 = BMO_slot_float_get(op, "diameter1");
- float dia2 = BMO_slot_float_get(op, "diameter2");
- float depth = BMO_slot_float_get(op, "depth");
- int segs = BMO_slot_int_get(op, "segments");
- int cap_ends = BMO_slot_bool_get(op, "cap_ends");
- int cap_tris = BMO_slot_bool_get(op, "cap_tris");
+ float dia1 = BMO_slot_float_get(op->slots_in, "diameter1");
+ float dia2 = BMO_slot_float_get(op->slots_in, "diameter2");
+ float depth = BMO_slot_float_get(op->slots_in, "depth");
+ int segs = BMO_slot_int_get(op->slots_in, "segments");
+ int cap_ends = BMO_slot_bool_get(op->slots_in, "cap_ends");
+ int cap_tris = BMO_slot_bool_get(op->slots_in, "cap_tris");
int a;
if (!segs)
return;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
phid = 2.0f * (float)M_PI / segs;
phi = 0;
@@ -662,15 +669,15 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, NULL, FALSE);
BMO_op_callf(bm, op->flag, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001);
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
{
BMVert *v1, *v2, *v3, *v4, *v5, *v6, *v7, *v8;
- float vec[3], mat[4][4], off = BMO_slot_float_get(op, "size") / 2.0f;
+ float vec[3], mat[4][4], off = BMO_slot_float_get(op->slots_in, "size") / 2.0f;
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
if (!off) off = 0.5f;
@@ -740,5 +747,5 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
BM_face_create_quad_tri(bm, v1, v2, v3, v4, NULL, FALSE);
BM_face_create_quad_tri(bm, v8, v7, v6, v5, NULL, FALSE);
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index ea6cd747037..45e678b96bb 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -36,7 +36,7 @@
#include "intern/bmesh_operators_private.h" /* own include */
-static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op)
+static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op, BMOpSlot *slot_targetmap)
{
BMIter liter;
BMLoop *l;
@@ -44,7 +44,7 @@ static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op)
int split = FALSE;
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", l->v);
+ v2 = BMO_slot_map_ptr_get(slot_targetmap, l->v);
/* ok: if v2 is NULL (e.g. not in the map) then it's
* a target vert, otherwise it's a double */
if ((v2 && BM_vert_in_face(f, v2)) &&
@@ -61,8 +61,8 @@ static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op)
BMLoop *nl;
BMFace *f2 = BM_face_split(bm, f, doub, v2, &nl, NULL, FALSE);
- remdoubles_splitface(f, bm, op);
- remdoubles_splitface(f2, bm, op);
+ remdoubles_splitface(f, bm, op, slot_targetmap);
+ remdoubles_splitface(f2, bm, op, slot_targetmap);
}
}
@@ -106,10 +106,11 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(loops);
BMFace *f, *f2;
int a, b;
+ BMOpSlot *slot_targetmap = BMO_slot_get(op->slots_in, "targetmap");
/* mark merge verts for deletion */
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if ((v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v))) {
+ if ((v2 = BMO_slot_map_ptr_get(slot_targetmap, v))) {
BMO_elem_flag_enable(bm, v, ELE_DEL);
/* merge the vertex flags, else we get randomly selected/unselected verts */
@@ -120,13 +121,13 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
/* check if any faces are getting their own corners merged
* together, split face if so */
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- remdoubles_splitface(f, bm, op);
+ remdoubles_splitface(f, bm, op, slot_targetmap);
}
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_elem_flag_test(bm, e->v1, ELE_DEL) || BMO_elem_flag_test(bm, e->v2, ELE_DEL)) {
- v = BMO_slot_map_ptr_get(bm, op, "targetmap", e->v1);
- v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", e->v2);
+ v = BMO_slot_map_ptr_get(slot_targetmap, e->v1);
+ v2 = BMO_slot_map_ptr_get(slot_targetmap, e->v2);
if (!v) v = e->v1;
if (!v2) v2 = e->v2;
@@ -174,10 +175,10 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
v = l->v;
v2 = l->next->v;
if (BMO_elem_flag_test(bm, v, ELE_DEL)) {
- v = BMO_slot_map_ptr_get(bm, op, "targetmap", v);
+ v = BMO_slot_map_ptr_get(slot_targetmap, v);
}
if (BMO_elem_flag_test(bm, v2, ELE_DEL)) {
- v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v2);
+ v2 = BMO_slot_map_ptr_get(slot_targetmap, v2);
}
e2 = v != v2 ? BM_edge_exists(v, v2) : NULL;
@@ -207,10 +208,10 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
v2 = loops[1]->v;
if (BMO_elem_flag_test(bm, v, ELE_DEL)) {
- v = BMO_slot_map_ptr_get(bm, op, "targetmap", v);
+ v = BMO_slot_map_ptr_get(slot_targetmap, v);
}
if (BMO_elem_flag_test(bm, v2, ELE_DEL)) {
- v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v2);
+ v2 = BMO_slot_map_ptr_get(slot_targetmap, v2);
}
f2 = BM_face_create_ngon(bm, v, v2, edges, a, TRUE);
@@ -262,7 +263,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
float fac;
int i, tot;
- snapv = BMO_iter_new(&siter, bm, op, "snapv", BM_VERT);
+ snapv = BMO_iter_new(&siter, op->slots_in, "snapv", BM_VERT);
tot = BM_vert_face_count(snapv);
if (!tot)
@@ -290,7 +291,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
if (l == firstl) {
continue;
@@ -318,7 +319,7 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op)
type = bm->ldata.layers[i].type;
CustomData_data_initminmax(type, &min, &max);
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
block = CustomData_bmesh_get_layer_n(&bm->ldata, l->head.data, i);
CustomData_data_dominmax(type, block, &min, &max);
@@ -329,7 +330,7 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op)
CustomData_data_multiply(type, &max, 0.5f);
CustomData_data_add(type, &min, &max);
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
block = CustomData_bmesh_get_layer_n(&bm->ldata, l->head.data, i);
CustomData_data_copy_value(type, &min, block);
@@ -344,19 +345,22 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op)
BMOIter siter;
BMVert *v, *snapv = NULL;
float vec[3];
+ BMOpSlot *slot_targetmap;
- BMO_slot_vec_get(op, "merge_co", vec);
+ BMO_slot_vec_get(op->slots_in, "merge_co", vec);
//BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
-
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+
+ slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
+
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
if (!snapv) {
snapv = v;
copy_v3_v3(snapv->co, vec);
}
else {
- BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", v, snapv);
+ BMO_slot_map_ptr_insert(&weldop, slot_targetmap, v, snapv);
}
}
@@ -373,11 +377,13 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(edges);
float min[3], max[3], center[3];
int i, tot;
+ BMOpSlot *slot_targetmap;
BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
+ slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
BMW_init(&walker, bm, BMW_SHELL,
BMW_MASK_NOP, EDGE_MARK, BMW_MASK_NOP,
@@ -408,9 +414,9 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
copy_v3_v3(edges[i]->v2->co, center);
if (edges[i]->v1 != edges[0]->v1)
- BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", edges[i]->v1, edges[0]->v1);
+ BMO_slot_map_ptr_insert(&weldop, slot_targetmap, edges[i]->v1, edges[0]->v1);
if (edges[i]->v2 != edges[0]->v1)
- BMO_slot_map_ptr_insert(bm, &weldop, "targetmap", edges[i]->v2, edges[0]->v1);
+ BMO_slot_map_ptr_insert(&weldop, slot_targetmap, edges[i]->v2, edges[0]->v1);
}
}
@@ -436,7 +442,7 @@ static void bmo_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer)
/* clear all short flags */
BMO_mesh_flag_disable_all(bm, op, BM_ALL, (1 << 16) - 1);
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK);
BMW_init(&walker, bm, BMW_LOOPDATA_ISLAND,
BMW_MASK_NOP, EDGE_MARK, BMW_MASK_NOP,
@@ -486,31 +492,32 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op)
}
}
-static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname)
+static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op,
+ BMOperator *optarget, BMOpSlot *optarget_slot)
{
BMVert **verts;
int verts_len;
int i, j, keepvert = 0;
- const float dist = BMO_slot_float_get(op, "dist");
+ const float dist = BMO_slot_float_get(op->slots_in, "dist");
const float dist3 = dist * 3.0f;
/* Test whether keep_verts arg exists and is non-empty */
- if (BMO_slot_exists(op, "keep_verts")) {
+ if (BMO_slot_exists(op->slots_in, "keep_verts")) {
BMOIter oiter;
- keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL;
+ keepvert = BMO_iter_new(&oiter, op->slots_in, "keep_verts", BM_VERT) != NULL;
}
/* get the verts as an array we can sort */
- verts = BMO_slot_as_arrayN(op, "verts", &verts_len);
+ verts = BMO_slot_as_arrayN(op->slots_in, "verts", &verts_len);
/* sort by vertex coordinates added together */
qsort(verts, verts_len, sizeof(BMVert *), vergaverco);
/* Flag keep_verts */
if (keepvert) {
- BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "keep_verts", BM_VERT, VERT_KEEP);
}
for (i = 0; i < verts_len; i++) {
@@ -547,7 +554,7 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *opt
BMO_elem_flag_enable(bm, v_other, VERT_DOUBLE);
BMO_elem_flag_enable(bm, v_check, VERT_TARGET);
- BMO_slot_map_ptr_insert(bm, optarget, targetmapname, v_other, v_check);
+ BMO_slot_map_ptr_insert(optarget, optarget_slot, v_other, v_check);
}
}
}
@@ -558,9 +565,12 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *opt
void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op)
{
BMOperator weldop;
+ BMOpSlot *slot_targetmap;
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
- bmesh_find_doubles_common(bm, op, &weldop, "targetmap");
+ slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
+ bmesh_find_doubles_common(bm, op,
+ &weldop, slot_targetmap);
BMO_op_exec(bm, &weldop);
BMO_op_finish(bm, &weldop);
}
@@ -568,7 +578,10 @@ void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op)
void bmo_find_doubles_exec(BMesh *bm, BMOperator *op)
{
- bmesh_find_doubles_common(bm, op, op, "targetmapout");
+ BMOpSlot *slot_targetmap_out;
+ slot_targetmap_out = BMO_slot_get(op->slots_out, "targetmap.out");
+ bmesh_find_doubles_common(bm, op,
+ op, slot_targetmap_out);
}
void bmo_automerge_exec(BMesh *bm, BMOperator *op)
@@ -580,7 +593,7 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op)
/* The "verts" input sent to this op is the set of verts that
* can be merged away into any other verts. Mark all other verts
* as VERT_KEEP. */
- BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_IN);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_IN);
BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
if (!BMO_elem_flag_test(bm, v, VERT_IN)) {
BMO_elem_flag_enable(bm, v, VERT_KEEP);
@@ -590,12 +603,14 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op)
/* Search for doubles among all vertices, but only merge non-VERT_KEEP
* vertices into VERT_KEEP vertices. */
BMO_op_initf(bm, &findop, op->flag, "find_doubles verts=%av keep_verts=%fv", VERT_KEEP);
- BMO_slot_copy(op, &findop, "dist", "dist");
+ BMO_slot_copy(op, slots_in, "dist",
+ &findop, slots_in, "dist");
BMO_op_exec(bm, &findop);
/* weld the vertices */
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
- BMO_slot_copy(&findop, &weldop, "targetmapout", "targetmap");
+ BMO_slot_copy(&findop, slots_out, "targetmap.out",
+ &weldop, slots_in, "targetmap");
BMO_op_exec(bm, &weldop);
BMO_op_finish(bm, &findop);
diff --git a/source/blender/bmesh/operators/bmo_similar.c b/source/blender/bmesh/operators/bmo_similar.c
index df03e50d2c4..548e1adf17d 100644
--- a/source/blender/bmesh/operators/bmo_similar.c
+++ b/source/blender/bmesh/operators/bmo_similar.c
@@ -103,10 +103,10 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
SimSel_FaceExt *f_ext = NULL;
int *indices = NULL;
float t_no[3]; /* temporary normal */
- const int type = BMO_slot_int_get(op, "type");
- const float thresh = BMO_slot_float_get(op, "thresh");
+ const int type = BMO_slot_int_get(op->slots_in, "type");
+ const float thresh = BMO_slot_float_get(op->slots_in, "thresh");
const float thresh_radians = thresh * (float)M_PI;
- const int compare = BMO_slot_int_get(op, "compare");
+ const int compare = BMO_slot_int_get(op->slots_in, "compare");
/* initial_elem - other_elem */
float delta_fl;
@@ -121,7 +121,7 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
* so the overall complexity will be less than $O(mn)$ where is the total number of selected faces,
* and n is the total number of faces
*/
- BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (!BMO_elem_flag_test(bm, fs, FACE_MARK)) { /* is this really needed ? */
BMO_elem_flag_enable(bm, fs, FACE_MARK);
num_sels++;
@@ -256,7 +256,7 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
MEM_freeN(indices);
/* transfer all marked faces to the output slot */
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_MARK);
#undef FACE_MARK
}
@@ -299,9 +299,9 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
float angle;
int num_sels = 0, num_total = 0;
- const int type = BMO_slot_int_get(op, "type");
- const float thresh = BMO_slot_float_get(op, "thresh");
- const int compare = BMO_slot_int_get(op, "compare");
+ const int type = BMO_slot_int_get(op->slots_in, "type");
+ const float thresh = BMO_slot_float_get(op->slots_in, "thresh");
+ const int compare = BMO_slot_int_get(op->slots_in, "compare");
/* initial_elem - other_elem */
float delta_fl;
@@ -324,7 +324,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
num_total = BM_mesh_elem_count(bm, BM_EDGE);
/* iterate through all selected edges and mark them */
- BMO_ITER (es, &es_iter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (es, &es_iter, op->slots_in, "edges", BM_EDGE) {
BMO_elem_flag_enable(bm, es, EDGE_MARK);
num_sels++;
}
@@ -474,7 +474,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
MEM_freeN(indices);
/* transfer all marked edges to the output slot */
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_MARK);
#undef EDGE_MARK
}
@@ -507,10 +507,10 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
SimSel_VertExt *v_ext = NULL;
int *indices = NULL;
int num_total = 0, num_sels = 0, i = 0, idx = 0;
- const int type = BMO_slot_int_get(op, "type");
- const float thresh = BMO_slot_float_get(op, "thresh");
+ const int type = BMO_slot_int_get(op->slots_in, "type");
+ const float thresh = BMO_slot_float_get(op->slots_in, "thresh");
const float thresh_radians = thresh * (float)M_PI;
- const int compare = BMO_slot_int_get(op, "compare");
+ const int compare = BMO_slot_int_get(op->slots_in, "compare");
/* initial_elem - other_elem */
// float delta_fl;
@@ -519,7 +519,7 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
num_total = BM_mesh_elem_count(bm, BM_VERT);
/* iterate through all selected edges and mark them */
- BMO_ITER (vs, &vs_iter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (vs, &vs_iter, op->slots_in, "verts", BM_VERT) {
BMO_elem_flag_enable(bm, vs, VERT_MARK);
num_sels++;
}
@@ -608,7 +608,7 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
MEM_freeN(indices);
MEM_freeN(v_ext);
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
#undef VERT_MARK
}
diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c
index 6db76119205..9dde2461364 100644
--- a/source/blender/bmesh/operators/bmo_slide.c
+++ b/source/blender/bmesh/operators/bmo_slide.c
@@ -53,10 +53,10 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op)
int selected_edges = 0;
/* Get slide amount */
- const float distance_t = BMO_slot_float_get(op, "distance_t");
+ const float distance_t = BMO_slot_float_get(op->slots_in, "distance_t");
/* Get start vertex */
- vertex = BMO_iter_new(&oiter, bm, op, "vert", BM_VERT);
+ vertex = BMO_iter_new(&oiter, op->slots_in, "vert", BM_VERT);
if (!vertex) {
@@ -68,7 +68,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op)
}
/* Count selected edges */
- BMO_ITER (h, &oiter, bm, op, "edge", BM_VERT | BM_EDGE) {
+ BMO_ITER (h, &oiter, op->slots_in, "edge", BM_VERT | BM_EDGE) {
switch (h->htype) {
case BM_EDGE:
selected_edges++;
@@ -108,7 +108,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op)
}
/* Return the new edge. The same previously marked with VERT_MARK */
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
return;
}
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
index 362123e412d..4137c31961c 100644
--- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -78,8 +78,8 @@ static void delete_laplacian_system(LaplacianSystem *sys);
static void delete_void_pointer(void *data);
static void fill_laplacian_matrix(LaplacianSystem *sys);
static void memset_laplacian_system(LaplacianSystem *sys, int val);
-static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int volumepreservation);
-static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez);
+static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume);
+static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez);
static void delete_void_pointer(void *data)
{
@@ -455,7 +455,7 @@ static float compute_volume(BMesh *bm)
return fabs(vol);
}
-static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez)
+static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez)
{
float beta;
BMOIter siter;
@@ -463,9 +463,9 @@ static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float ven
if (vend != 0.0f) {
beta = pow(vini / vend, 1.0f / 3.0f);
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
if (usex) {
- v->co[0] *= beta;
+ v->co[0] *= beta;
}
if (usey) {
v->co[1] *= beta;
@@ -478,7 +478,7 @@ static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float ven
}
}
-static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int volumepreservation)
+static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume)
{
int m_vertex_id;
float leni, lene;
@@ -509,10 +509,10 @@ static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez
}
}
- if (volumepreservation) {
+ if (preserve_volume) {
vini = compute_volume(sys->bm);
}
- BMO_ITER (v, &siter, sys->bm, sys->op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, sys->op->slots_in, "verts", BM_VERT) {
m_vertex_id = BM_elem_index_get(v);
if (sys->zerola[m_vertex_id] == 0) {
if (usex) {
@@ -526,9 +526,9 @@ static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez
}
}
}
- if (volumepreservation) {
+ if (preserve_volume) {
vend = compute_volume(sys->bm);
- volume_preservation(sys->bm, sys->op, vini, vend, usex, usey, usez);
+ volume_preservation(sys->op, vini, vend, usex, usey, usez);
}
}
@@ -537,7 +537,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
{
int i;
int m_vertex_id;
- int usex, usey, usez, volumepreservation;
+ int usex, usey, usez, preserve_volume;
float lambda, lambda_border;
float w;
BMOIter siter;
@@ -552,13 +552,13 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
memset_laplacian_system(sys, 0);
BM_mesh_elem_index_ensure(bm, BM_VERT);
- lambda = BMO_slot_float_get(op, "lambda");
- lambda_border = BMO_slot_float_get(op, "lambda_border");
+ lambda = BMO_slot_float_get(op->slots_in, "lambda");
+ lambda_border = BMO_slot_float_get(op->slots_in, "lambda_border");
sys->min_area = 0.00001f;
- usex = BMO_slot_bool_get(op, "use_x");
- usey = BMO_slot_bool_get(op, "use_y");
- usez = BMO_slot_bool_get(op, "use_z");
- volumepreservation = BMO_slot_bool_get(op, "volume_preservation");
+ usex = BMO_slot_bool_get(op->slots_in, "use_x");
+ usey = BMO_slot_bool_get(op->slots_in, "use_y");
+ usez = BMO_slot_bool_get(op->slots_in, "use_z");
+ preserve_volume = BMO_slot_bool_get(op->slots_in, "preserve_volume");
nlNewContext();
@@ -573,7 +573,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
for (i = 0; i < bm->totvert; i++) {
nlLockVariable(i);
}
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
m_vertex_id = BM_elem_index_get(v);
nlUnlockVariable(m_vertex_id);
nlSetVariable(0, m_vertex_id, v->co[0]);
@@ -583,7 +583,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
nlBegin(NL_MATRIX);
init_laplacian_matrix(sys);
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
m_vertex_id = BM_elem_index_get(v);
nlRightHandSideAdd(0, m_vertex_id, v->co[0]);
nlRightHandSideAdd(1, m_vertex_id, v->co[1]);
@@ -612,7 +612,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
nlEnd(NL_SYSTEM);
if (nlSolveAdvanced(NULL, NL_TRUE) ) {
- validate_solution(sys, usex, usey, usez, volumepreservation);
+ validate_solution(sys, usex, usey, usez, preserve_volume);
}
delete_laplacian_system(sys);
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index f6b9b18d716..f9b6611c88b 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -165,7 +165,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar
}
/* apply the new difference to the rest of the shape keys,
- * note that this doent take rotations into account, we _could_ support
+ * note that this dosn't take rotations into account, we _could_ support
* this by getting the normals and coords for each shape key and
* re-calculate the smooth value for each but this is quite involved.
* for now its ok to simply apply the difference IMHO - campbell */
@@ -225,8 +225,9 @@ static BMVert *subdivideedgenum(BMesh *bm, BMEdge *edge, BMEdge *oedge,
BMVert *ev;
float percent, percent2 = 0.0f;
- if (BMO_elem_flag_test(bm, edge, EDGE_PERCENT) && totpoint == 1)
- percent = BMO_slot_map_float_get(bm, params->op, "edgepercents", edge);
+ if (BMO_elem_flag_test(bm, edge, EDGE_PERCENT) && totpoint == 1) {
+ percent = BMO_slot_map_float_get(params->slot_edgepercents, edge);
+ }
else {
percent = 1.0f / (float)(totpoint + 1 - curpoint);
percent2 = (float)(curpoint + 1) / (float)(totpoint + 1);
@@ -717,18 +718,18 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
int use_sphere, cornertype, use_singleedge, use_gridfill;
int skey, seed, i, j, matched, a, b, numcuts, totesel;
- BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, SUBD_SPLIT);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT);
- numcuts = BMO_slot_int_get(op, "numcuts");
- seed = BMO_slot_int_get(op, "seed");
- smooth = BMO_slot_float_get(op, "smooth");
- fractal = BMO_slot_float_get(op, "fractal");
- along_normal = BMO_slot_float_get(op, "along_normal");
- cornertype = BMO_slot_int_get(op, "quadcornertype");
-
- use_singleedge = BMO_slot_bool_get(op, "use_singleedge");
- use_gridfill = BMO_slot_bool_get(op, "use_gridfill");
- use_sphere = BMO_slot_bool_get(op, "use_sphere");
+ numcuts = BMO_slot_int_get(op->slots_in, "cuts");
+ seed = BMO_slot_int_get(op->slots_in, "seed");
+ smooth = BMO_slot_float_get(op->slots_in, "smooth");
+ fractal = BMO_slot_float_get(op->slots_in, "fractal");
+ along_normal = BMO_slot_float_get(op->slots_in, "along_normal");
+ cornertype = BMO_slot_int_get(op->slots_in, "quad_corner_type");
+
+ use_singleedge = BMO_slot_bool_get(op->slots_in, "use_singleedge");
+ use_gridfill = BMO_slot_bool_get(op->slots_in, "use_gridfill");
+ use_sphere = BMO_slot_bool_get(op->slots_in, "use_sphere");
BLI_srandom(seed);
@@ -774,10 +775,12 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
/* first go through and tag edges */
- BMO_slot_buffer_from_enabled_flag(bm, op, "edges", BM_EDGE, SUBD_SPLIT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT);
params.numcuts = numcuts;
params.op = op;
+ params.slot_edgepercents = BMO_slot_get(op->slots_in, "edgepercents");
+ params.slot_custompatterns = BMO_slot_get(op->slots_in, "custompatterns");
params.smooth = smooth;
params.seed = seed;
params.fractal = fractal;
@@ -790,10 +793,10 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
params.off[1] = (float)BLI_drand() * 200.0f;
params.off[2] = (float)BLI_drand() * 200.0f;
- BMO_slot_map_to_flag(bm, op, "custompatterns",
+ BMO_slot_map_to_flag(bm, op->slots_in, "custompatterns",
BM_FACE, FACE_CUSTOMFILL);
- BMO_slot_map_to_flag(bm, op, "edgepercents",
+ BMO_slot_map_to_flag(bm, op->slots_in, "edgepercents",
BM_EDGE, EDGE_PERCENT);
@@ -837,8 +840,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
if (BMO_elem_flag_test(bm, face, FACE_CUSTOMFILL)) {
- pat = BMO_slot_map_data_get(bm, op,
- "custompatterns", face);
+ pat = BMO_slot_map_data_get(params.slot_custompatterns, face);
for (i = 0; i < pat->len; i++) {
matched = 1;
for (j = 0; j < pat->len; j++) {
@@ -910,11 +912,11 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
}
- einput = BMO_slot_get(op, "edges");
+ einput = BMO_slot_get(op->slots_in, "edges");
/* go through and split edges */
for (i = 0; i < einput->len; i++) {
- edge = ((BMEdge **)einput->data.p)[i];
+ edge = einput->data.buf[i];
bm_subdivide_multicut(bm, edge, &params, edge->v1, edge->v2);
}
@@ -1075,10 +1077,10 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BLI_array_free(loops_split);
BLI_array_free(loops);
- BMO_slot_buffer_from_enabled_flag(bm, op, "outinner", BM_ALL, ELE_INNER);
- BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_inner.out", BM_ALL, ELE_INNER);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_split.out", BM_ALL, ELE_SPLIT);
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, ELE_INNER | ELE_SPLIT | SUBD_SPLIT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, ELE_INNER | ELE_SPLIT | SUBD_SPLIT);
}
/* editmesh-emulating function */
@@ -1095,8 +1097,8 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
BMO_op_initf(bm, &op, BMO_FLAG_DEFAULTS,
"subdivide_edges edges=%he "
"smooth=%f fractal=%f along_normal=%f "
- "numcuts=%i "
- "quadcornertype=%i "
+ "cuts=%i "
+ "quad_corner_type=%i "
"use_singleedge=%b use_gridfill=%b "
"seed=%i",
edge_hflag,
@@ -1112,7 +1114,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
BMOIter iter;
BMElem *ele;
- for (ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) {
+ for (ele = BMO_iter_new(&iter, op.slots_out, "geom_inner.out", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) {
BM_elem_select_set(bm, ele, TRUE);
}
}
@@ -1123,7 +1125,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
/* deselect input */
BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE);
- for (ele = BMO_iter_new(&iter, bm, &op, "outinner", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) {
+ for (ele = BMO_iter_new(&iter, op.slots_out, "geom_inner.out", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) {
BM_elem_select_set(bm, ele, TRUE);
if (ele->head.htype == BM_VERT) {
@@ -1158,8 +1160,9 @@ void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op)
SubDParams params = {0};
int skey;
- params.numcuts = BMO_slot_int_get(op, "numcuts");
+ params.numcuts = BMO_slot_int_get(op->slots_in, "cuts");
params.op = op;
+ params.slot_edgepercents = BMO_slot_get(op->slots_in, "edgepercents");
BM_data_layer_add(bm, &bm->vdata, CD_SHAPEKEY);
skey = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY) - 1;
@@ -1167,11 +1170,11 @@ void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op)
params.origkey = skey;
/* go through and split edges */
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
bm_subdivide_multicut(bm, e, &params, e->v1, e->v2);
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom_split.out", BM_ALL, ELE_SPLIT);
BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, skey);
}
diff --git a/source/blender/bmesh/operators/bmo_subdivide.h b/source/blender/bmesh/operators/bmo_subdivide.h
index d4b926b9275..d0676508917 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.h
+++ b/source/blender/bmesh/operators/bmo_subdivide.h
@@ -39,6 +39,8 @@ typedef struct SubDParams {
int seed;
int origkey; /* shapekey holding displaced vertex coordinates for current geometry */
BMOperator *op;
+ BMOpSlot *slot_edgepercents; /* BMO_slot_get(params->op->slots_in, "edgepercents"); */
+ BMOpSlot *slot_custompatterns; /* BMO_slot_get(params->op->slots_in, "custompatterns"); */
float off[3];
} SubDParams;
diff --git a/source/blender/bmesh/operators/bmo_symmetrize.c b/source/blender/bmesh/operators/bmo_symmetrize.c
index a428405fb8b..8c440cae83e 100644
--- a/source/blender/bmesh/operators/bmo_symmetrize.c
+++ b/source/blender/bmesh/operators/bmo_symmetrize.c
@@ -96,7 +96,7 @@ static void symm_verts_mirror(Symm *symm)
symm->vert_symm_map = BLI_ghash_ptr_new(AT);
- BMO_ITER (src_v, &oiter, symm->bm, symm->op, "input", BM_VERT) {
+ BMO_ITER (src_v, &oiter, symm->op->slots_in, "input", BM_VERT) {
SymmSide side = symm_co_side(symm, src_v->co);
float co[3];
@@ -145,7 +145,7 @@ static void symm_split_asymmetric_edges(Symm *symm)
symm->edge_split_map = BLI_ghash_ptr_new(AT);
- BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) {
+ BMO_ITER (e, &oiter, symm->op->slots_in, "input", BM_EDGE) {
float flipped[3];
copy_v3_v3(flipped, e->v1->co);
@@ -195,7 +195,7 @@ static void symm_mirror_edges(Symm *symm)
BMOIter oiter;
BMEdge *e;
- BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) {
+ BMO_ITER (e, &oiter, symm->op->slots_in, "input", BM_EDGE) {
BMVert *v1 = NULL, *v2 = NULL;
BMEdge *e_new;
@@ -448,7 +448,7 @@ static void symm_mirror_polygons(Symm *symm)
BLI_array_declare(fv);
BLI_array_declare(fe);
- BMO_ITER (f, &oiter, symm->bm, symm->op, "input", BM_FACE) {
+ BMO_ITER (f, &oiter, symm->op->slots_in, "input", BM_FACE) {
BMIter iter;
BMLoop *l;
int mirror_all = TRUE, ignore_all = TRUE;
@@ -607,7 +607,7 @@ static void symm_kill_unused(Symm *symm)
BMVert *v;
/* Kill unused edges */
- BMO_ITER (e, &oiter, symm->bm, symm->op, "input", BM_EDGE) {
+ BMO_ITER (e, &oiter, symm->op->slots_in, "input", BM_EDGE) {
const int crosses = symm_edge_crosses_axis(symm, e);
const int symmetric = (crosses &&
(!BLI_ghash_haskey(symm->edge_split_map, e)));
@@ -617,13 +617,13 @@ static void symm_kill_unused(Symm *symm)
!symmetric)
{
/* The edge might be used by a face outside the input set */
- if (BM_edge_face_count(e) == 0)
+ if (BM_edge_is_wire(e))
BM_edge_kill(symm->bm, e);
}
}
/* Kill unused vertices */
- BMO_ITER (v, &oiter, symm->bm, symm->op, "input", BM_VERT) {
+ BMO_ITER (v, &oiter, symm->op->slots_in, "input", BM_VERT) {
if (symm_co_side(symm, v->co) == SYMM_SIDE_KILL) {
if (BM_vert_edge_count(v) == 0)
BM_vert_kill(symm->bm, v);
@@ -634,7 +634,7 @@ static void symm_kill_unused(Symm *symm)
void bmo_symmetrize_exec(BMesh *bm, BMOperator *op)
{
Symm symm;
- BMO_SymmDirection direction = BMO_slot_int_get(op, "direction");
+ BMO_SymmDirection direction = BMO_slot_int_get(op->slots_in, "direction");
symm.bm = bm;
symm.op = op;
@@ -658,6 +658,6 @@ void bmo_symmetrize_exec(BMesh *bm, BMOperator *op)
BLI_ghash_free(symm.vert_symm_map, NULL, NULL);
BLI_ghash_free(symm.edge_split_map, NULL, NULL);
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL,
- SYMM_OUTPUT_GEOM);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out",
+ BM_ALL, SYMM_OUTPUT_GEOM);
}
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index de876477e5a..775fa0cb60d 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -52,9 +52,10 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
float (*projectverts)[3] = NULL;
BLI_array_declare(projectverts);
int i;
- const int use_beauty = BMO_slot_bool_get(op, "use_beauty");
+ const int use_beauty = BMO_slot_bool_get(op->slots_in, "use_beauty");
+ BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "facemap.out");
- for (face = BMO_iter_new(&siter, bm, op, "faces", BM_FACE); face; face = BMO_iter_step(&siter)) {
+ for (face = BMO_iter_new(&siter, op->slots_in, "faces", BM_FACE); face; face = BMO_iter_step(&siter)) {
BLI_array_empty(projectverts);
BLI_array_empty(newfaces);
@@ -64,16 +65,14 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
BM_face_triangulate(bm, face, projectverts, EDGE_NEW, FACE_NEW, newfaces, use_beauty);
- BMO_slot_map_ptr_insert(bm, op, "facemap", face, face);
+ BMO_slot_map_ptr_insert(op, slot_facemap_out, face, face);
for (i = 0; newfaces[i]; i++) {
- BMO_slot_map_ptr_insert(bm, op, "facemap",
- newfaces[i], face);
-
+ BMO_slot_map_ptr_insert(op, slot_facemap_out, newfaces[i], face);
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_NEW);
- BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, FACE_NEW);
BLI_array_free(projectverts);
BLI_array_free(newfaces);
@@ -87,9 +86,9 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
int stop = 0;
- BMO_slot_buffer_flag_enable(bm, op, "constrain_edges", BM_EDGE, EDGE_MARK);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "constrain_edges", BM_EDGE, EDGE_MARK);
- BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
if (f->len == 3) {
BMO_elem_flag_enable(bm, f, FACE_MARK);
}
@@ -152,7 +151,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE | BM_FACE, ELE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW);
}
void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
@@ -170,7 +169,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
BLI_scanfill_begin(&sf_ctx);
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
BMO_elem_flag_enable(bm, e, EDGE_MARK);
if (!BLI_smallhash_haskey(&hash, (uintptr_t)e->v1)) {
@@ -214,8 +213,8 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
/* clean up fill */
BMO_op_initf(bm, &bmop, op->flag, "beautify_fill faces=%ff constrain_edges=%fe", ELE_NEW, EDGE_MARK);
BMO_op_exec(bm, &bmop);
- BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_FACE | BM_EDGE, ELE_NEW);
+ BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, ELE_NEW);
BMO_op_finish(bm, &bmop);
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE | BM_FACE, ELE_NEW);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW);
}
diff --git a/source/blender/bmesh/operators/bmo_unsubdivide.c b/source/blender/bmesh/operators/bmo_unsubdivide.c
index 3d44feac380..fae7db3d175 100644
--- a/source/blender/bmesh/operators/bmo_unsubdivide.c
+++ b/source/blender/bmesh/operators/bmo_unsubdivide.c
@@ -39,10 +39,10 @@ void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op)
BMVert *v;
BMIter iter;
- const int iterations = max_ii(1, BMO_slot_int_get(op, "iterations"));
+ const int iterations = max_ii(1, BMO_slot_int_get(op->slots_in, "iterations"));
- BMOpSlot *vinput = BMO_slot_get(op, "verts");
- BMVert **vinput_arr = (BMVert **)vinput->data.p;
+ BMOpSlot *vinput = BMO_slot_get(op->slots_in, "verts");
+ BMVert **vinput_arr = (BMVert **)vinput->data.buf;
int v_index;
/* tag verts */
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index aa514a5c0a7..d56b2ca0d73 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -45,21 +45,21 @@ void bmo_create_vert_exec(BMesh *bm, BMOperator *op)
{
float vec[3];
- BMO_slot_vec_get(op, "co", vec);
+ BMO_slot_vec_get(op->slots_in, "co", vec);
BMO_elem_flag_enable(bm, BM_vert_create(bm, vec, NULL), 1);
- BMO_slot_buffer_from_enabled_flag(bm, op, "newvertout", BM_VERT, 1);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "vert.out", BM_VERT, 1);
}
-void bmo_transform_exec(BMesh *bm, BMOperator *op)
+void bmo_transform_exec(BMesh *UNUSED(bm), BMOperator *op)
{
BMOIter iter;
BMVert *v;
float mat[4][4];
- BMO_slot_mat4_get(op, "mat", mat);
+ BMO_slot_mat4_get(op->slots_in, "mat", mat);
- BMO_ITER (v, &iter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &iter, op->slots_in, "verts", BM_VERT) {
mul_m4_v3(mat, v->co);
}
}
@@ -68,7 +68,7 @@ void bmo_translate_exec(BMesh *bm, BMOperator *op)
{
float mat[4][4], vec[3];
- BMO_slot_vec_get(op, "vec", vec);
+ BMO_slot_vec_get(op->slots_in, "vec", vec);
unit_m4(mat);
copy_v3_v3(mat[3], vec);
@@ -80,7 +80,7 @@ void bmo_scale_exec(BMesh *bm, BMOperator *op)
{
float mat[3][3], vec[3];
- BMO_slot_vec_get(op, "vec", vec);
+ BMO_slot_vec_get(op->slots_in, "vec", vec);
unit_m3(mat);
mat[0][0] = vec[0];
@@ -94,7 +94,7 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op)
{
float vec[3];
- BMO_slot_vec_get(op, "cent", vec);
+ BMO_slot_vec_get(op->slots_in, "cent", vec);
/* there has to be a proper matrix way to do this, but
* this is how editmesh did it and I'm too tired to think
@@ -113,7 +113,7 @@ void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op)
BMOIter siter;
BMFace *f;
- BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
BM_face_normal_flip(bm, f);
}
}
@@ -122,8 +122,8 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
{
BMOIter siter;
BMEdge *e, *e2;
- int ccw = BMO_slot_bool_get(op, "ccw");
- int is_single = BMO_slot_buffer_count(bm, op, "edges") == 1;
+ const int use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw");
+ const int is_single = BMO_slot_buffer_count(op->slots_in, "edges") == 1;
short check_flag = is_single ?
BM_EDGEROT_CHECK_EXISTS :
BM_EDGEROT_CHECK_EXISTS | BM_EDGEROT_CHECK_DEGENERATE;
@@ -131,7 +131,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
#define EDGE_OUT 1
#define FACE_TAINT 1
- BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
+ BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
/**
* this ends up being called twice, could add option to not to call check in
* #BM_edge_rotate to get some extra speed */
@@ -144,7 +144,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_test(bm, fb, FACE_TAINT) == FALSE)
{
- if (!(e2 = BM_edge_rotate(bm, e, ccw, check_flag))) {
+ if (!(e2 = BM_edge_rotate(bm, e, use_ccw, check_flag))) {
#if 0
BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Could not rotate edge");
return;
@@ -162,7 +162,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_OUT);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, EDGE_OUT);
#undef EDGE_OUT
#undef FACE_TAINT
@@ -180,7 +180,7 @@ static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces)
BMOIter siter;
if (!usefaces) {
- BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) {
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN))
if (!BMO_elem_flag_test(bm, e, SEL_ORIG))
@@ -202,7 +202,7 @@ static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces)
BMFace *f, *f2;
BMLoop *l;
- BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "geom", BM_FACE) {
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) {
if (!BM_elem_flag_test(f2, BM_ELEM_HIDDEN)) {
@@ -224,7 +224,7 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces)
BMOIter siter;
if (!usefaces) {
- BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) {
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN))
if (!BMO_elem_flag_test(bm, e, SEL_ORIG))
@@ -248,7 +248,7 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces)
BMFace *f, *f2;
BMLoop *l;
- BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "geom", BM_FACE) {
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) {
if (!BM_elem_flag_test(f2, BM_ELEM_HIDDEN)) {
@@ -265,17 +265,17 @@ static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces)
void bmo_region_extend_exec(BMesh *bm, BMOperator *op)
{
- int use_faces = BMO_slot_bool_get(op, "use_faces");
- int constrict = BMO_slot_bool_get(op, "constrict");
+ int use_faces = BMO_slot_bool_get(op->slots_in, "use_faces");
+ int constrict = BMO_slot_bool_get(op->slots_in, "use_constrict");
- BMO_slot_buffer_flag_enable(bm, op, "geom", BM_ALL, SEL_ORIG);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "geom", BM_ALL, SEL_ORIG);
if (constrict)
bmo_region_extend_constrict(bm, op, use_faces);
else
bmo_region_extend_extend(bm, op, use_faces);
- BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, SEL_FLAG);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL, SEL_FLAG);
}
/********* righthand faces implementation ****** */
@@ -314,15 +314,15 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(fstack);
BMLoop *l, *l2;
float maxx, maxx_test, cent[3];
- int i, i_max, flagflip = BMO_slot_bool_get(op, "do_flip");
+ int i, i_max, flagflip = BMO_slot_bool_get(op->slots_in, "use_flip");
startf = NULL;
maxx = -1.0e10;
- BMO_slot_buffer_flag_enable(bm, op, "faces", BM_FACE, FACE_FLAG);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_FLAG);
/* find a starting face */
- BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
/* clear dirty flag */
BM_elem_flag_disable(f, BM_ELEM_TAG);
@@ -405,7 +405,7 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
BLI_array_free(fstack);
/* check if we have faces yet to do. if so, recurse */
- BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
if (!BMO_elem_flag_test(bm, f, FACE_VIS)) {
bmo_recalc_face_normals_exec(bm, op);
break;
@@ -413,7 +413,7 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
}
}
-void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op)
+void bmo_smooth_vert_exec(BMesh *UNUSED(bm), BMOperator *op)
{
BMOIter siter;
BMIter iter;
@@ -421,20 +421,20 @@ void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op)
BMEdge *e;
BLI_array_declare(cos);
float (*cos)[3] = NULL;
- float *co, *co2, clipdist = BMO_slot_float_get(op, "clipdist");
+ float *co, *co2, clip_dist = BMO_slot_float_get(op->slots_in, "clip_dist");
int i, j, clipx, clipy, clipz;
int xaxis, yaxis, zaxis;
- clipx = BMO_slot_bool_get(op, "mirror_clip_x");
- clipy = BMO_slot_bool_get(op, "mirror_clip_y");
- clipz = BMO_slot_bool_get(op, "mirror_clip_z");
+ clipx = BMO_slot_bool_get(op->slots_in, "mirror_clip_x");
+ clipy = BMO_slot_bool_get(op->slots_in, "mirror_clip_y");
+ clipz = BMO_slot_bool_get(op->slots_in, "mirror_clip_z");
- xaxis = BMO_slot_bool_get(op, "use_axis_x");
- yaxis = BMO_slot_bool_get(op, "use_axis_y");
- zaxis = BMO_slot_bool_get(op, "use_axis_z");
+ xaxis = BMO_slot_bool_get(op->slots_in, "use_axis_x");
+ yaxis = BMO_slot_bool_get(op->slots_in, "use_axis_y");
+ zaxis = BMO_slot_bool_get(op->slots_in, "use_axis_z");
i = 0;
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
BLI_array_grow_one(cos);
co = cos[i];
@@ -454,18 +454,18 @@ void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op)
mul_v3_fl(co, 1.0f / (float)j);
mid_v3_v3v3(co, co, v->co);
- if (clipx && fabsf(v->co[0]) <= clipdist)
+ if (clipx && fabsf(v->co[0]) <= clip_dist)
co[0] = 0.0f;
- if (clipy && fabsf(v->co[1]) <= clipdist)
+ if (clipy && fabsf(v->co[1]) <= clip_dist)
co[1] = 0.0f;
- if (clipz && fabsf(v->co[2]) <= clipdist)
+ if (clipz && fabsf(v->co[2]) <= clip_dist)
co[2] = 0.0f;
i++;
}
i = 0;
- BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+ BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) {
if (xaxis)
v->co[0] = cos[i][0];
if (yaxis)
@@ -489,11 +489,11 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
BMFace *fs; /* current face */
BMIter l_iter; /* iteration loop */
- int dir = BMO_slot_int_get(op, "dir");
+ const int use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw");
- BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) {
- if (dir == DIRECTION_CW) { /* same loops direction */
+ if (use_ccw == FALSE) { /* same loops direction */
BMLoop *lf; /* current face loops */
MLoopUV *f_luv; /* first face loop uv */
float p_uv[2]; /* previous uvs */
@@ -517,7 +517,7 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
copy_v2_v2(f_luv->uv, p_uv);
}
- else if (dir == DIRECTION_CCW) { /* counter loop direction */
+ else { /* counter loop direction */
BMLoop *lf; /* current face loops */
MLoopUV *p_luv; /* previous loop uv */
MLoopUV *luv;
@@ -556,7 +556,7 @@ void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(uvs);
float (*uvs)[2] = NULL;
- BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) {
BMLoop *lf; /* current face loops */
int i;
@@ -594,11 +594,11 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
BMFace *fs; /* current face */
BMIter l_iter; /* iteration loop */
- int dir = BMO_slot_int_get(op, "dir");
+ const int use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw");
- BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL)) {
- if (dir == DIRECTION_CW) { /* same loops direction */
+ if (use_ccw == FALSE) { /* same loops direction */
BMLoop *lf; /* current face loops */
MLoopCol *f_lcol; /* first face loop color */
MLoopCol p_col; /* previous color */
@@ -622,7 +622,7 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
*f_lcol = p_col;
}
- else if (dir == DIRECTION_CCW) { /* counter loop direction */
+ else { /* counter loop direction */
BMLoop *lf; /* current face loops */
MLoopCol *p_lcol; /* previous loop color */
MLoopCol *lcol;
@@ -661,7 +661,7 @@ void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op)
BLI_array_declare(cols);
MLoopCol *cols = NULL;
- BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL)) {
BMLoop *lf; /* current face loops */
int i;
@@ -710,12 +710,13 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op)
ElemNode *vert_list = NULL;
int num_total = 0 /*, num_sels = 0 */, i = 0;
- const int type = BMO_slot_int_get(op, "type");
+ const int type = BMO_slot_int_get(op->slots_in, "type");
- BMO_ITER (vs, &vs_iter, bm, op, "startv", BM_VERT) {
+ /* BMESH_TODO use BMO_slot_buffer_elem_first here? */
+ BMO_ITER (vs, &vs_iter, op->slots_in, "startv", BM_VERT) {
sv = vs;
}
- BMO_ITER (vs, &vs_iter, bm, op, "endv", BM_VERT) {
+ BMO_ITER (vs, &vs_iter, op->slots_in, "endv", BM_VERT) {
ev = vs;
}
@@ -795,5 +796,5 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op)
BLI_heap_free(h, NULL);
MEM_freeN(vert_list);
- BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
}
diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c
index d572a1c5863..532145ab129 100644
--- a/source/blender/bmesh/operators/bmo_wireframe.c
+++ b/source/blender/bmesh/operators/bmo_wireframe.c
@@ -77,39 +77,60 @@ static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3
}
}
- l_a = bm_edge_tag_faceloop(e_a);
- l_b = bm_edge_tag_faceloop(e_b);
+ if (e_a && e_b) {
+ l_a = bm_edge_tag_faceloop(e_a);
+ l_b = bm_edge_tag_faceloop(e_b);
+
+ /* average edge face normal */
+ add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
+
+ /* average edge direction */
+ v_a = BM_edge_other_vert(e_a, v);
+ v_b = BM_edge_other_vert(e_b, v);
+
+ sub_v3_v3v3(tvec_a, v->co, v_a->co);
+ sub_v3_v3v3(tvec_b, v_b->co, v->co);
+ normalize_v3(tvec_a);
+ normalize_v3(tvec_b);
+ add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */
+
+ /* check are we flipped the right way */
+ BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
+ BM_edge_calc_face_tangent(e_b, l_b, tvec_b);
+ add_v3_v3(tvec_a, tvec_b);
+
+ *r_va_other = v_a;
+ *r_vb_other = v_b;
+ }
+ else {
+ /* degenerate case - vertex connects a boundary edged face to other faces,
+ * so we have only one boundary face - only use it for calculations */
+ l_a = bm_edge_tag_faceloop(e_a);
- /* average edge face normal */
- add_v3_v3v3(no_face, l_a->f->no, l_b->f->no);
+ copy_v3_v3(no_face, l_a->f->no);
- /* average edge direction */
- v_a = BM_edge_other_vert(e_a, v);
- v_b = BM_edge_other_vert(e_b, v);
+ /* edge direction */
+ v_a = BM_edge_other_vert(e_a, v);
+ v_b = NULL;
- sub_v3_v3v3(tvec_a, v->co, v_a->co);
- sub_v3_v3v3(tvec_b, v_b->co, v->co);
- normalize_v3(tvec_a);
- normalize_v3(tvec_b);
- add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */
+ sub_v3_v3v3(no_edge, v->co, v_a->co);
+ /* check are we flipped the right way */
+ BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
+
+ *r_va_other = NULL;
+ *r_vb_other = NULL;
+ }
/* find the normal */
cross_v3_v3v3(r_no, no_edge, no_face);
normalize_v3(r_no);
- /* check are we flipped the right way */
- BM_edge_calc_face_tangent(e_a, l_a, tvec_a);
- BM_edge_calc_face_tangent(e_b, l_b, tvec_b);
- add_v3_v3(tvec_a, tvec_b);
-
if (dot_v3v3(r_no, tvec_a) > 0.0f) {
negate_v3(r_no);
}
copy_v3_v3(r_no_face, no_face);
- *r_va_other = v_a;
- *r_vb_other = v_b;
}
/* check if we are the only tagged loop-face around this edge */
@@ -134,12 +155,12 @@ extern float BM_vert_calc_mean_tagged_edge_length(BMVert *v);
void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
{
- const int use_boundary = BMO_slot_bool_get(op, "use_boundary");
- const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset");
- const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset");
- const int use_crease = (BMO_slot_bool_get(op, "use_crease") &&
+ const int use_boundary = BMO_slot_bool_get(op->slots_in, "use_boundary");
+ const int use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
+ const int use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset");
+ const int use_crease = (BMO_slot_bool_get(op->slots_in, "use_crease") &&
CustomData_has_layer(&bm->edata, CD_CREASE));
- const float depth = BMO_slot_float_get(op, "thickness");
+ const float depth = BMO_slot_float_get(op->slots_in, "thickness");
const float inset = depth;
const int totvert_orig = bm->totvert;
@@ -184,7 +205,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
/* setup tags, all faces and verts will be tagged which will be duplicated */
BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE);
- BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) {
verts_loop_tot += f_src->len;
BM_elem_flag_enable(f_src, BM_ELEM_TAG);
BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
@@ -230,7 +251,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
verts_loop = MEM_mallocN(sizeof(BMVert **) * verts_loop_tot, __func__);
verts_loop_tot = 0; /* count up again */
- BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) {
BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
BM_elem_index_set(l, verts_loop_tot); /* set_loop */
@@ -269,10 +290,12 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
/* similar to code above but different angle calc */
fac = inset;
if (use_even_offset) {
- fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co,
- l_pair[i]->v->co,
- vb_other->co,
- no_face)) * 0.5f);
+ if (va_other) { /* for verts with only one boundary edge - this will be NULL */
+ fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co,
+ l_pair[i]->v->co,
+ vb_other->co,
+ no_face)) * 0.5f);
+ }
}
if (use_relative_offset) {
fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)];
@@ -288,7 +311,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
}
}
- BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) {
+ BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) {
BM_elem_flag_disable(f_src, BM_ELEM_TAG);
BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) {
BMFace *f_new;
@@ -400,5 +423,5 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
MEM_freeN(verts_pos);
MEM_freeN(verts_loop);
- BMO_slot_buffer_from_enabled_hflag(bm, op, "faceout", BM_FACE, BM_ELEM_TAG);
+ BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
}
diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c
index a632a4446ed..cdfd8372d61 100644
--- a/source/blender/bmesh/tools/BME_bevel.c
+++ b/source/blender/bmesh/tools/BME_bevel.c
@@ -1110,10 +1110,13 @@ BMesh *BME_bevel(BMesh *bm, float value, int res, int options, int defgrp_index,
td = BME_init_transdata(BLI_MEMARENA_STD_BUFSIZE);
/* recursion math courtesy of Martin Poirier (theeth) */
for (i = 0; i < res - 1; i++) {
- if (i == 0) fac += 1.0 / 3.0; else fac += 1.0 / (3.0 * i * 2.0);
+ if (i == 0) fac += 1.0 / 3.0;
+ else fac += 1.0 / (3.0 * i * 2.0);
}
d = 1.0 / fac;
+ BM_mesh_elem_toolflags_ensure(bm);
+
for (i = 0; i < res || (res == 0 && i == 0); i++) {
BMO_push(bm, NULL);
BME_bevel_initialize(bm, options, defgrp_index, angle, td);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
new file mode 100644
index 00000000000..4d8fc8e9c3f
--- /dev/null
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -0,0 +1,1749 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s):
+ * Joseph Eagar,
+ * Aleksandr Mokhov,
+ * Howard Trickey,
+ * Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/tools/bmesh_bevel.c
+ * \ingroup bmesh
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_array.h"
+#include "BLI_math.h"
+#include "BLI_memarena.h"
+
+#include "BKE_customdata.h"
+
+#include "bmesh.h"
+
+
+
+/* experemental - Campbell */
+// #define USE_ALTERNATE_ADJ
+
+#define BEVEL_EPSILON 1e-6
+
+/* for testing */
+// #pragma GCC diagnostic error "-Wpadded"
+
+/* Constructed vertex, sometimes later instantiated as BMVert */
+typedef struct NewVert {
+ BMVert *v;
+ float co[3];
+// int _pad;
+} NewVert;
+
+struct BoundVert;
+
+/* Data for one end of an edge involved in a bevel */
+typedef struct EdgeHalf {
+ struct EdgeHalf *next, *prev; /* in CCW order */
+ BMEdge *e; /* original mesh edge */
+ BMFace *fprev; /* face between this edge and previous, if any */
+ BMFace *fnext; /* face between this edge and next, if any */
+ struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */
+ struct BoundVert *rightv; /* right boundary vert, if beveled */
+ short is_bev; /* is this edge beveled? */
+ short is_rev; /* is e->v2 the vertex at this end? */
+ int seg; /* how many segments for the bevel */
+ float offset; /* offset for this edge */
+// int _pad;
+} EdgeHalf;
+
+/* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
+typedef struct BoundVert {
+ struct BoundVert *next, *prev; /* in CCW order */
+ NewVert nv;
+ EdgeHalf *efirst; /* first of edges attached here: in CCW order */
+ EdgeHalf *elast;
+ EdgeHalf *ebev; /* beveled edge whose left side is attached here, if any */
+ int index; /* used for vmesh indexing */
+// int _pad;
+} BoundVert;
+
+/* Mesh structure replacing a vertex */
+typedef struct VMesh {
+ NewVert *mesh; /* allocated array - size and structure depends on kind */
+ BoundVert *boundstart; /* start of boundary double-linked list */
+ int count; /* number of vertices in the boundary */
+ int seg; /* common # of segments for segmented edges */
+ enum {
+ M_NONE, /* no polygon mesh needed */
+ M_POLY, /* a simple polygon */
+ M_ADJ, /* "adjacent edges" mesh pattern */
+// M_CROSS, /* "cross edges" mesh pattern */
+ M_TRI_FAN, /* a simple polygon - fan filled */
+ M_QUAD_STRIP, /* a simple polygon - cut into paralelle strips */
+ } mesh_kind;
+// int _pad;
+} VMesh;
+
+/* Data for a vertex involved in a bevel */
+typedef struct BevVert {
+ BMVert *v; /* original mesh vertex */
+ int edgecount; /* total number of edges around the vertex */
+ int selcount; /* number of selected edges around the vertex */
+ EdgeHalf *edges; /* array of size edgecount; CCW order from vertex normal side */
+ VMesh *vmesh; /* mesh structure for replacing vertex */
+} BevVert;
+
+/* Bevel parameters and state */
+typedef struct BevelParams {
+ /* hash of BevVert for each vertex involved in bevel
+ * GHash: (key=(BMVert *), value=(BevVert *)) */
+ GHash *vert_hash;
+ MemArena *mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */
+
+ float offset; /* blender units to offset each side of a beveled edge */
+ int seg; /* number of segments in beveled edge profile */
+} BevelParams;
+
+// #pragma GCC diagnostic ignored "-Wpadded"
+
+//#include "bevdebug.c"
+
+/* Make a new BoundVert of the given kind, insert it at the end of the circular linked
+ * list with entry point bv->boundstart, and return it. */
+static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3])
+{
+ BoundVert *ans = (BoundVert *)BLI_memarena_alloc(mem_arena, sizeof(BoundVert));
+
+ copy_v3_v3(ans->nv.co, co);
+ if (!vm->boundstart) {
+ ans->index = 0;
+ vm->boundstart = ans;
+ ans->next = ans->prev = ans;
+ }
+ else {
+ BoundVert *tail = vm->boundstart->prev;
+ ans->index = tail->index + 1;
+ ans->prev = tail;
+ ans->next = vm->boundstart;
+ tail->next = ans;
+ vm->boundstart->prev = ans;
+ }
+ vm->count++;
+ return ans;
+}
+
+/* Mesh verts are indexed (i, j, k) where
+ * i = boundvert index (0 <= i < nv)
+ * j = ring index (0 <= j <= ns2)
+ * k = segment index (0 <= k <= ns)
+ * Not all of these are used, and some will share BMVerts */
+static NewVert *mesh_vert(VMesh *vm, int i, int j, int k)
+{
+ int nj = (vm->seg / 2) + 1;
+ int nk = vm->seg + 1;
+
+ return &vm->mesh[i * nk * nj + j * nk + k];
+}
+
+static void create_mesh_bmvert(BMesh *bm, VMesh *vm, int i, int j, int k, BMVert *eg)
+{
+ NewVert *nv = mesh_vert(vm, i, j, k);
+ nv->v = BM_vert_create(bm, nv->co, eg);
+}
+
+static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto,
+ int ifrom, int jfrom, int kfrom)
+{
+ NewVert *nvto, *nvfrom;
+
+ nvto = mesh_vert(vm, ito, jto, kto);
+ nvfrom = mesh_vert(vm, ifrom, jfrom, kfrom);
+ nvto->v = nvfrom->v;
+ copy_v3_v3(nvto->co, nvfrom->co);
+}
+
+/* find the EdgeHalf in bv's array that has edge bme */
+static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme)
+{
+ int i;
+
+ for (i = 0; i < bv->edgecount; i++) {
+ if (bv->edges[i].e == bme)
+ return &bv->edges[i];
+ }
+ return NULL;
+}
+
+/* Return the next EdgeHalf after from_e that is beveled.
+ * If from_e is NULL, find the first beveled edge. */
+static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e)
+{
+ EdgeHalf *e;
+
+ if (from_e == NULL)
+ from_e = &bv->edges[bv->edgecount - 1];
+ e = from_e;
+ do {
+ if (e->is_bev) {
+ return e;
+ }
+ } while ((e = e->next) != from_e);
+ return NULL;
+}
+
+/* find the BevVert corresponding to BMVert bmv */
+static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv)
+{
+ return BLI_ghash_lookup(bp->vert_hash, bmv);
+}
+
+/* Return a good respresentative face (for materials, etc.) for faces
+ * created around/near BoundVert v */
+static BMFace *boundvert_rep_face(BoundVert *v)
+{
+ BMFace *fans = NULL;
+ BMFace *firstf = NULL;
+ BMEdge *e1, *e2;
+ BMFace *f1, *f2;
+ BMIter iter1, iter2;
+
+ BLI_assert(v->efirst != NULL && v->elast != NULL);
+ e1 = v->efirst->e;
+ e2 = v->elast->e;
+ BM_ITER_ELEM (f1, &iter1, e1, BM_FACES_OF_EDGE) {
+ if (!firstf)
+ firstf = f1;
+ BM_ITER_ELEM (f2, &iter2, e2, BM_FACES_OF_EDGE) {
+ if (f1 == f2) {
+ fans = f1;
+ break;
+ }
+ }
+ }
+ if (!fans)
+ fans = firstf;
+
+ return fans;
+}
+
+/**
+ * Make ngon from verts alone.
+ * Make sure to properly copy face attributes and do custom data interpolation from
+ * example face, facerep.
+ *
+ * \note ALL face creation goes through this function, this is important to keep!
+ */
+static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv, BMFace *facerep)
+{
+ BMIter iter;
+ BMLoop *l;
+ BMFace *f;
+
+ if (totv == 3) {
+ f = BM_face_create_quad_tri_v(bm, vert_arr, 3, facerep, FALSE);
+ }
+ else if (totv == 4) {
+ f = BM_face_create_quad_tri_v(bm, vert_arr, 4, facerep, FALSE);
+ }
+ else {
+ int i;
+ BMEdge **ee = NULL;
+ BLI_array_staticdeclare(ee, BM_DEFAULT_NGON_STACK_SIZE);
+
+ BLI_array_grow_items(ee, totv);
+ for (i = 0; i < totv; i++) {
+ ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, TRUE);
+ }
+ f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, FALSE);
+ BLI_array_free(ee);
+ }
+ if (facerep && f) {
+ int has_mdisps = CustomData_has_layer(&bm->ldata, CD_MDISPS);
+ BM_elem_attrs_copy(bm, bm, facerep, f);
+ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+ BM_loop_interp_from_face(bm, l, facerep, TRUE, TRUE);
+ if (has_mdisps)
+ BM_loop_interp_multires(bm, l, facerep);
+ }
+ }
+
+ /* not essential for bevels own internal logic,
+ * this is done so the operator can select newly created faces */
+ if (f) {
+ BM_elem_flag_enable(f, BM_ELEM_TAG);
+ }
+
+ return f;
+}
+
+static BMFace *bev_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
+ BMFace *facerep)
+{
+ BMVert *varr[4] = {v1, v2, v3, v4};
+ return bev_create_ngon(bm, varr, v4 ? 4 : 3, facerep);
+}
+
+/*
+ * Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco.
+ * e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of
+ * the bevel vertex, e1 precedes e2 in CCW order.
+ * If on_right is true, offset edge is on right of both edges, where e1 enters v and
+ * e2 leave it. If on_right is false, then the offset edge is on the left.
+ * When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2),
+ * but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
+ * lead to different offsets) then meeting point can be found be intersecting offset lines.
+ */
+static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f,
+ int on_right, float meetco[3])
+{
+ float dir1[3], dir2[3], norm_v[3], norm_perp1[3], norm_perp2[3],
+ off1a[3], off1b[3], off2a[3], off2b[3], isect2[3];
+
+ /* get direction vectors for two offset lines */
+ sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
+ sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
+
+ /* get normal to plane where meet point should be */
+ cross_v3_v3v3(norm_v, dir2, dir1);
+ normalize_v3(norm_v);
+ if (!on_right)
+ negate_v3(norm_v);
+ if (is_zero_v3(norm_v)) {
+ /* special case: e1 and e2 are parallel; put offset point perp to both, from v.
+ * need to find a suitable plane.
+ * if offsets are different, we're out of luck: just use e1->offset */
+ if (f)
+ copy_v3_v3(norm_v, f->no);
+ else
+ copy_v3_v3(norm_v, v->no);
+ cross_v3_v3v3(norm_perp1, dir1, norm_v);
+ normalize_v3(norm_perp1);
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ copy_v3_v3(meetco, off1a);
+ }
+ else {
+ /* get vectors perp to each edge, perp to norm_v, and pointing into face */
+ if (f) {
+ copy_v3_v3(norm_v, f->no);
+ }
+ cross_v3_v3v3(norm_perp1, dir1, norm_v);
+ cross_v3_v3v3(norm_perp2, dir2, norm_v);
+ normalize_v3(norm_perp1);
+ normalize_v3(norm_perp2);
+
+ /* get points that are offset distances from each line, then another point on each line */
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ add_v3_v3v3(off1b, off1a, dir1);
+ copy_v3_v3(off2a, v->co);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset);
+ add_v3_v3v3(off2b, off2a, dir2);
+
+ /* intersect the lines; by construction they should be on the same plane and not parallel */
+ if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
+ BLI_assert(!"offset_meet failure");
+ copy_v3_v3(meetco, off1a); /* just to do something */
+ }
+ }
+}
+
+/* Like offset_meet, but here f1 and f2 must not be NULL and give the
+ * planes in which to run the offset lines. They may not meet exactly,
+ * but the line intersection routine will find the closest approach point. */
+static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v,
+ BMFace *f1, BMFace *f2, float meetco[3])
+{
+ float dir1[3], dir2[3], norm_perp1[3], norm_perp2[3],
+ off1a[3], off1b[3], off2a[3], off2b[3], isect2[3];
+
+ BLI_assert(f1 != NULL && f2 != NULL);
+
+ /* get direction vectors for two offset lines */
+ sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
+ sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
+
+ /* get directions into offset planes */
+ cross_v3_v3v3(norm_perp1, dir1, f1->no);
+ normalize_v3(norm_perp1);
+ cross_v3_v3v3(norm_perp2, dir2, f2->no);
+ normalize_v3(norm_perp2);
+
+ /* get points that are offset distances from each line, then another point on each line */
+ copy_v3_v3(off1a, v->co);
+ madd_v3_v3fl(off1a, norm_perp1, e1->offset);
+ add_v3_v3v3(off1b, off1a, dir1);
+ copy_v3_v3(off2a, v->co);
+ madd_v3_v3fl(off2a, norm_perp2, e2->offset);
+ add_v3_v3v3(off2b, off2a, dir2);
+
+ if (angle_v3v3(dir1, dir2) < 100.0f * (float)BEVEL_EPSILON) {
+ /* lines are parallel; off1a is a good meet point */
+ copy_v3_v3(meetco, off1a);
+ }
+ else if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
+ /* another test says they are parallel */
+ copy_v3_v3(meetco, off1a);
+ }
+}
+
+/* Offset by e->offset in plane with normal plane_no, on left if left==TRUE,
+ * else on right. If no is NULL, choose an arbitrary plane different
+ * from eh's direction. */
+static void offset_in_plane(EdgeHalf *e, const float plane_no[3], int left, float r[3])
+{
+ float dir[3], no[3];
+ BMVert *v;
+
+ v = e->is_rev ? e->e->v1 : e->e->v2;
+
+ sub_v3_v3v3(dir, BM_edge_other_vert(e->e, v)->co, v->co);
+ normalize_v3(dir);
+ if (plane_no) {
+ copy_v3_v3(no, plane_no);
+ }
+ else {
+ zero_v3(no);
+ if (fabs(dir[0]) < fabs(dir[1]))
+ no[0] = 1.0f;
+ else
+ no[1] = 1.0f;
+ }
+ if (left)
+ cross_v3_v3v3(r, no, dir);
+ else
+ cross_v3_v3v3(r, dir, no);
+ normalize_v3(r);
+ mul_v3_fl(r, e->offset);
+}
+
+/* Calculate coordinates of a point a distance d from v on e->e and return it in slideco */
+static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
+{
+ float dir[3], len;
+
+ sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co);
+ len = normalize_v3(dir);
+ if (d > len)
+ d = len - (float)(50.0 * BEVEL_EPSILON);
+ copy_v3_v3(slideco, v->co);
+ madd_v3_v3fl(slideco, dir, -d);
+}
+
+/* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */
+static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3])
+{
+ float otherco[3];
+
+ if (!isect_line_line_v3(e->v1->co, e->v2->co, co_a, co_b, projco, otherco)) {
+ BLI_assert(!"project meet failure");
+ copy_v3_v3(projco, e->v1->co);
+ }
+}
+
+/* return 1 if a and b are in CCW order on the normal side of f,
+ * and -1 if they are reversed, and 0 if there is no shared face f */
+static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
+{
+ BMLoop *la, *lb;
+
+ if (!f)
+ return 0;
+ la = BM_face_edge_share_loop(f, a);
+ lb = BM_face_edge_share_loop(f, b);
+ if (!la || !lb)
+ return 0;
+ return lb->next == la ? 1 : -1;
+}
+
+#ifdef USE_ALTERNATE_ADJ
+
+static void vmesh_cent(VMesh *vm, float r_cent[3])
+{
+ BoundVert *v;
+ zero_v3(r_cent);
+
+ v = vm->boundstart;
+ do {
+ add_v3_v3(r_cent, v->nv.co);
+ } while ((v = v->next) != vm->boundstart);
+ mul_v3_fl(r_cent, 1.0f / (float)vm->count);
+}
+
+/**
+ *
+ * This example shows a tri fan of quads,
+ * but could be an NGon fan of quads too.
+ * <pre>
+ * The whole triangle X
+ * represents the / \
+ * new bevel face. / \
+ * / \
+ * Split into / \
+ * a quad fan. / \
+ * / \
+ * / \
+ * / \
+ * co_prev +-. .-+
+ * / `-._ _.-' \
+ * / co_cent`-+-' \
+ * / | \
+ * Quad of / | \
+ * interest -- / ---> X | \
+ * / | \
+ * / | \
+ * / co_next| \
+ * co_orig +-----------------+-----------------+
+ *
+ * For each quad, calcualte UV's based on the following:
+ * U = k / (vm->seg * 2)
+ * V = ring / (vm->seg * 2)
+ * quad = (co_orig, co_prev, co_cent, co_next)
+ * ... note that co_cent is the same for all quads in the fan.
+ * </pre>
+ *
+ */
+
+static void get_point_uv(float uv[2],
+ /* all these args are int's originally
+ * but pass as floats to the function */
+ const float seg, const float ring, const float k)
+{
+ uv[0] = (ring / seg) * 2.0f;
+ uv[1] = (k / seg) * 2.0f;
+}
+
+/* TODO: make this a lot smarter!,
+ * this is the main reason USE_ALTERNATE_ADJ isn't so good right now :S */
+static float get_point_uv_factor(const float uv[2])
+{
+ return sinf(1.0f - max_ff(uv[0], uv[1]) / 2.0f);
+}
+
+static void get_point_on_round_edge(const float uv[2],
+ float quad[4][3],
+ float r_co[3])
+{
+ interp_bilinear_quad_v3(quad, uv[0], uv[1], r_co);
+}
+
+#else /* USE_ALTERNATE_ADJ */
+
+/*
+ * calculation of points on the round profile
+ * r - result, coordinate of point on round profile
+ * method:
+ * Inscribe a circle in angle va - v -vb
+ * such that it touches the arms at offset from v.
+ * Rotate the center-va segment by (i/n) of the
+ * angle va - center -vb, and put the endpoint
+ * of that segment in r.
+ */
+static void get_point_on_round_profile(float r_co[3], float offset, int k, int count,
+ const float va[3], const float v[3], const float vb[3])
+{
+ float vva[3], vvb[3], angle, center[3], rv[3], axis[3], co[3];
+
+ sub_v3_v3v3(vva, va, v);
+ sub_v3_v3v3(vvb, vb, v);
+ normalize_v3(vva);
+ normalize_v3(vvb);
+ angle = angle_normalized_v3v3(vva, vvb);
+
+ add_v3_v3v3(center, vva, vvb);
+ normalize_v3(center);
+ mul_v3_fl(center, offset * (1.0f / cosf(0.5f * angle)));
+ add_v3_v3(center, v); /* coordinates of the center of the inscribed circle */
+
+
+ sub_v3_v3v3(rv, va, center); /* radius vector */
+
+
+ sub_v3_v3v3(co, v, center);
+ cross_v3_v3v3(axis, rv, co); /* calculate axis */
+
+ sub_v3_v3v3(vva, va, center);
+ sub_v3_v3v3(vvb, vb, center);
+ angle = angle_v3v3(vva, vvb);
+
+ rotate_v3_v3v3fl(co, rv, axis, angle * (float)k / (float)count);
+
+ add_v3_v3(co, center);
+ copy_v3_v3(r_co, co);
+}
+
+/*
+ * Find the point (/n) of the way around the round profile for e,
+ * where start point is va, midarc point is vmid, and end point is vb.
+ * Return the answer in profileco.
+ * Method:
+ * Adjust va and vb (along edge direction) so that they are perpendicular
+ * to edge at v, then use get_point_on_round_profile, then project
+ * back onto original va - vmid - vb plane.
+ * If va, vmid, and vb are all on the same plane, just interpolate between va and vb.
+ */
+static void get_point_on_round_edge(EdgeHalf *e, int k,
+ const float va[3], const float vmid[3], const float vb[3],
+ float r_co[3])
+{
+ float vva[3], vvb[3], point[3], dir[3], vaadj[3], vbadj[3], p2[3], pn[3];
+ int n = e->seg;
+
+ sub_v3_v3v3(vva, va, vmid);
+ sub_v3_v3v3(vvb, vb, vmid);
+ if (e->is_rev)
+ sub_v3_v3v3(dir, e->e->v1->co, e->e->v2->co);
+ else
+ sub_v3_v3v3(dir, e->e->v2->co, e->e->v1->co);
+ normalize_v3(dir);
+ if (fabsf(angle_v3v3(vva, vvb) - (float)M_PI) > (float)BEVEL_EPSILON) {
+ copy_v3_v3(vaadj, va);
+ madd_v3_v3fl(vaadj, dir, -len_v3(vva) * cosf(angle_v3v3(vva, dir)));
+ copy_v3_v3(vbadj, vb);
+ madd_v3_v3fl(vbadj, dir, -len_v3(vvb) * cosf(angle_v3v3(vvb, dir)));
+
+ get_point_on_round_profile(point, e->offset, k, n, vaadj, vmid, vbadj);
+
+ add_v3_v3v3(p2, point, dir);
+ cross_v3_v3v3(pn, vva, vvb);
+ if (!isect_line_plane_v3(r_co, point, p2, vmid, pn, 0)) {
+ /* TODO: track down why this sometimes fails */
+ copy_v3_v3(r_co, point);
+ }
+ }
+ else {
+ /* planar case */
+ interp_v3_v3v3(r_co, va, vb, (float)k / (float)n);
+ }
+}
+
+#endif /* !USE_ALTERNATE_ADJ */
+
+/* Make a circular list of BoundVerts for bv, each of which has the coordinates
+ * of a vertex on the the boundary of the beveled vertex bv->v.
+ * Also decide on the mesh pattern that will be used inside the boundary.
+ * Doesn't make the actual BMVerts */
+static void build_boundary(MemArena *mem_arena, BevVert *bv)
+{
+ EdgeHalf *efirst, *e;
+ BoundVert *v;
+ VMesh *vm;
+ float co[3];
+ const float *no;
+ float lastd;
+
+ e = efirst = next_bev(bv, NULL);
+ vm = bv->vmesh;
+
+ BLI_assert(bv->edgecount >= 2); /* since bevel edges incident to 2 faces */
+
+ if (bv->edgecount == 2 && bv->selcount == 1) {
+ /* special case: beveled edge meets non-beveled one at valence 2 vert */
+ no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
+ offset_in_plane(e, no, TRUE, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = v->elast = v->ebev = e;
+ e->leftv = v;
+ no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
+ offset_in_plane(e, no, FALSE, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = v->elast = e;
+ e->rightv = v;
+ /* make artifical extra point along unbeveled edge, and form triangle */
+ slide_dist(e->next, bv->v, e->offset, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = v->elast = e->next;
+ vm->mesh_kind = M_POLY;
+ return;
+ }
+
+ lastd = e->offset;
+ vm->boundstart = NULL;
+ do {
+ if (e->is_bev) {
+ /* handle only left side of beveled edge e here: next iteration should do right side */
+ if (e->prev->is_bev) {
+ BLI_assert(e->prev != e); /* see: wire edge special case */
+ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = e->prev;
+ v->elast = v->ebev = e;
+ e->leftv = v;
+ e->prev->rightv = v;
+ }
+ else {
+ /* e->prev is not beveled */
+ if (e->prev->prev->is_bev) {
+ BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */
+ /* find meet point between e->prev->prev and e and attach e->prev there */
+ /* TODO: fix case when one or both faces in following are NULL */
+ offset_in_two_planes(e->prev->prev, e, bv->v,
+ e->prev->prev->fnext, e->fprev, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = e->prev->prev;
+ v->elast = v->ebev = e;
+ e->leftv = v;
+ e->prev->leftv = v;
+ e->prev->prev->rightv = v;
+ }
+ else {
+ /* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */
+ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = e->prev;
+ v->elast = v->ebev = e;
+ e->leftv = v;
+ e->prev->leftv = v;
+ }
+ }
+ lastd = len_v3v3(bv->v->co, v->nv.co);
+ }
+ else {
+ /* e is not beveled */
+ if (e->next->is_bev) {
+ /* next iteration will place e between beveled previous and next edges */
+ /* do nothing... */
+ }
+ else if (e->prev->is_bev) {
+ /* on-edge meet between e->prev and e */
+ offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = e->prev;
+ v->elast = e;
+ e->leftv = v;
+ e->prev->rightv = v;
+ }
+ else {
+ /* None of e->prev, e, e->next are beveled.
+ * could either leave alone or add slide points to make
+ * one polygon around bv->v. For now, we choose latter.
+ * Could slide to make an even bevel plane but for now will
+ * just use last distance a meet point moved from bv->v. */
+ slide_dist(e, bv->v, lastd, co);
+ v = add_new_bound_vert(mem_arena, vm, co);
+ v->efirst = v->elast = e;
+ e->leftv = v;
+ }
+ }
+ } while ((e = e->next) != efirst);
+
+ BLI_assert(vm->count >= 2);
+ if (vm->count == 2 && bv->edgecount == 3) {
+ vm->mesh_kind = M_NONE;
+ }
+ else if (bv->selcount == 2) {
+ vm->mesh_kind = M_QUAD_STRIP;
+ }
+ else if (efirst->seg == 1 || bv->selcount == 1) {
+ if (vm->count == 3 && bv->selcount == 1) {
+ vm->mesh_kind = M_TRI_FAN;
+ }
+ else {
+ vm->mesh_kind = M_POLY;
+ }
+ }
+ else {
+ vm->mesh_kind = M_ADJ;
+ }
+ /* TODO: if vm->count == 4 and bv->selcount == 4, use M_CROSS pattern */
+}
+
+/*
+ * Given that the boundary is built and the boundary BMVerts have been made,
+ * calculate the positions of the interior mesh points for the M_ADJ pattern,
+ * then make the BMVerts and the new faces. */
+static void bevel_build_rings(BMesh *bm, BevVert *bv)
+{
+ int k, ring, i, n, ns, ns2, nn;
+ VMesh *vm = bv->vmesh;
+ BoundVert *v, *vprev, *vnext;
+ NewVert *nv, *nvprev, *nvnext;
+ BMVert *bmv, *bmv1, *bmv2, *bmv3, *bmv4;
+ BMFace *f;
+ float co[3], coa[3], cob[3], midco[3];
+
+#ifdef USE_ALTERNATE_ADJ
+ /* ordered as follows (orig, prev, center, next)*/
+ float quad_plane[4][3];
+ float quad_orig[4][3];
+#endif
+
+
+#ifdef USE_ALTERNATE_ADJ
+ /* the rest are initialized inline, this remains the same for all */
+ vmesh_cent(vm, quad_plane[2]);
+ copy_v3_v3(quad_orig[2], bv->v->co);
+#endif
+
+ n = vm->count;
+ ns = vm->seg;
+ ns2 = ns / 2;
+ BLI_assert(n > 2 && ns > 1);
+ /* Make initial rings, going between points on neighbors.
+ * After this loop, will have coords for all (i, r, k) where
+ * BoundVert for i has a bevel, 0 <= r <= ns2, 0 <= k <= ns */
+ for (ring = 1; ring <= ns2; ring++) {
+ v = vm->boundstart;
+
+ do {
+ i = v->index;
+ if (v->ebev) {
+ /* get points coords of points a and b, on outer rings
+ * of prev and next edges, k away from this edge */
+ vprev = v->prev;
+ vnext = v->next;
+
+ if (vprev->ebev)
+ nvprev = mesh_vert(vm, vprev->index, 0, ns - ring);
+ else
+ nvprev = mesh_vert(vm, vprev->index, 0, ns);
+ copy_v3_v3(coa, nvprev->co);
+ nv = mesh_vert(vm, i, ring, 0);
+ copy_v3_v3(nv->co, coa);
+ nv->v = nvprev->v;
+
+ if (vnext->ebev)
+ nvnext = mesh_vert(vm, vnext->index, 0, ring);
+ else
+ nvnext = mesh_vert(vm, vnext->index, 0, 0);
+ copy_v3_v3(cob, nvnext->co);
+ nv = mesh_vert(vm, i, ring, ns);
+ copy_v3_v3(nv->co, cob);
+ nv->v = nvnext->v;
+
+#ifdef USE_ALTERNATE_ADJ
+ /* plane */
+ copy_v3_v3(quad_plane[0], v->nv.co);
+ mid_v3_v3v3(quad_plane[1], v->nv.co, v->prev->nv.co);
+ /* quad[2] is set */
+ mid_v3_v3v3(quad_plane[3], v->nv.co, v->next->nv.co);
+
+ /* orig */
+ copy_v3_v3(quad_orig[0], v->nv.co); /* only shared location between 2 quads */
+ project_to_edge(v->ebev->prev->e, v->nv.co, v->prev->nv.co, quad_orig[1]);
+ project_to_edge(v->ebev->e, v->nv.co, v->next->nv.co, quad_orig[3]);
+
+ //bl_debug_draw_quad_add(UNPACK4(quad_plane));
+ //bl_debug_draw_quad_add(UNPACK4(quad_orig));
+#endif
+
+#ifdef USE_ALTERNATE_ADJ
+ for (k = 1; k < ns; k++) {
+ float uv[2];
+ float fac;
+ float co_plane[3];
+ float co_orig[3];
+
+ get_point_uv(uv, v->ebev->seg, ring, k);
+ get_point_on_round_edge(uv, quad_plane, co_plane);
+ get_point_on_round_edge(uv, quad_orig, co_orig);
+ fac = get_point_uv_factor(uv);
+ interp_v3_v3v3(co, co_plane, co_orig, fac);
+ copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co);
+ }
+#else
+ /* TODO: better calculation of new midarc point? */
+ project_to_edge(v->ebev->e, coa, cob, midco);
+
+ for (k = 1; k < ns; k++) {
+ get_point_on_round_edge(v->ebev, k, coa, midco, cob, co);
+ copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co);
+ }
+#endif
+ }
+ } while ((v = v->next) != vm->boundstart);
+ }
+
+ /* Now make sure cross points of rings share coordinates and vertices.
+ * After this loop, will have BMVerts for all (i, r, k) where
+ * i is for a BoundVert that is beveled and has either a predecessor or
+ * successor BoundVert beveled too, and
+ * for odd ns: 0 <= r <= ns2, 0 <= k <= ns
+ * for even ns: 0 <= r < ns2, 0 <= k <= ns except k=ns2 */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ vprev = v->prev;
+ vnext = v->next;
+ if (vprev->ebev) {
+ for (ring = 1; ring <= ns2; ring++) {
+ for (k = 1; k <= ns2; k++) {
+ if (ns % 2 == 0 && (k == ns2 || ring == ns2))
+ continue; /* center line is special case: do after the rest are done */
+ nv = mesh_vert(vm, i, ring, k);
+ nvprev = mesh_vert(vm, vprev->index, k, ns - ring);
+ mid_v3_v3v3(co, nv->co, nvprev->co);
+#ifndef USE_ALTERNATE_ADJ
+ copy_v3_v3(nv->co, co);
+#endif
+ BLI_assert(nv->v == NULL && nvprev->v == NULL);
+ create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
+ copy_mesh_vert(vm, vprev->index, k, ns - ring, i, ring, k);
+ }
+ }
+ if (!vprev->prev->ebev) {
+ for (ring = 1; ring <= ns2; ring++) {
+ for (k = 1; k <= ns2; k++) {
+ if (ns % 2 == 0 && (k == ns2 || ring == ns2))
+ continue;
+ create_mesh_bmvert(bm, vm, vprev->index, ring, k, bv->v);
+ }
+ }
+ }
+ if (!vnext->ebev) {
+ for (ring = 1; ring <= ns2; ring++) {
+ for (k = ns - ns2; k < ns; k++) {
+ if (ns % 2 == 0 && (k == ns2 || ring == ns2))
+ continue;
+ create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
+ }
+ }
+ }
+ }
+ }
+ } while ((v = v->next) != vm->boundstart);
+
+ if (ns % 2 == 0) {
+ /* Do special case center lines.
+ * This loop makes verts for (i, ns2, k) for 1 <= k <= ns-1, k!=ns2
+ * and for (i, r, ns2) for 1 <= r <= ns2-1,
+ * whenever i is in a sequence of at least two beveled verts */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ vprev = v->prev;
+ vnext = v->next;
+ for (k = 1; k < ns2; k++) {
+ nv = mesh_vert(vm, i, k, ns2);
+ if (vprev->ebev)
+ nvprev = mesh_vert(vm, vprev->index, ns2, ns - k);
+ if (vnext->ebev)
+ nvnext = mesh_vert(vm, vnext->index, ns2, k);
+ if (vprev->ebev && vnext->ebev) {
+ mid_v3_v3v3v3(co, nvprev->co, nv->co, nvnext->co);
+#ifndef USE_ALTERNATE_ADJ
+ copy_v3_v3(nv->co, co);
+#endif
+ create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
+ copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
+ copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
+
+ }
+ else if (vprev->ebev) {
+ mid_v3_v3v3(co, nvprev->co, nv->co);
+#ifndef USE_ALTERNATE_ADJ
+ copy_v3_v3(nv->co, co);
+#endif
+ create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
+ copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
+
+ create_mesh_bmvert(bm, vm, i, ns2, ns - k, bv->v);
+ }
+ else if (vnext->ebev) {
+ mid_v3_v3v3(co, nv->co, nvnext->co);
+#ifndef USE_ALTERNATE_ADJ
+ copy_v3_v3(nv->co, co);
+#endif
+ create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
+ copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
+
+ create_mesh_bmvert(bm, vm, i, ns2, k, bv->v);
+ }
+ }
+ }
+ } while ((v = v->next) != vm->boundstart);
+
+ /* center point need to be average of all centers of rings */
+ /* TODO: this is wrong if not all verts have ebev: could have
+ * several disconnected sections of mesh. */
+ zero_v3(midco);
+ nn = 0;
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ nv = mesh_vert(vm, i, ns2, ns2);
+ add_v3_v3(midco, nv->co);
+ nn++;
+ }
+ } while ((v = v->next) != vm->boundstart);
+ mul_v3_fl(midco, 1.0f / nn);
+ bmv = BM_vert_create(bm, midco, NULL);
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ nv = mesh_vert(vm, i, ns2, ns2);
+ copy_v3_v3(nv->co, midco);
+ nv->v = bmv;
+ }
+ } while ((v = v->next) != vm->boundstart);
+ }
+
+ /* Make the ring quads */
+ for (ring = 0; ring < ns2; ring++) {
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ f = boundvert_rep_face(v);
+ if (v->ebev && (v->prev->ebev || v->next->ebev)) {
+ for (k = 0; k < ns2 + (ns % 2); k++) {
+ bmv1 = mesh_vert(vm, i, ring, k)->v;
+ bmv2 = mesh_vert(vm, i, ring, k + 1)->v;
+ bmv3 = mesh_vert(vm, i, ring + 1, k + 1)->v;
+ bmv4 = mesh_vert(vm, i, ring + 1, k)->v;
+ BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
+ if (bmv3 == bmv4 || bmv1 == bmv4)
+ bmv4 = NULL;
+ bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f);
+ }
+ }
+ else if (v->prev->ebev && v->prev->prev->ebev) {
+ /* finish off a sequence of beveled edges */
+ i = v->prev->index;
+ f = boundvert_rep_face(v->prev);
+ for (k = ns2 + (ns % 2); k < ns; k++) {
+ bmv1 = mesh_vert(vm, i, ring, k)->v;
+ bmv2 = mesh_vert(vm, i, ring, k + 1)->v;
+ bmv3 = mesh_vert(vm, i, ring + 1, k + 1)->v;
+ bmv4 = mesh_vert(vm, i, ring + 1, k)->v;
+ BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
+ if (bmv2 == bmv3) {
+ bmv3 = bmv4;
+ bmv4 = NULL;
+ }
+ bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f);
+ }
+ }
+ } while ((v = v->next) != vm->boundstart);
+ }
+
+ /* Make center ngon if odd number of segments and fully beveled */
+ if (ns % 2 == 1 && vm->count == bv->selcount) {
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ BLI_assert(v->ebev);
+ BLI_array_append(vv, mesh_vert(vm, i, ns2, ns2)->v);
+ } while ((v = v->next) != vm->boundstart);
+ f = boundvert_rep_face(vm->boundstart);
+ bev_create_ngon(bm, vv, BLI_array_count(vv), f);
+
+ BLI_array_free(vv);
+ }
+
+ /* Make 'rest-of-vmesh' polygon if not fully beveled */
+ if (vm->count > bv->selcount) {
+ int j;
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ v = vm->boundstart;
+ f = boundvert_rep_face(v);
+ j = 0;
+ do {
+ i = v->index;
+ if (v->ebev) {
+ if (!v->prev->ebev) {
+ for (k = 0; k < ns2; k++) {
+ bmv1 = mesh_vert(vm, i, ns2, k)->v;
+ if (!bmv1)
+ bmv1 = mesh_vert(vm, i, 0, k)->v;
+ if (!(j > 0 && bmv1 == vv[j - 1])) {
+ BLI_assert(bmv1 != NULL);
+ BLI_array_append(vv, bmv1);
+ j++;
+ }
+ }
+ }
+ bmv1 = mesh_vert(vm, i, ns2, ns2)->v;
+ if (!bmv1)
+ bmv1 = mesh_vert(vm, i, 0, ns2)->v;
+ if (!(j > 0 && bmv1 == vv[j - 1])) {
+ BLI_assert(bmv1 != NULL);
+ BLI_array_append(vv, bmv1);
+ j++;
+ }
+ if (!v->next->ebev) {
+ for (k = ns - ns2; k < ns; k++) {
+ bmv1 = mesh_vert(vm, i, ns2, k)->v;
+ if (!bmv1)
+ bmv1 = mesh_vert(vm, i, 0, k)->v;
+ if (!(j > 0 && bmv1 == vv[j - 1])) {
+ BLI_assert(bmv1 != NULL);
+ BLI_array_append(vv, bmv1);
+ j++;
+ }
+ }
+ }
+ }
+ else {
+ BLI_assert(mesh_vert(vm, i, 0, 0)->v != NULL);
+ BLI_array_append(vv, mesh_vert(vm, i, 0, 0)->v);
+ j++;
+ }
+ } while ((v = v->next) != vm->boundstart);
+ if (vv[0] == vv[j - 1])
+ j--;
+ bev_create_ngon(bm, vv, j, f);
+
+ BLI_array_free(vv);
+ }
+}
+
+static BMFace *bevel_build_poly_ex(BMesh *bm, BevVert *bv)
+{
+ BMFace *f;
+ int n, k;
+ VMesh *vm = bv->vmesh;
+ BoundVert *v;
+ BMVert **vv = NULL;
+ BLI_array_declare(vv);
+
+ v = vm->boundstart;
+ n = 0;
+ do {
+ /* accumulate vertices for vertex ngon */
+ BLI_array_append(vv, v->nv.v);
+ n++;
+ if (v->ebev && v->ebev->seg > 1) {
+ for (k = 1; k < v->ebev->seg; k++) {
+ BLI_array_append(vv, mesh_vert(vm, v->index, 0, k)->v);
+ n++;
+ }
+ }
+ } while ((v = v->next) != vm->boundstart);
+ if (n > 2) {
+ f = bev_create_ngon(bm, vv, n, boundvert_rep_face(v));
+ }
+ else {
+ f = NULL;
+ }
+ BLI_array_free(vv);
+ return f;
+}
+
+static void bevel_build_poly(BMesh *bm, BevVert *bv)
+{
+ bevel_build_poly_ex(bm, bv);
+}
+
+static void bevel_build_trifan(BMesh *bm, BevVert *bv)
+{
+ BMFace *f;
+ BLI_assert(next_bev(bv, NULL)->seg == 1 || bv->selcount == 1);
+
+ f = bevel_build_poly_ex(bm, bv);
+
+ if (f) {
+ /* we have a polygon which we know starts at the previous vertex, make it into a fan */
+ BMLoop *l_fan = BM_FACE_FIRST_LOOP(f)->prev;
+ BMVert *v_fan = l_fan->v;
+
+ while (f->len > 3) {
+ BMLoop *l_new;
+ BMFace *f_new;
+ BLI_assert(v_fan == l_fan->v);
+ f_new = BM_face_split(bm, f, l_fan->v, l_fan->next->next->v, &l_new, NULL, FALSE);
+
+ if (f_new->len > f->len) {
+ f = f_new;
+ if (l_new->v == v_fan) { l_fan = l_new; }
+ else if (l_new->next->v == v_fan) { l_fan = l_new->next; }
+ else if (l_new->prev->v == v_fan) { l_fan = l_new->prev; }
+ else { BLI_assert(0); }
+ }
+ else {
+ if (l_fan->v == v_fan) { l_fan = l_fan; }
+ else if (l_fan->next->v == v_fan) { l_fan = l_fan->next; }
+ else if (l_fan->prev->v == v_fan) { l_fan = l_fan->prev; }
+ else { BLI_assert(0); }
+ }
+ }
+ }
+}
+
+static void bevel_build_quadstrip(BMesh *bm, BevVert *bv)
+{
+ BMFace *f;
+ BLI_assert(bv->selcount == 2);
+
+ f = bevel_build_poly_ex(bm, bv);
+
+ if (f) {
+ /* we have a polygon which we know starts at this vertex, make it into strips */
+ EdgeHalf *eh_a = bv->vmesh->boundstart->elast;
+ EdgeHalf *eh_b = next_bev(bv, eh_a->next); /* since (selcount == 2) we know this is valid */
+ BMLoop *l_a = BM_face_vert_share_loop(f, eh_a->rightv->nv.v);
+ BMLoop *l_b = BM_face_vert_share_loop(f, eh_b->leftv->nv.v);
+ int seg_count = bv->vmesh->seg; /* ensure we don't walk past the segments */
+
+ if (l_a == l_b) {
+ /* step once around if we hit the same loop */
+ l_a = l_a->prev;
+ l_b = l_b->next;
+ seg_count--;
+ }
+
+ BLI_assert(l_a != l_b);
+
+ while (f->len > 4) {
+ BMLoop *l_new;
+ BLI_assert(l_a->f == f);
+ BLI_assert(l_b->f == f);
+
+ BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE);
+ if (seg_count-- == 0) {
+ break;
+ }
+
+ /* turns out we don't need this,
+ * because of how BM_face_split works we always get the loop of the next face */
+#if 0
+ if (l_new->f->len < l_new->radial_next->f->len) {
+ l_new = l_new->radial_next;
+ }
+#endif
+ f = l_new->f;
+
+ /* walk around the new face to get the next verts to split */
+ l_a = l_new->prev;
+ l_b = l_new->next->next;
+ }
+ }
+}
+
+/* Given that the boundary is built, now make the actual BMVerts
+ * for the boundary and the interior of the vertex mesh. */
+static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv)
+{
+ VMesh *vm = bv->vmesh;
+ BoundVert *v, *weld1, *weld2;
+ int n, ns, ns2, i, k, weld;
+ float *va, *vb, co[3];
+
+#ifdef USE_ALTERNATE_ADJ
+ /* ordered as follows (orig, prev, center, next)*/
+ float quad_plane[4][3];
+ float quad_orig_a[4][3];
+ float quad_orig_b[4][3];
+ const int is_odd = (vm->seg % 2);
+#else
+ float midco[3];
+#endif
+
+#ifdef USE_ALTERNATE_ADJ
+ /* the rest are initialized inline, this remains the same for all */
+ /* NOTE; in this usage we only interpolate on the 'V' so cent and next points are unused (2,3)*/
+ vmesh_cent(vm, quad_plane[2]);
+ copy_v3_v3(quad_orig_a[2], bv->v->co);
+ copy_v3_v3(quad_orig_b[2], bv->v->co);
+#endif
+
+ n = vm->count;
+ ns = vm->seg;
+ ns2 = ns / 2;
+
+ vm->mesh = (NewVert *)BLI_memarena_alloc(mem_arena, n * (ns2 + 1) * (ns + 1) * sizeof(NewVert));
+
+ /* special case: two beveled ends welded together */
+ weld = (bv->selcount == 2) && (vm->count == 2);
+ weld1 = weld2 = NULL; /* will hold two BoundVerts involved in weld */
+
+ /* make (i, 0, 0) mesh verts for all i */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ copy_v3_v3(mesh_vert(vm, i, 0, 0)->co, v->nv.co);
+ create_mesh_bmvert(bm, vm, i, 0, 0, bv->v);
+ v->nv.v = mesh_vert(vm, i, 0, 0)->v;
+ if (weld && v->ebev) {
+ if (!weld1)
+ weld1 = v;
+ else
+ weld2 = v;
+ }
+ } while ((v = v->next) != vm->boundstart);
+
+ /* copy other ends to (i, 0, ns) for all i, and fill in profiles for beveled edges */
+ v = vm->boundstart;
+ do {
+ i = v->index;
+ copy_mesh_vert(vm, i, 0, ns, v->next->index, 0, 0);
+ if (v->ebev) {
+
+#ifdef USE_ALTERNATE_ADJ
+ copy_v3_v3(quad_plane[0], v->nv.co);
+ mid_v3_v3v3(quad_plane[1], v->nv.co, v->prev->nv.co);
+ /* quad[2] is set */
+ mid_v3_v3v3(quad_plane[3], v->nv.co, v->next->nv.co);
+
+ /* orig 'A' */
+ copy_v3_v3(quad_orig_a[0], v->nv.co); /* only shared location between 2 quads */
+ project_to_edge(v->ebev->prev->e, v->nv.co, v->prev->nv.co, quad_orig_a[1]);
+ project_to_edge(v->ebev->e, v->nv.co, v->next->nv.co, quad_orig_a[3]);
+
+ /* orig 'B' */
+ copy_v3_v3(quad_orig_b[3], v->next->nv.co); /* only shared location between 2 quads */
+ project_to_edge(v->ebev->prev->e, v->nv.co, v->prev->nv.co, quad_orig_b[1]);
+ project_to_edge(v->ebev->e, v->nv.co, v->next->nv.co, quad_orig_b[0]);
+
+ //bl_debug_draw_quad_add(UNPACK4(quad_plane));
+ //bl_debug_draw_quad_add(UNPACK4(quad_orig_a));
+ //bl_debug_draw_quad_add(UNPACK4(quad_orig_b));
+#endif /* USE_ALTERNATE_ADJ */
+
+#ifdef USE_ALTERNATE_ADJ
+ for (k = 1; k < ns; k++) {
+ float uv[2];
+ float fac;
+ float co_plane[3];
+ float co_orig[3];
+
+ /* quad_plane */
+ get_point_uv(uv, v->ebev->seg, 0, k);
+ get_point_on_round_edge(uv, quad_plane, co_plane);
+
+ /* quad_orig */
+ /* each half has different UV's */
+ if (k <= ns2) {
+ get_point_uv(uv, v->ebev->seg, 0, k);
+ get_point_on_round_edge(uv, quad_orig_a, co_orig);
+ }
+ else {
+ get_point_uv(uv, v->ebev->seg, 0, (k - ns2) - (is_odd ? 0.5f : 0.0f));
+ get_point_on_round_edge(uv, quad_orig_b, co_orig);
+ uv[1] = 1.0f - uv[1]; /* so we can get the factor */
+ }
+ fac = get_point_uv_factor(uv);
+
+ /* done. interp */
+ interp_v3_v3v3(co, co_plane, co_orig, fac);
+ copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
+ if (!weld)
+ create_mesh_bmvert(bm, vm, i, 0, k, bv->v);
+ }
+#else /* USE_ALTERNATE_ADJ */
+ va = mesh_vert(vm, i, 0, 0)->co;
+ vb = mesh_vert(vm, i, 0, ns)->co;
+ project_to_edge(v->ebev->e, va, vb, midco);
+ for (k = 1; k < ns; k++) {
+ get_point_on_round_edge(v->ebev, k, va, midco, vb, co);
+ copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co);
+ if (!weld)
+ create_mesh_bmvert(bm, vm, i, 0, k, bv->v);
+ }
+#endif /* !USE_ALTERNATE_ADJ */
+ }
+ } while ((v = v->next) != vm->boundstart);
+
+ if (weld) {
+ vm->mesh_kind = M_NONE;
+ for (k = 1; k < ns; k++) {
+ va = mesh_vert(vm, weld1->index, 0, k)->co;
+ vb = mesh_vert(vm, weld2->index, 0, ns - k)->co;
+ mid_v3_v3v3(co, va, vb);
+ copy_v3_v3(mesh_vert(vm, weld1->index, 0, k)->co, co);
+ create_mesh_bmvert(bm, vm, weld1->index, 0, k, bv->v);
+ }
+ for (k = 1; k < ns; k++)
+ copy_mesh_vert(vm, weld2->index, 0, ns - k, weld1->index, 0, k);
+ }
+
+ switch (vm->mesh_kind) {
+ case M_NONE:
+ /* do nothing */
+ break;
+ case M_POLY:
+ bevel_build_poly(bm, bv);
+ break;
+ case M_ADJ:
+ bevel_build_rings(bm, bv);
+ break;
+ case M_TRI_FAN:
+ bevel_build_trifan(bm, bv);
+ break;
+ case M_QUAD_STRIP:
+ bevel_build_quadstrip(bm, bv);
+ break;
+ }
+}
+
+/* take care, this flag isn't cleared before use, it just so happens that its not set */
+#define BM_BEVEL_EDGE_TAG_ENABLE(bme) BM_elem_flag_enable( (bme)->l, BM_ELEM_TAG)
+#define BM_BEVEL_EDGE_TAG_DISABLE(bme) BM_elem_flag_disable( (bme)->l, BM_ELEM_TAG)
+#define BM_BEVEL_EDGE_TAG_TEST(bme) BM_elem_flag_test( (bme)->l, BM_ELEM_TAG)
+
+/*
+ * Construction around the vertex
+ */
+static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
+{
+ BMEdge *bme;
+ BevVert *bv;
+ BMEdge *bme2, *unflagged_bme;
+ BMFace *f;
+ BMIter iter, iter2;
+ EdgeHalf *e;
+ int i, found_shared_face, ccw_test_sum;
+ int nsel = 0;
+ int ntot = 0;
+
+ /* Gather input selected edges.
+ * Only bevel selected edges that have exactly two incident faces.
+ */
+
+ BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
+ if (BM_elem_flag_test(bme, BM_ELEM_TAG)) {
+ BLI_assert(BM_edge_is_manifold(bme));
+ nsel++;
+ }
+ ntot++;
+ }
+
+ if (nsel == 0) {
+ /* signal this vert isn't being beveled */
+ BM_elem_flag_disable(v, BM_ELEM_TAG);
+ return;
+ }
+
+ /* avoid calling BM_vert_edge_count since we loop over edges already */
+ // ntot = BM_vert_edge_count(v);
+ // BLI_assert(ntot == BM_vert_edge_count(v));
+
+ bv = (BevVert *)BLI_memarena_alloc(bp->mem_arena, (sizeof(BevVert)));
+ bv->v = v;
+ bv->edgecount = ntot;
+ bv->selcount = nsel;
+ bv->edges = (EdgeHalf *)BLI_memarena_alloc(bp->mem_arena, ntot * sizeof(EdgeHalf));
+ bv->vmesh = (VMesh *)BLI_memarena_alloc(bp->mem_arena, sizeof(VMesh));
+ bv->vmesh->seg = bp->seg;
+ BLI_ghash_insert(bp->vert_hash, v, bv);
+
+ /* add edges to bv->edges in order that keeps adjacent edges sharing
+ * a face, if possible */
+ i = 0;
+ bme = v->e;
+ BM_BEVEL_EDGE_TAG_ENABLE(bme);
+ e = &bv->edges[0];
+ e->e = bme;
+ for (i = 0; i < ntot; i++) {
+ if (i > 0) {
+ /* find an unflagged edge bme2 that shares a face f with previous bme */
+ found_shared_face = 0;
+ unflagged_bme = NULL;
+ BM_ITER_ELEM (bme2, &iter, v, BM_EDGES_OF_VERT) {
+ if (BM_BEVEL_EDGE_TAG_TEST(bme2))
+ continue;
+ if (!unflagged_bme)
+ unflagged_bme = bme2;
+ BM_ITER_ELEM (f, &iter2, bme2, BM_FACES_OF_EDGE) {
+ if (BM_face_edge_share_loop(f, bme)) {
+ found_shared_face = 1;
+ break;
+ }
+ }
+ if (found_shared_face)
+ break;
+ }
+ e = &bv->edges[i];
+ if (found_shared_face) {
+ e->e = bme2;
+ e->fprev = f;
+ bv->edges[i - 1].fnext = f;
+ }
+ else {
+ e->e = unflagged_bme;
+ }
+ }
+ bme = e->e;
+ BM_BEVEL_EDGE_TAG_ENABLE(bme);
+ if (BM_elem_flag_test(bme, BM_ELEM_TAG)) {
+ e->is_bev = TRUE;
+ e->seg = bp->seg;
+ }
+ else {
+ e->is_bev = FALSE;
+ e->seg = 0;
+ }
+ e->is_rev = (bme->v2 == v);
+ e->offset = e->is_bev ? bp->offset : 0.0f;
+ }
+ /* find wrap-around shared face */
+ BM_ITER_ELEM (f, &iter2, bme, BM_FACES_OF_EDGE) {
+ if (BM_face_edge_share_loop(f, bv->edges[0].e)) {
+ if (bv->edges[0].fnext == f)
+ continue; /* if two shared faces, want the other one now */
+ bv->edges[ntot - 1].fnext = f;
+ bv->edges[0].fprev = f;
+ break;
+ }
+ }
+
+ /* do later when we loop over edges */
+#if 0
+ /* clear BEVEL_EDGE_TAG now that we are finished with it*/
+ for (i = 0; i < ntot; i++) {
+ BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[i].e);
+ }
+#endif
+
+ /* if edge array doesn't go CCW around vertex from average normal side,
+ * reverse the array, being careful to reverse face pointers too */
+ if (ntot > 1) {
+ ccw_test_sum = 0;
+ for (i = 0; i < ntot; i++)
+ ccw_test_sum += bev_ccw_test(bv->edges[i].e, bv->edges[(i + 1) % ntot].e,
+ bv->edges[i].fnext);
+ if (ccw_test_sum < 0) {
+ for (i = 0; i <= (ntot / 2) - 1; i++) {
+ SWAP(EdgeHalf, bv->edges[i], bv->edges[ntot - i - 1]);
+ SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
+ SWAP(BMFace *, bv->edges[ntot - i - 1].fprev, bv->edges[ntot - i - 1].fnext);
+ }
+ if (ntot % 2 == 1) {
+ i = ntot / 2;
+ SWAP(BMFace *, bv->edges[i].fprev, bv->edges[i].fnext);
+ }
+ }
+ }
+
+ for (i = 0, e = bv->edges; i < ntot; i++, e++) {
+ e->next = &bv->edges[(i + 1) % ntot];
+ e->prev = &bv->edges[(i + ntot - 1) % ntot];
+ BM_BEVEL_EDGE_TAG_DISABLE(e->e);
+ }
+
+ build_boundary(bp->mem_arena, bv);
+ build_vmesh(bp->mem_arena, bm, bv);
+}
+
+/* Face f has at least one beveled vertex. Rebuild f */
+static int bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f)
+{
+ BMIter liter;
+ BMLoop *l, *lprev;
+ BevVert *bv;
+ BoundVert *v, *vstart, *vend;
+ EdgeHalf *e, *eprev;
+ VMesh *vm;
+ int i, k;
+ int do_rebuild = FALSE;
+ BMVert *bmv;
+ BMVert **vv = NULL;
+ BLI_array_staticdeclare(vv, BM_DEFAULT_NGON_STACK_SIZE);
+
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ if (BM_elem_flag_test(l->v, BM_ELEM_TAG)) {
+ lprev = l->prev;
+ bv = find_bevvert(bp, l->v);
+ e = find_edge_half(bv, l->e);
+ eprev = find_edge_half(bv, lprev->e);
+ BLI_assert(e != NULL && eprev != NULL);
+ vstart = eprev->leftv;
+ if (e->is_bev)
+ vend = e->rightv;
+ else
+ vend = e->leftv;
+ v = vstart;
+ vm = bv->vmesh;
+ BLI_array_append(vv, v->nv.v);
+ while (v != vend) {
+ if (vm->mesh_kind == M_NONE && v->ebev && v->ebev->seg > 1 && v->ebev != e && v->ebev != eprev) {
+ /* case of 3rd face opposite a beveled edge, with no vmesh */
+ i = v->index;
+ e = v->ebev;
+ for (k = 1; k < e->seg; k++) {
+ bmv = mesh_vert(vm, i, 0, k)->v;
+ BLI_array_append(vv, bmv);
+ }
+ }
+ v = v->prev;
+ BLI_array_append(vv, v->nv.v);
+ }
+
+ do_rebuild = TRUE;
+ }
+ else {
+ BLI_array_append(vv, l->v);
+ }
+ }
+ if (do_rebuild) {
+ BMFace *f_new = bev_create_ngon(bm, vv, BLI_array_count(vv), f);
+
+ /* don't select newly created boundary faces... */
+ if (f_new) {
+ BM_elem_flag_disable(f_new, BM_ELEM_TAG);
+ }
+ }
+
+ BLI_array_free(vv);
+ return do_rebuild;
+}
+
+/* All polygons touching v need rebuilding because beveling v has made new vertices */
+static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert *v)
+{
+ void *faces_stack[BM_DEFAULT_ITER_STACK_SIZE];
+ int faces_len, f_index;
+ BMFace **faces = BM_iter_as_arrayN(bm, BM_FACES_OF_VERT, v, &faces_len,
+ faces_stack, BM_DEFAULT_ITER_STACK_SIZE);
+
+ if (LIKELY(faces != NULL)) {
+ for (f_index = 0; f_index < faces_len; f_index++) {
+ BMFace *f = faces[f_index];
+ if (bev_rebuild_polygon(bm, bp, f)) {
+ BM_face_kill(bm, f);
+ }
+ }
+
+ if (faces != (BMFace **)faces_stack) {
+ MEM_freeN(faces);
+ }
+ }
+}
+
+
+/*
+ * Build the polygons along the selected Edge
+ */
+static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme)
+{
+ BevVert *bv1, *bv2;
+ BMVert *bmv1, *bmv2, *bmv3, *bmv4, *bmv1i, *bmv2i, *bmv3i, *bmv4i;
+ VMesh *vm1, *vm2;
+ EdgeHalf *e1, *e2;
+ BMFace *f1, *f2, *f;
+ int k, nseg, i1, i2;
+
+ if (!BM_edge_is_manifold(bme))
+ return;
+
+ bv1 = find_bevvert(bp, bme->v1);
+ bv2 = find_bevvert(bp, bme->v2);
+
+ BLI_assert(bv1 && bv2);
+
+ e1 = find_edge_half(bv1, bme);
+ e2 = find_edge_half(bv2, bme);
+
+ BLI_assert(e1 && e2);
+
+ /* v4 v3
+ * \ /
+ * e->v1 - e->v2
+ * / \
+ * v1 v2
+ */
+ nseg = e1->seg;
+ BLI_assert(nseg > 0 && nseg == e2->seg);
+
+ bmv1 = e1->leftv->nv.v;
+ bmv4 = e1->rightv->nv.v;
+ bmv2 = e2->rightv->nv.v;
+ bmv3 = e2->leftv->nv.v;
+
+ BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
+
+ f1 = boundvert_rep_face(e1->leftv);
+ f2 = boundvert_rep_face(e1->rightv);
+
+ if (nseg == 1) {
+ bev_create_quad_tri(bm, bmv1, bmv2, bmv3, bmv4, f1);
+ }
+ else {
+ i1 = e1->leftv->index;
+ i2 = e2->leftv->index;
+ vm1 = bv1->vmesh;
+ vm2 = bv2->vmesh;
+ bmv1i = bmv1;
+ bmv2i = bmv2;
+ for (k = 1; k <= nseg; k++) {
+ bmv4i = mesh_vert(vm1, i1, 0, k)->v;
+ bmv3i = mesh_vert(vm2, i2, 0, nseg - k)->v;
+ f = (k <= nseg / 2 + (nseg % 2)) ? f1 : f2;
+ bev_create_quad_tri(bm, bmv1i, bmv2i, bmv3i, bmv4i, f);
+ bmv1i = bmv4i;
+ bmv2i = bmv3i;
+ }
+ }
+}
+
+/**
+ * - Currently only bevels BM_ELEM_TAG'd verts and edges.
+ *
+ * - Newly created faces are BM_ELEM_TAG'd too,
+ * the caller needs to ensure this is cleared before calling
+ * if its going to use this face tag.
+ *
+ * \warning all tagged edges _must_ be manifold.
+ */
+void BM_mesh_bevel(BMesh *bm, const float offset, const float segments)
+{
+ BMIter iter;
+ BMVert *v;
+ BMEdge *e;
+ BevelParams bp = {NULL};
+
+ bp.offset = offset;
+ bp.seg = segments;
+
+ if (bp.offset > 0) {
+ /* primary alloc */
+ bp.vert_hash = BLI_ghash_ptr_new(__func__);
+ bp.mem_arena = BLI_memarena_new((1 << 16), __func__);
+ BLI_memarena_use_calloc(bp.mem_arena);
+
+ /* The analysis of the input vertices and execution additional constructions */
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ bevel_vert_construct(bm, &bp, v);
+ }
+ }
+
+ /* Build polygons for edges */
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ bevel_build_edge_polygons(bm, &bp, e);
+ }
+ }
+
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ bevel_rebuild_existing_polygons(bm, &bp, v);
+ }
+ }
+
+ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ BLI_assert(find_bevvert(&bp, v) != NULL);
+ BM_vert_kill(bm, v);
+ }
+ }
+
+ /* primary free */
+ BLI_ghash_free(bp.vert_hash, NULL, NULL);
+ BLI_memarena_free(bp.mem_arena);
+ }
+}
diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h
new file mode 100644
index 00000000000..a80e4f3a4a2
--- /dev/null
+++ b/source/blender/bmesh/tools/bmesh_bevel.h
@@ -0,0 +1,32 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s):
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BMESH_BEVEL_H__
+#define __BMESH_BEVEL_H__
+
+/** \file blender/bmesh/tools/bmesh_bevel.h
+ * \ingroup bmesh
+ */
+
+void BM_mesh_bevel(BMesh *bm, const float offset, const float segments);
+
+#endif /* __BMESH_BEVEL_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_decimate.h b/source/blender/bmesh/tools/bmesh_decimate.h
index 04dc0cfd2ea..4d382d65659 100644
--- a/source/blender/bmesh/intern/bmesh_decimate.h
+++ b/source/blender/bmesh/tools/bmesh_decimate.h
@@ -23,7 +23,7 @@
#ifndef __BMESH_DECIMATE_H__
#define __BMESH_DECIMATE_H__
-/** \file blender/bmesh/intern/bmesh_decimate.h
+/** \file blender/bmesh/tools/bmesh_decimate.h
* \ingroup bmesh
*/
diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 74792d1d558..781001508f2 100644
--- a/source/blender/bmesh/intern/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -20,7 +20,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/bmesh/intern/bmesh_decimate_collapse.c
+/** \file blender/bmesh/tools/bmesh_decimate_collapse.c
* \ingroup bmesh
*
* BMesh decimator that uses an edge collapse method.
@@ -39,9 +39,10 @@
#include "BKE_customdata.h"
#include "bmesh.h"
-#include "bmesh_structure.h"
#include "bmesh_decimate.h" /* own include */
+#include "../intern/bmesh_structure.h"
+
/* defines for testing */
#define USE_CUSTOMDATA
#define USE_TRIANGULATE
diff --git a/source/blender/bmesh/intern/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
index d1371a18160..d2a5c580ae6 100644
--- a/source/blender/bmesh/intern/bmesh_decimate_dissolve.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
@@ -20,7 +20,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/bmesh/intern/bmesh_decimate_dissolve.c
+/** \file blender/bmesh/tools/bmesh_decimate_dissolve.c
* \ingroup bmesh
*
* BMesh decimator that dissolves flat areas into polygons (ngons).
@@ -231,8 +231,8 @@ void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const int do_
int vinput_len;
int einput_len;
- BMVert **vinput_arr = BM_iter_as_arrayN(bm, BM_VERTS_OF_MESH, NULL, &vinput_len);
- BMEdge **einput_arr = BM_iter_as_arrayN(bm, BM_EDGES_OF_MESH, NULL, &einput_len);
+ BMVert **vinput_arr = BM_iter_as_arrayN(bm, BM_VERTS_OF_MESH, NULL, &vinput_len, NULL, 0);
+ BMEdge **einput_arr = BM_iter_as_arrayN(bm, BM_EDGES_OF_MESH, NULL, &einput_len, NULL, 0);
BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
vinput_arr, vinput_len,
diff --git a/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
index 1ec13010d80..acdab2510a4 100644
--- a/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
@@ -20,7 +20,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/bmesh/intern/bmesh_decimate_unsubdivide.c
+/** \file blender/bmesh/tools/bmesh_decimate_unsubdivide.c
* \ingroup bmesh
*
* BMesh decimator that uses a grid un-subdivide method.