From a131514d0f79f7b82be526438c125e35beab9f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 4 Feb 2019 20:06:30 +0100 Subject: Edit Mesh: Fix some problem with new implementation - Add manual depth offset to vertices and edges. - Revert to plain edge decoration. - Fix active edge coloring. - Remove active face display if not in face selection mode. - Add wide line support. --- source/blender/editors/screen/glutil.c | 55 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'source/blender/editors/screen/glutil.c') diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 498b2d5d036..512f1ba9bb5 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -341,6 +341,34 @@ void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state, /* *************** glPolygonOffset hack ************* */ +float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist) +{ + if (winmat[15] > 0.5f) { +#if 1 + return 0.00001f * dist * viewdist; // ortho tweaking +#else + static float depth_fac = 0.0f; + if (depth_fac == 0.0f) { + int depthbits; + glGetIntegerv(GL_DEPTH_BITS, &depthbits); + depth_fac = 1.0f / (float)((1 << depthbits) - 1); + } + offs = (-1.0 / winmat[10]) * dist * depth_fac; + + UNUSED_VARS(viewdist); +#endif + } + else { + /* This adjustment effectively results in reducing the Z value by 0.25%. + * + * winmat[14] actually evaluates to `-2 * far * near / (far - near)`, + * is very close to -0.2 with default clip range, and is used as the coefficient multiplied by `w / z`, + * thus controlling the z dependent part of the depth value. + */ + return winmat[14] * -0.0025f * dist; + } +} + /** * \note \a viewdist is only for ortho at the moment. */ @@ -349,8 +377,6 @@ void bglPolygonOffset(float viewdist, float dist) static float winmat[16], offset = 0.0f; if (dist != 0.0f) { - float offs; - // glEnable(GL_POLYGON_OFFSET_FILL); // glPolygonOffset(-1.0, -1.0); @@ -359,30 +385,7 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if (winmat[15] > 0.5f) { -#if 1 - offs = 0.00001f * dist * viewdist; // ortho tweaking -#else - static float depth_fac = 0.0f; - if (depth_fac == 0.0f) { - int depthbits; - glGetIntegerv(GL_DEPTH_BITS, &depthbits); - depth_fac = 1.0f / (float)((1 << depthbits) - 1); - } - offs = (-1.0 / winmat[10]) * dist * depth_fac; - - UNUSED_VARS(viewdist); -#endif - } - else { - /* This adjustment effectively results in reducing the Z value by 0.25%. - * - * winmat[14] actually evaluates to `-2 * far * near / (far - near)`, - * is very close to -0.2 with default clip range, and is used as the coefficient multiplied by `w / z`, - * thus controlling the z dependent part of the depth value. - */ - offs = winmat[14] * -0.0025f * dist; - } + float offs = bglPolygonOffsetCalc(winmat, viewdist, dist); winmat[14] -= offs; offset += offs; -- cgit v1.2.3