[Bf-blender-cvs] [859ac8f] master: Fix ortho part of T44505

Antony Riakiotakis noreply at git.blender.org
Tue Apr 28 20:42:00 CEST 2015


Commit: 859ac8fbc6eaaa303b04839538b590a5a240f857
Author: Antony Riakiotakis
Date:   Tue Apr 28 20:41:37 2015 +0200
Branches: master
https://developer.blender.org/rB859ac8fbc6eaaa303b04839538b590a5a240f857

Fix ortho part of T44505

In this case we can calculate an offset without worrying about
perspective correction. Unfortunately if looking from a camera we still
have depth issues here. There's no really general case that can fix this
so I'm leaving this as is.

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

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

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

diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 618d690..1ab03bf 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -991,7 +991,7 @@ void bgl_get_mats(bglMats *mats)
 /**
  * \note \a viewdist is only for ortho at the moment.
  */
-void bglPolygonOffset(float viewdist, float dist) 
+void bglPolygonOffset(float viewdist, float dist)
 {
 	static float winmat[16], offset = 0.0;
 	
@@ -1007,7 +1007,16 @@ void bglPolygonOffset(float viewdist, float dist)
 		
 		/* dist is from camera to center point */
 		
-		if (winmat[15] > 0.5f) offs = 0.00001f * dist * viewdist;  // ortho tweaking
+		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;
+			}
+			offs = (-1.0 / winmat[10]) * dist / (double) depthmax;
+			//offs = 0.00001f * dist * viewdist;  // ortho tweaking
+		}
 		else offs = 0.0001f * dist;  // should be clipping value or so...
 		
 		winmat[14] -= offs;




More information about the Bf-blender-cvs mailing list