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/draw/intern/draw_manager_data.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/draw/intern/draw_manager_data.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 302d726f74e..7887f6874b3 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -888,25 +888,17 @@ static void sculpt_debug_cb(void *user_data, } #endif -static void drw_sculpt_get_frustum_planes(Object *ob, float planes[4][4]) +static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4]) { /* TODO: take into account partial redraw for clipping planes. */ - float frustum_planes[6][4]; - DRW_view_frustum_planes_get(DRW_view_default_get(), frustum_planes); - - /* PBVH only needs X/Y clipping planes, no Z depth. - * TODO: support Z depth clipping in PBVH. */ - copy_v4_v4(planes[0], frustum_planes[0]); - copy_v4_v4(planes[1], frustum_planes[1]); - copy_v4_v4(planes[2], frustum_planes[3]); - copy_v4_v4(planes[3], frustum_planes[5]); + DRW_view_frustum_planes_get(DRW_view_default_get(), planes); /* Transform clipping planes to object space. Transforming a plane with a * 4x4 matrix is done by multiplying with the tranpose inverse. The inverse * cancels out here since we transform by inverse(obmat). */ float tmat[4][4]; transpose_m4_m4(tmat, ob->obmat); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 6; i++) { mul_m4_v4(tmat, planes[i]); } } @@ -919,8 +911,9 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) return; } - float planes[4][4]; + float planes[6][4]; drw_sculpt_get_frustum_planes(scd->ob, planes); + PBVHFrustumPlanes frustum = {.planes = planes, .num_planes = 6}; scd->fast_mode = false; @@ -936,7 +929,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg); BKE_pbvh_update_draw_buffers(pbvh, use_vcol); - BKE_pbvh_draw_cb(pbvh, planes, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd); + BKE_pbvh_draw_cb(pbvh, &frustum, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd); #ifdef SCULPT_DEBUG_BUFFERS int node_nr = 0; |