[Bf-blender-cvs] [f874bf7fc1f] refactor-mesh-hide-generic: Parallelize layer copying, fix names and todo
Hans Goudey
noreply at git.blender.org
Wed Aug 10 06:30:46 CEST 2022
Commit: f874bf7fc1ff2ca636f5c70abdd15900e8b38feb
Author: Hans Goudey
Date: Tue Aug 9 23:07:44 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rBf874bf7fc1ff2ca636f5c70abdd15900e8b38feb
Parallelize layer copying, fix names and todo
===================================================================
M source/blender/bmesh/intern/bmesh_mesh_convert.cc
===================================================================
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") :
More information about the Bf-blender-cvs
mailing list