diff options
author | Ton Roosendaal <ton@blender.org> | 2013-04-18 14:10:58 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2013-04-18 14:10:58 +0400 |
commit | dfa30f820797fdd00aa8677810e701f5183267f0 (patch) | |
tree | 707935dbc4db86616c9a2fb95cd60432624e0353 /source/blender/editors/interface/view2d.c | |
parent | 5f613886efdb0d4c24850c29d1d94dc2dee2e26b (diff) |
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 :)
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index a66169d54ae..a7061ca0fed 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -997,19 +997,24 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) *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)); - - 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); + float sizex = BLI_rcti_size_x(&v2d->mask); + float sizey = BLI_rcti_size_y(&v2d->mask); + /* 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); + } } } |