Mempool: delay allocating an initial chunk, its not always used
[blender.git] / source / blender / bmesh / tools / bmesh_edgenet.c
index 18efb9acd78e810da36091e122421e581e829eea..55df5cbc955f6b572382d7b3ac88ae456d8fffd5 100644 (file)
 #include "BLI_linklist.h"
 
 #include "bmesh.h"
+#include "bmesh_edgenet.h"  /* own include */
+
+#include "BLI_strict_flags.h"  /* keep last */
 
-#ifdef __GNUC__
-#  pragma GCC diagnostic error "-Wsign-conversion"
-#  if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406  /* gcc4.6+ only */
-#    pragma GCC diagnostic error "-Wsign-compare"
-#    pragma GCC diagnostic error "-Wconversion"
-#  endif
-#endif
 
-/* Data for one end of an edge involved in a bevel */
+/* Struct for storing a path of verts walked over */
 typedef struct VertNetInfo {
        BMVert *prev;               /* previous vertex */
        int pass;                   /* path scanning pass value, for internal calculation */
@@ -132,7 +128,7 @@ static bool bm_edgenet_path_check_overlap(
 {
        /* vert order doesn't matter */
        unsigned int v_ls_tot = 0;
-       LinkNode *v_ls;
+       LinkNode *v_ls = NULL;
        BMVert *v_pair[2] = {v1, v2};
        unsigned int i;
 
@@ -193,7 +189,7 @@ static BMFace *bm_edgenet_face_from_path(
        }
 #endif
 
-       f = BM_face_create(bm, vert_arr, edge_arr, (int)path_len, 0);
+       f = BM_face_create(bm, vert_arr, edge_arr, (int)path_len, NULL, BM_CREATE_NOP);
 
        return f;
 }
@@ -225,7 +221,7 @@ static BMEdge *bm_edgenet_path_step(
 
                                        if (vn_curr->pass == -vn_next->pass) {
                                                if ((vn_curr->flag & VNINFO_FLAG_IS_MIXFACE) ||
-                                                       (vn_next->flag & VNINFO_FLAG_IS_MIXFACE))
+                                                   (vn_next->flag & VNINFO_FLAG_IS_MIXFACE))
                                                {
                                                        /* found connecting edge */
                                                        if (bm_edgenet_path_check_overlap(v_curr, v_next, vnet_info) == false) {
@@ -241,8 +237,8 @@ static BMEdge *bm_edgenet_path_step(
                                                /* flush flag down the path */
                                                vn_next->flag &= ~VNINFO_FLAG_IS_MIXFACE;
                                                if ((vn_curr->flag & VNINFO_FLAG_IS_MIXFACE) ||
-                                                       (vn_next->face == -1) ||
-                                                       (vn_next->face != vn_curr->face))
+                                                   (vn_next->face == -1) ||
+                                                   (vn_next->face != vn_curr->face))
                                                {
                                                        vn_next->flag |= VNINFO_FLAG_IS_MIXFACE;
                                                }
@@ -443,11 +439,12 @@ static LinkNode *bm_edgenet_path_calc_best(
  * \param use_edge_tag  Only fill tagged edges.
  * \param face_oflag  if nonzero, apply all new faces with this bmo flag.
  */
-void BM_mesh_edgenet(BMesh *bm, const bool use_edge_tag, const short face_oflag)
+void BM_mesh_edgenet(BMesh *bm,
+                     const bool use_edge_tag, const bool use_new_face_tag)
 {
        VertNetInfo *vnet_info = MEM_callocN(sizeof(*vnet_info) * (size_t)bm->totvert, __func__);
-       BLI_mempool *edge_queue_pool = BLI_mempool_create(sizeof(LinkNode), 1, 512, 0);
-       BLI_mempool *path_pool = BLI_mempool_create(sizeof(LinkNode), 1, 512, 0);
+       BLI_mempool *edge_queue_pool = BLI_mempool_create(sizeof(LinkNode), 0, 512, BLI_MEMPOOL_NOP);
+       BLI_mempool *path_pool = BLI_mempool_create(sizeof(LinkNode), 0, 512, BLI_MEMPOOL_NOP);
        LinkNode *edge_queue = NULL;
 
        BMEdge *e;
@@ -491,8 +488,8 @@ void BM_mesh_edgenet(BMesh *bm, const bool use_edge_tag, const short face_oflag)
                                }
                        } while ((l_iter = l_iter->next) != l_first);
 
-                       if (face_oflag) {
-                               BMO_elem_flag_enable(bm, f, face_oflag);
+                       if (use_new_face_tag) {
+                               BM_elem_flag_enable(f, BM_ELEM_TAG);
                        }
 
                        /* the face index only needs to be unique, not kept valid */