more stuff
This commit is contained in:
parent
0000040001
commit
0000041053
6 changed files with 14 additions and 9 deletions
2
assignment-1b/.gitignore
vendored
2
assignment-1b/.gitignore
vendored
|
@ -5,3 +5,5 @@
|
|||
*.ppm
|
||||
*.zip
|
||||
*.pdf
|
||||
perf.data*
|
||||
flamegraph.svg
|
||||
|
|
|
@ -4,6 +4,10 @@ authors = ["Michael Zhang <zhan4854@umn.edu>"]
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# For profiling with flamegraphs
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
||||
[[bin]]
|
||||
name = "raytracer1b"
|
||||
path = "src/main.rs"
|
||||
|
|
|
@ -6,6 +6,7 @@ use assignment_1b::image::Image;
|
|||
use assignment_1b::ray::Ray;
|
||||
use assignment_1b::scene::Scene;
|
||||
use clap::Parser;
|
||||
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
|
||||
|
||||
/// Simple raycaster.
|
||||
#[derive(Parser)]
|
||||
|
@ -69,12 +70,8 @@ fn main() -> Result<()> {
|
|||
// Generate a parallel iterator for pixels
|
||||
// The iterator preserves order and uses row-major order
|
||||
let pixels_iter = (0..scene.image_height)
|
||||
// .into_par_iter()
|
||||
.flat_map(|y| {
|
||||
(0..scene.image_width)
|
||||
// .into_par_iter()
|
||||
.map(move |x| (x, y))
|
||||
});
|
||||
.into_par_iter()
|
||||
.flat_map(|y| (0..scene.image_width).into_par_iter().map(move |x| (x, y)));
|
||||
|
||||
// Loop through every single pixel of the output file
|
||||
let pixels = pixels_iter
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Scene {
|
|||
1 => LightKind::Point {
|
||||
location: read_vec3(0)?,
|
||||
},
|
||||
_ => bail!("Invalid w"),
|
||||
_ => bail!("Invalid w; must be either 0 or 1"),
|
||||
};
|
||||
let light = Light {
|
||||
kind,
|
||||
|
|
|
@ -33,9 +33,10 @@ pub fn compute_rotation_matrix(
|
|||
a: Vector3<f64>,
|
||||
b: Vector3<f64>,
|
||||
) -> Result<Matrix3<f64>> {
|
||||
// Special case: if a and b are in the same direction, just return the identity matrix
|
||||
// Special case: if a and b are in the same direction, just return the
|
||||
// identity matrix.
|
||||
if a.normalize() == b.normalize() {
|
||||
return Ok(Matrix3::identity())
|
||||
return Ok(Matrix3::identity());
|
||||
}
|
||||
|
||||
let cos_t = a.dot(&b);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
cargo-flamegraph
|
||||
cargo-watch
|
||||
imagemagick
|
||||
linuxPackages_latest.perf
|
||||
pandoc
|
||||
texlive.combined.scheme-full
|
||||
unzip
|
||||
|
|
Loading…
Reference in a new issue