Commit b4ed3a2e authored by Matt Keeler's avatar Matt Keeler Committed by Peter van der meulen

Get rid of some flooring in calculations

The Rust book says casting floats to ints will round towards 0 so for positive floats the behavior is the same as floor anyways.
parent 3814622c
......@@ -162,8 +162,8 @@ impl Display {
let height = cell_height as u32 * dimensions.lines_u32();
let new_viewport_size = PhysicalSize::new(
(width + 2 * u32::from(config.padding().x) * dpr.floor() as u32) as f64,
(height + 2 * u32::from(config.padding().y) * dpr.floor() as u32) as f64);
(width + 2 * (config.padding().x as f64 * dpr) as u32) as f64,
(height + 2 * (config.padding().y as f64 * dpr) as u32) as f64);
window.set_inner_size(new_viewport_size.to_logical(dpr));
renderer.resize(new_viewport_size, dpr);
......
......@@ -721,8 +721,8 @@ impl QuadRenderer {
pub fn resize(&mut self, size: PhysicalSize, dpr: f64) {
let (width, height) : (u32, u32) = size.into();
let padding_x = (self.program.padding_x as f64 * dpr).floor() as i32;
let padding_y = (self.program.padding_y as f64 * dpr).floor() as i32;
let padding_x = (self.program.padding_x as f64 * dpr) as i32;
let padding_y = (self.program.padding_y as f64 * dpr) as i32;
// viewport
unsafe {
......@@ -1039,8 +1039,8 @@ impl ShaderProgram {
fn update_projection(&self, width: f32, height: f32, dpr: f32) {
// Bounds check
if (width as u32) < (2 * (self.padding_x as f32 * dpr).floor() as u32) ||
(height as u32) < (2 * (self.padding_y as f32 * dpr).floor() as u32)
if (width as u32) < (2 * (self.padding_x as f32 * dpr) as u32) ||
(height as u32) < (2 * (self.padding_y as f32 * dpr) as u32)
{
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment