Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2013-04-18 14:22:42 +0400
committerTon Roosendaal <ton@blender.org>2013-04-18 14:22:42 +0400
commitbde6a939e62514be4df552d41fbdca9d6aa873af (patch)
tree0f85da614c2f7c5aac0dc056c399c57f078572d0 /source/blender/editors/interface/view2d.c
parentdfa30f820797fdd00aa8677810e701f5183267f0 (diff)
View2D could potentially divide stuff by zero, giving bad matrices.
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r--source/blender/editors/interface/view2d.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index a7061ca0fed..74047abb17e 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1022,15 +1022,19 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
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);