diff --git a/source/blender/blenkernel/BKE_paint.hh b/source/blender/blenkernel/BKE_paint.hh index db996e940e1..6fe90437fdb 100644 --- a/source/blender/blenkernel/BKE_paint.hh +++ b/source/blender/blenkernel/BKE_paint.hh @@ -504,17 +504,17 @@ struct SculptSession { /* Mesh connectivity maps. */ /* Vertices to adjacent polys. */ - blender::GroupedSpan pmap; + blender::GroupedSpan vert_to_face_map; /* Edges to adjacent faces. */ blender::Array edge_to_face_offsets; blender::Array edge_to_face_indices; - blender::GroupedSpan epmap; + blender::GroupedSpan edge_to_face_map; /* Vertices to adjacent edges. */ blender::Array vert_to_edge_offsets; blender::Array vert_to_edge_indices; - blender::GroupedSpan vemap; + blender::GroupedSpan vert_to_edge_map; /* Mesh Face Sets */ /* Total number of faces of the base mesh. */ diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index a2f2e0f3f51..6695b3c73c3 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -563,7 +563,7 @@ void BKE_pbvh_vertex_color_get(const PBVH *pbvh, PBVHVertRef vertex, float r_col void BKE_pbvh_ensure_node_loops(PBVH *pbvh); int BKE_pbvh_debug_draw_gen_get(PBVHNode *node); -void BKE_pbvh_pmap_set(PBVH *pbvh, blender::GroupedSpan pmap); +void BKE_pbvh_pmap_set(PBVH *pbvh, blender::GroupedSpan vert_to_face_map); namespace blender::bke::pbvh { Vector search_gather(PBVH *pbvh, diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.cc b/source/blender/blenkernel/intern/multires_reshape_apply_base.cc index f514d4c796b..4931b226807 100644 --- a/source/blender/blenkernel/intern/multires_reshape_apply_base.cc +++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.cc @@ -72,7 +72,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape blender::MutableSpan base_positions = base_mesh->vert_positions_for_write(); /* Update the context in case the vertices were duplicated. */ reshape_context->base_positions = base_positions; - const blender::GroupedSpan pmap = base_mesh->vert_to_face_map(); + const blender::GroupedSpan vert_to_face_map = base_mesh->vert_to_face_map(); float(*origco)[3] = static_cast( MEM_calloc_arrayN(base_mesh->verts_num, sizeof(float[3]), __func__)); @@ -84,17 +84,15 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape float avg_no[3] = {0, 0, 0}, center[3] = {0, 0, 0}, push[3]; /* Don't adjust vertices not used by at least one face. */ - if (!pmap[i].size()) { + if (!vert_to_face_map[i].size()) { continue; } /* Find center. */ int tot = 0; - for (int j = 0; j < pmap[i].size(); j++) { - const blender::IndexRange face = reshape_context->base_faces[pmap[i][j]]; - + for (const int face : vert_to_face_map[i]) { /* This double counts, not sure if that's bad or good. */ - for (const int corner : face) { + for (const int corner : reshape_context->base_faces[face]) { const int vndx = reshape_context->base_corner_verts[corner]; if (vndx != i) { add_v3_v3(center, origco[vndx]); @@ -105,8 +103,8 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape mul_v3_fl(center, 1.0f / tot); /* Find normal. */ - for (int j = 0; j < pmap[i].size(); j++) { - const blender::IndexRange face = reshape_context->base_faces[pmap[i][j]]; + for (int j = 0; j < vert_to_face_map[i].size(); j++) { + const blender::IndexRange face = reshape_context->base_faces[vert_to_face_map[i][j]]; /* Set up face, loops, and coords in order to call #bke::mesh::face_normal_calc(). */ blender::Array face_verts(face.size()); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 632f31d6b5a..2894de94efe 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1442,13 +1442,13 @@ static void sculptsession_free_pbvh(Object *object) ss->pbvh = nullptr; } - ss->pmap = {}; + ss->vert_to_face_map = {}; ss->edge_to_face_offsets = {}; ss->edge_to_face_indices = {}; - ss->epmap = {}; + ss->edge_to_face_map = {}; ss->vert_to_edge_offsets = {}; ss->vert_to_edge_indices = {}; - ss->vemap = {}; + ss->vert_to_edge_map = {}; MEM_SAFE_FREE(ss->preview_vert_list); ss->preview_vert_count = 0; @@ -1749,11 +1749,11 @@ static void sculpt_update_object(Depsgraph *depsgraph, sculpt_update_persistent_base(ob); if (ob->type == OB_MESH) { - ss->pmap = mesh->vert_to_face_map(); + ss->vert_to_face_map = mesh->vert_to_face_map(); } if (ss->pbvh) { - BKE_pbvh_pmap_set(ss->pbvh, ss->pmap); + BKE_pbvh_pmap_set(ss->pbvh, ss->vert_to_face_map); } if (ss->deform_modifiers_active) { @@ -2174,7 +2174,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) } BKE_pbvh_update_active_vcol(pbvh, BKE_object_get_original_mesh(ob)); - BKE_pbvh_pmap_set(pbvh, ob->sculpt->pmap); + BKE_pbvh_pmap_set(pbvh, ob->sculpt->vert_to_face_map); return pbvh; } @@ -2197,7 +2197,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) } } - BKE_pbvh_pmap_set(pbvh, ob->sculpt->pmap); + BKE_pbvh_pmap_set(pbvh, ob->sculpt->vert_to_face_map); ob->sculpt->pbvh = pbvh; sculpt_attribute_update_refs(ob); diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 6bc2d46d731..0c211bb088a 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -1170,7 +1170,7 @@ static void pbvh_faces_update_normals(PBVH &pbvh, Span nodes, Mesh & for (const PBVHNode *node : nodes) { for (const int vert : node->vert_indices.as_span().take_front(node->uniq_verts)) { if (update_tags[vert]) { - faces_to_update.add_multiple(pbvh.pmap[vert]); + faces_to_update.add_multiple(pbvh.vert_to_face_map[vert]); } } } @@ -1211,11 +1211,11 @@ static void pbvh_faces_update_normals(PBVH &pbvh, Span nodes, Mesh & if (pbvh.deformed) { normals_calc_verts_simple( - pbvh.pmap, pbvh.face_normals, verts_to_update, pbvh.vert_normals_deformed); + pbvh.vert_to_face_map, pbvh.face_normals, verts_to_update, pbvh.vert_normals_deformed); } else { mesh.runtime->vert_normals_cache.update([&](Vector &r_data) { - normals_calc_verts_simple(pbvh.pmap, pbvh.face_normals, verts_to_update, r_data); + normals_calc_verts_simple(pbvh.vert_to_face_map, pbvh.face_normals, verts_to_update, r_data); }); pbvh.vert_normals = mesh.runtime->vert_normals_cache.data(); } @@ -3043,9 +3043,9 @@ void BKE_pbvh_update_active_vcol(PBVH *pbvh, Mesh *mesh) BKE_pbvh_get_color_layer(mesh, &pbvh->color_layer, &pbvh->color_domain); } -void BKE_pbvh_pmap_set(PBVH *pbvh, const blender::GroupedSpan pmap) +void BKE_pbvh_pmap_set(PBVH *pbvh, const blender::GroupedSpan vert_to_face_map) { - pbvh->pmap = pmap; + pbvh->vert_to_face_map = vert_to_face_map; } void BKE_pbvh_ensure_node_loops(PBVH *pbvh) diff --git a/source/blender/blenkernel/intern/pbvh_colors.cc b/source/blender/blenkernel/intern/pbvh_colors.cc index cff85227c2a..b935fef6922 100644 --- a/source/blender/blenkernel/intern/pbvh_colors.cc +++ b/source/blender/blenkernel/intern/pbvh_colors.cc @@ -93,7 +93,7 @@ static void pbvh_vertex_color_get(const PBVH &pbvh, PBVHVertRef vertex, float r_ if (pbvh.color_domain == AttrDomain::Corner) { int count = 0; zero_v4(r_color); - for (const int i_face : pbvh.pmap[index]) { + for (const int i_face : pbvh.vert_to_face_map[index]) { const IndexRange face = pbvh.faces[i_face]; Span colors{static_cast(pbvh.color_layer->data) + face.start(), face.size()}; Span face_verts = pbvh.corner_verts.slice(face); @@ -124,7 +124,7 @@ static void pbvh_vertex_color_set(PBVH &pbvh, PBVHVertRef vertex, const float co int index = vertex.i; if (pbvh.color_domain == AttrDomain::Corner) { - for (const int i_face : pbvh.pmap[index]) { + for (const int i_face : pbvh.vert_to_face_map[index]) { const IndexRange face = pbvh.faces[i_face]; MutableSpan colors{static_cast(pbvh.color_layer->data) + face.start(), face.size()}; Span face_verts = pbvh.corner_verts.slice(face); diff --git a/source/blender/blenkernel/intern/pbvh_intern.hh b/source/blender/blenkernel/intern/pbvh_intern.hh index f7d2b998e1c..a21fad24de5 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.hh +++ b/source/blender/blenkernel/intern/pbvh_intern.hh @@ -183,7 +183,7 @@ struct PBVH { BMLog *bm_log; - blender::GroupedSpan pmap; + blender::GroupedSpan vert_to_face_map; CustomDataLayer *color_layer; blender::bke::AttrDomain color_domain; diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index ec91b0ff46a..d7327f88273 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -412,7 +412,7 @@ bool vert_any_face_visible_get(SculptSession *ss, PBVHVertRef vertex) if (!ss->hide_poly) { return true; } - for (const int face : ss->pmap[vertex.i]) { + for (const int face : ss->vert_to_face_map[vertex.i]) { if (!ss->hide_poly[face]) { return true; } @@ -434,7 +434,7 @@ bool vert_all_faces_visible_get(const SculptSession *ss, PBVHVertRef vertex) if (!ss->hide_poly) { return true; } - for (const int face : ss->pmap[vertex.i]) { + for (const int face : ss->vert_to_face_map[vertex.i]) { if (ss->hide_poly[face]) { return false; } @@ -490,7 +490,7 @@ int vert_face_set_get(SculptSession *ss, PBVHVertRef vertex) return SCULPT_FACE_SET_NONE; } int face_set = 0; - for (const int face_index : ss->pmap[vertex.i]) { + for (const int face_index : ss->vert_to_face_map[vertex.i]) { if (ss->face_sets[face_index] > face_set) { face_set = ss->face_sets[face_index]; } @@ -519,7 +519,7 @@ bool vert_has_face_set(SculptSession *ss, PBVHVertRef vertex, int face_set) if (!ss->face_sets) { return face_set == SCULPT_FACE_SET_NONE; } - for (const int face_index : ss->pmap[vertex.i]) { + for (const int face_index : ss->vert_to_face_map[vertex.i]) { if (ss->face_sets[face_index] == face_set) { return true; } @@ -547,7 +547,7 @@ static bool sculpt_check_unique_face_set_in_base_mesh(SculptSession *ss, int ind return true; } int face_set = -1; - for (const int face_index : ss->pmap[index]) { + for (const int face_index : ss->vert_to_face_map[index]) { if (face_set == -1) { face_set = ss->face_sets[face_index]; } @@ -566,7 +566,7 @@ static bool sculpt_check_unique_face_set_in_base_mesh(SculptSession *ss, int ind */ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(SculptSession *ss, int v1, int v2) { - const Span vert_map = ss->pmap[v1]; + const Span vert_map = ss->vert_to_face_map[v1]; int p1 = -1, p2 = -1; for (int i = 0; i < vert_map.size(); i++) { const int face_i = vert_map[i]; @@ -704,7 +704,7 @@ static void sculpt_vertex_neighbors_get_faces(SculptSession *ss, iter->neighbors = iter->neighbors_fixed; iter->neighbor_indices = iter->neighbor_indices_fixed; - for (const int face_i : ss->pmap[vertex.i]) { + for (const int face_i : ss->vert_to_face_map[vertex.i]) { if (ss->hide_poly && ss->hide_poly[face_i]) { /* Skip connectivity from hidden faces. */ continue; diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc b/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc index 6aac070af46..63995510236 100644 --- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc @@ -164,7 +164,7 @@ static void SCULPT_dynamic_topology_disable_ex( else { BKE_sculptsession_bm_to_me(ob, true); - /* Sync the visibility to vertices manually as the `pmap` is still not initialized. */ + /* Sync the visibility to vertices manually as `vert_to_face_map` is still not initialized. */ bool *hide_vert = (bool *)CustomData_get_layer_named_for_write( &mesh->vert_data, CD_PROP_BOOL, ".hide_vert", mesh->verts_num); if (hide_vert != nullptr) { diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index 7e821d01e03..bad8bf90a89 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -732,7 +732,7 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR int v_next_i = BKE_pbvh_vertex_to_index(ss->pbvh, v_next); - for (const int face : ss->pmap[v_next_i]) { + for (const int face : ss->vert_to_face_map[v_next_i]) { for (const int vert : ss->corner_verts.slice(ss->faces[face])) { const PBVHVertRef neighbor_v = BKE_pbvh_make_vref(vert); if (visited_verts[neighbor_v.i]) { @@ -1973,7 +1973,7 @@ static void sculpt_expand_delete_face_set_id( int *r_face_sets, SculptSession *ss, Cache *expand_cache, Mesh *mesh, const int delete_id) { const int totface = ss->totfaces; - const GroupedSpan pmap = ss->pmap; + const GroupedSpan vert_to_face_map = ss->vert_to_face_map; const OffsetIndices faces = mesh->faces(); const Span corner_verts = mesh->corner_verts(); @@ -2011,7 +2011,7 @@ static void sculpt_expand_delete_face_set_id( const int f_index = POINTER_AS_INT(BLI_LINKSTACK_POP(queue)); int other_id = delete_id; for (const int vert : corner_verts.slice(faces[f_index])) { - for (const int neighbor_face_index : pmap[vert]) { + for (const int neighbor_face_index : vert_to_face_map[vert]) { if (expand_cache->original_face_sets[neighbor_face_index] <= 0) { /* Skip picking IDs from hidden Face Sets. */ continue; diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 1e4834bf40c..855bc76dda3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -211,7 +211,7 @@ static void do_draw_face_sets_brush_faces(Object *ob, BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { auto_mask::node_update(automask_data, vd); - for (const int face_i : ss->pmap[vd.index]) { + for (const int face_i : ss->vert_to_face_map[vd.index]) { const IndexRange face = ss->faces[face_i]; const float3 poly_center = bke::mesh::face_center_calc(positions, @@ -716,8 +716,8 @@ static void sculpt_face_sets_init_flood_fill(Object *ob, const FaceSetsFloodFill const OffsetIndices faces = mesh->faces(); const Span corner_edges = mesh->corner_edges(); - if (ss->epmap.is_empty()) { - ss->epmap = bke::mesh::build_edge_to_face_map( + if (ss->edge_to_face_map.is_empty()) { + ss->edge_to_face_map = bke::mesh::build_edge_to_face_map( faces, corner_edges, edges.size(), ss->edge_to_face_offsets, ss->edge_to_face_indices); } @@ -738,7 +738,7 @@ static void sculpt_face_sets_init_flood_fill(Object *ob, const FaceSetsFloodFill queue.pop(); for (const int edge_i : corner_edges.slice(faces[face_i])) { - for (const int neighbor_i : ss->epmap[edge_i]) { + for (const int neighbor_i : ss->edge_to_face_map[edge_i]) { if (neighbor_i == face_i) { continue; } @@ -1228,7 +1228,7 @@ static void sculpt_face_set_grow_shrink(Object &object, Mesh &mesh = *static_cast(object.data); const OffsetIndices faces = mesh.faces(); const Span corner_verts = mesh.corner_verts(); - const GroupedSpan vert_to_face_map = ss.pmap; + const GroupedSpan vert_to_face_map = ss.vert_to_face_map; const bke::AttributeAccessor attributes = mesh.attributes(); const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); Array prev_face_sets = duplicate_face_sets(mesh); diff --git a/source/blender/editors/sculpt_paint/sculpt_geodesic.cc b/source/blender/editors/sculpt_paint/sculpt_geodesic.cc index 27de17ccc53..a0bdc4a4265 100644 --- a/source/blender/editors/sculpt_paint/sculpt_geodesic.cc +++ b/source/blender/editors/sculpt_paint/sculpt_geodesic.cc @@ -98,12 +98,12 @@ static float *geodesic_mesh_create(Object *ob, GSet *initial_verts, const float float *dists = static_cast(MEM_malloc_arrayN(totvert, sizeof(float), __func__)); BitVector<> edge_tag(totedge); - if (ss->epmap.is_empty()) { - ss->epmap = bke::mesh::build_edge_to_face_map( + if (ss->edge_to_face_map.is_empty()) { + ss->edge_to_face_map = bke::mesh::build_edge_to_face_map( faces, corner_edges, edges.size(), ss->edge_to_face_offsets, ss->edge_to_face_indices); } - if (ss->vemap.is_empty()) { - ss->vemap = bke::mesh::build_vert_to_edge_map( + if (ss->vert_to_edge_map.is_empty()) { + ss->vert_to_edge_map = bke::mesh::build_vert_to_edge_map( edges, mesh->verts_num, ss->vert_to_edge_offsets, ss->vert_to_edge_indices); } @@ -174,38 +174,32 @@ static float *geodesic_mesh_create(Object *ob, GSet *initial_verts, const float vert_positions, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_verts); } - if (ss->epmap[e].size() != 0) { - for (int face_map_index = 0; face_map_index < ss->epmap[e].size(); face_map_index++) { - const int face = ss->epmap[e][face_map_index]; - if (!hide_poly.is_empty() && hide_poly[face]) { + for (const int face : ss->edge_to_face_map[e]) { + if (!hide_poly.is_empty() && hide_poly[face]) { + continue; + } + for (const int v_other : corner_verts.slice(faces[face])) { + if (ELEM(v_other, v1, v2)) { continue; } - for (const int v_other : corner_verts.slice(faces[face])) { - if (ELEM(v_other, v1, v2)) { - continue; - } - if (sculpt_geodesic_mesh_test_dist_add( - vert_positions, v_other, v1, v2, dists, initial_verts)) - { - for (int edge_map_index = 0; edge_map_index < ss->vemap[v_other].size(); - edge_map_index++) - { - const int e_other = ss->vemap[v_other][edge_map_index]; - int ev_other; - if (edges[e_other][0] == v_other) { - ev_other = edges[e_other][1]; - } - else { - ev_other = edges[e_other][0]; - } + if (sculpt_geodesic_mesh_test_dist_add( + vert_positions, v_other, v1, v2, dists, initial_verts)) + { + for (const int e_other : ss->vert_to_edge_map[v_other]) { + int ev_other; + if (edges[e_other][0] == v_other) { + ev_other = edges[e_other][1]; + } + else { + ev_other = edges[e_other][0]; + } - if (e_other != e && !edge_tag[e_other] && - (ss->epmap[e_other].is_empty() || dists[ev_other] != FLT_MAX)) - { - if (affected_vert[v_other] || affected_vert[ev_other]) { - edge_tag[e_other].set(); - BLI_LINKSTACK_PUSH(queue_next, POINTER_FROM_INT(e_other)); - } + if (e_other != e && !edge_tag[e_other] && + (ss->edge_to_face_map[e_other].is_empty() || dists[ev_other] != FLT_MAX)) + { + if (affected_vert[v_other] || affected_vert[ev_other]) { + edge_tag[e_other].set(); + BLI_LINKSTACK_PUSH(queue_next, POINTER_FROM_INT(e_other)); } } }