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/operators')
-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
24 files changed, 646 insertions, 2692 deletions
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);
}