diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-21 11:35:59 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-22 14:29:04 +0300 |
commit | b944a6698659511b7c37c5bb33aa22df8c52826c (patch) | |
tree | 2c6a93925e8c2dd04efdc1522cfa84d8186124a8 /source/blender/draw/engines | |
parent | 21dc2816d6bb0a2a85e3a208830b629eb916ded0 (diff) |
GPencil: Use DRW_view_* API instead of DRW_viewport_matrix_*
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/gpencil/gpencil_engine.h | 4 | ||||
-rw-r--r-- | source/blender/draw/engines/gpencil/gpencil_render.c | 37 |
2 files changed, 21 insertions, 20 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 9ebd168bc4c..5dab0a56b63 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -187,9 +187,7 @@ typedef struct GPENCIL_Storage { float mix_stroke_factor; /* Render Matrices and data */ - float persmat[4][4], persinv[4][4]; - float viewmat[4][4], viewinv[4][4]; - float winmat[4][4], wininv[4][4]; + DRWView *view; float view_vecs[2][4]; /* vec4[2] */ float grid_matrix[4][4]; diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c index e6a3f45d60d..e4d099fbfdb 100644 --- a/source/blender/draw/engines/gpencil/gpencil_render.c +++ b/source/blender/draw/engines/gpencil/gpencil_render.c @@ -94,26 +94,26 @@ void GPENCIL_render_init(GPENCIL_Data *ved, RenderEngine *engine, struct Depsgra } /* Set the pers & view matrix. */ + float winmat[4][4], viewmat[4][4], viewinv[4][4], persmat[4][4]; + struct Object *camera = DEG_get_evaluated_object(depsgraph, RE_GetCamera(engine->re)); float frame = BKE_scene_frame_get(scene); - RE_GetCameraWindow(engine->re, camera, frame, stl->storage->winmat); - RE_GetCameraModelMatrix(engine->re, camera, stl->storage->viewinv); + RE_GetCameraWindow(engine->re, camera, frame, winmat); + RE_GetCameraModelMatrix(engine->re, camera, viewinv); + + invert_m4_m4(viewmat, viewinv); - invert_m4_m4(stl->storage->viewmat, stl->storage->viewinv); - mul_m4_m4m4(stl->storage->persmat, stl->storage->winmat, stl->storage->viewmat); - invert_m4_m4(stl->storage->persinv, stl->storage->persmat); - invert_m4_m4(stl->storage->wininv, stl->storage->winmat); + DRWView *view = DRW_view_create(viewmat, winmat, NULL, NULL, NULL); + DRW_view_default_set(view); + DRW_view_set_active(view); - DRW_viewport_matrix_override_set(stl->storage->persmat, DRW_MAT_PERS); - DRW_viewport_matrix_override_set(stl->storage->persinv, DRW_MAT_PERSINV); - DRW_viewport_matrix_override_set(stl->storage->winmat, DRW_MAT_WIN); - DRW_viewport_matrix_override_set(stl->storage->wininv, DRW_MAT_WININV); - DRW_viewport_matrix_override_set(stl->storage->viewmat, DRW_MAT_VIEW); - DRW_viewport_matrix_override_set(stl->storage->viewinv, DRW_MAT_VIEWINV); + DRW_view_persmat_get(view, persmat, false); /* calculate pixel size for render */ - stl->storage->render_pixsize = get_render_pixelsize( - stl->storage->persmat, viewport_size[0], viewport_size[1]); + stl->storage->render_pixsize = get_render_pixelsize(persmat, viewport_size[0], viewport_size[1]); + + stl->storage->view = view; + /* INIT CACHE */ GPENCIL_cache_init(vedata); } @@ -180,8 +180,8 @@ static void GPENCIL_render_update_vecs(GPENCIL_Data *vedata) GPENCIL_StorageList *stl = vedata->stl; float invproj[4][4], winmat[4][4]; - DRW_viewport_matrix_get(winmat, DRW_MAT_WIN); - DRW_viewport_matrix_get(invproj, DRW_MAT_WININV); + DRW_view_winmat_get(NULL, winmat, false); + DRW_view_winmat_get(NULL, invproj, true); /* this is separated to keep function equal to Eevee for future reuse of same code */ GPENCIL_render_update_viewvecs(invproj, winmat, stl->storage->view_vecs); @@ -211,6 +211,9 @@ static void GPENCIL_render_result_z(struct RenderLayer *rl, GPENCIL_render_update_vecs(vedata); + float winmat[4][4]; + DRW_view_persmat_get(stl->storage->view, winmat, false); + /* Convert ogl depth [0..1] to view Z [near..far] */ for (int i = 0; i < BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect); i++) { if (rp->rect[i] == 1.0f) { @@ -219,7 +222,7 @@ static void GPENCIL_render_result_z(struct RenderLayer *rl, else { if (is_persp) { rp->rect[i] = rp->rect[i] * 2.0f - 1.0f; - rp->rect[i] = stl->storage->winmat[3][2] / (rp->rect[i] + stl->storage->winmat[2][2]); + rp->rect[i] = winmat[3][2] / (rp->rect[i] + winmat[2][2]); } else { rp->rect[i] = -stl->storage->view_vecs[0][2] + |