Revision: 56129
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56129
Author:   ton
Date:     2013-04-18 10:10:58 +0000 (Thu, 18 Apr 2013)
Log Message:
-----------
Bug fix #34943

With extreme narrow scaled editors, the slider/mask code in View3d could deliver
zero sized or invalid window matrices.

Needs confirmation from Sergey if it works :)

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 
09:12:06 UTC (rev 56128)
+++ trunk/blender/source/blender/editors/interface/view2d.c     2013-04-18 
10:10:58 UTC (rev 56129)
@@ -997,19 +997,24 @@
        *curmasked = v2d->cur;
        
        if (view2d_scroll_mapped(v2d->scroll)) {
-               float dx = BLI_rctf_size_x(&v2d->cur) / 
((float)(BLI_rcti_size_x(&v2d->mask) + 1));
-               float dy = BLI_rctf_size_y(&v2d->cur) / 
((float)(BLI_rcti_size_y(&v2d->mask) + 1));
+               float sizex = BLI_rcti_size_x(&v2d->mask);
+               float sizey = BLI_rcti_size_y(&v2d->mask);
                
-               if (v2d->mask.xmin != 0)
-                       curmasked->xmin -= dx * (float)v2d->mask.xmin;
-               if (v2d->mask.xmax + 1 != v2d->winx)
-                       curmasked->xmax += dx * (float)(v2d->winx - 
v2d->mask.xmax - 1);
-               
-               if (v2d->mask.ymin != 0)
-                       curmasked->ymin -= dy * (float)v2d->mask.ymin;
-               if (v2d->mask.ymax + 1 != v2d->winy)
-                       curmasked->ymax += dy * (float)(v2d->winy - 
v2d->mask.ymax - 1);
-               
+               /* prevent tiny or narrow regions to get invalid coordinates - 
mask can get negative even... */
+               if (sizex > 0.0f && sizey > 0.0f) {
+                       float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
+                       float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
+                       
+                       if (v2d->mask.xmin != 0)
+                               curmasked->xmin -= dx * (float)v2d->mask.xmin;
+                       if (v2d->mask.xmax + 1 != v2d->winx)
+                               curmasked->xmax += dx * (float)(v2d->winx - 
v2d->mask.xmax - 1);
+                       
+                       if (v2d->mask.ymin != 0)
+                               curmasked->ymin -= dy * (float)v2d->mask.ymin;
+                       if (v2d->mask.ymax + 1 != v2d->winy)
+                               curmasked->ymax += dy * (float)(v2d->winy - 
v2d->mask.ymax - 1);
+               }
        }
 }
 

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to