Cleanup: replace term face with poly

Be consistent with naming to avoid mixing MPoly/MFace.
This commit is contained in:
Campbell Barton 2022-08-12 08:57:38 +10:00
parent 344919240c
commit 62d1ed0120
5 changed files with 34 additions and 34 deletions

View File

@ -761,7 +761,7 @@ void BKE_mesh_flush_hidden_from_verts(Mesh *me)
}
hide_edge.finish();
/* Hide faces when any of their vertices are hidden. */
/* Hide polygons when any of their vertices are hidden. */
SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
for (const int i : polys.index_range()) {
@ -787,7 +787,7 @@ void BKE_mesh_flush_hidden_from_polys(Mesh *me)
attributes.remove(".hide_edge");
return;
}
const VArraySpan<bool> hide_face_span{hide_poly};
const VArraySpan<bool> hide_poly_span{hide_poly};
const Span<MPoly> polys(me->mpoly, me->totpoly);
const Span<MLoop> loops(me->mloop, me->totloop);
SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_only_span<bool>(
@ -795,9 +795,9 @@ void BKE_mesh_flush_hidden_from_polys(Mesh *me)
SpanAttributeWriter<bool> hide_edge = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_edge", ATTR_DOMAIN_EDGE);
/* Hide all edges or vertices connected to hidden faces. */
/* Hide all edges or vertices connected to hidden polygons. */
for (const int i : polys.index_range()) {
if (hide_face_span[i]) {
if (hide_poly_span[i]) {
const MPoly &poly = polys[i];
for (const MLoop &loop : loops.slice(poly.loopstart, poly.totloop)) {
hide_vert.span[loop.v] = true;
@ -805,9 +805,9 @@ void BKE_mesh_flush_hidden_from_polys(Mesh *me)
}
}
}
/* Unhide vertices and edges connected to visible faces. */
/* Unhide vertices and edges connected to visible polygons. */
for (const int i : polys.index_range()) {
if (!hide_face_span[i]) {
if (!hide_poly_span[i]) {
const MPoly &poly = polys[i];
for (const MLoop &loop : loops.slice(poly.loopstart, poly.totloop)) {
hide_vert.span[loop.v] = false;

View File

@ -906,11 +906,11 @@ void BKE_mesh_legacy_convert_hide_layers_to_flags(Mesh *mesh)
});
MutableSpan<MPoly> polygons(mesh->mpoly, mesh->totpoly);
const VArray<bool> hide_face = attributes.lookup_or_default<bool>(
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
threading::parallel_for(polygons.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
SET_FLAG_FROM_TEST(polygons[i].flag, hide_face[i], ME_HIDE);
SET_FLAG_FROM_TEST(polygons[i].flag, hide_poly[i], ME_HIDE);
}
});
}
@ -952,14 +952,14 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
if (std::any_of(polygons.begin(), polygons.end(), [](const MPoly &poly) {
return poly.flag & ME_HIDE;
})) {
SpanAttributeWriter<bool> hide_face = attributes.lookup_or_add_for_write_only_span<bool>(
SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
threading::parallel_for(polygons.index_range(), 4096, [&](IndexRange range) {
for (const int i : range) {
hide_face.span[i] = polygons[i].flag & ME_HIDE;
hide_poly.span[i] = polygons[i].flag & ME_HIDE;
}
});
hide_face.finish();
hide_poly.finish();
}
}

View File

@ -950,7 +950,7 @@ static void write_elem_flag_to_attribute(blender::bke::MutableAttributeAccessor
static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm,
const bool need_hide_vert,
const bool need_hide_edge,
const bool need_hide_face,
const bool need_hide_poly,
Mesh &mesh)
{
using namespace blender;
@ -959,7 +959,7 @@ static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm,
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)) {
if (!(need_hide_vert || need_hide_edge || need_hide_poly)) {
return;
}
@ -975,7 +975,7 @@ static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm,
return BM_elem_flag_test(BM_edge_at_index(&bm, i), BM_ELEM_HIDDEN);
});
write_elem_flag_to_attribute(
attributes, ".hide_poly", ATTR_DOMAIN_FACE, need_hide_face, [&](const int i) {
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);
});
}
@ -1038,7 +1038,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
bool need_hide_vert = false;
bool need_hide_edge = false;
bool need_hide_face = false;
bool need_hide_poly = false;
/* Clear normals on the mesh completely, since the original vertex and polygon count might be
* different than the BMesh's. */
@ -1114,7 +1114,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
mpoly->mat_nr = f->mat_nr;
mpoly->flag = BM_face_flag_to_mflag(f);
if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
need_hide_face = true;
need_hide_poly = true;
}
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@ -1209,7 +1209,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
}
convert_bmesh_hide_flags_to_mesh_attributes(
*bm, need_hide_vert, need_hide_edge, need_hide_face, *me);
*bm, need_hide_vert, need_hide_edge, need_hide_poly, *me);
BKE_mesh_update_customdata_pointers(me, false);
@ -1306,7 +1306,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
bool need_hide_vert = false;
bool need_hide_edge = false;
bool need_hide_face = false;
bool need_hide_poly = false;
/* Clear normals on the mesh completely, since the original vertex and polygon count might be
* different than the BMesh's. */
@ -1381,7 +1381,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
mp->totloop = efa->len;
mp->flag = BM_face_flag_to_mflag(efa);
if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
need_hide_face = true;
need_hide_poly = true;
}
mp->loopstart = j;
@ -1404,7 +1404,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
convert_bmesh_hide_flags_to_mesh_attributes(
*bm, need_hide_vert, need_hide_edge, need_hide_face, *me);
*bm, need_hide_vert, need_hide_edge, need_hide_poly, *me);
me->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
}

