Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r--source/blender/blenkernel/intern/pbvh.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index bfedd4d3f49..c925942d810 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -610,7 +610,9 @@ void BKE_pbvh_build_mesh(PBVH *pbvh,
}
MEM_freeN(prim_bbc);
- MEM_freeN(pbvh->vert_bitmap);
+
+ /* Clear the bitmap so it can be used as an update tag later on. */
+ BLI_bitmap_set_all(pbvh->vert_bitmap, false, totvert);
}
void BKE_pbvh_build_grids(PBVH *pbvh,
@@ -714,6 +716,8 @@ void BKE_pbvh_free(PBVH *pbvh)
MEM_freeN(pbvh->prim_indices);
}
+ MEM_SAFE_FREE(pbvh->vert_bitmap);
+
MEM_freeN(pbvh);
}
@@ -1021,8 +1025,7 @@ static void pbvh_update_normals_clear_task_cb(void *__restrict userdata,
const int totvert = node->uniq_verts;
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
- const MVert *mvert = &pbvh->verts[v];
- if (mvert->flag & ME_VERT_PBVH_UPDATE) {
+ if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
zero_v3(vnors[v]);
}
}
@@ -1065,7 +1068,7 @@ static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
for (int j = sides; j--;) {
const int v = vtri[j];
- if (pbvh->verts[v].flag & ME_VERT_PBVH_UPDATE) {
+ if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
/* NOTE: This avoids `lock, add_v3_v3, unlock`
* and is five to ten times quicker than a spin-lock.
* Not exact equivalent though, since atomicity is only ensured for one component
@@ -1094,13 +1097,12 @@ static void pbvh_update_normals_store_task_cb(void *__restrict userdata,
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
- MVert *mvert = &pbvh->verts[v];
/* No atomics necessary because we are iterating over uniq_verts only,
* so we know only this thread will handle this vertex. */
- if (mvert->flag & ME_VERT_PBVH_UPDATE) {
+ if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
normalize_v3(vnors[v]);
- mvert->flag &= ~ME_VERT_PBVH_UPDATE;
+ BLI_BITMAP_DISABLE(pbvh->vert_bitmap, v);
}
}
@@ -1117,7 +1119,7 @@ static void pbvh_faces_update_normals(PBVH *pbvh, PBVHNode **nodes, int totnode)
* bounding box of its adjacent faces will be as well.
* - However this is only true for the vertices that have actually been
* edited, not for all vertices in the nodes marked for update, so we
- * can only update vertices marked with ME_VERT_PBVH_UPDATE.
+ * can only update vertices marked in the `vert_bitmap`.
*/
PBVHUpdateData data = {
@@ -1826,6 +1828,12 @@ bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node)
return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyUnmasked);
}
+void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index)
+{
+ BLI_assert(pbvh->type == PBVH_FACES);
+ BLI_BITMAP_ENABLE(pbvh->vert_bitmap, index);
+}
+
void BKE_pbvh_node_get_verts(PBVH *pbvh,
PBVHNode *node,
const int **r_vert_indices,
@@ -1971,9 +1979,8 @@ bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node)
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
- const MVert *mvert = &pbvh->verts[v];
- if (mvert->flag & ME_VERT_PBVH_UPDATE) {
+ if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
return true;
}
}
@@ -2827,7 +2834,7 @@ void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], const int
/* no need for float comparison here (memory is exactly equal or not) */
if (memcmp(mvert->co, vertCos[a], sizeof(float[3])) != 0) {
copy_v3_v3(mvert->co, vertCos[a]);
- mvert->flag |= ME_VERT_PBVH_UPDATE;
+ BKE_pbvh_vert_mark_update(pbvh, a);
}
}