diff options
Diffstat (limited to 'source/blender/draw/intern/draw_manager_data.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 4bed8cf6a40..302d726f74e 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -888,6 +888,29 @@ static void sculpt_debug_cb(void *user_data, } #endif +static void drw_sculpt_get_frustum_planes(Object *ob, float planes[4][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]); + + /* 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++) { + mul_m4_v4(tmat, planes[i]); + } +} + static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) { /* PBVH should always exist for non-empty meshes, created by depsgrah eval. */ @@ -896,7 +919,9 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) return; } - float(*planes)[4] = NULL; /* TODO proper culling. */ + float planes[4][4]; + drw_sculpt_get_frustum_planes(scd->ob, planes); + scd->fast_mode = false; const DRWContextState *drwctx = DRW_context_state_get(); |