This commit is contained in:
parent
ea30bc9ed4
commit
4cddc8571f
@ -78,10 +78,10 @@ fn box_z_compare(ah: &Box<dyn Hit>, bh: &Box<dyn Hit>) -> std::cmp::Ordering {
|
|||||||
// returns a reference.)
|
// returns a reference.)
|
||||||
fn vec_first_into<T>(v: Vec<T>) -> T {
|
fn vec_first_into<T>(v: Vec<T>) -> T {
|
||||||
if v.len() != 1 {
|
if v.len() != 1 {
|
||||||
panic!(format!(
|
panic!(
|
||||||
"vec_first_into called for vector length != 1, length {}",
|
"vec_first_into called for vector length != 1, length {}",
|
||||||
v.len()
|
v.len()
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
v.into_iter().next().unwrap()
|
v.into_iter().next().unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,10 @@ pub enum KDTree {
|
|||||||
// returns a reference.)
|
// returns a reference.)
|
||||||
fn vec_first_into<T>(v: Vec<T>) -> T {
|
fn vec_first_into<T>(v: Vec<T>) -> T {
|
||||||
if v.len() != 1 {
|
if v.len() != 1 {
|
||||||
panic!(format!(
|
panic!(
|
||||||
"vec_first_into called for vector length != 1, length {}",
|
"vec_first_into called for vector length != 1, length {}",
|
||||||
v.len()
|
v.len()
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
v.into_iter().next().unwrap()
|
v.into_iter().next().unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,16 +27,16 @@ impl Texture for ImageTexture {
|
|||||||
let x = (u % 1. * (self.width - 1.)) as u32;
|
let x = (u % 1. * (self.width - 1.)) as u32;
|
||||||
let y = ((1. - v % 1.) * (self.height - 1.)) as u32;
|
let y = ((1. - v % 1.) * (self.height - 1.)) as u32;
|
||||||
if x >= self.width as u32 {
|
if x >= self.width as u32 {
|
||||||
panic!(format!(
|
panic!(
|
||||||
"u {} v {} x {} y {} w {} h {}",
|
"u {} v {} x {} y {} w {} h {}",
|
||||||
u, v, x, y, self.width, self.height
|
u, v, x, y, self.width, self.height
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
if y >= self.height as u32 {
|
if y >= self.height as u32 {
|
||||||
panic!(format!(
|
panic!(
|
||||||
"u {} v {} x {} y {} w {} h {}",
|
"u {} v {} x {} y {} w {} h {}",
|
||||||
u, v, x, y, self.width, self.height
|
u, v, x, y, self.width, self.height
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
let pixel = self.img.get_pixel(x, y);
|
let pixel = self.img.get_pixel(x, y);
|
||||||
Vec3::new(
|
Vec3::new(
|
||||||
|
|||||||
@ -27,7 +27,7 @@ fn hsv_to_rgb(h: f32, s: f32, v: f32) -> Vec3 {
|
|||||||
3 => Vec3::new(p, q, v),
|
3 => Vec3::new(p, q, v),
|
||||||
4 => Vec3::new(t, p, v),
|
4 => Vec3::new(t, p, v),
|
||||||
5 => Vec3::new(v, p, q),
|
5 => Vec3::new(v, p, q),
|
||||||
_ => panic!(format!("Unknown H value {}", h_i)),
|
_ => panic!("Unknown H value {}", h_i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ impl Index<usize> for Vec3 {
|
|||||||
0 => &self.x,
|
0 => &self.x,
|
||||||
1 => &self.y,
|
1 => &self.y,
|
||||||
2 => &self.z,
|
2 => &self.z,
|
||||||
_ => panic!(format!("idx {} out of range for vec3", idx)),
|
_ => panic!("idx {} out of range for vec3", idx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user