diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index c5a90529670..7b4492f8dc8 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -58,23 +58,6 @@ struct NodeData; } // namespace bke::pbvh } // namespace blender -enum PBVHNodeFlags : uint32_t { - PBVH_Leaf = 1 << 0, - - PBVH_UpdateRedraw = 1 << 5, - - PBVH_FullyHidden = 1 << 10, - PBVH_FullyMasked = 1 << 11, - PBVH_FullyUnmasked = 1 << 12, - - PBVH_UpdateTopology = 1 << 13, - PBVH_RebuildPixels = 1 << 15, - PBVH_TexLeaf = 1 << 16, - /** Used internally by `pbvh_bmesh.cc`. */ - PBVH_TopologyUpdated = 1 << 17, -}; -ENUM_OPERATORS(PBVHNodeFlags, PBVH_TopologyUpdated); - namespace blender::bke::pbvh { class Tree; @@ -87,6 +70,22 @@ class Node { friend Tree; public: + enum Flags : uint32_t { + Leaf = 1 << 0, + + UpdateRedraw = 1 << 5, + + FullyHidden = 1 << 10, + FullyMasked = 1 << 11, + FullyUnmasked = 1 << 12, + + UpdateTopology = 1 << 13, + RebuildPixels = 1 << 15, + TexLeaf = 1 << 16, + /** Used internally by `pbvh_bmesh.cc`. */ + TopologyUpdated = 1 << 17, + }; + /** Axis aligned min and max of all vertex positions in the node. */ Bounds bounds_ = {}; /** Bounds from the start of current brush stroke. */ @@ -98,7 +97,7 @@ class Node { /* Indicates whether this node is a leaf or not; also used for * marking various updates that need to be applied. */ - PBVHNodeFlags flag_ = PBVH_UpdateRedraw; + Flags flag_ = UpdateRedraw; /** * Used for ray-casting: how close the bounding-box is to the ray point. @@ -117,6 +116,8 @@ class Node { pixels::NodeData *pixels_ = nullptr; }; +ENUM_OPERATORS(Node::Flags, Node::Flags::TopologyUpdated); + struct MeshNode : public Node { /** * Use a 16 bit integer for the slot index type because there will always be less than diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index f47a59b2613..3b8cd75d468 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -161,7 +161,7 @@ static void build_nodes_recursive_mesh(const Span material_indices, if (below_leaf_limit) { if (!leaf_needs_material_split(faces, material_indices)) { MeshNode &node = nodes[node_index]; - node.flag_ |= PBVH_Leaf; + node.flag_ |= Node::Leaf; node.face_indices_ = faces; return; } @@ -314,7 +314,7 @@ static void build_nodes_recursive_grids(const Span material_indices, if (below_leaf_limit) { if (!leaf_needs_material_split(faces, material_indices)) { GridsNode &node = nodes[node_index]; - node.flag_ |= PBVH_Leaf; + node.flag_ |= Node::Leaf; node.prim_indices_ = faces; return; } @@ -535,7 +535,7 @@ Tree::~Tree() std::visit( [](auto &nodes) { for (Node &node : nodes) { - if (node.flag_ & (PBVH_Leaf | PBVH_TexLeaf)) { + if (node.flag_ & (Node::Leaf | Node::TexLeaf)) { node_pixels_free(&node); } } @@ -626,7 +626,7 @@ static void pbvh_iter_begin(PBVHIter *iter, Tree &pbvh, FunctionRefstack.push({&first_node(pbvh), false}); } -static Node *pbvh_iter_next(PBVHIter *iter, PBVHNodeFlags leaf_flag) +static Node *pbvh_iter_next(PBVHIter *iter, Node::Flags leaf_flag) { /* purpose here is to traverse tree, visiting child nodes before their * parents, this order is necessary for e.g. computing bounding boxes */ @@ -687,7 +687,7 @@ static Node *pbvh_iter_next_occluded(PBVHIter *iter) continue; /* don't traverse, outside of search zone */ } - if (node->flag_ & PBVH_Leaf) { + if (node->flag_ & Node::Leaf) { /* immediately hit leaf node */ return node; } @@ -783,7 +783,7 @@ static void search_callback_occluded(Tree &pbvh, pbvh_iter_begin(&iter, pbvh, scb); while ((node = pbvh_iter_next_occluded(&iter))) { - if (node->flag_ & PBVH_Leaf) { + if (node->flag_ & Node::Leaf) { node_tree *new_node = static_cast(malloc(sizeof(node_tree))); new_node->data = node; @@ -1114,7 +1114,7 @@ static BoundsMergeInfo merge_child_bounds(MutableSpan nodes, const int node_index) { NodeT &node = nodes[node_index]; - if (node.flag_ & PBVH_Leaf) { + if (node.flag_ & Node::Leaf) { const bool update = node_index < dirty.size() && dirty[node_index]; return {node.bounds_, update}; } @@ -1222,8 +1222,8 @@ void node_update_mask_mesh(const Span mask, MeshNode &node) verts.begin(), verts.end(), [&](const int vert) { return mask[vert] == 1.0f; }); const bool fully_unmasked = std::all_of( verts.begin(), verts.end(), [&](const int vert) { return mask[vert] <= 0.0f; }); - SET_FLAG_FROM_TEST(node.flag_, fully_masked, PBVH_FullyMasked); - SET_FLAG_FROM_TEST(node.flag_, fully_unmasked, PBVH_FullyUnmasked); + SET_FLAG_FROM_TEST(node.flag_, fully_masked, Node::FullyMasked); + SET_FLAG_FROM_TEST(node.flag_, fully_unmasked, Node::FullyUnmasked); } void update_mask_mesh(const Mesh &mesh, const IndexMask &node_mask, Tree &pbvh) @@ -1233,8 +1233,8 @@ void update_mask_mesh(const Mesh &mesh, const IndexMask &node_mask, Tree &pbvh) const VArraySpan mask = *attributes.lookup(".sculpt_mask", AttrDomain::Point); if (mask.is_empty()) { node_mask.foreach_index([&](const int i) { - nodes[i].flag_ &= ~PBVH_FullyMasked; - nodes[i].flag_ |= PBVH_FullyUnmasked; + nodes[i].flag_ &= ~Node::FullyMasked; + nodes[i].flag_ |= Node::FullyUnmasked; }); return; } @@ -1253,8 +1253,8 @@ void node_update_mask_grids(const CCGKey &key, const Span masks, GridsNod fully_unmasked &= mask <= 0.0f; } } - SET_FLAG_FROM_TEST(node.flag_, fully_masked, PBVH_FullyMasked); - SET_FLAG_FROM_TEST(node.flag_, fully_unmasked, PBVH_FullyUnmasked); + SET_FLAG_FROM_TEST(node.flag_, fully_masked, Node::FullyMasked); + SET_FLAG_FROM_TEST(node.flag_, fully_unmasked, Node::FullyUnmasked); } void update_mask_grids(const SubdivCCG &subdiv_ccg, const IndexMask &node_mask, Tree &pbvh) @@ -1263,8 +1263,8 @@ void update_mask_grids(const SubdivCCG &subdiv_ccg, const IndexMask &node_mask, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); if (subdiv_ccg.masks.is_empty()) { node_mask.foreach_index([&](const int i) { - nodes[i].flag_ &= ~PBVH_FullyMasked; - nodes[i].flag_ |= PBVH_FullyUnmasked; + nodes[i].flag_ &= ~Node::FullyMasked; + nodes[i].flag_ |= Node::FullyUnmasked; }); return; } @@ -1286,8 +1286,8 @@ void node_update_mask_bmesh(const int mask_offset, BMeshNode &node) fully_masked &= BM_ELEM_CD_GET_FLOAT(vert, mask_offset) == 1.0f; fully_unmasked &= BM_ELEM_CD_GET_FLOAT(vert, mask_offset) <= 0.0f; } - SET_FLAG_FROM_TEST(node.flag_, fully_masked, PBVH_FullyMasked); - SET_FLAG_FROM_TEST(node.flag_, fully_unmasked, PBVH_FullyUnmasked); + SET_FLAG_FROM_TEST(node.flag_, fully_masked, Node::FullyMasked); + SET_FLAG_FROM_TEST(node.flag_, fully_unmasked, Node::FullyUnmasked); } void update_mask_bmesh(const BMesh &bm, const IndexMask &node_mask, Tree &pbvh) @@ -1296,8 +1296,8 @@ void update_mask_bmesh(const BMesh &bm, const IndexMask &node_mask, Tree &pbvh) const int offset = CustomData_get_offset_named(&bm.vdata, CD_PROP_FLOAT, ".sculpt_mask"); if (offset == -1) { node_mask.foreach_index([&](const int i) { - nodes[i].flag_ &= ~PBVH_FullyMasked; - nodes[i].flag_ |= PBVH_FullyUnmasked; + nodes[i].flag_ &= ~Node::FullyMasked; + nodes[i].flag_ |= Node::FullyUnmasked; }); return; } @@ -1312,7 +1312,7 @@ void node_update_visibility_mesh(const Span hide_vert, MeshNode &node) const Span verts = node.all_verts(); const bool fully_hidden = std::all_of( verts.begin(), verts.end(), [&](const int vert) { return hide_vert[vert]; }); - SET_FLAG_FROM_TEST(node.flag_, fully_hidden, PBVH_FullyHidden); + SET_FLAG_FROM_TEST(node.flag_, fully_hidden, Node::FullyHidden); } static void update_visibility_faces(const Mesh &mesh, @@ -1322,7 +1322,7 @@ static void update_visibility_faces(const Mesh &mesh, const AttributeAccessor attributes = mesh.attributes(); const VArraySpan hide_vert = *attributes.lookup(".hide_vert", AttrDomain::Point); if (hide_vert.is_empty()) { - node_mask.foreach_index([&](const int i) { nodes[i].flag_ &= ~PBVH_FullyHidden; }); + node_mask.foreach_index([&](const int i) { nodes[i].flag_ &= ~Node::FullyHidden; }); return; } @@ -1337,7 +1337,7 @@ void node_update_visibility_grids(const BitGroupVector<> &grid_hidden, GridsNode node.prim_indices_.begin(), node.prim_indices_.end(), [&](const int grid) { return bits::any_bit_unset(grid_hidden[grid]); }); - SET_FLAG_FROM_TEST(node.flag_, fully_hidden, PBVH_FullyHidden); + SET_FLAG_FROM_TEST(node.flag_, fully_hidden, Node::FullyHidden); } static void update_visibility_grids(const SubdivCCG &subdiv_ccg, @@ -1346,7 +1346,7 @@ static void update_visibility_grids(const SubdivCCG &subdiv_ccg, { const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; if (grid_hidden.is_empty()) { - node_mask.foreach_index([&](const int i) { nodes[i].flag_ &= ~PBVH_FullyHidden; }); + node_mask.foreach_index([&](const int i) { nodes[i].flag_ &= ~Node::FullyHidden; }); return; } @@ -1364,7 +1364,7 @@ void node_update_visibility_bmesh(BMeshNode &node) node.bm_other_verts_.begin(), node.bm_other_verts_.end(), [&](const BMVert *vert) { return BM_elem_flag_test(vert, BM_ELEM_HIDDEN); }); - SET_FLAG_FROM_TEST(node.flag_, unique_hidden && other_hidden, PBVH_FullyHidden); + SET_FLAG_FROM_TEST(node.flag_, unique_hidden && other_hidden, Node::FullyHidden); } static void update_visibility_bmesh(const MutableSpan nodes, const IndexMask &node_mask) @@ -1447,8 +1447,8 @@ blender::Bounds BKE_pbvh_redraw_BB(const blender::bke::pbvh::Tr PBVHIter iter; pbvh_iter_begin(&iter, const_cast(pbvh), {}); Node *node; - while ((node = pbvh_iter_next(&iter, PBVH_Leaf))) { - if (node->flag_ & PBVH_UpdateRedraw) { + while ((node = pbvh_iter_next(&iter, Node::Leaf))) { + if (node->flag_ & Node::UpdateRedraw) { bounds = bounds::merge(bounds, node->bounds_); } } @@ -1510,7 +1510,7 @@ int BKE_pbvh_get_grid_num_faces(const Object &object) void BKE_pbvh_node_mark_update(blender::bke::pbvh::Node &node) { - node.flag_ |= PBVH_RebuildPixels; + node.flag_ |= blender::bke::pbvh::Node::RebuildPixels; } void BKE_pbvh_mark_rebuild_pixels(blender::bke::pbvh::Tree &pbvh) @@ -1518,8 +1518,8 @@ void BKE_pbvh_mark_rebuild_pixels(blender::bke::pbvh::Tree &pbvh) std::visit( [](auto &nodes) { for (blender::bke::pbvh::Node &node : nodes) { - if (node.flag_ & PBVH_Leaf) { - node.flag_ |= PBVH_RebuildPixels; + if (node.flag_ & blender::bke::pbvh::Node::Leaf) { + node.flag_ |= blender::bke::pbvh::Node::RebuildPixels; } } }, @@ -1528,53 +1528,56 @@ void BKE_pbvh_mark_rebuild_pixels(blender::bke::pbvh::Tree &pbvh) void BKE_pbvh_node_fully_hidden_set(blender::bke::pbvh::Node &node, int fully_hidden) { - BLI_assert(node.flag_ & PBVH_Leaf); + BLI_assert(node.flag_ & blender::bke::pbvh::Node::Leaf); if (fully_hidden) { - node.flag_ |= PBVH_FullyHidden; + node.flag_ |= blender::bke::pbvh::Node::FullyHidden; } else { - node.flag_ &= ~PBVH_FullyHidden; + node.flag_ &= ~blender::bke::pbvh::Node::FullyHidden; } } bool BKE_pbvh_node_fully_hidden_get(const blender::bke::pbvh::Node &node) { - return (node.flag_ & PBVH_Leaf) && (node.flag_ & PBVH_FullyHidden); + return (node.flag_ & blender::bke::pbvh::Node::Leaf) && + (node.flag_ & blender::bke::pbvh::Node::FullyHidden); } void BKE_pbvh_node_fully_masked_set(blender::bke::pbvh::Node &node, int fully_masked) { - BLI_assert(node.flag_ & PBVH_Leaf); + BLI_assert(node.flag_ & blender::bke::pbvh::Node::Leaf); if (fully_masked) { - node.flag_ |= PBVH_FullyMasked; + node.flag_ |= blender::bke::pbvh::Node::FullyMasked; } else { - node.flag_ &= ~PBVH_FullyMasked; + node.flag_ &= ~blender::bke::pbvh::Node::FullyMasked; } } bool BKE_pbvh_node_fully_masked_get(const blender::bke::pbvh::Node &node) { - return (node.flag_ & PBVH_Leaf) && (node.flag_ & PBVH_FullyMasked); + return (node.flag_ & blender::bke::pbvh::Node::Leaf) && + (node.flag_ & blender::bke::pbvh::Node::FullyMasked); } void BKE_pbvh_node_fully_unmasked_set(blender::bke::pbvh::Node &node, int fully_masked) { - BLI_assert(node.flag_ & PBVH_Leaf); + BLI_assert(node.flag_ & blender::bke::pbvh::Node::Leaf); if (fully_masked) { - node.flag_ |= PBVH_FullyUnmasked; + node.flag_ |= blender::bke::pbvh::Node::FullyUnmasked; } else { - node.flag_ &= ~PBVH_FullyUnmasked; + node.flag_ &= ~blender::bke::pbvh::Node::FullyUnmasked; } } bool BKE_pbvh_node_fully_unmasked_get(const blender::bke::pbvh::Node &node) { - return (node.flag_ & PBVH_Leaf) && (node.flag_ & PBVH_FullyUnmasked); + return (node.flag_ & blender::bke::pbvh::Node::Leaf) && + (node.flag_ & blender::bke::pbvh::Node::FullyUnmasked); } namespace blender::bke::pbvh { @@ -2274,7 +2277,7 @@ bool find_nearest_to_ray_node(Tree &pbvh, float *depth, float *dist_sq) { - if (node.flag_ & PBVH_FullyHidden) { + if (node.flag_ & Node::FullyHidden) { return false; } switch (pbvh.type()) { @@ -2368,13 +2371,13 @@ void BKE_pbvh_draw_debug_cb(blender::bke::pbvh::Tree &pbvh, void (*draw_fn)(blender::bke::pbvh::Node *node, void *user_data), void *user_data) { - PBVHNodeFlags flag = PBVH_Leaf; + blender::bke::pbvh::Node::Flags flag = blender::bke::pbvh::Node::Leaf; std::visit( [&](auto &nodes) { for (blender::bke::pbvh::Node &node : nodes) { - if (node.flag_ & PBVH_TexLeaf) { - flag = PBVH_TexLeaf; + if (node.flag_ & blender::bke::pbvh::Node::TexLeaf) { + flag = blender::bke::pbvh::Node::TexLeaf; break; } } @@ -2586,7 +2589,7 @@ IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory) [&](const auto &nodes) { return IndexMask::from_predicate( nodes.index_range(), GrainSize(1024), memory, [&](const int i) { - return (nodes[i].flag_ & PBVH_Leaf) != 0; + return (nodes[i].flag_ & Node::Leaf) != 0; }); }, pbvh.nodes_); @@ -2594,7 +2597,7 @@ IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory) static Vector search_gather(Tree &pbvh, const FunctionRef scb, - PBVHNodeFlags leaf_flag) + Node::Flags leaf_flag) { if (tree_is_empty(pbvh)) { return {}; @@ -2620,7 +2623,7 @@ IndexMask search_nodes(const Tree &pbvh, FunctionRef filter_fn) { Vector nodes = search_gather( - const_cast(pbvh), [&](Node &node) { return filter_fn(node); }, PBVH_Leaf); + const_cast(pbvh), [&](Node &node) { return filter_fn(node); }, Node::Leaf); Array indices(nodes.size()); std::visit( [&](const auto &pbvh_nodes) { diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.cc b/source/blender/blenkernel/intern/pbvh_bmesh.cc index 4cac1938753..fa3ebef60b5 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.cc +++ b/source/blender/blenkernel/intern/pbvh_bmesh.cc @@ -289,8 +289,8 @@ static void pbvh_bmesh_node_split(Vector &nodes, /* Initialize children */ BMeshNode *c1 = &nodes[children], *c2 = &nodes[children + 1]; - c1->flag_ |= PBVH_Leaf; - c2->flag_ |= PBVH_Leaf; + c1->flag_ |= Node::Leaf; + c2->flag_ |= Node::Leaf; c1->bm_faces_.reserve(n->bm_faces_.size() / 2); c2->bm_faces_.reserve(n->bm_faces_.size() / 2); @@ -337,7 +337,7 @@ static void pbvh_bmesh_node_split(Vector &nodes, } n->bm_faces_.clear_and_shrink(); - n->flag_ &= ~PBVH_Leaf; + n->flag_ &= ~Node::Leaf; node_changed[node_index] = true; /* Recurse. */ @@ -454,7 +454,7 @@ static BMVert *pbvh_bmesh_vert_create(BMesh &bm, node->bm_unique_verts_.add(v); BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, node_index); - node->flag_ |= PBVH_TopologyUpdated; + node->flag_ |= Node::Leaf; node_changed[node_index] = true; /* Log the new vertex. */ @@ -487,9 +487,9 @@ static BMFace *pbvh_bmesh_face_create(BMesh &bm, node->bm_faces_.add(f); BM_ELEM_CD_SET_INT(f, cd_face_node_offset, node_index); - node->flag_ |= PBVH_TopologyUpdated; + node->flag_ |= Node::Leaf; node_changed[node_index] = true; - node->flag_ &= ~PBVH_FullyHidden; + node->flag_ &= ~Node::FullyHidden; /* Log the new face. */ BM_log_face_added(&bm_log, f); @@ -551,7 +551,7 @@ static void pbvh_bmesh_vert_ownership_transfer(MutableSpan nodes, { const int current_owner_index = pbvh_bmesh_node_index_from_vert(cd_vert_node_offset, v); BMeshNode *current_owner = &nodes[current_owner_index]; - current_owner->flag_ |= PBVH_TopologyUpdated; + current_owner->flag_ |= Node::Leaf; node_changed[new_owner_index] = true; BMeshNode *new_owner = &nodes[new_owner_index]; @@ -567,7 +567,7 @@ static void pbvh_bmesh_vert_ownership_transfer(MutableSpan nodes, new_owner->bm_other_verts_.remove(v); BLI_assert(!new_owner->bm_other_verts_.contains(v)); - new_owner->flag_ |= PBVH_TopologyUpdated; + new_owner->flag_ |= Node::Leaf; node_changed[new_owner_index] = true; } @@ -594,7 +594,7 @@ static void pbvh_bmesh_vert_remove(MutableSpan nodes, f_node_index_prev = f_node_index; BMeshNode *f_node = &nodes[f_node_index]; - f_node->flag_ |= PBVH_TopologyUpdated; + f_node->flag_ |= Node::Leaf; node_changed[f_node_index] = true; /* Remove current ownership. */ @@ -650,7 +650,7 @@ static void pbvh_bmesh_face_remove(MutableSpan nodes, BM_log_face_removed(&bm_log, f); /* Mark node for update. */ - f_node->flag_ |= PBVH_TopologyUpdated; + f_node->flag_ |= Node::Leaf; node_changed[node_index] = true; } @@ -1068,8 +1068,8 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx, for (BMeshNode &node : nodes) { /* Check leaf nodes marked for topology update. */ - if ((node.flag_ & PBVH_Leaf) && (node.flag_ & PBVH_UpdateTopology) && - !(node.flag_ & PBVH_FullyHidden)) + if ((node.flag_ & Node::Leaf) && (node.flag_ & Node::UpdateTopology) && + !(node.flag_ & Node::FullyHidden)) { for (BMFace *f : node.bm_faces_) { long_edge_queue_face_add(eq_ctx, f); @@ -1123,8 +1123,8 @@ static void short_edge_queue_create(EdgeQueueContext *eq_ctx, for (BMeshNode &node : nodes) { /* Check leaf nodes marked for topology update */ - if ((node.flag_ & PBVH_Leaf) && (node.flag_ & PBVH_UpdateTopology) && - !(node.flag_ & PBVH_FullyHidden)) + if ((node.flag_ & Node::Leaf) && (node.flag_ & Node::UpdateTopology) && + !(node.flag_ & Node::FullyHidden)) { for (BMFace *f : node.bm_faces_) { short_edge_queue_face_add(eq_ctx, f); @@ -1935,7 +1935,7 @@ bool raycast_node_detail_bmesh(BMeshNode &node, float *depth, float *r_edge_length) { - if (node.flag_ & PBVH_FullyHidden) { + if (node.flag_ & Node::FullyHidden) { return false; } @@ -2172,7 +2172,7 @@ static void pbvh_bmesh_create_nodes_fast_recursive(Vector &nodes, /* Node does not have children so it's a leaf node, populate with faces and tag accordingly * this is an expensive part but it's not so easily thread-able due to vertex node indices. */ - n->flag_ |= PBVH_Leaf; + n->flag_ |= Node::Leaf; n->bm_faces_.reserve(node->totface); const int end = node->start + node->totface; @@ -2275,7 +2275,7 @@ Tree Tree::from_bmesh(BMesh &bm) return BM_elem_flag_test(face, BM_ELEM_HIDDEN); })) { - nodes[i].flag_ |= PBVH_FullyHidden; + nodes[i].flag_ |= Node::FullyHidden; } } }); @@ -2367,15 +2367,15 @@ bool bmesh_update_topology(BMesh &bm, /* Unmark nodes. */ for (Node &node : nodes) { - if (node.flag_ & PBVH_Leaf && node.flag_ & PBVH_UpdateTopology) { - node.flag_ &= ~PBVH_UpdateTopology; + if (node.flag_ & Node::Leaf && node.flag_ & Node::UpdateTopology) { + node.flag_ &= ~Node::UpdateTopology; } } /* Go over all changed nodes and check if anything needs to be updated. */ for (BMeshNode &node : nodes) { - if (node.flag_ & PBVH_Leaf && node.flag_ & PBVH_TopologyUpdated) { - node.flag_ &= ~PBVH_TopologyUpdated; + if (node.flag_ & Node::Leaf && node.flag_ & Node::Leaf) { + node.flag_ &= ~Node::Leaf; if (!node.orig_tris_.is_empty()) { /* Reallocate original triangle data. */ @@ -2480,7 +2480,7 @@ void BKE_pbvh_bmesh_after_stroke(BMesh &bm, blender::bke::pbvh::Tree &pbvh) const IndexRange orig_range = nodes.index_range(); for (const int i : orig_range) { bke::pbvh::BMeshNode *n = &nodes[i]; - if (n->flag_ & PBVH_Leaf) { + if (n->flag_ & bke::pbvh::Node::Leaf) { /* Free `orco` / `ortri` data. */ pbvh_bmesh_node_drop_orig(n); @@ -2499,7 +2499,7 @@ void BKE_pbvh_bmesh_after_stroke(BMesh &bm, blender::bke::pbvh::Tree &pbvh) void BKE_pbvh_node_mark_topology_update(blender::bke::pbvh::Node &node) { - node.flag_ |= PBVH_UpdateTopology; + node.flag_ |= blender::bke::pbvh::Node::UpdateTopology; } const blender::Set &BKE_pbvh_bmesh_node_unique_verts( @@ -2544,7 +2544,7 @@ static void pbvh_bmesh_print(Tree *pbvh) for (int n = 0; n < pbvh->totnode; n++) { Node *node = &pbvh->nodes_[n]; - if (!(node->flag & PBVH_Leaf)) { + if (!(node->flag & Node::Leaf)) { continue; } @@ -2619,7 +2619,7 @@ static void pbvh_bmesh_verify(Tree *pbvh) Node *n = pbvh_bmesh_node_lookup(pbvh, f); /* Check that the face's node is a leaf. */ - BLI_assert(n->flag & PBVH_Leaf); + BLI_assert(n->flag & Node::Leaf); /* Check that the face's node knows it owns the face. */ BLI_assert(n->bm_faces_.contains(f)); @@ -2656,7 +2656,7 @@ static void pbvh_bmesh_verify(Tree *pbvh) Node *n = pbvh_bmesh_node_lookup(pbvh, v); /* Check that the vert's node is a leaf. */ - BLI_assert(n->flag & PBVH_Leaf); + BLI_assert(n->flag & Node::Leaf); /* Check that the vert's node knows it owns the vert. */ BLI_assert(BLI_gset_haskey(n->bm_unique_verts_, v)); @@ -2711,7 +2711,7 @@ static void pbvh_bmesh_verify(Tree *pbvh) /* Check that node elements are recorded in the top level */ for (int i = 0; i < pbvh->totnode; i++) { Node *n = &pbvh->nodes_[i]; - if (n->flag & PBVH_Leaf) { + if (n->flag & Node::Leaf) { GSetIterator gs_iter; for (BMFace *f : n->bm_faces_) { diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 9bb450e621b..d13fc16db03 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -217,13 +217,13 @@ static void do_encode_pixels(const uv_islands::MeshData &mesh_data, static bool should_pixels_be_updated(const Node &node) { - if ((node.flag_ & (PBVH_Leaf | PBVH_TexLeaf)) == 0) { + if ((node.flag_ & (Node::Leaf | Node::TexLeaf)) == 0) { return false; } if (node.children_offset_ != 0) { return false; } - if ((node.flag_ & PBVH_RebuildPixels) != 0) { + if ((node.flag_ & Node::RebuildPixels) != 0) { return true; } NodeData *node_data = static_cast(node.pixels_); @@ -277,7 +277,7 @@ static bool find_nodes_to_update(Tree &pbvh, Vector &r_nodes_to_upda continue; } r_nodes_to_update.append(&node); - node.flag_ = static_cast(node.flag_ | PBVH_RebuildPixels); + node.flag_ = static_cast(node.flag_ | Node::RebuildPixels); if (node.pixels_ == nullptr) { NodeData *node_data = MEM_new(__func__); @@ -303,7 +303,7 @@ static void apply_watertight_check(Tree &pbvh, Image &image, ImageUser &image_us continue; } for (Node &node : pbvh.nodes()) { - if ((node.flag_ & PBVH_Leaf) == 0) { + if ((node.flag_ & Node::Leaf) == 0) { continue; } NodeData *node_data = static_cast(node.pixels_); @@ -403,13 +403,13 @@ static bool update_pixels(const Depsgraph &depsgraph, /* Clear the UpdatePixels flag. */ for (Node *node : nodes_to_update) { - node->flag_ = static_cast(node->flag_ & ~PBVH_RebuildPixels); + node->flag_ &= ~Node::RebuildPixels; } - /* Add PBVH_TexLeaf flag */ + /* Add Node::TexLeaf flag */ for (Node &node : pbvh.nodes()) { - if (node.flag_ & PBVH_Leaf) { - node.flag_ = (PBVHNodeFlags)(int(node.flag_) | int(PBVH_TexLeaf)); + if (node.flag_ & Node::Leaf) { + node.flag_ |= Node::TexLeaf; } } @@ -421,7 +421,7 @@ static bool update_pixels(const Depsgraph &depsgraph, int num_pixels = 0; for (int n = 0; n < pbvh->totnode; n++) { Node *node = &pbvh->nodes[n]; - if ((node->flag & PBVH_Leaf) == 0) { + if ((node->flag & Node::Leaf) == 0) { continue; } NodeData *node_data = static_cast(node->pixels.node_data); diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc index 356316f3d89..fd905e17699 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc @@ -190,7 +190,7 @@ class PixelNodesTileData : public Vector> static bool should_add_node(blender::bke::pbvh::Node &node, const image::ImageTileWrapper &image_tile) { - if ((node.flag_ & PBVH_Leaf) == 0) { + if ((node.flag_ & Node::Leaf) == 0) { return false; } if (node.pixels_ == nullptr) { diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 2c7e7462a0b..ce5474c5f55 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -4408,7 +4408,7 @@ static void sculpt_raycast_cb(blender::bke::pbvh::Node &node, SculptRaycastData } } - if (node.flag_ & PBVH_FullyHidden) { + if (node.flag_ & bke::pbvh::Node::FullyHidden) { return; }