[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52673] trunk/blender/source/blender: fix for r51636 - making the lens work in ortho mode made view-all and local-view operators give bad zoom levels .

Campbell Barton ideasman42 at gmail.com
Fri Nov 30 07:10:04 CET 2012


Revision: 52673
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52673
Author:   campbellbarton
Date:     2012-11-30 06:10:01 +0000 (Fri, 30 Nov 2012)
Log Message:
-----------
fix for r51636 - making the lens work in ortho mode made view-all and local-view operators give bad zoom levels.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51636

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/camera.c
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
    trunk/blender/source/blender/editors/space_view3d/view3d_view.c

Modified: trunk/blender/source/blender/blenkernel/intern/camera.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/camera.c	2012-11-30 05:29:34 UTC (rev 52672)
+++ trunk/blender/source/blender/blenkernel/intern/camera.c	2012-11-30 06:10:01 UTC (rev 52673)
@@ -267,6 +267,7 @@
 		params->clipsta = -params->clipend;
 
 		params->is_ortho = TRUE;
+		/* make sure any changes to this match ED_view3d_radius_to_ortho_dist() */
 		params->ortho_scale = rv3d->dist * sensor_size / v3d->lens;
 		params->zoom = 2.0f;
 	}

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2012-11-30 05:29:34 UTC (rev 52672)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2012-11-30 06:10:01 UTC (rev 52673)
@@ -219,8 +219,10 @@
 void ED_view3d_clipping_disable(void);
 
 float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]);
-float ED_view3d_dist_from_radius(const float angle, const float radius);
 
+float ED_view3d_radius_to_persp_dist(const float angle, const float radius);
+float ED_view3d_radius_to_ortho_dist(const float lens, const float radius);
+
 void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]);
 
 /* backbuffer select and draw support */

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2012-11-30 05:29:34 UTC (rev 52672)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2012-11-30 06:10:01 UTC (rev 52673)
@@ -2238,7 +2238,7 @@
 				lens = v3d->lens;
 				sensor_size = DEFAULT_SENSOR_WIDTH;
 			}
-			size = ED_view3d_dist_from_radius(focallength_to_fov(lens, sensor_size), size / 2.0f);
+			size = ED_view3d_radius_to_persp_dist(focallength_to_fov(lens, sensor_size), size / 2.0f);
 
 			/* do not zoom closer than the near clipping plane */
 			size = max_ff(size, v3d->near * 1.5f);
@@ -2250,7 +2250,7 @@
 			}
 			else {
 				/* adjust zoom so it looks nicer */
-				size *= 0.7f;
+				size = ED_view3d_radius_to_ortho_dist(v3d->lens, size / 2.0f);
 			}
 		}
 	}

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2012-11-30 05:29:34 UTC (rev 52672)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2012-11-30 06:10:01 UTC (rev 52673)
@@ -1029,7 +1029,7 @@
 	View3D *v3d = sa->spacedata.first;
 	Base *base;
 	float min[3], max[3], box[3];
-	float size = 0.0, size_persp;
+	float size = 0.0f, size_persp = 0.0f, size_ortho = 0.0f;
 	unsigned int locallay;
 	int ok = FALSE;
 
@@ -1074,7 +1074,8 @@
 		size = max_ff(size, v3d->near * 1.5f);
 
 		/* perspective size (we always switch out of camera view so no need to use its lens size) */
-		size_persp = ED_view3d_dist_from_radius(focallength_to_fov(v3d->lens, DEFAULT_SENSOR_WIDTH), size / 2.0f);
+		size_persp = ED_view3d_radius_to_persp_dist(focallength_to_fov(v3d->lens, DEFAULT_SENSOR_WIDTH), size / 2.0f);
+		size_ortho = ED_view3d_radius_to_ortho_dist(v3d->lens, size / 2.0f);
 	}
 	
 	if (ok == TRUE) {
@@ -1103,7 +1104,7 @@
 					rv3d->dist = size_persp;
 				}
 				else {
-					rv3d->dist = size * 0.7f;
+					rv3d->dist = size_ortho;
 				}
 
 				/* correction for window aspect ratio */
@@ -1526,12 +1527,16 @@
 	        ) * rv3d->pixsize;
 }
 
-/* use for perspective view only */
-float ED_view3d_dist_from_radius(const float angle, const float radius)
+float ED_view3d_radius_to_persp_dist(const float angle, const float radius)
 {
-	return radius * fabsf(1.0f / cosf((((float)M_PI) - angle) / 2.0f));
+	return (radius / 2.0f) * fabsf(1.0f / cosf((((float)M_PI) - angle) / 2.0f));
 }
 
+float ED_view3d_radius_to_ortho_dist(const float lens, const float radius)
+{
+	return radius / (DEFAULT_SENSOR_WIDTH / lens);
+}
+
 /* view matrix properties utilities */
 
 /* unused */




More information about the Bf-blender-cvs mailing list