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:
authorDaniel Stokes <kupomail@gmail.com>2012-04-29 04:33:24 +0400
committerDaniel Stokes <kupomail@gmail.com>2012-04-29 04:33:24 +0400
commitafb8fffb1827a4fffc8e6b3d620a02f59b62e3a9 (patch)
tree328e3c204210d68392805f371ef4d296175b6b6e /source/blender/bmesh
parentf306b50700b05707f44b5472ac0b38d58fb01b0d (diff)
parent72ec4c813a2c544341d0c4ae83369cea60e52c9e (diff)
Merged revisions 45967-46052 from trunk/blendersoc-2011-cucumber
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/bmesh.h35
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c91
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.c44
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c2
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c12
-rw-r--r--source/blender/bmesh/operators/bmo_connect.c12
-rw-r--r--source/blender/bmesh/operators/bmo_create.c12
-rw-r--r--source/blender/bmesh/operators/bmo_dupe.c4
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c6
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c26
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c2
-rw-r--r--source/blender/bmesh/operators/bmo_mirror.c2
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c10
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c18
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c4
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c10
-rw-r--r--source/blender/bmesh/tools/BME_bevel.c36
22 files changed, 242 insertions, 99 deletions
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index 6b41babd927..13926c42192 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -192,6 +192,41 @@
* - bmo_xxx() - Low level / internal operator API functions.
* - _bm_xxx() - Functions which are called via macros only.
*
+ * \section bm_todo BMesh TODO's
+ *
+ * There may be a better place for this section, but adding here for now.
+ *
+ *
+ * \subsection bm_todo_tools Tools
+ *
+ * Probably most of these will be bmesh operators.
+ *
+ * - make ngons flat.
+ * - make ngons into tris/quads (ngon poke?), many methods could be used here (triangulate/fan/quad-fan).
+ * - solidify (precise mode), keeps even wall thickness, re-creates outlines of offset faces with plane-plane
+ * intersections.
+ * - split vert (we already have in our API, just no tool)
+ * - bridge (add option to bridge between different edge loop counts, option to remove selected face regions)
+ * - flip selected region (invert all faces about the plane defined by the selected region outline)
+ * - interactive dissolve (like the knife tool but draw over edges to dissolve)
+ *
+ *
+ * \subsection bm_todo_optimize Optimizations
+ *
+ * - skip normal calc when its not needed (when calling chain of operators & for modifiers, flag as dirty)
+ * - skip BMO flag allocation, its not needed in many cases, this is fairly redundant to calc by default.
+ * - ability to call BMO's with option not to create return data (will save some time)
+ * - binary diff UNDO, currently this uses huge amount of ram when all shapes are stored for each undo step for eg.
+ * - use two differnt iterator types for BMO map/buffer types.
+ * - avoid string lookups for BMO slot lookups _especially_ when used in loops, this is very crappy.
+ *
+ *
+ * \subsection bm_todo_tools_enhance Tool Enhancements
+ *
+ * - face inset interpolate loop data from face (currently copies - but this stretches UV's in an ugly way)
+ * - vert slide UV correction (like we have for edge slide)
+ * - fill-face edge net - produce consistant normals, currently it won't, fix should be to fill in edge-net node
+ * connected with previous one - since they already check for normals of adjacent edge-faces before creating.
*/
#ifdef __cplusplus
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index cbdd5dd6983..c2d5d93cbc3 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -871,8 +871,8 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
BLI_array_empty(loops);
BLI_array_empty(edges);
- BLI_array_growitems(loops, f->len);
- BLI_array_growitems(edges, f->len);
+ BLI_array_grow_items(loops, f->len);
+ BLI_array_grow_items(edges, f->len);
l = BM_iter_new(&liter, bm_old, BM_LOOPS_OF_FACE, f);
for (j = 0; j < f->len; j++, l = BM_iter_step(&liter)) {
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index f3f7614fe02..f38c737b8ac 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -50,6 +50,9 @@
#endif
+/**
+ * \brief Main function for creating a new vertex.
+ */
BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
{
BMVert *v = BLI_mempool_calloc(bm->vpool);
@@ -85,6 +88,12 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
return v;
}
+/**
+ * \brief Main function for creating a new edge.
+ *
+ * \note Duplicate edges are supported by the API however users should _never_ see them.
+ * so unless you need a unique edge or know the edge won't exist, you should call wih \a nodouble=TRUE
+ */
BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble)
{
BMEdge *e;
@@ -175,32 +184,32 @@ static BMLoop *bm_face_boundary_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge
BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short copyedges)
{
- BMEdge **edges = NULL;
BMVert **verts = NULL;
- BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE);
- BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);
+ BMEdge **edges = NULL;
+ BLI_array_fixedstack_declare(verts, BM_NGON_STACK_SIZE, f->len, __func__);
+ BLI_array_fixedstack_declare(edges, BM_NGON_STACK_SIZE, f->len, __func__);
BMLoop *l_iter;
BMLoop *l_first;
- BMLoop *l2;
- BMFace *f2;
+ BMLoop *l_copy;
+ BMFace *f_copy;
int i;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ i = 0;
do {
if (copyverts) {
- BMVert *v = BM_vert_create(bm, l_iter->v->co, l_iter->v);
- BLI_array_append(verts, v);
+ verts[i] = BM_vert_create(bm, l_iter->v->co, l_iter->v);
}
else {
- BLI_array_append(verts, l_iter->v);
+ verts[i] = l_iter->v;
}
+ i++;
} while ((l_iter = l_iter->next) != l_first);
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
i = 0;
do {
if (copyedges) {
- BMEdge *e;
BMVert *v1, *v2;
if (l_iter->e->v1 == verts[i]) {
@@ -212,28 +221,29 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short co
v1 = verts[(i + 1) % f->len];
}
- e = BM_edge_create(bm, v1, v2, l_iter->e, FALSE);
- BLI_array_append(edges, e);
+ edges[i] = BM_edge_create(bm, v1, v2, l_iter->e, FALSE);
}
else {
- BLI_array_append(edges, l_iter->e);
+ edges[i] = l_iter->e;
}
-
i++;
} while ((l_iter = l_iter->next) != l_first);
- f2 = BM_face_create(bm, verts, edges, f->len, FALSE);
+ f_copy = BM_face_create(bm, verts, edges, f->len, FALSE);
- BM_elem_attrs_copy(bm, bm, f, f2);
+ BM_elem_attrs_copy(bm, bm, f, f_copy);
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- l2 = BM_FACE_FIRST_LOOP(f2);
+ l_copy = BM_FACE_FIRST_LOOP(f_copy);
do {
- BM_elem_attrs_copy(bm, bm, l_iter, l2);
- l2 = l2->next;
+ BM_elem_attrs_copy(bm, bm, l_iter, l_copy);
+ l_copy = l_copy->next;
} while ((l_iter = l_iter->next) != l_first);
-
- return f2;
+
+ BLI_array_fixedstack_free(verts);
+ BLI_array_fixedstack_free(edges);
+
+ return f_copy;
}
/**
@@ -270,6 +280,9 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
return f;
}
+/**
+ * \brief Main face creation function
+ */
BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, int nodouble)
{
BMFace *f = NULL;
@@ -319,6 +332,12 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
return f;
}
+/**
+ * Check the element is valid.
+ *
+ * BMESH_TODO, when this raises an error the output is incredible confusing.
+ * need to have some nice way to print/debug what the hecks going on.
+ */
int bmesh_elem_check(void *element, const char htype)
{
BMHeader *head = element;
@@ -446,14 +465,16 @@ int bmesh_elem_check(void *element, const char htype)
}
/**
- * low level function, only free's,
- * does not change adjust surrounding geometry */
+ * low level function, only frees the vert,
+ * doesn't change or adjust surrounding geometry
+ */
static void bm_kill_only_vert(BMesh *bm, BMVert *v)
{
bm->totvert--;
bm->elem_index_dirty |= BM_VERT;
BM_select_history_remove(bm, v);
+
if (v->head.data)
CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
@@ -461,6 +482,10 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v)
BLI_mempool_free(bm->vpool, v);
}
+/**
+ * low level function, only frees the edge,
+ * doesn't change or adjust surrounding geometry
+ */
static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
{
bm->totedge--;
@@ -475,6 +500,10 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e)
BLI_mempool_free(bm->epool, e);
}
+/**
+ * low level function, only frees the face,
+ * doesn't change or adjust surrounding geometry
+ */
static void bm_kill_only_face(BMesh *bm, BMFace *f)
{
if (bm->act_face == f)
@@ -492,6 +521,10 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f)
BLI_mempool_free(bm->fpool, f);
}
+/**
+ * low level function, only frees the loop,
+ * doesn't change or adjust surrounding geometry
+ */
static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
{
bm->totloop--;
@@ -502,7 +535,7 @@ static void bm_kill_only_loop(BMesh *bm, BMLoop *l)
}
/**
- * kills all edges associated with f, along with any other faces containing
+ * kills all edges associated with \a f, along with any other faces containing
* those edges
*/
void BM_face_edges_kill(BMesh *bm, BMFace *f)
@@ -526,7 +559,7 @@ void BM_face_edges_kill(BMesh *bm, BMFace *f)
}
/**
- * kills all verts associated with f, along with any other faces containing
+ * kills all verts associated with \a f, along with any other faces containing
* those vertices
*/
void BM_face_verts_kill(BMesh *bm, BMFace *f)
@@ -587,7 +620,9 @@ void BM_face_kill(BMesh *bm, BMFace *f)
bm_kill_only_face(bm, f);
}
-
+/**
+ * kills \a e and all faces that use it.
+ */
void BM_edge_kill(BMesh *bm, BMEdge *e)
{
@@ -615,6 +650,9 @@ void BM_edge_kill(BMesh *bm, BMEdge *e)
bm_kill_only_edge(bm, e);
}
+/**
+ * kills \a v and all edges that use it.
+ */
void BM_vert_kill(BMesh *bm, BMVert *v)
{
if (v->e) {
@@ -746,6 +784,9 @@ static int bm_loop_reverse_loop(BMesh *bm, BMFace *f
return 1;
}
+/**
+ * \brief Flip the faces direction
+ */
int bmesh_loop_reverse(BMesh *bm, BMFace *f)
{
#ifdef USE_BMESH_HOLES
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c
index 384715d74f7..8103ae1ee11 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.c
+++ b/source/blender/bmesh/intern/bmesh_iterators.c
@@ -104,6 +104,50 @@ int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, cons
return i;
}
+/**
+ * \brief Elem Iter Flag Count
+ *
+ * Counts how many flagged / unflagged items are found in this element.
+ */
+int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, const short value)
+{
+ BMIter iter;
+ BMElem *ele;
+ int count = 0;
+
+ BLI_assert(ELEM(value, TRUE, FALSE));
+
+ for (ele = BM_iter_new(&iter, NULL, itype, data); ele; ele = BM_iter_step(&iter)) {
+ if (BM_elem_flag_test_bool(ele, hflag) == value) {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+/**
+ * \brief Mesh Iter Flag Count
+ *
+ * Counts how many flagged / unflagged items are found in this mesh.
+ */
+int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const short value)
+{
+ BMIter iter;
+ BMElem *ele;
+ int count = 0;
+
+ BLI_assert(ELEM(value, TRUE, FALSE));
+
+ for (ele = BM_iter_new(&iter, bm, itype, NULL); ele; ele = BM_iter_step(&iter)) {
+ if (BM_elem_flag_test_bool(ele, hflag) == value) {
+ count++;
+ }
+ }
+
+ return count;
+}
+
/**
* \brief Init Iterator
diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h
index c687e4b4e7a..1361a91a692 100644
--- a/source/blender/bmesh/intern/bmesh_iterators.h
+++ b/source/blender/bmesh/intern/bmesh_iterators.h
@@ -117,6 +117,8 @@ typedef struct BMIter {
void *BM_iter_at_index(BMesh *bm, const char itype, void *data, int index);
int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, const int len);
+int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, const short value);
+int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const short value);
/* private for bmesh_iterators_inline.c */
void bmiter__vert_of_mesh_begin(struct BMIter *iter);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index f72efe8ab5f..351fb8e941b 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -282,8 +282,8 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
BLI_array_empty(fedges);
BLI_array_empty(verts);
- BLI_array_growitems(fedges, mpoly->totloop);
- BLI_array_growitems(verts, mpoly->totloop);
+ BLI_array_grow_items(fedges, mpoly->totloop);
+ BLI_array_grow_items(verts, mpoly->totloop);
for (j = 0; j < mpoly->totloop; j++) {
ml = &me->mloop[mpoly->loopstart + j];
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index a5e761af783..5f3836cc413 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -771,7 +771,7 @@ int BM_face_validate(BMFace *face, FILE *err)
fflush(err);
}
- BLI_array_growitems(verts, face->len);
+ BLI_array_grow_items(verts, face->len);
BM_ITER_ELEM_INDEX (l, &iter, face, BM_LOOPS_OF_FACE, i) {
verts[i] = l->v;
if (l->e->v1 == l->e->v2) {
diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c
index a3b5d94ba8e..ea29c149c1a 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.c
+++ b/source/blender/bmesh/intern/bmesh_walkers.c
@@ -226,8 +226,7 @@ void *BMW_state_add(BMWalker *walker)
BMwGenericWalker *newstate;
newstate = BLI_mempool_alloc(walker->worklist);
newstate->depth = walker->depth;
- switch (walker->order)
- {
+ switch (walker->order) {
case BMW_DEPTH_FIRST:
BLI_addhead(&walker->states, newstate);
break;
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 113e1ddc164..ec4b97d59f3 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -880,7 +880,7 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker)
}
/* only walk to manifold edge */
if ((l->f->len % 2 == 0) && EDGE_CHECK(l->e) &&
- !BLI_ghash_haskey(walker->visithash, l->e))
+ !BLI_ghash_haskey(walker->visithash, l->e))
#else
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 46dd7606940..b6b54b82f3d 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -242,7 +242,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
if (!BMO_elem_flag_test(bm, e, EDGE_OLD)) {
BM_elem_index_set(e, BLI_array_count(etags)); /* set_dirty! */
- BLI_array_growone(etags);
+ BLI_array_grow_one(etags);
BMO_elem_flag_enable(bm, e, EDGE_OLD);
}
@@ -256,11 +256,11 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) {
BM_elem_index_set(l2, BLI_array_count(tags)); /* set_loop */
- BLI_array_growone(tags);
+ 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_growone(etags);
+ BLI_array_grow_one(etags);
BMO_elem_flag_enable(bm, l2->e, EDGE_OLD);
}
@@ -291,7 +291,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
}
if (!BLI_smallhash_haskey(&hash, (intptr_t)e)) {
- BLI_array_growone(etags);
+ 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);
@@ -309,11 +309,11 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
/* create tags for all loops in l-> */
BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) {
- BLI_array_growone(tags);
+ 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_growone(etags);
+ 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);
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index 3c1f10be4c4..b8abe112c4d 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -71,10 +71,10 @@ void bmo_connectverts_exec(BMesh *bm, BMOperator *op)
}
if (lastl != l->prev && lastl != l->next) {
- BLI_array_growone(loops);
+ BLI_array_grow_one(loops);
loops[BLI_array_count(loops) - 1] = lastl;
- BLI_array_growone(loops);
+ BLI_array_grow_one(loops);
loops[BLI_array_count(loops) - 1] = l;
}
@@ -87,10 +87,10 @@ void bmo_connectverts_exec(BMesh *bm, BMOperator *op)
}
if (BLI_array_count(loops) > 2) {
- BLI_array_growone(loops);
+ BLI_array_grow_one(loops);
loops[BLI_array_count(loops) - 1] = loops[BLI_array_count(loops) - 2];
- BLI_array_growone(loops);
+ BLI_array_grow_one(loops);
loops[BLI_array_count(loops) - 1] = loops[0];
}
@@ -101,10 +101,10 @@ void bmo_connectverts_exec(BMesh *bm, BMOperator *op)
continue;
}
- BLI_array_growone(verts);
+ BLI_array_grow_one(verts);
verts[BLI_array_count(verts) - 1] = loops[i * 2]->v;
- BLI_array_growone(verts);
+ BLI_array_grow_one(verts);
verts[BLI_array_count(verts) - 1] = loops[i * 2 + 1]->v;
}
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index f2ba110b43d..6f08ab421f3 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -766,7 +766,7 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E
i = 0;
BLI_array_empty(verts);
for (i = 0, node = path->nodes.first; node; node = node->next, i++) {
- BLI_array_growone(verts);
+ BLI_array_grow_one(verts);
verts[i] = node->v;
}
@@ -999,7 +999,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
}
edata[BM_elem_index_get(e)].ftag++;
- BLI_array_growone(edges);
+ BLI_array_grow_one(edges);
edges[i++] = e;
BLI_array_append(verts, node->v);
@@ -1009,7 +1009,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
vote_on_winding(edge, path->nodes.last, winding);
}
- BLI_array_growone(edges);
+ BLI_array_grow_one(edges);
edges[i++] = edge;
edata[BM_elem_index_get(edge)].ftag++;
@@ -1157,7 +1157,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
i = 0;
while (e) {
BMO_elem_flag_enable(bm, e, EDGE_VIS);
- BLI_array_growone(edges);
+ BLI_array_grow_one(edges);
edges[i] = e;
e = edge_next(bm, e);
@@ -1166,11 +1166,11 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
if (!count) {
edges1 = edges;
- BLI_array_set_length(edges1, BLI_array_count(edges));
+ BLI_array_length_set(edges1, BLI_array_count(edges));
}
else {
edges2 = edges;
- BLI_array_set_length(edges2, BLI_array_count(edges));
+ BLI_array_length_set(edges2, BLI_array_count(edges));
}
BLI_array_empty(edges);
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index 36d446a0a8c..0659a42c26d 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -277,8 +277,8 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
BLI_array_empty(vtar);
BLI_array_empty(edar);
- BLI_array_growitems(vtar, f->len);
- BLI_array_growitems(edar, f->len);
+ 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);
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 19e2dd85b0e..4fced09c588 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -58,7 +58,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
BLI_array_empty(edges);
- BLI_array_growitems(edges, f->len);
+ BLI_array_grow_items(edges, f->len);
i = 0;
firstv = lastv = NULL;
@@ -573,12 +573,12 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
continue;
}
- BLI_array_growitems(verts, f->len);
+ BLI_array_grow_items(verts, f->len);
BM_ITER_ELEM_INDEX (l, &loopIter, f, BM_LOOPS_OF_FACE, i) {
verts[i] = l->v->co;
}
- BLI_array_growitems(face_angles, f->len);
+ BLI_array_grow_items(face_angles, f->len);
angle_poly_v3(face_angles, (const float **)verts, f->len);
i = 0;
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index ee52f8bc0a9..712f6b736d6 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -495,8 +495,6 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
BM_face_copy_shared(bm, f);
}
- MEM_freeN(edge_info);
-
/* we could flag new edges/verts too, is it useful? */
BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, ELE_NEW);
@@ -505,6 +503,28 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
float (*varr_co)[3];
BMOIter oiter;
+ /* we need to re-calculate tagged normals, but for this purpose we can copy tagged verts from the
+ * faces they inset from, */
+ for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
+ zero_v3(es->e_new->v1->no);
+ zero_v3(es->e_new->v2->no);
+ }
+ for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
+ float *no = es->l->f->no;
+ add_v3_v3(es->e_new->v1->no, no);
+ add_v3_v3(es->e_new->v2->no, no);
+ }
+ for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
+ /* annoying, avoid normalizing twice */
+ if (len_squared_v3(es->e_new->v1->no) != 1.0f) {
+ normalize_v3(es->e_new->v1->no);
+ }
+ if (len_squared_v3(es->e_new->v2->no) != 1.0f) {
+ normalize_v3(es->e_new->v2->no);
+ }
+ }
+ /* done correcting edge verts normals */
+
/* untag verts */
BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE);
@@ -537,4 +557,6 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
}
MEM_freeN(varr_co);
}
+
+ MEM_freeN(edge_info);
}
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 582039fc1a2..d780e309118 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -293,7 +293,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
measure = measure_facepair(v1, v2, v3, v4, limit);
if (measure < limit) {
- BLI_array_growone(jedges);
+ BLI_array_grow_one(jedges);
jedges[i].e = e;
jedges[i].weight = measure;
diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c
index cf1669d441e..53c51dfd483 100644
--- a/source/blender/bmesh/operators/bmo_mirror.c
+++ b/source/blender/bmesh/operators/bmo_mirror.c
@@ -71,7 +71,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
i = 0;
/* v2 = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); */ /* UNUSED */
BMO_ITER (v, &siter, bm, &dupeop, "newout", BM_VERT) {
- BLI_array_growone(vmap);
+ BLI_array_grow_one(vmap);
vmap[i] = v;
/* v2 = BM_iter_step(&iter); */ /* UNUSED */
i++;
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 149f2537a12..70dcc6fa3ae 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -191,8 +191,8 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
continue;
}
- BLI_array_growone(edges);
- BLI_array_growone(loops);
+ BLI_array_grow_one(edges);
+ BLI_array_grow_one(loops);
edges[a] = e2;
loops[a] = l;
@@ -393,7 +393,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
INIT_MINMAX(min, max);
for (tot = 0; e; tot++, e = BMW_step(&walker)) {
- BLI_array_growone(edges);
+ BLI_array_grow_one(edges);
edges[tot] = e;
DO_MINMAX(e->v1->co, min, max);
@@ -454,7 +454,7 @@ static void bmo_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer)
CustomData_data_initminmax(type, &min, &max);
for (tot = 0; l2; tot++, l2 = BMW_step(&walker)) {
- BLI_array_growone(blocks);
+ BLI_array_grow_one(blocks);
blocks[tot] = CustomData_bmesh_get_layer_n(&bm->ldata, l2->head.data, layer);
CustomData_data_dominmax(type, blocks[tot], &min, &max);
}
@@ -501,7 +501,7 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c
i = 0;
BMO_ITER (v, &oiter, bm, op, "verts", BM_VERT) {
- BLI_array_growone(verts);
+ BLI_array_grow_one(verts);
verts[i++] = v;
}
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 7da02a594d5..d96d0f6c74d 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -778,8 +778,8 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
BLI_array_empty(edges);
BLI_array_empty(verts);
- BLI_array_growitems(edges, face->len);
- BLI_array_growitems(verts, face->len);
+ BLI_array_grow_items(edges, face->len);
+ BLI_array_grow_items(verts, face->len);
matched = 0;
@@ -825,7 +825,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
}
}
if (matched) {
- BLI_array_growone(facedata);
+ BLI_array_grow_one(facedata);
b = BLI_array_count(facedata) - 1;
facedata[b].pat = pat;
facedata[b].start = verts[i];
@@ -861,7 +861,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
}
}
if (matched) {
- BLI_array_growone(facedata);
+ BLI_array_grow_one(facedata);
j = BLI_array_count(facedata) - 1;
BMO_elem_flag_enable(bm, face, SUBD_SPLIT);
@@ -877,7 +877,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
}
if (!matched && totesel) {
- BLI_array_growone(facedata);
+ BLI_array_grow_one(facedata);
j = BLI_array_count(facedata) - 1;
BMO_elem_flag_enable(bm, face, SUBD_SPLIT);
@@ -918,7 +918,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
/* for case of two edges, connecting them shouldn't be too hard */
BM_ITER_ELEM (l, &liter, face, BM_LOOPS_OF_FACE) {
- BLI_array_growone(loops);
+ BLI_array_grow_one(loops);
loops[BLI_array_count(loops) - 1] = l;
}
@@ -951,10 +951,10 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
b += numcuts - 1;
for (j = 0; j < numcuts; j++) {
- BLI_array_growone(splits);
+ BLI_array_grow_one(splits);
splits[BLI_array_count(splits) - 1] = loops[a];
- BLI_array_growone(splits);
+ BLI_array_grow_one(splits);
splits[BLI_array_count(splits) - 1] = loops[b];
b = (b - 1) % vlen;
@@ -989,7 +989,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op)
}
for (j = 0; j < face->len; j++) {
- BLI_array_growone(verts);
+ BLI_array_grow_one(verts);
}
j = 0;
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index 7fd6cf6769c..9632a79b7dd 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -59,8 +59,8 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
BLI_array_empty(projectverts);
BLI_array_empty(newfaces);
- BLI_array_growitems(projectverts, face->len * 3);
- BLI_array_growitems(newfaces, face->len);
+ BLI_array_grow_items(projectverts, face->len * 3);
+ BLI_array_grow_items(newfaces, face->len);
BM_face_triangulate(bm, face, projectverts, EDGE_NEW, FACE_NEW, newfaces, use_beauty);
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 3cfa70f6e6c..8409c5b76b8 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -348,7 +348,7 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
* stack (if we use simple function recursion, we'd end up overloading
* the stack on large meshes). */
- BLI_array_growone(fstack);
+ BLI_array_grow_one(fstack);
fstack[0] = startf;
BMO_elem_flag_enable(bm, startf, FACE_VIS);
@@ -382,7 +382,7 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
}
if (i == maxi) {
- BLI_array_growone(fstack);
+ BLI_array_grow_one(fstack);
maxi++;
}
@@ -420,7 +420,7 @@ void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op)
i = 0;
BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
- BLI_array_growone(cos);
+ BLI_array_grow_one(cos);
co = cos[i];
j = 0;
@@ -1035,7 +1035,7 @@ void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op)
int i;
BLI_array_empty(uvs);
- BLI_array_growitems(uvs, fs->len);
+ BLI_array_grow_items(uvs, fs->len);
BM_ITER_ELEM_INDEX (lf, &l_iter, fs, BM_LOOPS_OF_FACE, i) {
MLoopUV *luv = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPUV);
@@ -1141,7 +1141,7 @@ void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op)
int i;
BLI_array_empty(cols);
- BLI_array_growitems(cols, fs->len);
+ BLI_array_grow_items(cols, fs->len);
BM_ITER_ELEM_INDEX (lf, &l_iter, fs, BM_LOOPS_OF_FACE, i) {
cols[i] = *((MLoopCol *)CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPCOL));
diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c
index 6a91d6f9d00..a357767e1d8 100644
--- a/source/blender/bmesh/tools/BME_bevel.c
+++ b/source/blender/bmesh/tools/BME_bevel.c
@@ -305,7 +305,7 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l,
e1 = e2;
}
ov = BM_edge_other_vert(e1, v);
- sv = BM_edge_split(bm, e1, v, &ne, 0);
+ sv = BM_edge_split(bm, e1, v, &ne, 0.0f);
//BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /* this is technically wrong.. */
//BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
//BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
@@ -347,7 +347,7 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l,
else {
is_split_vert = 0;
ov = BM_edge_other_vert(l->e, v);
- sv = BM_edge_split(bm, l->e, v, &ne, 0);
+ sv = BM_edge_split(bm, l->e, v, &ne, 0.0f);
//BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /* this is technically wrong.. */
//BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
//BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25);
@@ -371,8 +371,8 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l,
if (vtd1->loc == NULL) {
/* this is a vert with data only for calculating initial weights */
- if (vtd1->weight < 0) {
- vtd1->weight = 0;
+ if (vtd1->weight < 0.0f) {
+ vtd1->weight = 0.0f;
}
scale = vtd1->weight / vtd1->factor;
if (!vtd1->max) {
@@ -537,14 +537,14 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti
se = l->next->e;
jf = NULL;
if (kl->v == kv) {
- BM_face_split(bm, kl->f, kl->prev->v, kl->next->v, &nl, kl->prev->e, FALSE);
+ BM_face_split(bm, kl->f, kl->prev->v, kl->next->v, &nl, kl->prev->e, TRUE);
ke = kl->e;
/* BMESH-TODO: jfke doesn't handle customdata */
jf = bmesh_jfke(bm, kl->prev->radial_next->f, kl->f, kl->prev->e);
BM_vert_collapse_edge(bm, ke, kv, FALSE);
}
else {
- BM_face_split(bm, kl->f, kl->next->next->v, kl->v, &nl, kl->next->e, FALSE);
+ BM_face_split(bm, kl->f, kl->next->next->v, kl->v, &nl, kl->next->e, TRUE);
ke = kl->e;
/* BMESH-TODO: jfke doesn't handle customdata */
jf = bmesh_jfke(bm, kl->next->radial_next->f, kl->f, kl->next->e);
@@ -583,14 +583,14 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti
se = l->e;
jf = NULL;
if (kl->v == kv) {
- BM_face_split(bm, kl->f, kl->prev->v, kl->next->v, &nl, kl->prev->e, FALSE);
+ BM_face_split(bm, kl->f, kl->prev->v, kl->next->v, &nl, kl->prev->e, TRUE);
ke = kl->e;
/* BMESH-TODO: jfke doesn't handle customdata */
jf = bmesh_jfke(bm, kl->prev->radial_next->f, kl->f, kl->prev->e);
BM_vert_collapse_edge(bm, ke, kv, FALSE);
}
else {
- BM_face_split(bm, kl->f, kl->next->next->v, kl->v, &nl, kl->next->e, FALSE);
+ BM_face_split(bm, kl->f, kl->next->next->v, kl->v, &nl, kl->next->e, TRUE);
ke = kl->e;
/* BMESH-TODO: jfke doesn't handle customdata */
jf = bmesh_jfke(bm, kl->next->radial_next->f, kl->f, kl->next->e);
@@ -605,7 +605,7 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti
}
if (!BMO_elem_flag_test(bm, v1, BME_BEVEL_NONMAN) || !BMO_elem_flag_test(bm, v2, BME_BEVEL_NONMAN)) {
- BM_face_split(bm, f, v2, v1, &l, e, FALSE);
+ BM_face_split(bm, f, v2, v1, &l, e, TRUE);
BMO_elem_flag_enable(bm, l->e, BME_BEVEL_BEVEL);
l = l->radial_next;
}
@@ -633,7 +633,7 @@ static BMLoop *BME_bevel_vert(BMesh *bm, BMLoop *l, float value, int UNUSED(opti
l = l->next->next;
/* "cut off" this corner */
- /* f = */ BM_face_split(bm, l->f, v2, v1, NULL, l->e, FALSE);
+ /* f = */ BM_face_split(bm, l->f, v2, v1, NULL, l->e, TRUE);
return l;
}
@@ -694,7 +694,7 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM
f = l->f;
/* max pass */
- if (value > 0.5f && max > 0) {
+ if (value > 0.5f && max > 0.0f) {
max = -1;
BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
if (BMO_elem_flag_test(bm, l->e, BME_BEVEL_BEVEL) || BMO_elem_flag_test(bm, l->e, BME_BEVEL_ORIG)) {
@@ -835,7 +835,7 @@ static void BME_bevel_add_vweight(BME_TransData_Head *td, BMesh *bm, BMVert *v,
vtd->weight = weight;
}
}
- else if (vtd->weight < 0) {
+ else if (vtd->weight < 0.0f) {
vtd->factor = factor;
vtd->weight = weight;
}
@@ -897,11 +897,11 @@ static void bevel_init_edges(BMesh *bm, int options, float angle, BME_TransData_
const float threshold = (options & BME_BEVEL_ANGLE) ? cosf(angle + 0.001) : 0.0f;
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- weight = 0.0;
+ weight = 0.0f;
if (!BMO_elem_flag_test(bm, e, BME_BEVEL_NONMAN)) {
if (options & BME_BEVEL_SELECT) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
- weight = 1.0;
+ weight = 1.0f;
}
}
else if (options & BME_BEVEL_WEIGHT) {
@@ -925,10 +925,10 @@ static void bevel_init_edges(BMesh *bm, int options, float angle, BME_TransData_
}
}
else {
- weight = 1.0;
+ weight = 1.0f;
}
- if (weight > 0.0) {
+ if (weight > 0.0f) {
BMO_elem_flag_enable(bm, e, BME_BEVEL_BEVEL);
BME_bevel_add_vweight(td, bm, e->v1, weight, 1.0, options);
BME_bevel_add_vweight(td, bm, e->v2, weight, 1.0, options);
@@ -1071,9 +1071,9 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option
if (l->v != v) l = l->next;
if (l2->v != v) l2 = l2->next;
if (l->f->len > 3)
- BM_face_split(bm, l->f, l->next->v, l->prev->v, &l, l->e, FALSE); /* clip this corner off */
+ BM_face_split(bm, l->f, l->next->v, l->prev->v, &l, l->e, TRUE); /* clip this corner off */
if (l2->f->len > 3)
- BM_face_split(bm, l2->f, l2->next->v, l2->prev->v, &l, l2->e, FALSE); /* clip this corner off */
+ BM_face_split(bm, l2->f, l2->next->v, l2->prev->v, &l, l2->e, TRUE); /* clip this corner off */
curedge = bmesh_disk_edge_next(curedge, v);
} while (curedge != v->e);
BME_Bevel_Dissolve_Disk(bm, v);