diff options
author | Hans Goudey <h.goudey@me.com> | 2022-08-10 07:07:44 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-08-10 07:07:44 +0300 |
commit | f874bf7fc1ff2ca636f5c70abdd15900e8b38feb (patch) | |
tree | f47ff3a4972bd1739b6a465907fe2824c92874ed | |
parent | 81d6dcf0b370fb9d9832bc9afa010b1be89a7e85 (diff) |
Parallelize layer copying, fix names and todo
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_convert.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index d7decc28fb6..8148a50f106 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -84,6 +84,7 @@ #include "BLI_math_vector.h" #include "BLI_span.hh" #include "BLI_string_ref.hh" +#include "BLI_task.hh" #include "BKE_attribute.hh" #include "BKE_customdata.h" @@ -933,9 +934,11 @@ static void write_elem_flag_to_attribute(blender::bke::MutableAttributeAccessor if (do_write) { bke::SpanAttributeWriter<bool> attribute = attributes.lookup_or_add_for_write_only_span<bool>( attribute_name, domain); - for (const int i : attribute.span.index_range()) { - attribute.span[i] = get_fn(i); - } + threading::parallel_for(attribute.span.index_range(), 4096, [&](IndexRange range) { + for (const int i : range) { + attribute.span[i] = get_fn(i); + } + }); attribute.finish(); } else { @@ -953,8 +956,8 @@ static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm, using namespace blender; /* The "hide" attributes are stored as flags on #BMesh. */ BLI_assert(CustomData_get_layer_named(&bm.vdata, CD_PROP_BOOL, ".hide_vert") == nullptr); - BLI_assert(CustomData_get_layer_named(&bm.edata, CD_PROP_BOOL, ".edge_vert") == nullptr); - BLI_assert(CustomData_get_layer_named(&bm.pdata, CD_PROP_BOOL, ".face_vert") == nullptr); + BLI_assert(CustomData_get_layer_named(&bm.edata, CD_PROP_BOOL, ".hide_edge") == nullptr); + BLI_assert(CustomData_get_layer_named(&bm.pdata, CD_PROP_BOOL, ".hide_poly") == nullptr); if (!(need_hide_vert || need_hide_edge || need_hide_face)) { return; @@ -1011,14 +1014,12 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh me->act_face = -1; { - /* TODO: Somehow deal with BMesh storage of hide layers (currently it's still stored as a - * generic attribute there too). */ CustomData_MeshMasks mask = CD_MASK_MESH; CustomData_MeshMasks_update(&mask, ¶ms->cd_mask_extra); - CustomData_copy(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert); - CustomData_copy(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge); - CustomData_copy(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop); - CustomData_copy(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly); + CustomData_copy_mesh_to_bmesh(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert); + CustomData_copy_mesh_to_bmesh(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge); + CustomData_copy_mesh_to_bmesh(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop); + CustomData_copy_mesh_to_bmesh(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly); } MVert *mvert = bm->totvert ? (MVert *)MEM_callocN(sizeof(MVert) * bm->totvert, "bm_to_me.vert") : |