ENABLE_THUMBNAIL_GENERATOR -> Reduce thumbnail size if exceeding 3D scene canvas size
This commit is contained in:
parent
2896e12a46
commit
f36dd833d2
1 changed files with 10 additions and 1 deletions
|
@ -1658,6 +1658,16 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
|||
static const float orange[] = { 0.99f, 0.49f, 0.26f };
|
||||
static const float gray[] = { 0.64f, 0.64f, 0.64f };
|
||||
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
unsigned int cnv_w = (unsigned int)cnv_size.get_width();
|
||||
unsigned int cnv_h = (unsigned int)cnv_size.get_height();
|
||||
if ((w > cnv_w) || (h > cnv_h))
|
||||
{
|
||||
float ratio = std::min((float)cnv_w / (float)w, (float)cnv_h / (float)h);
|
||||
w = (unsigned int)(ratio * (float)w);
|
||||
h = (unsigned int)(ratio * (float)h);
|
||||
}
|
||||
|
||||
thumbnail_data.set(w, h);
|
||||
|
||||
GLVolumePtrs visible_volumes;
|
||||
|
@ -1720,7 +1730,6 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
|||
#endif
|
||||
|
||||
// restore the framebuffer size to avoid flickering on the 3D scene
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
m_camera.apply_viewport(0, 0, cnv_size.get_width(), cnv_size.get_height());
|
||||
}
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
|
Loading…
Add table
Reference in a new issue