[Bf-blender-cvs] [e0ae693] master: Store bit-depth for reuse, replace loop with shift

Campbell Barton noreply at git.blender.org
Tue Apr 28 21:33:00 CEST 2015


Commit: e0ae6939242ed5a50f9904b87a059b4edf9aeabf
Author: Campbell Barton
Date:   Wed Apr 29 05:30:30 2015 +1000
Branches: master
https://developer.blender.org/rBe0ae6939242ed5a50f9904b87a059b4edf9aeabf

Store bit-depth for reuse, replace loop with shift

===================================================================

M	source/blender/editors/screen/glutil.c

===================================================================

diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index f29ba78..ca0047b 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;




More information about the Bf-blender-cvs mailing list