[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56130] trunk/blender/source/blender/ editors/interface/view2d.c: View2D could potentially divide stuff by zero, giving bad matrices.

Ton Roosendaal ton at blender.org
Thu Apr 18 12:22:43 CEST 2013


Revision: 56130
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56130
Author:   ton
Date:     2013-04-18 10:22:42 +0000 (Thu, 18 Apr 2013)
Log Message:
-----------
View2D could potentially divide stuff by zero, giving bad matrices.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/view2d.c

Modified: trunk/blender/source/blender/editors/interface/view2d.c
===================================================================
--- trunk/blender/source/blender/editors/interface/view2d.c	2013-04-18 10:10:58 UTC (rev 56129)
+++ trunk/blender/source/blender/editors/interface/view2d.c	2013-04-18 10:22:42 UTC (rev 56130)
@@ -1022,15 +1022,19 @@
 void UI_view2d_view_ortho(View2D *v2d)
 {
 	rctf curmasked;
-	float xofs, yofs;
+	int sizex = BLI_rcti_size_x(&v2d->mask);
+	int sizey = BLI_rcti_size_y(&v2d->mask);
+	float xofs = 0.0f, yofs = 0.0f;
 	
 	/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
 	 * but only applied where requested
 	 */
 	/* XXX brecht: instead of zero at least use a tiny offset, otherwise
 	 * pixel rounding is effectively random due to float inaccuracy */
-	xofs = 0.001f * BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
-	yofs = 0.001f * BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+	if (sizex > 0)
+		xofs = 0.001f * BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
+	if (sizey > 0)
+		yofs = 0.001f * BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
 	
 	/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
 	view2d_map_cur_using_mask(v2d, &curmasked);




More information about the Bf-blender-cvs mailing list