diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-12-29 22:34:19 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-12-29 23:45:56 +0300 |
commit | 04ead39daee88433e7dfbe5f86986026e6e9ed1e (patch) | |
tree | 428eb1eb6c1099a60ac5ea1380282f9967b5702d /source | |
parent | bb0da7dbbd4b210fce8c15714a3cb50a756d8075 (diff) |
Modifiers: decrease maximum allocation size for Weld vertices
At the time of allocating the buffer with vertices in context, we don't
know exactly how many vertices are affected, but we do know that it is
less than or equal to twice the number of vertices killed.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/modifiers/intern/MOD_weld.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/modifiers/intern/MOD_weld.cc b/source/blender/modifiers/intern/MOD_weld.cc index 1f7783f8b28..92207e1fbe6 100644 --- a/source/blender/modifiers/intern/MOD_weld.cc +++ b/source/blender/modifiers/intern/MOD_weld.cc @@ -31,6 +31,8 @@ //#define USE_WELD_NORMALS //#define USE_BVHTREEKDOP +#include <algorithm> + #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" @@ -376,10 +378,11 @@ static void weld_assert_poly_len(const WeldPoly *wp, const Span<WeldLoop> wloop) /** \name Weld Vert API * \{ */ -static Vector<WeldVert> weld_vert_ctx_alloc_and_setup(Span<int> vert_dest_map) +static Vector<WeldVert> weld_vert_ctx_alloc_and_setup(Span<int> vert_dest_map, + const int vert_kill_len) { Vector<WeldVert> wvert; - wvert.reserve(vert_dest_map.size()); + wvert.reserve(std::min<int>(2 * vert_kill_len, vert_dest_map.size())); for (const int i : vert_dest_map.index_range()) { if (vert_dest_map[i] != OUT_OF_CONTEXT) { @@ -1260,7 +1263,7 @@ static void weld_mesh_context_create(const Mesh *mesh, Span<MLoop> mloop{mesh->mloop, mesh->totloop}; const int mvert_len = mesh->totvert; - Vector<WeldVert> wvert = weld_vert_ctx_alloc_and_setup(vert_dest_map); + Vector<WeldVert> wvert = weld_vert_ctx_alloc_and_setup(vert_dest_map, vert_kill_len); r_weld_mesh->vert_kill_len = vert_kill_len; Array<int> edge_dest_map(medge.size()); |