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')
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h6
-rw-r--r--source/blender/blenkernel/intern/pbvh.c29
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h3
3 files changed, 35 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 2020d45ae86..a59ce816e26 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -81,6 +81,9 @@ typedef struct PBVHFrustumPlanes {
int num_planes;
} PBVHFrustumPlanes;
+void BKE_pbvh_set_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes);
+void BKE_pbvh_get_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes);
+
/* Callbacks */
/* returns 1 if the search should continue from this node, 0 otherwise */
@@ -190,7 +193,8 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh,
void BKE_pbvh_draw_cb(PBVH *bvh,
bool show_vcol,
bool update_only_visible,
- PBVHFrustumPlanes *frustum,
+ PBVHFrustumPlanes *update_frustum,
+ PBVHFrustumPlanes *draw_frustum,
void (*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers),
void *user_data);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 879f1e507ba..06622f0d009 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2683,7 +2683,8 @@ static bool pbvh_draw_search_cb(PBVHNode *node, void *data_v)
void BKE_pbvh_draw_cb(PBVH *bvh,
bool show_vcol,
bool update_only_visible,
- PBVHFrustumPlanes *frustum,
+ PBVHFrustumPlanes *update_frustum,
+ PBVHFrustumPlanes *draw_frustum,
void (*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers),
void *user_data)
{
@@ -2704,7 +2705,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
}
/* Gather visible nodes. */
- PBVHDrawSearchData data = {.frustum = frustum, .accum_update_flag = 0};
+ PBVHDrawSearchData data = {.frustum = update_frustum, .accum_update_flag = 0};
BKE_pbvh_search_gather(bvh, pbvh_draw_search_cb, &data, &nodes, &totnode);
if (update_only_visible && (data.accum_update_flag & update_flag)) {
@@ -2722,7 +2723,15 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
}
node->flag &= ~(PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers);
+ }
+
+ MEM_SAFE_FREE(nodes);
+
+ PBVHDrawSearchData draw_data = {.frustum = draw_frustum, .accum_update_flag = 0};
+ BKE_pbvh_search_gather(bvh, pbvh_draw_search_cb, &draw_data, &nodes, &totnode);
+ for (int a = 0; a < totnode; a++) {
+ PBVHNode *node = nodes[a];
if (!(node->flag & PBVH_FullyHidden)) {
draw_fn(user_data, node->draw_buffers);
}
@@ -2998,6 +3007,22 @@ void pbvh_show_face_sets_set(PBVH *bvh, bool show_face_sets)
bvh->show_face_sets = show_face_sets;
}
+void BKE_pbvh_set_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes)
+{
+ bvh->num_planes = planes->num_planes;
+ for (int i = 0; i < bvh->num_planes; i++) {
+ copy_v4_v4(bvh->planes[i], planes->planes[i]);
+ }
+}
+
+void BKE_pbvh_get_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes)
+{
+ planes->num_planes = bvh->num_planes;
+ for (int i = 0; i < planes->num_planes; i++) {
+ copy_v4_v4(planes->planes[i], bvh->planes[i]);
+ }
+}
+
void BKE_pbvh_parallel_range_settings(PBVHParallelSettings *settings,
bool use_threading,
int totnode)
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 21cb5649330..d3e42ac7705 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -168,6 +168,9 @@ struct PBVH {
int cd_vert_node_offset;
int cd_face_node_offset;
+ float planes[6][4];
+ int num_planes;
+
struct BMLog *bm_log;
struct SubdivCCG *subdiv_ccg;
};