Cleanup: Avoid inconsistent naming in mesh topology API

Mesh corners are called "loops" in the code currently. Avoid diverging
naming and just use that convention in some newly added code.
This commit is contained in:
Hans Goudey 2022-10-06 17:34:53 -05:00
parent 79b1e267ef
commit b04b87b322
8 changed files with 22 additions and 23 deletions

View File

@ -338,14 +338,14 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
#ifdef __cplusplus
namespace blender::mesh_topology {
Array<int> build_corner_to_poly_map(Span<MPoly> polys, int loops_num);
Array<int> build_loop_to_poly_map(Span<MPoly> polys, int loops_num);
Array<Vector<int>> build_vert_to_edge_map(Span<MEdge> edges, int verts_num);
Array<Vector<int>> build_vert_to_corner_map(Span<MLoop> loops, int verts_num);
Array<Vector<int>> build_vert_to_loop_map(Span<MLoop> loops, int verts_num);
inline int previous_poly_corner(const MPoly &poly, int corner_i)
inline int previous_poly_loop(const MPoly &poly, int loop_i)
{
return corner_i - 1 + (corner_i == poly.loopstart) * poly.totloop;
return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop;
}
} // namespace blender::mesh_topology

View File

@ -221,7 +221,7 @@ class MeshFairingContext : public FairingContext {
}
}
loop_to_poly_map_ = blender::mesh_topology::build_corner_to_poly_map(mpoly_, mloop_.size());
loop_to_poly_map_ = blender::mesh_topology::build_loop_to_poly_map(mpoly_, mloop_.size());
}
~MeshFairingContext() override

View File

@ -555,7 +555,7 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map,
namespace blender::mesh_topology {
Array<int> build_corner_to_poly_map(const Span<MPoly> polys, const int loops_num)
Array<int> build_loop_to_poly_map(const Span<MPoly> polys, const int loops_num)
{
Array<int> map(loops_num);
threading::parallel_for(polys.index_range(), 1024, [&](IndexRange range) {
@ -577,7 +577,7 @@ Array<Vector<int>> build_vert_to_edge_map(const Span<MEdge> edges, const int ver
return map;
}
Array<Vector<int>> build_vert_to_corner_map(const Span<MLoop> loops, const int verts_num)
Array<Vector<int>> build_vert_to_loop_map(const Span<MLoop> loops, const int verts_num)
{
Array<Vector<int>> map(verts_num);
for (const int64_t i : loops.index_range()) {

View File

@ -60,8 +60,8 @@ class CornersOfVertInput final : public bke::MeshFieldInput {
{
const IndexRange vert_range(mesh.totvert);
const Span<MLoop> loops = mesh.loops();
Array<Vector<int>> vert_to_corner_map = mesh_topology::build_vert_to_corner_map(loops,
mesh.totvert);
Array<Vector<int>> vert_to_loop_map = mesh_topology::build_vert_to_loop_map(loops,
mesh.totvert);
const bke::MeshFieldContext context{mesh, domain};
fn::FieldEvaluator evaluator{context, &mask};
@ -92,7 +92,7 @@ class CornersOfVertInput final : public bke::MeshFieldInput {
continue;
}
const Span<int> corners = vert_to_corner_map[vert_i];
const Span<int> corners = vert_to_loop_map[vert_i];
/* Retrieve the connected edge indices as 64 bit integers for #materialize_compressed. */
corner_indices.reinitialize(corners.size());

View File

@ -77,13 +77,13 @@ class CornerPreviousEdgeFieldInput final : public bke::MeshFieldInput {
}
const Span<MPoly> polys = mesh.polys();
const Span<MLoop> loops = mesh.loops();
Array<int> corner_to_poly_map = mesh_topology::build_corner_to_poly_map(polys, mesh.totloop);
Array<int> loop_to_poly_map = mesh_topology::build_loop_to_poly_map(polys, mesh.totloop);
return VArray<int>::ForFunc(
mesh.totloop,
[polys, loops, corner_to_poly_map = std::move(corner_to_poly_map)](const int corner_i) {
const int poly_i = corner_to_poly_map[corner_i];
[polys, loops, loop_to_poly_map = std::move(loop_to_poly_map)](const int corner_i) {
const int poly_i = loop_to_poly_map[corner_i];
const MPoly &poly = polys[poly_i];
const int corner_i_prev = mesh_topology::previous_poly_corner(poly, corner_i);
const int corner_i_prev = mesh_topology::previous_poly_loop(poly, corner_i);
return loops[corner_i_prev].e;
});
}

View File

@ -36,7 +36,7 @@ class CornerFaceIndexInput final : public bke::MeshFieldInput {
return {};
}
return VArray<int>::ForContainer(
mesh_topology::build_corner_to_poly_map(mesh.polys(), mesh.totloop));
mesh_topology::build_loop_to_poly_map(mesh.polys(), mesh.totloop));
}
uint64_t hash() const final
@ -65,11 +65,10 @@ class CornerIndexInFaceInput final : public bke::MeshFieldInput {
return {};
}
const Span<MPoly> polys = mesh.polys();
Array<int> corner_to_poly_map = mesh_topology::build_corner_to_poly_map(polys, mesh.totloop);
Array<int> loop_to_poly_map = mesh_topology::build_loop_to_poly_map(polys, mesh.totloop);
return VArray<int>::ForFunc(
mesh.totloop,
[polys, corner_to_poly_map = std::move(corner_to_poly_map)](const int corner_i) {
const int poly_i = corner_to_poly_map[corner_i];
mesh.totloop, [polys, loop_to_poly_map = std::move(loop_to_poly_map)](const int corner_i) {
const int poly_i = loop_to_poly_map[corner_i];
return corner_i - polys[poly_i].loopstart;
});
}

View File

@ -52,7 +52,7 @@ class OffsetCornerInFaceFieldInput final : public bke::MeshFieldInput {
const VArray<int> corner_indices = evaluator.get_evaluated<int>(0);
const VArray<int> offsets = evaluator.get_evaluated<int>(1);
Array<int> corner_to_poly_map = mesh_topology::build_corner_to_poly_map(polys, mesh.totloop);
Array<int> loop_to_poly_map = mesh_topology::build_loop_to_poly_map(polys, mesh.totloop);
Array<int> offset_corners(mask.min_array_size());
threading::parallel_for(mask.index_range(), 2048, [&](const IndexRange range) {
@ -64,7 +64,7 @@ class OffsetCornerInFaceFieldInput final : public bke::MeshFieldInput {
continue;
}
const int poly_i = corner_to_poly_map[corner_i];
const int poly_i = loop_to_poly_map[corner_i];
const IndexRange poly_range(polys[poly_i].loopstart, polys[poly_i].totloop);
offset_corners[selection_i] = apply_offset_in_cyclic_range(poly_range, corner_i, offset);
}

View File

@ -290,8 +290,8 @@ class TextureMarginMap {
void build_tables()
{
loop_to_poly_map_ = blender::mesh_topology::build_corner_to_poly_map({mpoly_, totpoly_},
totloop_);
loop_to_poly_map_ = blender::mesh_topology::build_loop_to_poly_map({mpoly_, totpoly_},
totloop_);
loop_adjacency_map_.resize(totloop_, -1);