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/intern/bmesh_polygon_edgenet.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index 14b73693b03..83ac7df058a 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -495,13 +495,16 @@ bool BM_face_split_edgenet(BMesh *bm,
return false;
}
+ /* These arrays used to be stack memory, however they can be
+ * large for single faces with complex edgenets, see: T65980. */
+
/* over-alloc (probably 2-4 is only used in most cases), for the biggest-fan */
- edge_order = BLI_array_alloca(edge_order, edge_order_len);
+ edge_order = MEM_mallocN(sizeof(*edge_order) * edge_order_len, __func__);
/* use later */
- face_verts = BLI_array_alloca(face_verts, edge_net_len + f->len);
+ face_verts = MEM_mallocN(sizeof(*face_verts) * (edge_net_len + f->len), __func__);
- vert_queue = BLI_array_alloca(vert_queue, edge_net_len + f->len);
+ vert_queue = MEM_mallocN(sizeof(vert_queue) * (edge_net_len + f->len), __func__);
STACK_INIT(vert_queue, f->len + edge_net_len);
BLI_assert(BM_ELEM_API_FLAG_TEST(f, FACE_NET) == 0);
@@ -687,6 +690,10 @@ bool BM_face_split_edgenet(BMesh *bm,
}
}
+ MEM_freeN(edge_order);
+ MEM_freeN(face_verts);
+ MEM_freeN(vert_queue);
+
return true;
}
@@ -758,8 +765,8 @@ struct EdgeGroupIsland {
/* Set the following vars once we have >1 groups */
- /* when when an edge in a previous group connects to this one,
- * so theres no need to create one pointing back. */
+ /* when an edge in a previous group connects to this one,
+ * so there's no need to create one pointing back. */
uint has_prev_edge : 1;
/* verts in the group which has the lowest & highest values,
@@ -993,7 +1000,7 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn
* until a vertex is found which isn't blocked by an edge.
*
* \note It's possible none of the verts can be accessed (with self-intersecting lines).
- * In that case theres no right answer (without subdividing edges),
+ * In that case there's no right answer (without subdividing edges),
* so return a fall-back vertex in that case.
*/
@@ -1247,7 +1254,7 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
*/
const uint edge_arr_len = (uint)edge_net_init_len + (uint)f->len;
- BMEdge **edge_arr = BLI_array_alloca(edge_arr, edge_arr_len);
+ BMEdge **edge_arr = BLI_memarena_alloc(mem_arena, sizeof(*edge_arr) * edge_arr_len);
bool ok = false;
uint edge_net_new_len = (uint)edge_net_init_len;
@@ -1342,7 +1349,7 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
BM_elem_flag_disable(e_iter, EDGE_NOT_IN_STACK);
unique_edges_in_group++;
- BLI_linklist_prepend_alloca(&edge_links, e_iter);
+ BLI_linklist_prepend_arena(&edge_links, e_iter, mem_arena);
BMVert *v_other = BM_edge_other_vert(e_iter, v_iter);
if (BM_elem_flag_test(v_other, VERT_NOT_IN_STACK)) {
@@ -1353,7 +1360,7 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
} while ((e_iter = BM_DISK_EDGE_NEXT(e_iter, v_iter)) != v_iter->e);
}
- struct EdgeGroupIsland *g = alloca(sizeof(*g));
+ struct EdgeGroupIsland *g = BLI_memarena_alloc(mem_arena, sizeof(*g));
g->vert_len = unique_verts_in_group;
g->edge_len = unique_edges_in_group;
edge_in_group_tot += unique_edges_in_group;
@@ -1474,7 +1481,7 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
if (!BM_elem_flag_test(v_iter, VERT_IN_ARRAY)) {
BM_elem_flag_enable(v_iter, VERT_IN_ARRAY);
- /* not nice, but alternatives arent much better :S */
+ /* not nice, but alternatives aren't much better :S */
{
copy_v3_v3(vert_coords_backup[v_index], v_iter->co);