[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53536] trunk/blender/source/blender/ editors/space_node/node_view.c: fix for NODE_OT_view_all / NODE_OT_view_selected not working properly.

Campbell Barton ideasman42 at gmail.com
Thu Jan 3 17:36:20 CET 2013


Revision: 53536
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53536
Author:   campbellbarton
Date:     2013-01-03 16:36:17 +0000 (Thu, 03 Jan 2013)
Log Message:
-----------
fix for NODE_OT_view_all / NODE_OT_view_selected not working properly.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_node/node_view.c

Modified: trunk/blender/source/blender/editors/space_node/node_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_view.c	2013-01-03 15:52:31 UTC (rev 53535)
+++ trunk/blender/source/blender/editors/space_node/node_view.c	2013-01-03 16:36:17 UTC (rev 53536)
@@ -69,12 +69,15 @@
 	bNode *node;
 	rctf cur_new;
 	float oldwidth, oldheight, width, height;
+	float oldasp, asp;
 	int tot = 0;
 	int has_frame = FALSE;
 	
 	oldwidth  = BLI_rctf_size_x(&ar->v2d.cur);
 	oldheight = BLI_rctf_size_y(&ar->v2d.cur);
 
+	oldasp = oldwidth / oldheight;
+
 	BLI_rctf_init_minmax(&cur_new);
 
 	if (snode->edittree) {
@@ -93,6 +96,7 @@
 	if (tot) {
 		width  = BLI_rctf_size_x(&cur_new);
 		height = BLI_rctf_size_y(&cur_new);
+		asp = width / height;
 
 		/* for single non-frame nodes, don't zoom in, just pan view,
 		 * but do allow zooming out, this allows for big nodes to be zoomed out */
@@ -104,17 +108,15 @@
 			BLI_rctf_resize(&cur_new, oldwidth, oldheight);
 		}
 		else {
-			if (width > height) {
-				float newheight;
-				newheight = oldheight * width / oldwidth;
-				cur_new.ymin = cur_new.ymin - newheight / 4;
-				cur_new.ymax = cur_new.ymax + newheight / 4;
+			if (oldasp < asp) {
+				const float height_new = width / oldasp;
+				cur_new.ymin = cur_new.ymin - height_new / 2.0f;
+				cur_new.ymax = cur_new.ymax + height_new / 2.0f;
 			}
 			else {
-				float newwidth;
-				newwidth = oldwidth * height / oldheight;
-				cur_new.xmin = cur_new.xmin - newwidth / 4;
-				cur_new.xmax = cur_new.xmax + newwidth / 4;
+				const float width_new = height * oldasp;
+				cur_new.xmin = cur_new.xmin - width_new / 2.0f;
+				cur_new.xmax = cur_new.xmax + width_new / 2.0f;
 			}
 		}
 




More information about the Bf-blender-cvs mailing list