diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-04-28 21:41:37 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-04-28 21:41:49 +0300 |
commit | 859ac8fbc6eaaa303b04839538b590a5a240f857 (patch) | |
tree | 593d01ec0e30ab1b81fd793bb5385ea55bab5343 /source/blender/editors/screen | |
parent | 85ae4b87afa80527a36d3bd3164a9df6544f0c3b (diff) |
Fix ortho part of T44505
In this case we can calculate an offset without worrying about
perspective correction. Unfortunately if looking from a camera we still
have depth issues here. There's no really general case that can fix this
so I'm leaving this as is.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/glutil.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 618d6906b76..1ab03bfb7ef 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -991,7 +991,7 @@ void bgl_get_mats(bglMats *mats) /** * \note \a viewdist is only for ortho at the moment. */ -void bglPolygonOffset(float viewdist, float dist) +void bglPolygonOffset(float viewdist, float dist) { static float winmat[16], offset = 0.0; @@ -1007,7 +1007,16 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if (winmat[15] > 0.5f) offs = 0.00001f * dist * viewdist; // ortho tweaking + if (winmat[15] > 0.5f) { + int depthbits, i, depthmax = 1; + glGetIntegerv(GL_DEPTH_BITS, &depthbits); + + for (i = 1; i < depthbits; i++) { + depthmax = (depthmax << 1) + 1; + } + offs = (-1.0 / winmat[10]) * dist / (double) depthmax; + //offs = 0.00001f * dist * viewdist; // ortho tweaking + } else offs = 0.0001f * dist; // should be clipping value or so... winmat[14] -= offs; |