[Bf-blender-cvs] [582b9c3145c] refactor-mesh-selection-generic: Merge branch 'master' into refactor-mesh-selection-generic
Hans Goudey
noreply at git.blender.org
Wed Sep 21 20:24:32 CEST 2022
Commit: 582b9c3145c12a26dc4069362604fff0cd62a81b
Author: Hans Goudey
Date: Wed Sep 21 13:20:52 2022 -0500
Branches: refactor-mesh-selection-generic
https://developer.blender.org/rB582b9c3145c12a26dc4069362604fff0cd62a81b
Merge branch 'master' into refactor-mesh-selection-generic
===================================================================
===================================================================
diff --cc source/blender/bmesh/intern/bmesh_mesh_convert.cc
index 088b04b8351,399d5e1517b..689bdcf68ec
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
@@@ -930,47 -935,18 +930,53 @@@ static void convert_bmesh_hide_flags_to
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
BM_mesh_elem_table_ensure(&bm, BM_VERT | BM_EDGE | BM_FACE);
- write_fn_to_attribute<bool>(attributes, ".hide_vert", ATTR_DOMAIN_POINT, [&](const int i) {
- return BM_elem_flag_test(BM_vert_at_index(&bm, i), BM_ELEM_HIDDEN);
- });
- write_fn_to_attribute<bool>(attributes, ".hide_edge", ATTR_DOMAIN_EDGE, [&](const int i) {
- return BM_elem_flag_test(BM_edge_at_index(&bm, i), BM_ELEM_HIDDEN);
- });
- write_fn_to_attribute<bool>(attributes, ".hide_poly", ATTR_DOMAIN_FACE, [&](const int i) {
- return BM_elem_flag_test(BM_face_at_index(&bm, i), BM_ELEM_HIDDEN);
- });
- write_fn_to_attribute<bool>(
- attributes, ".hide_vert", ATTR_DOMAIN_POINT, need_hide_vert, [&](const int i) {
- return BM_elem_flag_test(BM_vert_at_index(&bm, i), BM_ELEM_HIDDEN);
- });
- write_fn_to_attribute<bool>(
- attributes, ".hide_edge", ATTR_DOMAIN_EDGE, need_hide_edge, [&](const int i) {
- return BM_elem_flag_test(BM_edge_at_index(&bm, i), BM_ELEM_HIDDEN);
- });
- write_fn_to_attribute<bool>(
- attributes, ".hide_poly", ATTR_DOMAIN_FACE, need_hide_poly, [&](const int i) {
- return BM_elem_flag_test(BM_face_at_index(&bm, i), BM_ELEM_HIDDEN);
- });
++ if (need_hide_vert) {
++ write_fn_to_attribute<bool>(attributes, ".hide_vert", ATTR_DOMAIN_POINT, [&](const int i) {
++ return BM_elem_flag_test(BM_vert_at_index(&bm, i), BM_ELEM_HIDDEN);
++ });
++ }
++ if (need_hide_edge) {
++ write_fn_to_attribute<bool>(attributes, ".hide_edge", ATTR_DOMAIN_EDGE, [&](const int i) {
++ return BM_elem_flag_test(BM_edge_at_index(&bm, i), BM_ELEM_HIDDEN);
++ });
++ }
++ if (need_hide_poly) {
++ write_fn_to_attribute<bool>(attributes, ".hide_poly", ATTR_DOMAIN_FACE, [&](const int i) {
++ return BM_elem_flag_test(BM_face_at_index(&bm, i), BM_ELEM_HIDDEN);
++ });
++ }
+}
+
+static void convert_bmesh_selection_flags_to_mesh_attributes(BMesh &bm,
+ const bool need_selection_vert,
+ const bool need_selection_edge,
+ const bool need_selection_poly,
+ Mesh &mesh)
+{
+ using namespace blender;
+ if (!(need_selection_vert || need_selection_edge || need_selection_poly)) {
+ return;
+ }
+
+ bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
+ BM_mesh_elem_table_ensure(&bm, BM_VERT | BM_EDGE | BM_FACE);
+
+ if (need_selection_vert) {
+ write_fn_to_attribute<bool>(
+ attributes, ".selection_vert", ATTR_DOMAIN_POINT, [&](const int i) {
+ return BM_elem_flag_test(BM_vert_at_index(&bm, i), BM_ELEM_SELECT);
+ });
+ }
+ if (need_selection_edge) {
+ write_fn_to_attribute<bool>(attributes, ".selection_edge", ATTR_DOMAIN_EDGE, [&](const int i) {
+ return BM_elem_flag_test(BM_edge_at_index(&bm, i), BM_ELEM_SELECT);
+ });
+ }
+ if (need_selection_poly) {
+ write_fn_to_attribute<bool>(attributes, ".selection_poly", ATTR_DOMAIN_FACE, [&](const int i) {
+ return BM_elem_flag_test(BM_face_at_index(&bm, i), BM_ELEM_SELECT);
+ });
+ }
}
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMeshParams *params)
@@@ -1314,9 -1276,10 +1320,9 @@@ void BM_mesh_bm_to_me_for_eval(BMesh *b
BM_elem_index_set(eve, i); /* set_inline */
- mv->flag = BM_vert_flag_to_mflag(eve);
if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
if (!hide_vert_attribute) {
- hide_vert_attribute = mesh_attributes.lookup_or_add_for_write_only_span<bool>(
+ hide_vert_attribute = mesh_attributes.lookup_or_add_for_write_span<bool>(
".hide_vert", ATTR_DOMAIN_POINT);
}
hide_vert_attribute.span[i] = true;
@@@ -1428,30 -1368,12 +1434,15 @@@
}
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
- if (material_index_attribute) {
- material_index_attribute.finish();
- }
-
assert_bmesh_has_no_mesh_only_attributes(*bm);
- if (hide_vert_attribute) {
- hide_vert_attribute.finish();
- }
- if (hide_edge_attribute) {
- hide_edge_attribute.finish();
- }
- if (hide_poly_attribute) {
- hide_poly_attribute.finish();
- }
- if (selection_vert_attribute) {
- selection_vert_attribute.finish();
- }
- if (selection_edge_attribute) {
- selection_edge_attribute.finish();
- }
- if (selection_poly_attribute) {
- selection_poly_attribute.finish();
- }
+ material_index_attribute.finish();
+ hide_vert_attribute.finish();
+ hide_edge_attribute.finish();
+ hide_poly_attribute.finish();
++ selection_vert_attribute.finish();
++ selection_edge_attribute.finish();
++ selection_poly_attribute.finish();
me->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
}
More information about the Bf-blender-cvs
mailing list