Refactor: Sculpt: Tag all nodes positions changed together, store in array
Replace the `PBVH_UpdateBB` flag with a separate vector of booleans. The simplest impact of this is that we can tell when there are no changed nodes in constant time. Besides that, it also works better with the recent IndexMask usage for selections of nodes, and allows better const correctness too, since nodes themselves don't have to be changed when positions are changed. This also leads into plans to change PBVH draw data tagging to avoid having to reupload all attributes when only one changes. Part of #118145. Pull Request: https://projects.blender.org/blender/blender/pulls/127587
This commit is contained in:
@@ -30,7 +30,6 @@ enum PBVHNodeFlags {
|
||||
PBVH_Leaf = 1 << 0,
|
||||
|
||||
PBVH_UpdateNormals = 1 << 1,
|
||||
PBVH_UpdateBB = 1 << 2,
|
||||
PBVH_UpdateDrawBuffers = 1 << 4,
|
||||
PBVH_UpdateRedraw = 1 << 5,
|
||||
PBVH_UpdateMask = 1 << 6,
|
||||
|
||||
@@ -79,8 +79,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_UpdateBB | PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers |
|
||||
PBVH_UpdateRedraw;
|
||||
PBVHNodeFlags flag_ = PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
|
||||
|
||||
/* Used for ray-casting: how close the bounding-box is to the ray point. */
|
||||
float tmin_ = 0.0f;
|
||||
@@ -192,6 +191,13 @@ class Tree {
|
||||
/* Memory backing for Node.prim_indices. */
|
||||
Array<int> prim_indices_;
|
||||
|
||||
/**
|
||||
* If true, the bounds for the corresponding node index is out of dat.
|
||||
* \note Values are only meaningful for leaf nodes.
|
||||
* \note The vector's size may not match the size of the nodes array.
|
||||
*/
|
||||
Vector<bool> bounds_dirty_;
|
||||
|
||||
float planes_[6][4];
|
||||
int num_planes_;
|
||||
|
||||
@@ -211,6 +217,12 @@ class Tree {
|
||||
{
|
||||
return this->type_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark data based on positions for specific BVH nodes dirty. In particular: bounds, normals,
|
||||
* and GPU data buffers. That data is recomputed later on in functions like #update_bounds.
|
||||
*/
|
||||
void tag_positions_changed(const IndexMask &node_mask);
|
||||
};
|
||||
|
||||
} // namespace blender::bke::pbvh
|
||||
@@ -379,7 +391,6 @@ void BKE_pbvh_node_mark_update_face_sets(blender::bke::pbvh::Node &node);
|
||||
void BKE_pbvh_node_mark_update_visibility(blender::bke::pbvh::Node &node);
|
||||
void BKE_pbvh_node_mark_rebuild_draw(blender::bke::pbvh::Node &node);
|
||||
void BKE_pbvh_node_mark_redraw(blender::bke::pbvh::Node &node);
|
||||
void BKE_pbvh_node_mark_positions_update(blender::bke::pbvh::Node &node);
|
||||
void BKE_pbvh_node_mark_topology_update(blender::bke::pbvh::Node &node);
|
||||
void BKE_pbvh_node_fully_hidden_set(blender::bke::pbvh::Node &node, int fully_hidden);
|
||||
bool BKE_pbvh_node_fully_hidden_get(const blender::bke::pbvh::Node &node);
|
||||
@@ -444,7 +455,7 @@ namespace blender::bke::pbvh {
|
||||
|
||||
/**
|
||||
* Recalculate node bounding boxes based on the current coordinates. Calculation is only done for
|
||||
* affected nodes with the #PBVH_UpdateBB flag set.
|
||||
* affected nodes that have been tagged by #PBVH::tag_positions_changed().
|
||||
*/
|
||||
void update_bounds(const Depsgraph &depsgraph, const Object &object, Tree &pbvh);
|
||||
void update_bounds_mesh(Span<float3> vert_positions, Tree &pbvh);
|
||||
|
||||
@@ -2129,6 +2129,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob_eval)
|
||||
else if (pbvh) {
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask node_mask = bke::pbvh::all_leaf_nodes(*pbvh, memory);
|
||||
pbvh->tag_positions_changed(node_mask);
|
||||
switch (pbvh->type()) {
|
||||
case bke::pbvh::Type::Mesh: {
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh->nodes<bke::pbvh::MeshNode>();
|
||||
|
||||
@@ -279,6 +279,8 @@ std::unique_ptr<Tree> build_mesh(const Mesh &mesh)
|
||||
|
||||
build_mesh_leaf_nodes(mesh.verts_num, faces, corner_verts, nodes);
|
||||
|
||||
pbvh->tag_positions_changed(nodes.index_range());
|
||||
|
||||
update_bounds_mesh(vert_positions, *pbvh);
|
||||
store_bounds_orig(*pbvh);
|
||||
|
||||
@@ -461,6 +463,8 @@ std::unique_ptr<Tree> build_grids(const Mesh &base_mesh, const SubdivCCG &subdiv
|
||||
}
|
||||
});
|
||||
|
||||
pbvh->tag_positions_changed(nodes.index_range());
|
||||
|
||||
update_bounds_grids(key, positions, *pbvh);
|
||||
store_bounds_orig(*pbvh);
|
||||
|
||||
@@ -542,6 +546,22 @@ Tree::~Tree()
|
||||
pixels_free(this);
|
||||
}
|
||||
|
||||
void Tree::tag_positions_changed(const IndexMask &node_mask)
|
||||
{
|
||||
this->bounds_dirty_.resize(std::max(this->bounds_dirty_.size(), node_mask.min_array_size()),
|
||||
false);
|
||||
/* TODO: Use `to_bools` with first clear disabled. */
|
||||
node_mask.foreach_index_optimized<int>(GrainSize(2048),
|
||||
[&](const int i) { this->bounds_dirty_[i] = true; });
|
||||
return std::visit(
|
||||
[&](auto &nodes) {
|
||||
node_mask.foreach_index([&](const int i) {
|
||||
nodes[i].flag_ |= PBVH_UpdateNormals | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
|
||||
});
|
||||
},
|
||||
this->nodes_);
|
||||
}
|
||||
|
||||
static bool tree_is_empty(const Tree &pbvh)
|
||||
{
|
||||
return std::visit([](const auto &nodes) { return nodes.is_empty(); }, pbvh.nodes_);
|
||||
@@ -1067,75 +1087,74 @@ struct BoundsMergeInfo {
|
||||
};
|
||||
|
||||
template<typename NodeT>
|
||||
static BoundsMergeInfo merge_child_bounds(MutableSpan<NodeT> nodes, const int node_index)
|
||||
static BoundsMergeInfo merge_child_bounds(MutableSpan<NodeT> nodes,
|
||||
const Span<bool> dirty,
|
||||
const int node_index)
|
||||
{
|
||||
NodeT &node = nodes[node_index];
|
||||
if (node.flag_ & PBVH_Leaf) {
|
||||
const bool update = node.flag_ & PBVH_UpdateBB;
|
||||
node.flag_ &= ~PBVH_UpdateBB;
|
||||
const bool update = node_index < dirty.size() && dirty[node_index];
|
||||
return {node.bounds_, update};
|
||||
}
|
||||
|
||||
const BoundsMergeInfo info_0 = merge_child_bounds(nodes, node.children_offset_ + 0);
|
||||
const BoundsMergeInfo info_1 = merge_child_bounds(nodes, node.children_offset_ + 1);
|
||||
const BoundsMergeInfo info_0 = merge_child_bounds(nodes, dirty, node.children_offset_ + 0);
|
||||
const BoundsMergeInfo info_1 = merge_child_bounds(nodes, dirty, node.children_offset_ + 1);
|
||||
const bool update = info_0.update || info_1.update;
|
||||
if (update) {
|
||||
node.bounds_ = bounds::merge(info_0.bounds, info_1.bounds);
|
||||
}
|
||||
node.flag_ &= ~PBVH_UpdateBB;
|
||||
return {node.bounds_, update};
|
||||
}
|
||||
|
||||
void flush_bounds_to_parents(Tree &pbvh)
|
||||
{
|
||||
std::visit(
|
||||
[](auto &nodes) {
|
||||
nodes.first().bounds_ = merge_child_bounds(nodes.as_mutable_span(), 0).bounds;
|
||||
[&](auto &nodes) {
|
||||
nodes.first().bounds_ =
|
||||
merge_child_bounds(nodes.as_mutable_span(), pbvh.bounds_dirty_, 0).bounds;
|
||||
},
|
||||
pbvh.nodes_);
|
||||
pbvh.bounds_dirty_.clear_and_shrink();
|
||||
}
|
||||
|
||||
void update_bounds_mesh(const Span<float3> vert_positions, Tree &pbvh)
|
||||
{
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask nodes_to_update = search_nodes(
|
||||
pbvh, memory, [&](const Node &node) { return update_search(node, PBVH_UpdateBB); });
|
||||
|
||||
const IndexMask nodes_to_update = IndexMask::from_bools(pbvh.bounds_dirty_, memory);
|
||||
if (nodes_to_update.is_empty()) {
|
||||
return;
|
||||
}
|
||||
MutableSpan<MeshNode> nodes = pbvh.nodes<MeshNode>();
|
||||
nodes_to_update.foreach_index(
|
||||
GrainSize(1), [&](const int i) { update_node_bounds_mesh(vert_positions, nodes[i]); });
|
||||
if (!nodes.is_empty()) {
|
||||
flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
void update_bounds_grids(const CCGKey &key, const Span<float3> positions, Tree &pbvh)
|
||||
{
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask nodes_to_update = search_nodes(
|
||||
pbvh, memory, [&](const Node &node) { return update_search(node, PBVH_UpdateBB); });
|
||||
|
||||
const IndexMask nodes_to_update = IndexMask::from_bools(pbvh.bounds_dirty_, memory);
|
||||
if (nodes_to_update.is_empty()) {
|
||||
return;
|
||||
}
|
||||
MutableSpan<GridsNode> nodes = pbvh.nodes<GridsNode>();
|
||||
nodes_to_update.foreach_index(GrainSize(1), [&](const int i) {
|
||||
update_node_bounds_grids(key.grid_area, positions, nodes[i]);
|
||||
});
|
||||
if (!nodes.is_empty()) {
|
||||
flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
void update_bounds_bmesh(const BMesh & /*bm*/, Tree &pbvh)
|
||||
{
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask nodes_to_update = search_nodes(
|
||||
pbvh, memory, [&](const Node &node) { return update_search(node, PBVH_UpdateBB); });
|
||||
|
||||
const IndexMask nodes_to_update = IndexMask::from_bools(pbvh.bounds_dirty_, memory);
|
||||
if (nodes_to_update.is_empty()) {
|
||||
return;
|
||||
}
|
||||
MutableSpan<BMeshNode> nodes = pbvh.nodes<BMeshNode>();
|
||||
nodes_to_update.foreach_index(GrainSize(1),
|
||||
[&](const int i) { update_node_bounds_bmesh(nodes[i]); });
|
||||
if (!nodes.is_empty()) {
|
||||
flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
void update_bounds(const Depsgraph &depsgraph, const Object &object, Tree &pbvh)
|
||||
@@ -1513,7 +1532,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_UpdateNormals | PBVH_UpdateBB | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw |
|
||||
node.flag_ |= PBVH_UpdateNormals | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw |
|
||||
PBVH_RebuildPixels;
|
||||
}
|
||||
|
||||
@@ -1560,11 +1579,6 @@ void BKE_pbvh_node_mark_redraw(blender::bke::pbvh::Node &node)
|
||||
node.flag_ |= PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw;
|
||||
}
|
||||
|
||||
void BKE_pbvh_node_mark_positions_update(blender::bke::pbvh::Node &node)
|
||||
{
|
||||
node.flag_ |= PBVH_UpdateNormals | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw | PBVH_UpdateBB;
|
||||
}
|
||||
|
||||
void BKE_pbvh_node_fully_hidden_set(blender::bke::pbvh::Node &node, int fully_hidden)
|
||||
{
|
||||
BLI_assert(node.flag_ & PBVH_Leaf);
|
||||
@@ -2541,9 +2555,7 @@ void BKE_pbvh_vert_coords_apply(blender::bke::pbvh::Tree &pbvh,
|
||||
const blender::Span<blender::float3> vert_positions)
|
||||
{
|
||||
using namespace blender::bke::pbvh;
|
||||
for (MeshNode &node : pbvh.nodes<MeshNode>()) {
|
||||
BKE_pbvh_node_mark_positions_update(node);
|
||||
}
|
||||
pbvh.tag_positions_changed(blender::IndexRange(pbvh.nodes_num()));
|
||||
update_bounds_mesh(vert_positions, pbvh);
|
||||
store_bounds_orig(pbvh);
|
||||
}
|
||||
|
||||
@@ -427,6 +427,7 @@ BLI_INLINE BMeshNode *pbvh_bmesh_node_from_face(MutableSpan<BMeshNode> nodes,
|
||||
|
||||
static BMVert *pbvh_bmesh_vert_create(BMesh &bm,
|
||||
MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
BMLog &bm_log,
|
||||
const BMVert *v1,
|
||||
const BMVert *v2,
|
||||
@@ -451,7 +452,8 @@ 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_UpdateDrawBuffers | PBVH_UpdateBB | PBVH_TopologyUpdated;
|
||||
node->flag_ |= PBVH_UpdateDrawBuffers | PBVH_TopologyUpdated;
|
||||
node_changed[node_index] = true;
|
||||
|
||||
/* Log the new vertex. */
|
||||
BM_log_vert_added(&bm_log, v, cd_vert_mask_offset);
|
||||
@@ -519,16 +521,15 @@ static int pbvh_bmesh_node_vert_use_count_at_most(MutableSpan<BMeshNode> nodes,
|
||||
}
|
||||
|
||||
/** Return a node that uses vertex `v` other than its current owner. */
|
||||
static BMeshNode *pbvh_bmesh_vert_other_node_find(MutableSpan<BMeshNode> nodes,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMVert *v)
|
||||
static std::optional<int> pbvh_bmesh_vert_other_node_find(const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMVert *v)
|
||||
{
|
||||
BMeshNode *current_node = pbvh_bmesh_node_from_vert(nodes, cd_vert_node_offset, v);
|
||||
const int current_node = pbvh_bmesh_node_index_from_vert(cd_vert_node_offset, v);
|
||||
BMFace *f;
|
||||
|
||||
BM_FACES_OF_VERT_ITER_BEGIN (f, v) {
|
||||
BMeshNode *f_node = pbvh_bmesh_node_from_face(nodes, cd_face_node_offset, f);
|
||||
const int f_node = pbvh_bmesh_node_index_from_face(cd_face_node_offset, f);
|
||||
|
||||
if (f_node != current_node) {
|
||||
return f_node;
|
||||
@@ -536,17 +537,21 @@ static BMeshNode *pbvh_bmesh_vert_other_node_find(MutableSpan<BMeshNode> nodes,
|
||||
}
|
||||
BM_FACES_OF_VERT_ITER_END;
|
||||
|
||||
return nullptr;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static void pbvh_bmesh_vert_ownership_transfer(MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
BMeshNode *new_owner,
|
||||
const int new_owner_index,
|
||||
BMVert *v)
|
||||
{
|
||||
BMeshNode *current_owner = pbvh_bmesh_node_from_vert(nodes, cd_vert_node_offset, v);
|
||||
current_owner->flag_ |= PBVH_UpdateDrawBuffers | PBVH_RebuildDrawBuffers | PBVH_UpdateBB |
|
||||
PBVH_TopologyUpdated;
|
||||
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_UpdateDrawBuffers | PBVH_RebuildDrawBuffers | PBVH_TopologyUpdated;
|
||||
node_changed[new_owner_index] = true;
|
||||
|
||||
BMeshNode *new_owner = &nodes[new_owner_index];
|
||||
|
||||
BLI_assert(current_owner != new_owner);
|
||||
|
||||
@@ -554,16 +559,17 @@ static void pbvh_bmesh_vert_ownership_transfer(MutableSpan<BMeshNode> nodes,
|
||||
current_owner->bm_unique_verts_.remove(v);
|
||||
|
||||
/* Set new ownership */
|
||||
BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, new_owner - nodes.data());
|
||||
BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, new_owner_index);
|
||||
new_owner->bm_unique_verts_.add(v);
|
||||
new_owner->bm_other_verts_.remove(v);
|
||||
BLI_assert(!new_owner->bm_other_verts_.contains(v));
|
||||
|
||||
new_owner->flag_ |= PBVH_UpdateDrawBuffers | PBVH_RebuildDrawBuffers | PBVH_UpdateBB |
|
||||
PBVH_TopologyUpdated;
|
||||
new_owner->flag_ |= PBVH_UpdateDrawBuffers | PBVH_RebuildDrawBuffers | PBVH_TopologyUpdated;
|
||||
node_changed[new_owner_index] = true;
|
||||
}
|
||||
|
||||
static void pbvh_bmesh_vert_remove(MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMVert *v)
|
||||
@@ -585,8 +591,8 @@ static void pbvh_bmesh_vert_remove(MutableSpan<BMeshNode> nodes,
|
||||
f_node_index_prev = f_node_index;
|
||||
|
||||
BMeshNode *f_node = &nodes[f_node_index];
|
||||
f_node->flag_ |= PBVH_UpdateDrawBuffers | PBVH_RebuildDrawBuffers | PBVH_UpdateBB |
|
||||
PBVH_TopologyUpdated;
|
||||
f_node->flag_ |= PBVH_UpdateDrawBuffers | PBVH_RebuildDrawBuffers | PBVH_TopologyUpdated;
|
||||
node_changed[f_node_index] = true;
|
||||
|
||||
/* Remove current ownership. */
|
||||
f_node->bm_other_verts_.remove(v);
|
||||
@@ -599,6 +605,7 @@ static void pbvh_bmesh_vert_remove(MutableSpan<BMeshNode> nodes,
|
||||
}
|
||||
|
||||
static void pbvh_bmesh_face_remove(MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMLog &bm_log,
|
||||
@@ -614,14 +621,14 @@ static void pbvh_bmesh_face_remove(MutableSpan<BMeshNode> nodes,
|
||||
if (pbvh_bmesh_node_vert_use_count_is_equal(nodes, cd_face_node_offset, f_node, v, 1)) {
|
||||
if (f_node->bm_unique_verts_.contains(v)) {
|
||||
/* Find a different node that uses 'v'. */
|
||||
BMeshNode *new_node;
|
||||
|
||||
new_node = pbvh_bmesh_vert_other_node_find(
|
||||
nodes, cd_vert_node_offset, cd_face_node_offset, v);
|
||||
const std::optional<int> new_node = pbvh_bmesh_vert_other_node_find(
|
||||
cd_vert_node_offset, cd_face_node_offset, v);
|
||||
BLI_assert(new_node || BM_vert_face_count_is_equal(v, 1));
|
||||
|
||||
if (new_node) {
|
||||
pbvh_bmesh_vert_ownership_transfer(nodes, cd_vert_node_offset, new_node, v);
|
||||
pbvh_bmesh_vert_ownership_transfer(
|
||||
nodes, node_changed, cd_vert_node_offset, *new_node, v);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1152,6 +1159,7 @@ static void merge_edge_data(BMesh &bm, BMEdge &dst, const BMEdge &src)
|
||||
static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
|
||||
BMesh &bm,
|
||||
MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMLog &bm_log,
|
||||
@@ -1170,6 +1178,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
|
||||
int node_index = BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset);
|
||||
BMVert *v_new = pbvh_bmesh_vert_create(bm,
|
||||
nodes,
|
||||
node_changed,
|
||||
bm_log,
|
||||
e->v1,
|
||||
e->v2,
|
||||
@@ -1196,7 +1205,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
|
||||
BMVert *v2 = l_adj->next->v;
|
||||
|
||||
if (ni != node_index && i == 0) {
|
||||
pbvh_bmesh_vert_ownership_transfer(nodes, cd_vert_node_offset, &nodes[ni], v_new);
|
||||
pbvh_bmesh_vert_ownership_transfer(nodes, node_changed, cd_vert_node_offset, ni, v_new);
|
||||
}
|
||||
|
||||
/* The 2 new faces created and assigned to `f_new` have their
|
||||
@@ -1247,7 +1256,8 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
|
||||
long_edge_queue_face_add(eq_ctx, f_new_second);
|
||||
|
||||
/* Delete original */
|
||||
pbvh_bmesh_face_remove(nodes, cd_vert_node_offset, cd_face_node_offset, bm_log, f_adj);
|
||||
pbvh_bmesh_face_remove(
|
||||
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, f_adj);
|
||||
BM_face_kill(&bm, f_adj);
|
||||
|
||||
/* Ensure new vertex is in the node */
|
||||
@@ -1270,6 +1280,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
|
||||
static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx,
|
||||
BMesh &bm,
|
||||
MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMLog &bm_log)
|
||||
@@ -1309,7 +1320,8 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx,
|
||||
|
||||
any_subdivided = true;
|
||||
|
||||
pbvh_bmesh_split_edge(eq_ctx, bm, nodes, cd_vert_node_offset, cd_face_node_offset, bm_log, e);
|
||||
pbvh_bmesh_split_edge(
|
||||
eq_ctx, bm, nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, e);
|
||||
}
|
||||
|
||||
#ifdef USE_EDGEQUEUE_TAG_VERIFY
|
||||
@@ -1568,6 +1580,7 @@ static void merge_face_edge_data(BMesh &bm,
|
||||
|
||||
static void pbvh_bmesh_collapse_edge(BMesh &bm,
|
||||
MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMLog &bm_log,
|
||||
@@ -1610,7 +1623,7 @@ static void pbvh_bmesh_collapse_edge(BMesh &bm,
|
||||
}
|
||||
|
||||
/* Remove the merge vertex from the Tree. */
|
||||
pbvh_bmesh_vert_remove(nodes, cd_vert_node_offset, cd_face_node_offset, v_del);
|
||||
pbvh_bmesh_vert_remove(nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, v_del);
|
||||
|
||||
/* For all remaining faces of v_del, create a new face that is the
|
||||
* same except it uses v_conn instead of v_del */
|
||||
@@ -1649,7 +1662,8 @@ static void pbvh_bmesh_collapse_edge(BMesh &bm,
|
||||
while ((l_adj = e->l)) {
|
||||
BMFace *f_adj = l_adj->f;
|
||||
|
||||
pbvh_bmesh_face_remove(nodes, cd_vert_node_offset, cd_face_node_offset, bm_log, f_adj);
|
||||
pbvh_bmesh_face_remove(
|
||||
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, f_adj);
|
||||
BM_face_kill(&bm, f_adj);
|
||||
}
|
||||
|
||||
@@ -1698,7 +1712,8 @@ static void pbvh_bmesh_collapse_edge(BMesh &bm,
|
||||
try_merge_flap_edge_data_before_dissolve(bm, *f_del);
|
||||
|
||||
/* Remove the face */
|
||||
pbvh_bmesh_face_remove(nodes, cd_vert_node_offset, cd_face_node_offset, bm_log, f_del);
|
||||
pbvh_bmesh_face_remove(
|
||||
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, f_del);
|
||||
BM_face_kill(&bm, f_del);
|
||||
|
||||
/* Check if any of the face's edges are now unused by any
|
||||
@@ -1713,7 +1728,8 @@ static void pbvh_bmesh_collapse_edge(BMesh &bm,
|
||||
* remove them from the Tree */
|
||||
for (const int j : IndexRange(3)) {
|
||||
if ((v_tri[j] != v_del) && (v_tri[j]->e == nullptr)) {
|
||||
pbvh_bmesh_vert_remove(nodes, cd_vert_node_offset, cd_face_node_offset, v_tri[j]);
|
||||
pbvh_bmesh_vert_remove(
|
||||
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, v_tri[j]);
|
||||
|
||||
BM_log_vert_removed(&bm_log, v_tri[j], eq_ctx->cd_vert_mask_offset);
|
||||
|
||||
@@ -1742,8 +1758,9 @@ static void pbvh_bmesh_collapse_edge(BMesh &bm,
|
||||
/* Update bounding boxes attached to the connected vertex.
|
||||
* Note that we can often get-away without this but causes #48779. */
|
||||
BM_LOOPS_OF_VERT_ITER_BEGIN (l, v_conn) {
|
||||
Node *f_node = pbvh_bmesh_node_from_face(nodes, cd_face_node_offset, l->f);
|
||||
f_node->flag_ |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals | PBVH_UpdateBB;
|
||||
const int f_node = pbvh_bmesh_node_index_from_face(cd_face_node_offset, l->f);
|
||||
nodes[f_node].flag_ |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
|
||||
node_changed[f_node] = true;
|
||||
}
|
||||
BM_LOOPS_OF_VERT_ITER_END;
|
||||
}
|
||||
@@ -1760,6 +1777,7 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
|
||||
const float min_edge_len,
|
||||
BMesh &bm,
|
||||
MutableSpan<BMeshNode> nodes,
|
||||
MutableSpan<bool> node_changed,
|
||||
const int cd_vert_node_offset,
|
||||
const int cd_face_node_offset,
|
||||
BMLog &bm_log)
|
||||
@@ -1811,6 +1829,7 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
|
||||
|
||||
pbvh_bmesh_collapse_edge(bm,
|
||||
nodes,
|
||||
node_changed,
|
||||
cd_vert_node_offset,
|
||||
cd_face_node_offset,
|
||||
bm_log,
|
||||
@@ -2250,6 +2269,7 @@ std::unique_ptr<Tree> build_bmesh(BMesh *bm)
|
||||
pbvh_bmesh_create_nodes_fast_recursive(
|
||||
nodes, cd_vert_node_offset, cd_face_node_offset, nodeinfo, face_bounds, &rootnode, 0);
|
||||
|
||||
pbvh->tag_positions_changed(nodes.index_range());
|
||||
update_bounds_bmesh(*bm, *pbvh);
|
||||
store_bounds_orig(*pbvh);
|
||||
|
||||
@@ -2295,6 +2315,7 @@ bool bmesh_update_topology(BMesh &bm,
|
||||
}
|
||||
|
||||
MutableSpan<BMeshNode> nodes = pbvh.nodes<BMeshNode>();
|
||||
Array<bool> node_changed(nodes.size(), false);
|
||||
|
||||
if (mode & PBVH_Collapse) {
|
||||
EdgeQueue q;
|
||||
@@ -2310,8 +2331,14 @@ bool bmesh_update_topology(BMesh &bm,
|
||||
|
||||
short_edge_queue_create(
|
||||
&eq_ctx, min_edge_len, nodes, center, view_normal, radius, use_frontface, use_projected);
|
||||
modified |= pbvh_bmesh_collapse_short_edges(
|
||||
&eq_ctx, min_edge_len, bm, nodes, cd_vert_node_offset, cd_face_node_offset, bm_log);
|
||||
modified |= pbvh_bmesh_collapse_short_edges(&eq_ctx,
|
||||
min_edge_len,
|
||||
bm,
|
||||
nodes,
|
||||
node_changed,
|
||||
cd_vert_node_offset,
|
||||
cd_face_node_offset,
|
||||
bm_log);
|
||||
BLI_heapsimple_free(q.heap, nullptr);
|
||||
BLI_mempool_destroy(queue_pool);
|
||||
}
|
||||
@@ -2331,11 +2358,15 @@ bool bmesh_update_topology(BMesh &bm,
|
||||
long_edge_queue_create(
|
||||
&eq_ctx, max_edge_len, nodes, center, view_normal, radius, use_frontface, use_projected);
|
||||
modified |= pbvh_bmesh_subdivide_long_edges(
|
||||
&eq_ctx, bm, nodes, cd_vert_node_offset, cd_face_node_offset, bm_log);
|
||||
&eq_ctx, bm, nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log);
|
||||
BLI_heapsimple_free(q.heap, nullptr);
|
||||
BLI_mempool_destroy(queue_pool);
|
||||
}
|
||||
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask changed_nodes = IndexMask::from_bools(node_changed, memory);
|
||||
pbvh.tag_positions_changed(changed_nodes);
|
||||
|
||||
/* Unmark nodes. */
|
||||
for (Node &node : nodes) {
|
||||
if (node.flag_ & PBVH_Leaf && node.flag_ & PBVH_UpdateTopology) {
|
||||
|
||||
@@ -127,11 +127,11 @@ void do_bmesh_topology_rake_brush(const Depsgraph &depsgraph,
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(
|
||||
depsgraph, sd, object, brush, direction, factor * ss.cache->pressure, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,6 @@ void do_clay_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -258,7 +257,6 @@ void do_clay_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, test_plane, bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -270,13 +268,13 @@ void do_clay_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, test_plane, bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,6 @@ void do_clay_strips_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -312,7 +311,6 @@ void do_clay_strips_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, mat, plane, strength, flip, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -324,13 +322,13 @@ void do_clay_strips_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, mat, plane, strength, flip, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,6 @@ void do_clay_thumb_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -291,7 +290,6 @@ void do_clay_thumb_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, brush, plane_tilt, clay_strength, nodes[i], object, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -303,13 +301,13 @@ void do_clay_thumb_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, brush, plane_tilt, clay_strength, object, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,6 @@ static void do_crease_or_blob_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -294,7 +293,6 @@ static void do_crease_or_blob_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, offset, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -306,13 +304,13 @@ static void do_crease_or_blob_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, offset, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@ static void offset_positions(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -209,7 +208,6 @@ static void offset_positions(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, offset, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -221,13 +219,13 @@ static void offset_positions(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, offset, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,6 @@ static void offset_positions(const Depsgraph &depsgraph,
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_faces(
|
||||
depsgraph, sd, brush, offset, positions_eval, nodes[i], object, tls, positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -205,7 +204,6 @@ static void offset_positions(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, offset, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -217,13 +215,13 @@ static void offset_positions(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, offset, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,6 @@ void do_draw_vector_displacement_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -258,7 +257,6 @@ void do_draw_vector_displacement_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -270,13 +268,13 @@ void do_draw_vector_displacement_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,6 @@ void do_elastic_deform_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -272,7 +271,6 @@ void do_elastic_deform_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, params, grab_delta, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -284,12 +282,12 @@ void do_elastic_deform_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, params, grab_delta, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
} break;
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +333,6 @@ void do_enhance_details_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -347,7 +346,6 @@ void do_enhance_details_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, translations, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -359,13 +357,13 @@ void do_enhance_details_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, translations, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,6 @@ void do_fill_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -244,7 +243,6 @@ void do_fill_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, plane, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -256,13 +254,13 @@ void do_fill_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, plane, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,6 @@ void do_flatten_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -237,7 +236,6 @@ void do_flatten_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, plane, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -249,13 +247,14 @@ void do_flatten_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, plane, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
||||
|
||||
@@ -232,7 +232,6 @@ void do_grab_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -246,7 +245,6 @@ void do_grab_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, grab_delta, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -258,13 +256,13 @@ void do_grab_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, grab_delta, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,6 @@ void do_inflate_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -222,7 +221,6 @@ void do_inflate_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, scale, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -234,13 +232,13 @@ void do_inflate_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, scale, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +410,6 @@ void do_layer_brush(const Depsgraph &depsgraph,
|
||||
tls,
|
||||
displacement,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -429,7 +428,6 @@ void do_layer_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, brush, object, nodes[i], tls, displacement);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -445,13 +443,13 @@ void do_layer_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, brush, object, nodes[i], tls, displacement);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -662,7 +662,6 @@ void do_multiplane_scrape_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
}
|
||||
});
|
||||
@@ -685,7 +684,6 @@ void do_multiplane_scrape_brush(const Depsgraph &depsgraph,
|
||||
nodes[i],
|
||||
object,
|
||||
tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -706,13 +704,13 @@ void do_multiplane_scrape_brush(const Depsgraph &depsgraph,
|
||||
nodes[i],
|
||||
object,
|
||||
tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,10 +112,10 @@ void do_displacement_eraser_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_node(depsgraph, sd, object, brush, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,10 +201,10 @@ void do_displacement_smear_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_node(depsgraph, ob, brush, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,6 @@ void do_pinch_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -283,7 +282,6 @@ void do_pinch_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, stroke_xz, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -295,13 +293,13 @@ void do_pinch_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, stroke_xz, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -542,9 +542,9 @@ static void do_topology_relax_brush_mesh(const Depsgraph &depsgraph,
|
||||
object,
|
||||
translations.as_mutable_span().slice(node_vert_offsets[pos]),
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -655,9 +655,9 @@ static void do_topology_relax_brush_grids(const Depsgraph &depsgraph,
|
||||
object,
|
||||
current_positions.as_mutable_span().slice(node_vert_offsets[pos]),
|
||||
translations.as_mutable_span().slice(node_vert_offsets[pos]));
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -750,9 +750,9 @@ static void do_topology_relax_brush_bmesh(const Depsgraph &depsgraph,
|
||||
object,
|
||||
translations.as_mutable_span().slice(node_vert_offsets[pos]),
|
||||
current_positions.as_span().slice(node_vert_offsets[pos]));
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
@@ -222,7 +222,6 @@ void do_rotate_brush(const Depsgraph &depsgraph,
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_faces(
|
||||
depsgraph, sd, brush, angle, positions_eval, nodes[i], object, tls, positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -236,7 +235,6 @@ void do_rotate_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, angle, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -248,13 +246,13 @@ void do_rotate_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, angle, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,6 @@ void do_scrape_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -245,7 +244,6 @@ void do_scrape_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, plane, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -257,13 +255,13 @@ void do_scrape_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, plane, ss.cache->bstrength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ BLI_NOINLINE static void do_smooth_brush_mesh(const Depsgraph &depsgraph,
|
||||
tls,
|
||||
new_positions.as_span().slice(node_vert_offsets[pos]),
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -310,7 +309,6 @@ void do_smooth_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
nodes[i],
|
||||
tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -326,13 +324,13 @@ void do_smooth_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, strength, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::update_bounds(depsgraph, object, pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,6 @@ void do_snake_hook_brush(const Depsgraph &depsgraph,
|
||||
nodes[i],
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -409,7 +408,6 @@ void do_snake_hook_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, &spvc, grab_delta, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -421,13 +419,13 @@ void do_snake_hook_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, &spvc, grab_delta, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,6 @@ void do_thumb_brush(const Depsgraph &depsgraph,
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_faces(
|
||||
depsgraph, sd, brush, offset, positions_eval, nodes[i], object, tls, positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -212,7 +211,6 @@ void do_thumb_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, offset, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -224,13 +222,13 @@ void do_thumb_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, offset, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,6 @@ void do_topology_slide_brush(const Depsgraph &depsgraph,
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -356,7 +355,6 @@ void do_topology_slide_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, object, brush, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -368,13 +366,13 @@ void do_topology_slide_brush(const Depsgraph &depsgraph,
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, object, brush, nodes[i], tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -1415,8 +1415,6 @@ void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object)
|
||||
update_shape_keys(
|
||||
object, mesh, *active_key, verts, tls.translations, positions_orig);
|
||||
}
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1433,7 +1431,6 @@ void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object)
|
||||
copy_v3_v3(vert->co, orig_co);
|
||||
}
|
||||
}
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -1457,12 +1454,12 @@ void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object)
|
||||
index++;
|
||||
}
|
||||
}
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
|
||||
/* Update normals for potentially-changed positions. Theoretically this may be unnecessary if
|
||||
* the brush restoring to the initial state doesn't use the normals, but we have no easy way to
|
||||
@@ -3322,6 +3319,7 @@ static void dynamic_topology_update(const Depsgraph &depsgraph,
|
||||
else {
|
||||
undo::push_nodes(depsgraph, ob, node_mask, undo::Type::Position);
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
node_mask.foreach_index([&](const int i) { BKE_pbvh_node_mark_update(nodes[i]); });
|
||||
node_mask.foreach_index([&](const int i) { BKE_pbvh_node_mark_topology_update(nodes[i]); });
|
||||
node_mask.foreach_index(GrainSize(1), [&](const int i) {
|
||||
|
||||
@@ -1310,7 +1310,6 @@ static void do_bend_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
deform_target,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1337,7 +1336,6 @@ static void do_bend_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1361,13 +1359,13 @@ static void do_bend_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -1607,7 +1605,6 @@ static void do_slide_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
deform_target,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1633,7 +1630,6 @@ static void do_slide_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1656,13 +1652,13 @@ static void do_slide_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -1887,7 +1883,6 @@ static void do_inflate_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
deform_target,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1912,7 +1907,6 @@ static void do_inflate_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1934,13 +1928,13 @@ static void do_inflate_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -2169,7 +2163,6 @@ static void do_grab_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
deform_target,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2195,7 +2188,6 @@ static void do_grab_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2218,13 +2210,13 @@ static void do_grab_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -2459,7 +2451,6 @@ static void do_twist_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
deform_target,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2486,7 +2477,6 @@ static void do_twist_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2510,13 +2500,13 @@ static void do_twist_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -2870,7 +2860,6 @@ static void do_smooth_brush(const Depsgraph &depsgraph,
|
||||
strength,
|
||||
deform_target,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2894,7 +2883,6 @@ static void do_smooth_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2915,13 +2903,13 @@ static void do_smooth_brush(const Depsgraph &depsgraph,
|
||||
boundary.initial_vert_position,
|
||||
strength,
|
||||
deform_target);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -1431,7 +1431,6 @@ void do_simulation_step(const Depsgraph &depsgraph,
|
||||
|
||||
cloth_sim.node_state[cloth_sim.node_state_index.lookup(&nodes[i])] =
|
||||
SCULPT_CLOTH_NODE_INACTIVE;
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1470,7 +1469,6 @@ void do_simulation_step(const Depsgraph &depsgraph,
|
||||
|
||||
cloth_sim.node_state[cloth_sim.node_state_index.lookup(&nodes[i])] =
|
||||
SCULPT_CLOTH_NODE_INACTIVE;
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1505,13 +1503,13 @@ void do_simulation_step(const Depsgraph &depsgraph,
|
||||
|
||||
cloth_sim.node_state[cloth_sim.node_state_index.lookup(&nodes[i])] =
|
||||
SCULPT_CLOTH_NODE_INACTIVE;
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
@@ -2354,7 +2352,6 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
||||
nodes[i],
|
||||
object,
|
||||
tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2373,7 +2370,6 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
apply_filter_forces_grids(
|
||||
*depsgraph, face_sets, filter_type, filter_strength, gravity, nodes[i], object, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -2386,13 +2382,13 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
apply_filter_forces_bmesh(
|
||||
*depsgraph, filter_type, filter_strength, gravity, nodes[i], object, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
|
||||
/* Activate all nodes. */
|
||||
|
||||
@@ -2481,7 +2481,6 @@ static void cache_initial_config_set(bContext *C, wmOperator *op, Cache &expand_
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
Object &ob = *CTX_data_active_object(C);
|
||||
const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt;
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
expand_cache.brush = BKE_paint_brush_for_read(&sd.paint);
|
||||
BKE_curvemapping_init(expand_cache.brush->curve);
|
||||
copy_v4_fl(expand_cache.fill_color, 1.0f);
|
||||
|
||||
@@ -1448,14 +1448,7 @@ static void edit_modify_coordinates(
|
||||
undo::push_begin(ob, op);
|
||||
undo::push_nodes(depsgraph, ob, node_mask, undo::Type::Position);
|
||||
|
||||
if (pbvh.type() == bke::pbvh::Type::Mesh) {
|
||||
MutableSpan<bke::pbvh::MeshNode> nodes = pbvh.nodes<bke::pbvh::MeshNode>();
|
||||
node_mask.foreach_index([&](const int i) { BKE_pbvh_node_mark_positions_update(nodes[i]); });
|
||||
}
|
||||
else if (pbvh.type() == bke::pbvh::Type::Grids) {
|
||||
MutableSpan<bke::pbvh::GridsNode> nodes = pbvh.nodes<bke::pbvh::GridsNode>();
|
||||
node_mask.foreach_index([&](const int i) { BKE_pbvh_node_mark_positions_update(nodes[i]); });
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
|
||||
switch (mode) {
|
||||
case EditMode::FairPositions:
|
||||
|
||||
@@ -396,8 +396,6 @@ static void calc_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -439,8 +437,6 @@ static void calc_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -478,8 +474,6 @@ static void calc_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -530,8 +524,6 @@ static void calc_inflate_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -563,8 +555,6 @@ static void calc_inflate_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -598,8 +588,6 @@ static void calc_inflate_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -650,8 +638,6 @@ static void calc_scale_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -683,8 +669,6 @@ static void calc_scale_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -717,8 +701,6 @@ static void calc_scale_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -785,8 +767,6 @@ static void calc_sphere_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -817,8 +797,6 @@ static void calc_sphere_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -850,8 +828,6 @@ static void calc_sphere_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -915,8 +891,6 @@ static void calc_random_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -949,8 +923,6 @@ static void calc_random_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -985,8 +957,6 @@ static void calc_random_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1055,8 +1025,6 @@ static void calc_relax_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1109,8 +1077,6 @@ static void calc_relax_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1147,8 +1113,6 @@ static void calc_relax_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1227,8 +1191,6 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1291,8 +1253,6 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1331,8 +1291,6 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1410,8 +1368,6 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
@@ -1448,8 +1404,6 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1495,8 +1449,6 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
@@ -1530,8 +1482,6 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1574,8 +1524,6 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
@@ -1610,8 +1558,6 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1730,8 +1676,6 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[node_index]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1819,8 +1763,6 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[node_index]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1893,8 +1835,6 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[node_index]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1945,8 +1885,6 @@ static void calc_enhance_details_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
write_translations(
|
||||
depsgraph, sd, object, positions_eval, verts, translations, positions_orig);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -1977,8 +1915,6 @@ static void calc_enhance_details_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -2010,8 +1946,6 @@ static void calc_enhance_details_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_positions, translations);
|
||||
apply_translations(translations, verts);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -2062,8 +1996,6 @@ static void calc_erase_displacement_filter(const Depsgraph &depsgraph,
|
||||
zero_disabled_axis_components(*ss.filter_cache, translations);
|
||||
clip_and_lock_translations(sd, ss, orig_data.positions, translations);
|
||||
apply_translations(translations, grids, subdiv_ccg);
|
||||
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -2306,9 +2238,12 @@ static void sculpt_mesh_filter_apply(bContext *C, wmOperator *op)
|
||||
break;
|
||||
}
|
||||
|
||||
bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob);
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
|
||||
ss.filter_cache->iteration_count++;
|
||||
|
||||
bke::pbvh::update_bounds(depsgraph, ob, *bke::object::pbvh_get(ob));
|
||||
bke::pbvh::update_bounds(depsgraph, ob, pbvh);
|
||||
flush_update_step(C, UpdateType::Position);
|
||||
}
|
||||
|
||||
|
||||
@@ -1540,7 +1540,6 @@ void do_pose_brush(const Depsgraph &depsgraph,
|
||||
BrushLocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_mesh(depsgraph, sd, brush, positions_eval, nodes[i], ob, tls, positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1554,7 +1553,6 @@ void do_pose_brush(const Depsgraph &depsgraph,
|
||||
BrushLocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_grids(depsgraph, sd, brush, nodes[i], ob, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -1566,13 +1564,13 @@ void do_pose_brush(const Depsgraph &depsgraph,
|
||||
BrushLocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
calc_bmesh(depsgraph, sd, brush, nodes[i], ob, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ static void gesture_apply_for_symmetry_pass(bContext &C, gesture::GestureData &g
|
||||
object,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -181,7 +180,6 @@ static void gesture_apply_for_symmetry_pass(bContext &C, gesture::GestureData &g
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
apply_projection_grids(sd, gesture_data, nodes[i], object, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -194,7 +192,6 @@ static void gesture_apply_for_symmetry_pass(bContext &C, gesture::GestureData &g
|
||||
LocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
apply_projection_bmesh(sd, gesture_data, nodes[i], object, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -208,6 +205,7 @@ static void gesture_apply_for_symmetry_pass(bContext &C, gesture::GestureData &g
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -307,18 +307,20 @@ static void sculpt_transform_all_vertices(const Depsgraph &depsgraph, const Scul
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
transform_node_mesh(
|
||||
depsgraph, sd, transform_mats, positions_eval, nodes[i], ob, tls, positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
case bke::pbvh::Type::Grids: {
|
||||
SubdivCCG &subdiv_ccg = *ob.sculpt->subdiv_ccg;
|
||||
MutableSpan<float3> positions = subdiv_ccg.positions;
|
||||
MutableSpan<bke::pbvh::GridsNode> nodes = pbvh.nodes<bke::pbvh::GridsNode>();
|
||||
threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) {
|
||||
TransformLocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
transform_node_grids(sd, transform_mats, nodes[i], ob, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -329,12 +331,14 @@ static void sculpt_transform_all_vertices(const Depsgraph &depsgraph, const Scul
|
||||
TransformLocalData &tls = all_tls.local();
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
transform_node_bmesh(sd, transform_mats, nodes[i], ob, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
BLI_NOINLINE static void calc_transform_translations(const float4x4 &elastic_transform_mat,
|
||||
@@ -505,7 +509,6 @@ static void transform_radius_elastic(const Depsgraph &depsgraph,
|
||||
ob,
|
||||
tls,
|
||||
positions_orig);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_mesh(positions_eval, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -520,7 +523,6 @@ static void transform_radius_elastic(const Depsgraph &depsgraph,
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
elastic_transform_node_grids(
|
||||
sd, params, elastic_transform_mat, elastic_transform_pivot, nodes[i], ob, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -533,7 +535,6 @@ static void transform_radius_elastic(const Depsgraph &depsgraph,
|
||||
node_mask.slice(range).foreach_index([&](const int i) {
|
||||
elastic_transform_node_bmesh(
|
||||
sd, params, elastic_transform_mat, elastic_transform_pivot, nodes[i], ob, tls);
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
bke::pbvh::update_node_bounds_bmesh(nodes[i]);
|
||||
});
|
||||
});
|
||||
@@ -541,6 +542,7 @@ static void transform_radius_elastic(const Depsgraph &depsgraph,
|
||||
}
|
||||
}
|
||||
}
|
||||
pbvh.tag_positions_changed(node_mask);
|
||||
bke::pbvh::flush_bounds_to_parents(pbvh);
|
||||
}
|
||||
|
||||
|
||||
@@ -1002,12 +1002,11 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data)
|
||||
for (std::unique_ptr<Node> &unode : step_data.nodes) {
|
||||
restore_position_grids(subdiv_ccg.positions, key, *unode, modified_grids);
|
||||
}
|
||||
node_mask.foreach_index([&](const int i) {
|
||||
const Span<int> grids = nodes[i].grids();
|
||||
if (indices_contain_true(modified_grids, grids)) {
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
}
|
||||
});
|
||||
const IndexMask changed_nodes = IndexMask::from_predicate(
|
||||
node_mask, GrainSize(1), memory, [&](const int i) {
|
||||
return indices_contain_true(modified_grids, nodes[i].grids());
|
||||
});
|
||||
pbvh.tag_positions_changed(changed_nodes);
|
||||
multires_mark_as_modified(depsgraph, &object, MULTIRES_COORDS_MODIFIED);
|
||||
}
|
||||
else {
|
||||
@@ -1018,11 +1017,12 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data)
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
Array<bool> modified_verts(mesh.verts_num, false);
|
||||
restore_position_mesh(object, step_data.nodes, modified_verts);
|
||||
node_mask.foreach_index([&](const int i) {
|
||||
if (indices_contain_true(modified_verts, nodes[i].all_verts())) {
|
||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||
}
|
||||
});
|
||||
|
||||
const IndexMask changed_nodes = IndexMask::from_predicate(
|
||||
node_mask, GrainSize(1), memory, [&](const int i) {
|
||||
return indices_contain_true(modified_verts, nodes[i].all_verts());
|
||||
});
|
||||
pbvh.tag_positions_changed(changed_nodes);
|
||||
}
|
||||
|
||||
if (tag_update) {
|
||||
|
||||
Reference in New Issue
Block a user