diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-27 15:44:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-27 15:59:41 +0300 |
commit | 770e91703d1196751432ef4a2db5ca7afed02aee (patch) | |
tree | 893865b32f87ccd1d6c04b442bd8c9bccad93ea2 /source/blender/blenkernel/intern/pbvh.c | |
parent | d3a98b2c3b44244bff3b0386f33a277286b26f59 (diff) |
Fix part of T70295: sculpt drawing not clipping PBVH behind the camera
Use all 6 clipping planes for drawing.
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh.c')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index eac18c79891..636a5c62e4d 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2167,13 +2167,14 @@ typedef enum { * Returns true if the AABB is at least partially within the frustum * (ok, not a real frustum), false otherwise. */ -static PlaneAABBIsect test_planes_aabb(const float bb_min[3], - const float bb_max[3], - const float (*planes)[4]) +static PlaneAABBIsect test_frustum_aabb(const float bb_min[3], + const float bb_max[3], + PBVHFrustumPlanes *frustum) { PlaneAABBIsect ret = ISECT_INSIDE; + float(*planes)[4] = frustum->planes; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < frustum->num_planes; i++) { float vmin[3], vmax[3]; for (int axis = 0; axis < 3; axis++) { @@ -2198,24 +2199,24 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3], return ret; } -bool BKE_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data) +bool BKE_pbvh_node_frustum_contain_AABB(PBVHNode *node, void *data) { const float *bb_min, *bb_max; /* BKE_pbvh_node_get_BB */ bb_min = node->vb.bmin; bb_max = node->vb.bmax; - return test_planes_aabb(bb_min, bb_max, data) != ISECT_OUTSIDE; + return test_frustum_aabb(bb_min, bb_max, data) != ISECT_OUTSIDE; } -bool BKE_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) +bool BKE_pbvh_node_frustum_exclude_AABB(PBVHNode *node, void *data) { const float *bb_min, *bb_max; /* BKE_pbvh_node_get_BB */ bb_min = node->vb.bmin; bb_max = node->vb.bmax; - return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE; + return test_frustum_aabb(bb_min, bb_max, data) != ISECT_INSIDE; } typedef struct PBVHNodeDrawCallbackData { @@ -2282,7 +2283,7 @@ void BKE_pbvh_update_draw_buffers(PBVH *bvh, bool show_vcol) * Version of #BKE_pbvh_draw that runs a callback. */ void BKE_pbvh_draw_cb(PBVH *bvh, - float (*planes)[4], + PBVHFrustumPlanes *frustum, void (*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers), void *user_data) { @@ -2291,9 +2292,9 @@ void BKE_pbvh_draw_cb(PBVH *bvh, .user_data = user_data, }; - if (planes) { + if (frustum) { BKE_pbvh_search_callback( - bvh, BKE_pbvh_node_planes_contain_AABB, planes, pbvh_node_draw_cb, &draw_data); + bvh, BKE_pbvh_node_frustum_contain_AABB, frustum, pbvh_node_draw_cb, &draw_data); } else { BKE_pbvh_search_callback(bvh, NULL, NULL, pbvh_node_draw_cb, &draw_data); |