View File

@ -87,7 +87,7 @@ static void extract_pos_nor_iter_poly_mesh(const MeshRenderData *mr,
void *_data)
{
MeshExtract_PosNor_Data *data = static_cast<MeshExtract_PosNor_Data *>(_data);
const bool face_hidden = mr->hide_poly && mr->hide_poly[mp_index];
const bool poly_hidden = mr->hide_poly && mr->hide_poly[mp_index];
const MLoop *mloop = mr->mloop;
const int ml_index_end = mp->loopstart + mp->totloop;
@ -100,7 +100,7 @@ static void extract_pos_nor_iter_poly_mesh(const MeshRenderData *mr,
copy_v3_v3(vert->pos, mv->co);
vert->nor = data->normals[ml->v].low;
/* Flag for paint mode overlay. */
if (face_hidden || vert_hidden ||
if (poly_hidden || vert_hidden ||
((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) &&
(mr->v_origindex[ml->v] == ORIGINDEX_NONE))) {
vert->nor.w = -1;
@ -434,7 +434,7 @@ static void extract_pos_nor_hq_iter_poly_mesh(const MeshRenderData *mr,
void *_data)
{
MeshExtract_PosNorHQ_Data *data = static_cast<MeshExtract_PosNorHQ_Data *>(_data);
const bool face_hidden = mr->hide_poly && mr->hide_poly[mp - mr->mpoly];
const bool poly_hidden = mr->hide_poly && mr->hide_poly[mp - mr->mpoly];
const MLoop *mloop = mr->mloop;
const int ml_index_end = mp->loopstart + mp->totloop;
@ -448,7 +448,7 @@ static void extract_pos_nor_hq_iter_poly_mesh(const MeshRenderData *mr,
copy_v3_v3_short(vert->nor, data->normals[ml->v].high);
/* Flag for paint mode overlay. */
if (face_hidden || vert_hidden ||
if (poly_hidden || vert_hidden ||
((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->v_origindex) &&
(mr->v_origindex[ml->v] == ORIGINDEX_NONE))) {
vert->nor[3] = -1;

View File

@ -82,12 +82,12 @@ void paintface_flush_flags(bContext *C,
me_orig->mpoly[i].flag = me->mpoly[i].flag;
}
if (flush_hidden) {
const VArray<bool> hide_face_me = attributes_me.lookup_or_default<bool>(
const VArray<bool> hide_poly_me = attributes_me.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
bke::SpanAttributeWriter<bool> hide_face_orig =
bke::SpanAttributeWriter<bool> hide_poly_orig =
attributes_orig.lookup_or_add_for_write_only_span<bool>(".hide_poly", ATTR_DOMAIN_FACE);
hide_face_me.materialize(hide_face_orig.span);
hide_face_orig.finish();
hide_poly_me.materialize(hide_poly_orig.span);
hide_poly_orig.finish();
}
/* Mesh polys => Final derived polys */
@ -103,17 +103,17 @@ void paintface_flush_flags(bContext *C,
polys[i].flag = mp_orig->flag;
}
}
const VArray<bool> hide_face_orig = attributes_orig.lookup_or_default<bool>(
const VArray<bool> hide_poly_orig = attributes_orig.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
bke::SpanAttributeWriter<bool> hide_face_eval =
bke::SpanAttributeWriter<bool> hide_poly_eval =
attributes_eval.lookup_or_add_for_write_only_span<bool>(".hide_poly", ATTR_DOMAIN_FACE);
for (const int i : IndexRange(me_eval->totpoly)) {
const int orig_face_index = index_array[i];
if (orig_face_index != ORIGINDEX_NONE) {
hide_face_eval.span[i] = hide_face_orig[orig_face_index];
const int orig_poly_index = index_array[i];
if (orig_poly_index != ORIGINDEX_NONE) {
hide_poly_eval.span[i] = hide_poly_orig[orig_poly_index];
}
}
hide_face_eval.finish();
hide_poly_eval.finish();
updated = true;
}