diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-02-04 22:06:30 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-02-05 17:02:15 +0300 |
commit | a131514d0f79f7b82be526438c125e35beab9f8f (patch) | |
tree | 16fb27a321d52435ba4f3e3e1f2cbaf4c36572ac /source/blender/editors | |
parent | 112cf6eadff5642af21235aa1cd4eaecd575755d (diff) |
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/BIF_glutil.h | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 55 |
2 files changed, 30 insertions, 26 deletions
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 1da8d19f800..e4111380bf1 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -106,6 +106,7 @@ void set_inverted_drawing(int enable); void setlinestyle(int nr); /* own working polygon offset */ +float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist); void bglPolygonOffset(float viewdist, float dist); /* **** Color management helper functions for GLSL display/transform ***** */ 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; |