diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-26 02:13:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-27 13:58:14 +0300 |
commit | 01f5ef82afddcdb078644ce6b63ce370784b2a84 (patch) | |
tree | c339dd0a88175b63b0b72c5babc4a5465d019590 /source/blender/draw/intern/draw_common.c | |
parent | 5c371cd36a8db2a322c52b5248061c1df01b0818 (diff) |
Cleanup: EditMesh: Remove DRW_STATE_OFFSET_*
Diffstat (limited to 'source/blender/draw/intern/draw_common.c')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 378324b4871..28b34bffe3e 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -31,6 +31,8 @@ #include "BKE_global.h" #include "BKE_colorband.h" +#include "BIF_glutil.h" + #include "draw_common.h" #if 0 @@ -1035,6 +1037,26 @@ struct GPUShader *volume_velocity_shader_get(bool use_needle) } } +DRWView *DRW_view_create_with_zoffset(const RegionView3D *rv3d, float offset) +{ + /* Create view with depth offset */ + const DRWView *default_view = DRW_view_default_get(); + float viewmat[4][4], winmat[4][4]; + DRW_view_viewmat_get(default_view, viewmat, false); + DRW_view_winmat_get(default_view, winmat, false); + + float viewdist = rv3d->dist; + + /* special exception for ortho camera (viewdist isnt used for perspective cameras) */ + if (rv3d->persp == RV3D_CAMOB && rv3d->is_persp == false) { + viewdist = 1.0f / max_ff(fabsf(winmat[0][0]), fabsf(winmat[1][1])); + } + + winmat[3][2] -= bglPolygonOffsetCalc((float *)winmat, viewdist, offset); + + return DRW_view_create_sub(default_view, viewmat, winmat); +} + /* ******************************************** COLOR UTILS ************************************ */ /* TODO FINISH */ |