Cleanup lint in renderer.

This commit is contained in:
Bill Thiede 2019-10-13 07:51:16 -07:00
parent 5d5f3c7244
commit 92c8f1980c

View File

@ -294,16 +294,8 @@ enum Request {
} }
enum Response { enum Response {
Pixel { Pixel { x: usize, y: usize, pixel: Vec3 },
x: usize, Line { y: usize, pixels: Vec<Vec3> },
y: usize,
pixel: Vec3,
},
Line {
width: usize,
y: usize,
pixels: Vec<Vec3>,
},
} }
static PIXEL_COUNT: AtomicUsize = AtomicUsize::new(0); static PIXEL_COUNT: AtomicUsize = AtomicUsize::new(0);
@ -341,12 +333,16 @@ fn render_worker(
Request::Line { width, y } => { Request::Line { width, y } => {
trace!("tid {} width {} y {}", tid, width, y); trace!("tid {} width {} y {}", tid, width, y);
let pixels = (0..width).map(|x| render_pixel(scene, x, y)).collect(); let pixels = (0..width).map(|x| render_pixel(scene, x, y)).collect();
output_chan.send(Response::Line { width, y, pixels }); output_chan
.send(Response::Line { y, pixels })
.expect("failed to send pixel response");
} }
Request::Pixel { x, y } => { Request::Pixel { x, y } => {
trace!("tid {} x {} y {}", tid, x, y); trace!("tid {} x {} y {}", tid, x, y);
let pixel = render_pixel(scene, x, y); let pixel = render_pixel(scene, x, y);
output_chan.send(Response::Pixel { x, y, pixel }); output_chan
.send(Response::Pixel { x, y, pixel })
.expect("failed to send line response");
} }
}, },
} }
@ -378,12 +374,16 @@ pub fn render(scene: Scene, output_dir: &Path) -> std::result::Result<(), std::i
let batch_line_requests = true; let batch_line_requests = true;
if batch_line_requests { if batch_line_requests {
for y in 0..h { for y in 0..h {
pixel_req_tx.send(Request::Line { width: w, y }); pixel_req_tx
.send(Request::Line { width: w, y })
.expect("failed to send line request");
} }
} else { } else {
for y in 0..h { for y in 0..h {
for x in 0..w { for x in 0..w {
pixel_req_tx.send(Request::Pixel { x, y }); pixel_req_tx
.send(Request::Pixel { x, y })
.expect("failed to send pixel request");
} }
} }
} }
@ -435,11 +435,7 @@ pub fn render(scene: Scene, output_dir: &Path) -> std::result::Result<(), std::i
]), ]),
); );
} }
Response::Line { Response::Line { y, pixels } => {
width: _,
y,
pixels,
} => {
for (x, pixel) in pixels.iter().enumerate() { for (x, pixel) in pixels.iter().enumerate() {
let y_inv = scene.height - y - 1; let y_inv = scene.height - y - 1;
img.put_pixel( img.put_pixel(