Refactor: Sculpt: Remove vertex to face map from SculptSession
Just retrieve it from the mesh as necessary, it's already cached there. Part of #118145.
This commit is contained in:
@@ -347,10 +347,6 @@ struct SculptSession : blender::NonCopyable, blender::NonMovable {
|
||||
|
||||
KeyBlock *shapekey_active = nullptr;
|
||||
|
||||
/* Mesh connectivity maps. */
|
||||
/* Vertices to adjacent polys. */
|
||||
blender::GroupedSpan<int> vert_to_face_map;
|
||||
|
||||
/* Edges to adjacent faces. */
|
||||
blender::Array<int> edge_to_face_offsets;
|
||||
blender::Array<int> edge_to_face_indices;
|
||||
|
||||
@@ -1675,7 +1675,6 @@ void BKE_sculptsession_free_pbvh(Object &object)
|
||||
}
|
||||
|
||||
ss->pbvh.reset();
|
||||
ss->vert_to_face_map = {};
|
||||
ss->edge_to_face_offsets = {};
|
||||
ss->edge_to_face_indices = {};
|
||||
ss->edge_to_face_map = {};
|
||||
@@ -2018,10 +2017,6 @@ static void sculpt_update_object(Depsgraph *depsgraph,
|
||||
|
||||
pbvh::Tree &pbvh = object::pbvh_ensure(*depsgraph, *ob);
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
ss.vert_to_face_map = mesh_orig->vert_to_face_map();
|
||||
}
|
||||
|
||||
if (ss.deform_modifiers_active) {
|
||||
/* Painting doesn't need crazyspace, use already evaluated mesh coordinates if possible. */
|
||||
bool used_me_eval = false;
|
||||
|
||||
@@ -254,17 +254,13 @@ void calc_smooth_translations(const Depsgraph &depsgraph,
|
||||
const Span<float3> positions_eval = bke::pbvh::vert_positions_eval(depsgraph, object);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_translations_faces(positions_eval,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
nodes[i],
|
||||
tls,
|
||||
translations);
|
||||
calc_translations_faces(
|
||||
positions_eval, faces, corner_verts, vert_to_face_map, nodes[i], tls, translations);
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -103,6 +103,7 @@ BLI_NOINLINE static void calc_factors_faces(const Depsgraph &depsgraph,
|
||||
const Brush &brush,
|
||||
const Span<float3> positions_eval,
|
||||
const Span<float3> vert_normals,
|
||||
const GroupedSpan<int> vert_to_face_map,
|
||||
const float strength,
|
||||
const bool relax_face_sets,
|
||||
const Object &object,
|
||||
@@ -137,7 +138,7 @@ BLI_NOINLINE static void calc_factors_faces(const Depsgraph &depsgraph,
|
||||
calc_brush_texture_factors(ss, brush, positions_eval, verts, factors);
|
||||
|
||||
face_set::filter_verts_with_unique_face_sets_mesh(
|
||||
ss.vert_to_face_map, ss.face_sets, relax_face_sets, verts, factors);
|
||||
vert_to_face_map, ss.face_sets, relax_face_sets, verts, factors);
|
||||
}
|
||||
|
||||
static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph,
|
||||
@@ -154,6 +155,7 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph,
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -175,6 +177,7 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph,
|
||||
brush,
|
||||
positions_eval,
|
||||
vert_normals,
|
||||
vert_to_face_map,
|
||||
strength,
|
||||
relax_face_sets,
|
||||
object,
|
||||
@@ -190,7 +193,7 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph,
|
||||
vert_normals,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
ss.face_sets,
|
||||
hide_poly,
|
||||
@@ -214,8 +217,9 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph,
|
||||
|
||||
BLI_NOINLINE static void calc_factors_grids(const Depsgraph &depsgraph,
|
||||
const Brush &brush,
|
||||
const Span<int> corner_verts,
|
||||
const OffsetIndices<int> faces,
|
||||
const Span<int> corner_verts,
|
||||
const GroupedSpan<int> vert_to_face_map,
|
||||
const bke::pbvh::GridsNode &node,
|
||||
const float strength,
|
||||
const bool relax_face_sets,
|
||||
@@ -253,7 +257,7 @@ 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(ss.vert_to_face_map,
|
||||
face_set::filter_verts_with_unique_face_sets_grids(vert_to_face_map,
|
||||
corner_verts,
|
||||
faces,
|
||||
subdiv_ccg,
|
||||
@@ -280,6 +284,7 @@ static void do_relax_face_sets_brush_grids(const Depsgraph &depsgraph,
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -296,8 +301,9 @@ static void do_relax_face_sets_brush_grids(const Depsgraph &depsgraph,
|
||||
GridLocalData &tls = all_tls.local();
|
||||
calc_factors_grids(depsgraph,
|
||||
brush,
|
||||
corner_verts,
|
||||
faces,
|
||||
corner_verts,
|
||||
vert_to_face_map,
|
||||
nodes[i],
|
||||
strength,
|
||||
relax_face_sets,
|
||||
@@ -314,7 +320,7 @@ static void do_relax_face_sets_brush_grids(const Depsgraph &depsgraph,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.face_sets,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
nodes[i].grids(),
|
||||
relax_face_sets,
|
||||
@@ -476,6 +482,7 @@ static void do_topology_relax_brush_mesh(const Depsgraph &depsgraph,
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -509,7 +516,7 @@ static void do_topology_relax_brush_mesh(const Depsgraph &depsgraph,
|
||||
vert_normals,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
ss.face_sets,
|
||||
hide_poly,
|
||||
@@ -588,6 +595,7 @@ static void do_topology_relax_brush_grids(const Depsgraph &depsgraph,
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -620,7 +628,7 @@ static void do_topology_relax_brush_grids(const Depsgraph &depsgraph,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.face_sets,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
nodes[i].grids(),
|
||||
false,
|
||||
|
||||
@@ -115,6 +115,7 @@ BLI_NOINLINE static void do_smooth_brush_mesh(const Depsgraph &depsgraph,
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -139,7 +140,7 @@ BLI_NOINLINE static void do_smooth_brush_mesh(const Depsgraph &depsgraph,
|
||||
tls.vert_neighbors.resize(verts.size());
|
||||
calc_vert_neighbors_interior(faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
hide_poly,
|
||||
verts,
|
||||
|
||||
@@ -122,12 +122,12 @@ static void do_smooth_brush_mesh(const Depsgraph &depsgraph,
|
||||
const IndexMask &node_mask,
|
||||
const float brush_strength)
|
||||
{
|
||||
const SculptSession &ss = *object.sculpt;
|
||||
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -152,7 +152,7 @@ static void do_smooth_brush_mesh(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
calc_smooth_masks_faces(faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
hide_poly,
|
||||
nodes[i].verts(),
|
||||
mask.span.as_span(),
|
||||
|
||||
@@ -62,6 +62,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -112,7 +113,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph
|
||||
|
||||
tls.vert_neighbors.resize(verts.size());
|
||||
calc_vert_neighbors(
|
||||
faces, corner_verts, ss.vert_to_face_map, hide_poly, verts, tls.vert_neighbors);
|
||||
faces, corner_verts, vert_to_face_map, hide_poly, verts, tls.vert_neighbors);
|
||||
|
||||
tls.average_positions.resize(verts.size());
|
||||
const MutableSpan<float3> average_positions = tls.average_positions;
|
||||
@@ -142,7 +143,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph
|
||||
|
||||
tls.vert_neighbors.resize(verts.size());
|
||||
calc_vert_neighbors(
|
||||
faces, corner_verts, ss.vert_to_face_map, hide_poly, verts, tls.vert_neighbors);
|
||||
faces, corner_verts, vert_to_face_map, hide_poly, verts, tls.vert_neighbors);
|
||||
|
||||
tls.average_positions.resize(verts.size());
|
||||
const MutableSpan<float3> average_laplacian_disps = tls.average_positions;
|
||||
|
||||
@@ -323,6 +323,7 @@ void do_topology_slide_brush(const Depsgraph &depsgraph,
|
||||
MutableSpan<float3> positions_orig = mesh.vert_positions_for_write();
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
@@ -335,7 +336,7 @@ void do_topology_slide_brush(const Depsgraph &depsgraph,
|
||||
positions_eval,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
hide_poly,
|
||||
nodes[i],
|
||||
object,
|
||||
|
||||
@@ -270,8 +270,10 @@ int vert_face_set_get(const Object &object, PBVHVertRef vertex)
|
||||
if (!ss.face_sets) {
|
||||
return SCULPT_FACE_SET_NONE;
|
||||
}
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
int face_set = 0;
|
||||
for (const int face_index : ss.vert_to_face_map[vertex.i]) {
|
||||
for (const int face_index : vert_to_face_map[vertex.i]) {
|
||||
if (ss.face_sets[face_index] > face_set) {
|
||||
face_set = ss.face_sets[face_index];
|
||||
}
|
||||
@@ -352,7 +354,9 @@ bool vert_has_face_set(const Object &object, PBVHVertRef vertex, int face_set)
|
||||
if (!ss.face_sets) {
|
||||
return face_set == SCULPT_FACE_SET_NONE;
|
||||
}
|
||||
for (const int face_index : ss.vert_to_face_map[vertex.i]) {
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
for (const int face_index : vert_to_face_map[vertex.i]) {
|
||||
if (ss.face_sets[face_index] == face_set) {
|
||||
return true;
|
||||
}
|
||||
@@ -379,7 +383,9 @@ bool vert_has_unique_face_set(const Object &object, PBVHVertRef vertex)
|
||||
const SculptSession &ss = *object.sculpt;
|
||||
switch (bke::object::pbvh_get(object)->type()) {
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
return vert_has_unique_face_set(ss.vert_to_face_map, ss.face_sets, vertex.i);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
return vert_has_unique_face_set(vert_to_face_map, ss.face_sets, vertex.i);
|
||||
}
|
||||
case bke::pbvh::Type::BMesh: {
|
||||
BMVert *v = (BMVert *)vertex.i;
|
||||
@@ -389,11 +395,12 @@ bool vert_has_unique_face_set(const Object &object, PBVHVertRef vertex)
|
||||
const Mesh &base_mesh = *static_cast<const Mesh *>(object.data);
|
||||
const OffsetIndices<int> faces = base_mesh.faces();
|
||||
const Span<int> corner_verts = base_mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = base_mesh.vert_to_face_map();
|
||||
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(
|
||||
ss.vert_to_face_map, corner_verts, faces, ss.face_sets, *ss.subdiv_ccg, coord);
|
||||
vert_to_face_map, corner_verts, faces, ss.face_sets, *ss.subdiv_ccg, coord);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -582,11 +589,12 @@ static void vertex_neighbors_get_faces(const Object &object,
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
iter->num_duplicates = 0;
|
||||
iter->neighbors.clear();
|
||||
iter->neighbor_indices.clear();
|
||||
|
||||
for (const int face_i : ss.vert_to_face_map[vertex.i]) {
|
||||
for (const int face_i : vert_to_face_map[vertex.i]) {
|
||||
if (ss.hide_poly && ss.hide_poly[face_i]) {
|
||||
/* Skip connectivity from hidden faces. */
|
||||
continue;
|
||||
@@ -701,9 +709,11 @@ bool vert_is_boundary(const Object &object, const PBVHVertRef vertex)
|
||||
const SculptSession &ss = *object.sculpt;
|
||||
switch (bke::object::pbvh_get(object)->type()) {
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
if (!hide::vert_all_faces_visible_get(ss.hide_poly ? Span(ss.hide_poly, ss.faces_num) :
|
||||
Span<bool>(),
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
vertex.i))
|
||||
{
|
||||
return true;
|
||||
@@ -1246,7 +1256,6 @@ static void restore_mask_from_undo_step(Object &object)
|
||||
|
||||
static void restore_color_from_undo_step(Object &object)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
IndexMaskMemory memory;
|
||||
@@ -1256,7 +1265,7 @@ static void restore_color_from_undo_step(Object &object)
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
bke::GSpanAttributeWriter color_attribute = color::active_color_attribute_for_write(mesh);
|
||||
node_mask.foreach_index(GrainSize(1), [&](const int i) {
|
||||
if (const std::optional<Span<float4>> orig_data = orig_color_data_lookup_mesh(object,
|
||||
|
||||
@@ -316,12 +316,11 @@ static void calc_blurred_cavity_mesh(const Depsgraph &depsgraph,
|
||||
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
const SculptSession &ss = *object.sculpt;
|
||||
|
||||
Span<float3> positions_eval = bke::pbvh::vert_positions_eval(depsgraph, object);
|
||||
Span<float3> normals_eval = bke::pbvh::vert_normals_eval(depsgraph, object);
|
||||
|
||||
@@ -370,7 +369,7 @@ static void calc_blurred_cavity_mesh(const Depsgraph &depsgraph,
|
||||
}
|
||||
|
||||
for (const int neighbor : vert_neighbors_get_mesh(
|
||||
current_vert, faces, corner_verts, ss.vert_to_face_map, hide_poly, neighbors))
|
||||
current_vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
|
||||
{
|
||||
if (visited_verts.contains(neighbor)) {
|
||||
continue;
|
||||
@@ -905,6 +904,8 @@ static void fill_topology_automasking_factors_mesh(const Depsgraph &depsgraph,
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
const Brush *brush = BKE_paint_brush_for_read(&sd.paint);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
|
||||
const float radius = ss.cache ? ss.cache->radius : std::numeric_limits<float>::max();
|
||||
const int active_vert = std::get<int>(ss.active_vert());
|
||||
@@ -917,7 +918,7 @@ static void fill_topology_automasking_factors_mesh(const Depsgraph &depsgraph,
|
||||
|
||||
float3 location = vert_positions[active_vert];
|
||||
|
||||
flood.execute(ob, ss.vert_to_face_map, [&](int from_v, int to_v) {
|
||||
flood.execute(ob, vert_to_face_map, [&](int from_v, int to_v) {
|
||||
factors[from_v] = 1.0f;
|
||||
factors[to_v] = 1.0f;
|
||||
return (use_radius || SCULPT_is_vertex_inside_brush_radius_symm(
|
||||
@@ -1100,7 +1101,7 @@ static void init_boundary_masking_mesh(Object &object,
|
||||
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -1110,13 +1111,12 @@ 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, ss.vert_to_face_map, ss.vertex_info.boundary, i))
|
||||
{
|
||||
if (boundary::vert_is_boundary(hide_poly, vert_to_face_map, ss.vertex_info.boundary, i)) {
|
||||
edge_distance[i] = 0;
|
||||
}
|
||||
break;
|
||||
case BoundaryAutomaskMode::FaceSets:
|
||||
if (!face_set::vert_has_unique_face_set(ss.vert_to_face_map, ss.face_sets, i)) {
|
||||
if (!face_set::vert_has_unique_face_set(vert_to_face_map, ss.face_sets, i)) {
|
||||
edge_distance[i] = 0;
|
||||
}
|
||||
break;
|
||||
@@ -1130,8 +1130,8 @@ static void init_boundary_masking_mesh(Object &object,
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const int neighbor : vert_neighbors_get_mesh(
|
||||
i, faces, corner_verts, ss.vert_to_face_map, hide_poly, neighbors))
|
||||
for (const int neighbor :
|
||||
vert_neighbors_get_mesh(i, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
|
||||
{
|
||||
if (edge_distance[neighbor] == propagation_it) {
|
||||
edge_distance[i] = propagation_it + 1;
|
||||
@@ -1166,6 +1166,7 @@ static void init_boundary_masking_grids(Object &object,
|
||||
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
|
||||
Array<int> edge_distance(positions.size(), EDGE_DISTANCE_INF);
|
||||
for (const int i : positions.index_range()) {
|
||||
@@ -1180,7 +1181,7 @@ static void init_boundary_masking_grids(Object &object,
|
||||
break;
|
||||
case BoundaryAutomaskMode::FaceSets:
|
||||
if (!face_set::vert_has_unique_face_set(
|
||||
ss.vert_to_face_map, corner_verts, faces, ss.face_sets, subdiv_ccg, coord))
|
||||
vert_to_face_map, corner_verts, faces, ss.face_sets, subdiv_ccg, coord))
|
||||
{
|
||||
edge_distance[i] = 0;
|
||||
}
|
||||
|
||||
@@ -2815,7 +2815,7 @@ static void do_smooth_brush(const Depsgraph &depsgraph,
|
||||
MutableSpan<float3> positions_orig = mesh.vert_positions_for_write();
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -3441,6 +3441,7 @@ std::unique_ptr<SculptBoundary> data_init_mesh(const Depsgraph &depsgraph,
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point);
|
||||
|
||||
@@ -3448,7 +3449,7 @@ std::unique_ptr<SculptBoundary> data_init_mesh(const Depsgraph &depsgraph,
|
||||
|
||||
const std::optional<int> boundary_initial_vert = get_closest_boundary_vert_mesh(
|
||||
object,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
positions_eval,
|
||||
hide_vert,
|
||||
hide_poly,
|
||||
@@ -3467,7 +3468,7 @@ std::unique_ptr<SculptBoundary> data_init_mesh(const Depsgraph &depsgraph,
|
||||
* be fixed. */
|
||||
if (!is_vert_in_editable_boundary_mesh(faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
hide_vert,
|
||||
hide_poly,
|
||||
ss.vertex_info.boundary,
|
||||
@@ -3486,7 +3487,7 @@ std::unique_ptr<SculptBoundary> data_init_mesh(const Depsgraph &depsgraph,
|
||||
indices_init_mesh(object,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
hide_vert,
|
||||
hide_poly,
|
||||
ss.vertex_info.boundary,
|
||||
@@ -3497,7 +3498,7 @@ std::unique_ptr<SculptBoundary> data_init_mesh(const Depsgraph &depsgraph,
|
||||
const float boundary_radius = brush ? radius * (1.0f + brush->boundary_offset) : radius;
|
||||
edit_data_init_mesh(faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
positions_eval,
|
||||
hide_vert,
|
||||
hide_poly,
|
||||
|
||||
@@ -507,6 +507,7 @@ void ensure_nodes_constraints(const Sculpt &sd,
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan<bool> hide_vert = *attributes.lookup<bool>(".hide_vert",
|
||||
bke::AttrDomain::Point);
|
||||
@@ -529,7 +530,7 @@ void ensure_nodes_constraints(const Sculpt &sd,
|
||||
const Span<int> verts = hide::node_visible_verts(nodes[i], hide_vert, vert_indices);
|
||||
vert_neighbors.resize(verts.size());
|
||||
calc_vert_neighbors(
|
||||
faces, corner_verts, ss.vert_to_face_map, hide_poly, verts, vert_neighbors);
|
||||
faces, corner_verts, vert_to_face_map, hide_poly, verts, vert_neighbors);
|
||||
add_constraints_for_verts(object,
|
||||
brush,
|
||||
initial_location,
|
||||
@@ -2069,6 +2070,7 @@ static void apply_filter_forces_mesh(const Depsgraph &depsgraph,
|
||||
const float3 &gravity,
|
||||
const Span<float3> positions_eval,
|
||||
const Span<float3> vert_normals,
|
||||
const GroupedSpan<int> vert_to_face_map,
|
||||
const bke::pbvh::MeshNode &node,
|
||||
Object &object,
|
||||
FilterLocalData &tls)
|
||||
@@ -2089,7 +2091,7 @@ static void apply_filter_forces_mesh(const Depsgraph &depsgraph,
|
||||
for (const int i : verts.index_range()) {
|
||||
const int vert = verts[i];
|
||||
if (!face_set::vert_has_face_set(
|
||||
ss.vert_to_face_map, ss.face_sets, vert, ss.filter_cache->active_face_set))
|
||||
vert_to_face_map, ss.face_sets, vert, ss.filter_cache->active_face_set))
|
||||
{
|
||||
factors[i] = 0.0f;
|
||||
}
|
||||
@@ -2323,6 +2325,8 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
const Span<float3> positions_eval = bke::pbvh::vert_positions_eval(*depsgraph, object);
|
||||
const Span<float3> vert_normals = bke::pbvh::vert_normals_eval(*depsgraph, object);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
FilterLocalData &tls = all_tls.local();
|
||||
@@ -2333,6 +2337,7 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
||||
gravity,
|
||||
positions_eval,
|
||||
vert_normals,
|
||||
vert_to_face_map,
|
||||
nodes[i],
|
||||
object,
|
||||
tls);
|
||||
|
||||
@@ -205,6 +205,7 @@ static void sample_detail_voxel(bContext *C, ViewContext *vc, const int mval[2])
|
||||
const Span<float3> positions = bke::pbvh::vert_positions_eval(*depsgraph, ob);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -221,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, ss.vert_to_face_map, hide_poly, neighbors))
|
||||
active_vert, faces, corner_verts, vert_to_face_map, hide_poly, neighbors))
|
||||
{
|
||||
edge_length += math::distance(active_vert_position, positions[neighbor]);
|
||||
}
|
||||
|
||||
@@ -693,6 +693,8 @@ static void calc_topology_falloff_from_verts(Object &ob,
|
||||
MutableSpan<float> distances)
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
|
||||
const int totvert = SCULPT_vertex_count_get(ob);
|
||||
|
||||
@@ -700,7 +702,7 @@ static void calc_topology_falloff_from_verts(Object &ob,
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
flood_fill::FillDataMesh flood(totvert);
|
||||
initial_verts.foreach_index([&](const int vert) { flood.add_and_skip_initial(vert); });
|
||||
flood.execute(ob, ss.vert_to_face_map, [&](const int from_vert, const int to_vert) {
|
||||
flood.execute(ob, vert_to_face_map, [&](const int from_vert, const int to_vert) {
|
||||
distances[to_vert] = distances[from_vert] + 1.0f;
|
||||
return true;
|
||||
});
|
||||
@@ -781,12 +783,14 @@ static Array<float> normals_falloff_create(const Depsgraph &depsgraph,
|
||||
|
||||
switch (pbvh.type()) {
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const Span<float3> vert_normals = bke::pbvh::vert_normals_eval(depsgraph, ob);
|
||||
|
||||
const float3 orig_normal = vert_normals[vert];
|
||||
flood_fill::FillDataMesh flood(totvert);
|
||||
flood.add_initial_with_symmetry(depsgraph, ob, pbvh, vert, FLT_MAX);
|
||||
flood.execute(ob, ss.vert_to_face_map, [&](const int from_vert, const int to_vert) {
|
||||
flood.execute(ob, vert_to_face_map, [&](const int from_vert, const int to_vert) {
|
||||
const float3 &from_normal = vert_normals[from_vert];
|
||||
const float3 &to_normal = vert_normals[to_vert];
|
||||
const float from_edge_factor = edge_factors[from_vert];
|
||||
@@ -977,11 +981,11 @@ static Array<float> diagonals_falloff_create(const Depsgraph &depsgraph,
|
||||
Object &ob,
|
||||
const int vert)
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob.data);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const int totvert = SCULPT_vertex_count_get(ob);
|
||||
Array<float> dists(totvert, 0.0f);
|
||||
|
||||
@@ -1012,7 +1016,7 @@ static Array<float> diagonals_falloff_create(const Depsgraph &depsgraph,
|
||||
const int next_vert = queue.front();
|
||||
queue.pop();
|
||||
|
||||
for (const int face : ss.vert_to_face_map[next_vert]) {
|
||||
for (const int face : vert_to_face_map[next_vert]) {
|
||||
for (const int vert : corner_verts.slice(faces[face])) {
|
||||
if (visited_verts[vert]) {
|
||||
continue;
|
||||
@@ -1439,7 +1443,6 @@ static void restore_face_set_data(Object &object, Cache &expand_cache)
|
||||
|
||||
static void restore_color_data(Object &ob, Cache &expand_cache)
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob.data);
|
||||
@@ -1448,7 +1451,7 @@ static void restore_color_data(Object &ob, Cache &expand_cache)
|
||||
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
bke::GSpanAttributeWriter color_attribute = color::active_color_attribute_for_write(mesh);
|
||||
node_mask.foreach_index([&](const int i) {
|
||||
for (const int vert : nodes[i].verts()) {
|
||||
@@ -1785,7 +1788,6 @@ static void colors_update_task(const Depsgraph &depsgraph,
|
||||
/* Store the original mesh data state in the expand cache. */
|
||||
static void original_state_store(Object &ob, Cache &expand_cache)
|
||||
{
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob.data);
|
||||
const int totvert = SCULPT_vertex_count_get(ob);
|
||||
|
||||
@@ -1803,7 +1805,7 @@ static void original_state_store(Object &ob, Cache &expand_cache)
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob.data);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::GAttributeReader color_attribute = color::active_color_attribute(mesh);
|
||||
const GVArraySpan colors = *color_attribute;
|
||||
|
||||
@@ -1909,7 +1911,7 @@ static void update_for_vert(bContext *C, Object &ob, const std::optional<int> ve
|
||||
const Span<float3> vert_positions = bke::pbvh::vert_positions_eval(depsgraph, ob);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point);
|
||||
const VArraySpan mask = *attributes.lookup<float>(".sculpt_mask", bke::AttrDomain::Point);
|
||||
@@ -2393,7 +2395,7 @@ static void delete_face_set_id(
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
const int totface = ss.totfaces;
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh->vert_to_face_map();
|
||||
const OffsetIndices faces = mesh->faces();
|
||||
const Span<int> corner_verts = mesh->corner_verts();
|
||||
|
||||
|
||||
@@ -1180,12 +1180,11 @@ static void edit_grow_shrink(const Depsgraph &depsgraph,
|
||||
const bool modify_hidden,
|
||||
wmOperator *op)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
|
||||
BLI_assert(attributes.contains(".sculpt_face_set"));
|
||||
|
||||
@@ -317,7 +317,7 @@ static void sculpt_color_presmooth_init(const Mesh &mesh, Object &object)
|
||||
const IndexMask &node_mask = ss.filter_cache->node_mask;
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::GAttributeReader color_attribute = active_color_attribute(mesh);
|
||||
const GVArraySpan colors = *color_attribute;
|
||||
|
||||
@@ -385,7 +385,7 @@ static void sculpt_color_filter_apply(bContext *C, wmOperator *op, Object &ob)
|
||||
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
bke::GSpanAttributeWriter color_attribute = active_color_attribute_for_write(mesh);
|
||||
|
||||
threading::EnumerableThreadSpecific<LocalData> all_tls;
|
||||
|
||||
@@ -675,7 +675,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob.data);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
|
||||
const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point);
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
|
||||
@@ -355,6 +355,7 @@ static void calc_smooth_filter(const Depsgraph &depsgraph,
|
||||
MutableSpan<float3> positions_orig = mesh.vert_positions_for_write();
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
threading::EnumerableThreadSpecific<LocalData> all_tls;
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
@@ -376,7 +377,7 @@ static void calc_smooth_filter(const Depsgraph &depsgraph,
|
||||
MutableSpan<Vector<int>> neighbors = tls.vert_neighbors;
|
||||
calc_vert_neighbors_interior(faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
{},
|
||||
verts,
|
||||
@@ -1015,7 +1016,7 @@ static void calc_relax_filter(const Depsgraph &depsgraph,
|
||||
MutableSpan<float3> positions_orig = mesh.vert_positions_for_write();
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
threading::EnumerableThreadSpecific<LocalData> all_tls;
|
||||
@@ -1179,7 +1180,7 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
|
||||
MutableSpan<float3> positions_orig = mesh.vert_positions_for_write();
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
threading::EnumerableThreadSpecific<LocalData> all_tls;
|
||||
@@ -1206,7 +1207,7 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
|
||||
vert_normals,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
ss.face_sets,
|
||||
hide_poly,
|
||||
@@ -1268,7 +1269,7 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
|
||||
faces,
|
||||
corner_verts,
|
||||
ss.face_sets,
|
||||
ss.vert_to_face_map,
|
||||
vert_to_face_map,
|
||||
ss.vertex_info.boundary,
|
||||
grids,
|
||||
relax_face_sets,
|
||||
@@ -1354,6 +1355,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
MutableSpan<float3> positions_orig = mesh.vert_positions_for_write();
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
threading::EnumerableThreadSpecific<LocalData> all_tls;
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
@@ -1373,7 +1375,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
|
||||
tls.vert_neighbors.reinitialize(verts.size());
|
||||
calc_vert_neighbors(
|
||||
faces, corner_verts, ss.vert_to_face_map, {}, verts, tls.vert_neighbors);
|
||||
faces, corner_verts, vert_to_face_map, {}, verts, tls.vert_neighbors);
|
||||
|
||||
tls.average_positions.reinitialize(verts.size());
|
||||
const MutableSpan<float3> average_positions = tls.average_positions;
|
||||
@@ -1419,7 +1421,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
|
||||
tls.vert_neighbors.resize(verts.size());
|
||||
calc_vert_neighbors(
|
||||
faces, corner_verts, ss.vert_to_face_map, {}, verts, tls.vert_neighbors);
|
||||
faces, corner_verts, vert_to_face_map, {}, verts, tls.vert_neighbors);
|
||||
|
||||
tls.average_positions.resize(verts.size());
|
||||
const MutableSpan<float3> average_laplacian_disps = tls.average_positions;
|
||||
@@ -1651,6 +1653,7 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph,
|
||||
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
threading::EnumerableThreadSpecific<LocalData> all_tls;
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
@@ -1676,7 +1679,7 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph,
|
||||
|
||||
tls.vert_neighbors.resize(verts.size());
|
||||
const MutableSpan<Vector<int>> neighbors = tls.vert_neighbors;
|
||||
calc_vert_neighbors(faces, corner_verts, ss.vert_to_face_map, {}, verts, neighbors);
|
||||
calc_vert_neighbors(faces, corner_verts, vert_to_face_map, {}, verts, neighbors);
|
||||
|
||||
tls.smooth_positions.resize(verts.size());
|
||||
const MutableSpan<float3> smooth_positions = tls.smooth_positions;
|
||||
@@ -2134,6 +2137,7 @@ static void mesh_filter_sharpen_init(const Depsgraph &depsgraph,
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
const OffsetIndices faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const Span<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
LocalData &tls = all_tls.local();
|
||||
@@ -2142,7 +2146,7 @@ static void mesh_filter_sharpen_init(const Depsgraph &depsgraph,
|
||||
|
||||
tls.vert_neighbors.resize(verts.size());
|
||||
const MutableSpan<Vector<int>> neighbors = tls.vert_neighbors;
|
||||
calc_vert_neighbors(faces, corner_verts, ss.vert_to_face_map, {}, verts, neighbors);
|
||||
calc_vert_neighbors(faces, corner_verts, vert_to_face_map, {}, verts, neighbors);
|
||||
|
||||
tls.smooth_directions.resize(verts.size());
|
||||
smooth::neighbor_data_average_mesh(
|
||||
|
||||
@@ -671,7 +671,7 @@ static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob.data);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::GAttributeReader color_attribute = color::active_color_attribute(mesh);
|
||||
|
||||
float4 active_vertex_color;
|
||||
@@ -766,9 +766,9 @@ static void sculpt_mask_by_color_contiguous_mesh(const Depsgraph &depsgraph,
|
||||
const bool invert,
|
||||
const bool preserve_mask)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan colors = *attributes.lookup_or_default<ColorGeometry4f>(
|
||||
mesh.active_color_attribute, bke::AttrDomain::Point, {});
|
||||
@@ -779,7 +779,7 @@ static void sculpt_mask_by_color_contiguous_mesh(const Depsgraph &depsgraph,
|
||||
flood_fill::FillDataMesh flood(mesh.verts_num);
|
||||
flood.add_initial(vert);
|
||||
|
||||
flood.execute(object, ss.vert_to_face_map, [&](int /*from_v*/, int to_v) {
|
||||
flood.execute(object, vert_to_face_map, [&](int /*from_v*/, int to_v) {
|
||||
const float4 current_color = float4(colors[to_v]);
|
||||
|
||||
float new_vertex_mask = sculpt_mask_by_color_delta_get(
|
||||
|
||||
@@ -564,7 +564,7 @@ void do_paint_brush(const Depsgraph &depsgraph,
|
||||
const Span<float3> vert_normals = bke::pbvh::vert_normals_eval(depsgraph, ob);
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan hide_vert = *attributes.lookup<bool>(".hide_vert", bke::AttrDomain::Point);
|
||||
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
@@ -845,7 +845,7 @@ void do_smear_brush(const Depsgraph &depsgraph,
|
||||
|
||||
const OffsetIndices<int> faces = mesh.faces();
|
||||
const Span<int> corner_verts = mesh.corner_verts();
|
||||
const GroupedSpan<int> vert_to_face_map = ss.vert_to_face_map;
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const Span<float3> vert_positions = bke::pbvh::vert_positions_eval(depsgraph, ob);
|
||||
const Span<float3> vert_normals = bke::pbvh::vert_normals_eval(depsgraph, ob);
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
|
||||
@@ -765,7 +765,9 @@ static void calc_pose_origin_and_factor_mesh(const Depsgraph &depsgraph,
|
||||
{
|
||||
BLI_assert(!r_pose_factor.is_empty());
|
||||
|
||||
Span<float3> positions_eval = bke::pbvh::vert_positions_eval(depsgraph, object);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const GroupedSpan<int> vert_to_face_map = mesh.vert_to_face_map();
|
||||
const Span<float3> positions_eval = bke::pbvh::vert_positions_eval(depsgraph, object);
|
||||
const bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(object);
|
||||
|
||||
/* Calculate the pose rotation point based on the boundaries of the brush factor. */
|
||||
@@ -778,7 +780,7 @@ static void calc_pose_origin_and_factor_mesh(const Depsgraph &depsgraph,
|
||||
int tot_co = 0;
|
||||
float3 pose_origin(0);
|
||||
float3 fallback_floodfill_origin = initial_location;
|
||||
flood.execute(object, ss.vert_to_face_map, [&](int /*from_v*/, int to_v) {
|
||||
flood.execute(object, vert_to_face_map, [&](int /*from_v*/, int to_v) {
|
||||
r_pose_factor[to_v] = 1.0f;
|
||||
|
||||
const float3 co = positions_eval[to_v];
|
||||
|
||||
Reference in New Issue
Block a user