Stop rendering 0 size images

This commit is contained in:
Imbris 2020-06-14 12:05:27 -04:00
parent 24f6c585a5
commit aff43e6bea
2 changed files with 12 additions and 13 deletions

View File

@ -114,13 +114,14 @@ pub fn draw_vox(
sample_strat: SampleStrat,
) -> RgbaImage {
let output_size = output_size.map(|e| e as usize);
debug_assert!(output_size.map(|e| e != 0).reduce_and());
let ori_mat = Mat4::from(transform.ori);
let rotated_segment_dims = (ori_mat * Vec4::from_direction(segment.size().map(|e| e as f32)))
.xyz()
.map(|e| e.abs());
let mut dims = match sample_strat {
let dims = match sample_strat {
SampleStrat::None => output_size,
SampleStrat::SuperSampling(min_samples) => {
output_size * (min_samples as f32).sqrt().ceil() as usize
@ -137,15 +138,7 @@ pub fn draw_vox(
}
.into_array();
// TODO: Imbris please fix
if dims[0] == 0 {
log::warn!("Tried to render an image with a width of 0. Defaulting to 1.");
dims[0] = 1;
}
if dims[1] == 0 {
log::warn!("Tried to render an image with a height of 0. Defaulting to 1.");
dims[1] = 1;
}
debug_assert!(dims[0] != 0 && dims[1] != 0);
// Rendering buffers
let mut color = Buffer2d::new(dims, [0; 4]);

View File

@ -511,14 +511,20 @@ impl Ui {
)
};
let color =
srgba_to_linear(color.unwrap_or(conrod_core::color::WHITE).to_fsa().into());
let resolution = Vec2::new(
(gl_size.w * half_res.x).round() as u16,
(gl_size.h * half_res.y).round() as u16,
);
// Don't do anything if resolution is zero
if resolution.map(|e| e == 0).reduce_or() {
continue;
// TODO: consider logging uneeded elements
}
let color =
srgba_to_linear(color.unwrap_or(conrod_core::color::WHITE).to_fsa().into());
// Cache graphic at particular resolution.
let (uv_aabr, tex_id) = match graphic_cache.cache_res(
renderer,