Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-02-04 22:06:30 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-02-05 17:02:15 +0300
commita131514d0f79f7b82be526438c125e35beab9f8f (patch)
tree16fb27a321d52435ba4f3e3e1f2cbaf4c36572ac /source/blender/editors/screen/glutil.c
parent112cf6eadff5642af21235aa1cd4eaecd575755d (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/screen/glutil.c')
-rw-r--r--source/blender/editors/screen/glutil.c55
1 files changed, 29 insertions, 26 deletions
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;