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:
authorCampbell Barton <ideasman42@gmail.com>2015-04-28 22:30:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-04-28 22:32:25 +0300
commite0ae6939242ed5a50f9904b87a059b4edf9aeabf (patch)
tree5752b0429c887d1294dceaed7a7cb6935785e3c3 /source/blender/editors/screen
parentd2ac3abbc2f9c66f5912b92768765ea326f800c5 (diff)
Store bit-depth for reuse, replace loop with shift
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/glutil.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index f29ba785180..ca0047b202a 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -1008,16 +1008,22 @@ void bglPolygonOffset(float UNUSED(viewdist), float dist)
/* dist is from camera to center point */
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;
+#if 0
+ 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)(depthbits - 1);
}
- offs = (-1.0 / winmat[10]) * dist / (double) depthmax;
- //offs = 0.00001f * dist * viewdist; // ortho tweaking
+ offs = (-1.0 / winmat[10]) * dist * depth_fac;
+#endif
+ }
+ else {
+ /* should be clipping value or so... */
+ offs = 0.0001f * dist;
}
- else offs = 0.0001f * dist; // should be clipping value or so...
winmat[14] -= offs;
offset += offs;