Cleanup: Sculpt: Unify face PBVH node face index access
Remove one function from the API.
This commit is contained in:
@@ -319,8 +319,6 @@ Span<int> node_face_indices_calc_grids(const PBVH &pbvh, const PBVHNode &node, V
|
||||
|
||||
} // namespace blender::bke::pbvh
|
||||
|
||||
blender::Vector<int> BKE_pbvh_node_calc_face_indices(const PBVH &pbvh, const PBVHNode &node);
|
||||
|
||||
blender::Bounds<blender::float3> BKE_pbvh_node_get_BB(const PBVHNode *node);
|
||||
blender::Bounds<blender::float3> BKE_pbvh_node_get_original_BB(const PBVHNode *node);
|
||||
|
||||
|
||||
@@ -1834,26 +1834,6 @@ Span<int> node_face_indices_calc_grids(const PBVH &pbvh, const PBVHNode &node, V
|
||||
|
||||
} // namespace blender::bke::pbvh
|
||||
|
||||
blender::Vector<int> BKE_pbvh_node_calc_face_indices(const PBVH &pbvh, const PBVHNode &node)
|
||||
{
|
||||
using namespace blender::bke::pbvh;
|
||||
Vector<int> faces;
|
||||
switch (pbvh.header.type) {
|
||||
case PBVH_FACES: {
|
||||
node_face_indices_calc_mesh(pbvh, node, faces);
|
||||
break;
|
||||
}
|
||||
case PBVH_GRIDS: {
|
||||
node_face_indices_calc_grids(pbvh, node, faces);
|
||||
break;
|
||||
}
|
||||
case PBVH_BMESH:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
return faces;
|
||||
}
|
||||
|
||||
int BKE_pbvh_node_num_unique_verts(const PBVH &pbvh, const PBVHNode &node)
|
||||
{
|
||||
switch (pbvh.header.type) {
|
||||
|
||||
@@ -539,7 +539,7 @@ static void clear_face_sets(Object &object, const Span<PBVHNode *> nodes)
|
||||
Vector<int> &face_indices = all_face_indices.local();
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
const Span<int> faces =
|
||||
(BKE_pbvh_type(&pbvh) == PBVH_FACES) ?
|
||||
BKE_pbvh_type(&pbvh) == PBVH_FACES ?
|
||||
bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, face_indices) :
|
||||
bke::pbvh::node_face_indices_calc_grids(pbvh, *node, face_indices);
|
||||
if (std::any_of(faces.begin(), faces.end(), [&](const int face) {
|
||||
@@ -1000,7 +1000,7 @@ static void face_hide_update(Object &object,
|
||||
TLS &tls = all_tls.local();
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
const Span<int> faces =
|
||||
(BKE_pbvh_type(&pbvh) == PBVH_FACES) ?
|
||||
BKE_pbvh_type(&pbvh) == PBVH_FACES ?
|
||||
bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, tls.face_indices) :
|
||||
bke::pbvh::node_face_indices_calc_grids(pbvh, *node, tls.face_indices);
|
||||
|
||||
@@ -1686,12 +1686,22 @@ static void face_set_gesture_apply_mesh(gesture::GestureData &gesture_data,
|
||||
const VArraySpan<bool> hide_poly = *attributes.lookup<bool>(".hide_poly", bke::AttrDomain::Face);
|
||||
bke::SpanAttributeWriter<int> face_sets = face_set::ensure_face_sets_mesh(object);
|
||||
|
||||
struct TLS {
|
||||
Vector<int> face_indices;
|
||||
};
|
||||
|
||||
threading::EnumerableThreadSpecific<TLS> all_tls;
|
||||
threading::parallel_for(gesture_data.nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
TLS &tls = all_tls.local();
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(gesture_data.vc.obact, node, undo::Type::FaceSet);
|
||||
const Span<int> node_faces =
|
||||
BKE_pbvh_type(&pbvh) == PBVH_FACES ?
|
||||
bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, tls.face_indices) :
|
||||
bke::pbvh::node_face_indices_calc_grids(pbvh, *node, tls.face_indices);
|
||||
|
||||
bool any_updated = false;
|
||||
for (const int face : BKE_pbvh_node_calc_face_indices(pbvh, *node)) {
|
||||
for (const int face : node_faces) {
|
||||
if (!hide_poly.is_empty() && hide_poly[face]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1213,7 +1213,12 @@ static Node *alloc_node(Object *ob, PBVHNode *node, Type type)
|
||||
}
|
||||
|
||||
if (need_faces) {
|
||||
unode->face_indices = BKE_pbvh_node_calc_face_indices(*ss->pbvh, *node);
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
|
||||
bke::pbvh::node_face_indices_calc_mesh(*ss->pbvh, *node, unode->face_indices);
|
||||
}
|
||||
else {
|
||||
bke::pbvh::node_face_indices_calc_grids(*ss->pbvh, *node, unode->face_indices);
|
||||
}
|
||||
usculpt->undo_size += unode->face_indices.as_span().size_in_bytes();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user