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 :)
This commit is contained in:
Ton Roosendaal
2013-04-18 10:10:58 +00:00
parent 5f613886ef
commit dfa30f8207

View File

@@ -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);
}
}
}