Cleanup: Consistent order for Mesh/SubdivCCG arguments

Order is verts, edges, faces, corners, topology data, attributes,
then for the multires case, subdivided geometry info next.
This commit is contained in:
Hans Goudey
2024-09-16 22:20:15 -04:00
parent 4fcc1b2ba1
commit d53862d155
16 changed files with 66 additions and 66 deletions

View File

@@ -261,11 +261,11 @@ BLI_NOINLINE static void calc_factors_grids(const Depsgraph &depsgraph,
calc_brush_texture_factors(ss, brush, positions, factors);
face_set::filter_verts_with_unique_face_sets_grids(vert_to_face_map,
face_set::filter_verts_with_unique_face_sets_grids(faces,
corner_verts,
faces,
subdiv_ccg,
vert_to_face_map,
face_sets,
subdiv_ccg,
relax_face_sets,
grids,
factors);

View File

@@ -406,7 +406,7 @@ bool vert_has_unique_face_set(const Object &object, PBVHVertRef vertex)
const CCGKey key = BKE_subdiv_ccg_key_top_level(*ss.subdiv_ccg);
SubdivCCGCoord coord = SubdivCCGCoord::from_index(key, vertex.i);
return vert_has_unique_face_set(
vert_to_face_map, corner_verts, faces, face_sets, *ss.subdiv_ccg, coord);
faces, corner_verts, vert_to_face_map, face_sets, *ss.subdiv_ccg, coord);
}
}
return false;
@@ -471,9 +471,9 @@ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(
return true;
}
bool vert_has_unique_face_set(const GroupedSpan<int> vert_to_face_map,
bool vert_has_unique_face_set(const OffsetIndices<int> faces,
const Span<int> corner_verts,
const OffsetIndices<int> faces,
const GroupedSpan<int> vert_to_face_map,
const Span<int> face_sets,
const SubdivCCG &subdiv_ccg,
SubdivCCGCoord coord)
@@ -624,11 +624,11 @@ static void vertex_neighbors_get_faces(const Object &object,
}
}
Span<int> vert_neighbors_get_mesh(const int vert,
const OffsetIndices<int> faces,
Span<int> vert_neighbors_get_mesh(const OffsetIndices<int> faces,
const Span<int> corner_verts,
const GroupedSpan<int> vert_to_face,
const Span<bool> hide_poly,
const int vert,
Vector<int> &r_neighbors)
{
r_neighbors.clear();
@@ -752,8 +752,8 @@ bool vert_is_boundary(const Object &object, const PBVHVertRef vertex)
return false;
}
bool vert_is_boundary(const Span<bool> hide_poly,
const GroupedSpan<int> vert_to_face_map,
bool vert_is_boundary(const GroupedSpan<int> vert_to_face_map,
const Span<bool> hide_poly,
const BitSpan boundary,
const int vert)
{
@@ -763,10 +763,10 @@ bool vert_is_boundary(const Span<bool> hide_poly,
return boundary[vert].test();
}
bool vert_is_boundary(const SubdivCCG &subdiv_ccg,
bool vert_is_boundary(const OffsetIndices<int> faces,
const Span<int> corner_verts,
const OffsetIndices<int> faces,
const BitSpan boundary,
const SubdivCCG &subdiv_ccg,
const SubdivCCGCoord vert)
{
/* TODO: Unlike the base mesh implementation this method does NOT take into account face
@@ -7423,7 +7423,7 @@ void calc_vert_neighbors(const OffsetIndices<int> faces,
BLI_assert(result.size() == verts.size());
BLI_assert(corner_verts.size() == faces.total_size());
for (const int i : verts.index_range()) {
vert_neighbors_get_mesh(verts[i], faces, corner_verts, vert_to_face, hide_poly, result[i]);
vert_neighbors_get_mesh(faces, corner_verts, vert_to_face, hide_poly, verts[i], result[i]);
}
}
@@ -7482,7 +7482,7 @@ void calc_vert_neighbors_interior(const OffsetIndices<int> faces,
for (const int i : verts.index_range()) {
const int vert = verts[i];
Vector<int> &neighbors = result[i];
vert_neighbors_get_mesh(verts[i], faces, corner_verts, vert_to_face, hide_poly, neighbors);
vert_neighbors_get_mesh(faces, corner_verts, vert_to_face, hide_poly, verts[i], neighbors);
if (boundary_verts[vert]) {
if (neighbors.size() == 2) {

View File

@@ -347,7 +347,7 @@ static void calc_blurred_cavity_mesh(const Depsgraph &depsgraph,
}
for (const int neighbor : vert_neighbors_get_mesh(
current_vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, current_vert, neighbors))
{
if (visited_verts.contains(neighbor)) {
continue;
@@ -763,7 +763,7 @@ void calc_vert_factors(const Depsgraph &depsgraph,
}
if (automasking.settings.flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
if (boundary::vert_is_boundary(hide_poly, vert_to_face_map, boundary, vert)) {
if (boundary::vert_is_boundary(vert_to_face_map, hide_poly, boundary, vert)) {
factors[i] = 0.0f;
continue;
}
@@ -870,7 +870,7 @@ void calc_face_factors(const Depsgraph &depsgraph,
}
if (automasking.settings.flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
if (boundary::vert_is_boundary(hide_poly, vert_to_face_map, boundary, vert)) {
if (boundary::vert_is_boundary(vert_to_face_map, hide_poly, boundary, vert)) {
factor = 0.0f;
continue;
}
@@ -992,7 +992,7 @@ void calc_grids_factors(const Depsgraph &depsgraph,
if (automasking.settings.flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
if (boundary::vert_is_boundary(
subdiv_ccg, corner_verts, faces, boundary, SubdivCCGCoord::from_index(key, vert)))
faces, corner_verts, boundary, subdiv_ccg, SubdivCCGCoord::from_index(key, vert)))
{
factors[node_vert] = 0.0f;
continue;
@@ -1004,9 +1004,9 @@ void calc_grids_factors(const Depsgraph &depsgraph,
ss.cache->brush->sculpt_brush_type == SCULPT_BRUSH_TYPE_DRAW_FACE_SETS &&
grid_face_set == ss.cache->paint_face_set;
if (!ignore && !face_set::vert_has_unique_face_set(vert_to_face_map,
if (!ignore && !face_set::vert_has_unique_face_set(faces,
corner_verts,
faces,
vert_to_face_map,
face_sets,
subdiv_ccg,
SubdivCCGCoord::from_index(key, vert)))
@@ -1350,7 +1350,7 @@ static void init_boundary_masking_mesh(Object &object,
for (const int i : IndexRange(num_verts)) {
switch (mode) {
case BoundaryAutomaskMode::Edges:
if (boundary::vert_is_boundary(hide_poly, vert_to_face_map, ss.vertex_info.boundary, i)) {
if (boundary::vert_is_boundary(vert_to_face_map, hide_poly, ss.vertex_info.boundary, i)) {
edge_distance[i] = 0;
}
break;
@@ -1370,7 +1370,7 @@ static void init_boundary_masking_mesh(Object &object,
}
for (const int neighbor :
vert_neighbors_get_mesh(i, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
vert_neighbors_get_mesh(faces, corner_verts, vert_to_face_map, hide_poly, i, neighbors))
{
if (edge_distance[neighbor] == propagation_it) {
edge_distance[i] = propagation_it + 1;
@@ -1415,14 +1415,14 @@ static void init_boundary_masking_grids(Object &object,
switch (mode) {
case BoundaryAutomaskMode::Edges:
if (boundary::vert_is_boundary(
subdiv_ccg, corner_verts, faces, ss.vertex_info.boundary, coord))
faces, corner_verts, ss.vertex_info.boundary, subdiv_ccg, coord))
{
edge_distance[i] = 0;
}
break;
case BoundaryAutomaskMode::FaceSets:
if (!face_set::vert_has_unique_face_set(
vert_to_face_map, corner_verts, faces, face_sets, subdiv_ccg, coord))
faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, coord))
{
edge_distance[i] = 0;
}

View File

@@ -75,11 +75,11 @@ static bool is_vert_in_editable_boundary_mesh(const OffsetIndices<int> faces,
Vector<int> neighbors;
for (const int neighbor : vert_neighbors_get_mesh(
initial_vert, faces, corner_verts, vert_to_face, hide_poly, neighbors))
faces, corner_verts, vert_to_face, hide_poly, initial_vert, neighbors))
{
if (hide_vert.is_empty() || !hide_vert[neighbor]) {
neighbor_count++;
if (boundary::vert_is_boundary(hide_poly, vert_to_face, boundary, neighbor)) {
if (boundary::vert_is_boundary(vert_to_face, hide_poly, boundary, neighbor)) {
boundary_vertex_count++;
}
}
@@ -109,7 +109,7 @@ static bool is_vert_in_editable_boundary_grids(const OffsetIndices<int> faces,
for (const SubdivCCGCoord neighbor : neighbors.coords) {
if (grid_hidden.is_empty() || !grid_hidden[neighbor.grid_index][neighbor.to_index(key)]) {
neighbor_count++;
if (boundary::vert_is_boundary(subdiv_ccg, corner_verts, faces, boundary, neighbor)) {
if (boundary::vert_is_boundary(faces, corner_verts, boundary, subdiv_ccg, neighbor)) {
boundary_vertex_count++;
}
}
@@ -156,7 +156,7 @@ static std::optional<int> get_closest_boundary_vert_mesh(Object &object,
const int initial_vert,
const float radius)
{
if (boundary::vert_is_boundary(hide_poly, vert_to_face, boundary, initial_vert)) {
if (boundary::vert_is_boundary(vert_to_face, hide_poly, boundary, initial_vert)) {
return initial_vert;
}
@@ -177,7 +177,7 @@ static std::optional<int> get_closest_boundary_vert_mesh(Object &object,
floodfill_steps[to_v] = floodfill_steps[from_v] + 1;
if (boundary::vert_is_boundary(hide_poly, vert_to_face, boundary, to_v)) {
if (boundary::vert_is_boundary(vert_to_face, hide_poly, boundary, to_v)) {
if (floodfill_steps[to_v] < boundary_initial_vert_steps) {
boundary_initial_vert_steps = floodfill_steps[to_v];
boundary_initial_vert = to_v;
@@ -200,7 +200,7 @@ static std::optional<SubdivCCGCoord> get_closest_boundary_vert_grids(
const SubdivCCGCoord initial_vert,
const float radius)
{
if (boundary::vert_is_boundary(subdiv_ccg, corner_verts, faces, boundary, initial_vert)) {
if (boundary::vert_is_boundary(faces, corner_verts, boundary, subdiv_ccg, initial_vert)) {
return initial_vert;
}
@@ -233,7 +233,7 @@ static std::optional<SubdivCCGCoord> get_closest_boundary_vert_grids(
floodfill_steps[to_v_index] = floodfill_steps[from_v_index] + 1;
}
if (boundary::vert_is_boundary(subdiv_ccg, corner_verts, faces, boundary, to_v)) {
if (boundary::vert_is_boundary(faces, corner_verts, boundary, subdiv_ccg, to_v)) {
if (floodfill_steps[to_v_index] < boundary_initial_vert_steps) {
boundary_initial_vert_steps = floodfill_steps[to_v_index];
boundary_initial_vert = to_v;
@@ -338,7 +338,7 @@ static void indices_init_mesh(Object &object,
const float3 from_v_co = vert_positions[from_v];
const float3 to_v_co = vert_positions[to_v];
if (!boundary::vert_is_boundary(hide_poly, vert_to_face, boundary_verts, to_v)) {
if (!boundary::vert_is_boundary(vert_to_face, hide_poly, boundary_verts, to_v)) {
return false;
}
const float edge_len = len_v3v3(from_v_co, to_v_co);
@@ -378,7 +378,7 @@ static void indices_init_grids(Object &object,
const float3 &from_v_co = positions[from_v_i];
const float3 &to_v_co = positions[to_v_i];
if (!boundary::vert_is_boundary(subdiv_ccg, corner_verts, faces, boundary_verts, to_v)) {
if (!boundary::vert_is_boundary(faces, corner_verts, boundary_verts, subdiv_ccg, to_v)) {
return false;
}
const float edge_len = len_v3v3(from_v_co, to_v_co);
@@ -486,7 +486,7 @@ static void edit_data_init_mesh(OffsetIndices<int> faces,
Vector<int> neighbors;
for (const int neighbor : vert_neighbors_get_mesh(
from_v, faces, corner_verts, vert_to_face, hide_poly, neighbors))
faces, corner_verts, vert_to_face, hide_poly, from_v, neighbors))
{
if ((!hide_vert.is_empty() && hide_vert[from_v]) ||
boundary.edit_info.propagation_steps_num[neighbor] != BOUNDARY_STEPS_NONE)

View File

@@ -104,14 +104,14 @@ void ensure_boundary_info(Object &object);
* Requires #ensure_boundary_info to have been called.
*/
bool vert_is_boundary(const Object &object, PBVHVertRef vertex);
bool vert_is_boundary(Span<bool> hide_poly,
GroupedSpan<int> vert_to_face_map,
bool vert_is_boundary(GroupedSpan<int> vert_to_face_map,
Span<bool> hide_poly,
BitSpan boundary,
int vert);
bool vert_is_boundary(const SubdivCCG &subdiv_ccg,
bool vert_is_boundary(OffsetIndices<int> faces,
Span<int> corner_verts,
OffsetIndices<int> faces,
BitSpan boundary,
const SubdivCCG &subdiv_ccg,
SubdivCCGCoord vert);
bool vert_is_boundary(BMVert *vert);

View File

@@ -222,7 +222,7 @@ static void sample_detail_voxel(bContext *C, ViewContext *vc, const int mval[2])
float edge_length = 0.0f;
Vector<int> neighbors;
for (const int neighbor : vert_neighbors_get_mesh(
active_vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, active_vert, neighbors))
{
edge_length += math::distance(active_vert_position, positions[neighbor]);
}

View File

@@ -468,7 +468,7 @@ static IndexMask boundary_from_enabled(Object &object,
return IndexMask::from_predicate(enabled_mask, GrainSize(1024), memory, [&](const int vert) {
Vector<int> neighbors;
for (const int neighbor : vert_neighbors_get_mesh(
vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, vert, neighbors))
{
if (!enabled_verts[neighbor]) {
return true;
@@ -476,7 +476,7 @@ static IndexMask boundary_from_enabled(Object &object,
}
if (use_mesh_boundary &&
boundary::vert_is_boundary(hide_poly, vert_to_face_map, ss.vertex_info.boundary, vert))
boundary::vert_is_boundary(vert_to_face_map, hide_poly, ss.vertex_info.boundary, vert))
{
return true;
}
@@ -503,7 +503,7 @@ static IndexMask boundary_from_enabled(Object &object,
if (use_mesh_boundary &&
boundary::vert_is_boundary(
subdiv_ccg, corner_verts, faces, ss.vertex_info.boundary, coord))
faces, corner_verts, ss.vertex_info.boundary, subdiv_ccg, coord))
{
return true;
}

View File

@@ -220,11 +220,11 @@ void filter_verts_with_unique_face_sets_mesh(const GroupedSpan<int> vert_to_face
}
}
void filter_verts_with_unique_face_sets_grids(const GroupedSpan<int> vert_to_face_map,
void filter_verts_with_unique_face_sets_grids(const OffsetIndices<int> faces,
const Span<int> corner_verts,
const OffsetIndices<int> faces,
const SubdivCCG &subdiv_ccg,
const GroupedSpan<int> vert_to_face_map,
const Span<int> face_sets,
const SubdivCCG &subdiv_ccg,
const bool unique,
const Span<int> grids,
const MutableSpan<float> factors)
@@ -247,7 +247,7 @@ void filter_verts_with_unique_face_sets_grids(const GroupedSpan<int> vert_to_fac
coord.x = x;
coord.y = y;
if (unique == face_set::vert_has_unique_face_set(
vert_to_face_map, corner_verts, faces, face_sets, subdiv_ccg, coord))
faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, coord))
{
factors[node_vert] = 0.0f;
}
@@ -1334,7 +1334,7 @@ static void edit_fairing(const Depsgraph &depsgraph,
Array<bool> fair_verts(positions.size(), false);
for (const int vert : positions.index_range()) {
if (boundary::vert_is_boundary(hide_poly, vert_to_face_map, boundary_verts, vert)) {
if (boundary::vert_is_boundary(vert_to_face_map, hide_poly, boundary_verts, vert)) {
continue;
}
if (!vert_has_face_set(vert_to_face_map, face_sets, vert, active_face_set_id)) {

View File

@@ -38,9 +38,9 @@ bool vert_has_face_set(const SubdivCCG &subdiv_ccg, Span<int> face_sets, int gri
bool vert_has_face_set(int face_set_offset, const BMVert &vert, int face_set);
bool vert_has_unique_face_set(const Object &object, PBVHVertRef vertex);
bool vert_has_unique_face_set(GroupedSpan<int> vert_to_face_map, Span<int> face_sets, int vert);
bool vert_has_unique_face_set(GroupedSpan<int> vert_to_face_map,
bool vert_has_unique_face_set(OffsetIndices<int> faces,
Span<int> corner_verts,
OffsetIndices<int> faces,
GroupedSpan<int> vert_to_face_map,
Span<int> face_sets,
const SubdivCCG &subdiv_ccg,
SubdivCCGCoord coord);
@@ -68,11 +68,11 @@ void filter_verts_with_unique_face_sets_mesh(GroupedSpan<int> vert_to_face_map,
bool unique,
Span<int> verts,
MutableSpan<float> factors);
void filter_verts_with_unique_face_sets_grids(GroupedSpan<int> vert_to_face_map,
void filter_verts_with_unique_face_sets_grids(OffsetIndices<int> faces,
Span<int> corner_verts,
OffsetIndices<int> faces,
const SubdivCCG &subdiv_ccg,
GroupedSpan<int> vert_to_face_map,
Span<int> face_sets,
const SubdivCCG &subdiv_ccg,
bool unique,
Span<int> grids,
MutableSpan<float> factors);

View File

@@ -1230,11 +1230,11 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
scale_factors(factors, strength);
clamp_factors(factors, 0.0f, 1.0f);
face_set::filter_verts_with_unique_face_sets_grids(vert_to_face_map,
face_set::filter_verts_with_unique_face_sets_grids(faces,
corner_verts,
faces,
subdiv_ccg,
vert_to_face_map,
face_sets,
subdiv_ccg,
relax_face_sets,
grids,
factors);

View File

@@ -269,7 +269,7 @@ void FillDataMesh::execute(Object &object,
this->queue.pop();
for (const int neighbor : vert_neighbors_get_mesh(
from_v, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, from_v, neighbors))
{
if (this->visited_verts[neighbor]) {
continue;

View File

@@ -533,11 +533,11 @@ namespace blender::ed::sculpt_paint {
Span<BMVert *> vert_neighbors_get_bmesh(BMVert &vert, Vector<BMVert *, 64> &r_neighbors);
Span<BMVert *> vert_neighbors_get_interior_bmesh(BMVert &vert, Vector<BMVert *, 64> &r_neighbors);
Span<int> vert_neighbors_get_mesh(int vert,
OffsetIndices<int> faces,
Span<int> vert_neighbors_get_mesh(OffsetIndices<int> faces,
Span<int> corner_verts,
GroupedSpan<int> vert_to_face,
Span<bool> hide_poly,
int vert,
Vector<int> &r_neighbors);
}

View File

@@ -630,7 +630,7 @@ void geometry_preview_lines_update(bContext *C, SculptSession &ss, float radius)
neighbors.clear();
for (const int neighbor : vert_neighbors_get_mesh(
from_vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, from_vert, neighbors))
{
preview_verts.append(from_vert);
preview_verts.append(neighbor);

View File

@@ -766,11 +766,11 @@ static void do_smear_brush_task(const Depsgraph &depsgraph,
*/
for (const int neigbor : vert_neighbors_get_mesh(
vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, vert, neighbors))
{
const float3 &nco = vert_positions[neigbor];
for (const int neighbor_neighbor : vert_neighbors_get_mesh(
vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbor_neighbors))
faces, corner_verts, vert_to_face_map, hide_poly, vert, neighbor_neighbors))
{
if (neighbor_neighbor == vert) {
continue;

View File

@@ -1356,15 +1356,15 @@ static std::unique_ptr<IKChain> ik_chain_init_face_sets_fk_grids(const Depsgraph
const int to_face_set = face_sets[grid_to_face_map[to_v.grid_index]];
if (!visited_face_sets.contains(to_face_set)) {
if (face_set::vert_has_unique_face_set(mesh.vert_to_face_map(),
if (face_set::vert_has_unique_face_set(mesh.faces(),
mesh.corner_verts(),
mesh.faces(),
mesh.vert_to_face_map(),
face_sets,
subdiv_ccg,
to_v) &&
!face_set::vert_has_unique_face_set(mesh.vert_to_face_map(),
!face_set::vert_has_unique_face_set(mesh.faces(),
mesh.corner_verts(),
mesh.faces(),
mesh.vert_to_face_map(),
face_sets,
subdiv_ccg,
from_v) &&

View File

@@ -568,7 +568,7 @@ void calc_relaxed_translations_grids(const SubdivCCG &subdiv_ccg,
if (filter_boundary_face_sets) {
neighbors[node_vert].remove_if([&](const SubdivCCGCoord neighbor) {
return face_set::vert_has_unique_face_set(
vert_to_face_map, corner_verts, faces, face_sets, subdiv_ccg, neighbor);
faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, neighbor);
});
}