ft: moved random scene code to function; cleaned up tri/quad/cube hit logic; made camera attributes private
This commit is contained in:
1 parent
71985a6c34
commit
64cad7eda6
11 files changed
+259
-221
No files matched your search
@@ -7,6 +7,11 @@ use crate::{
|
||||
vec3::Vec3,
|
||||
};
|
||||
|
||||
// TODO: overhaul texture implementation so we can support textures for arbitrary materials.
|
||||
// Basically remove this struct, and instead make lambertian/metal/dielectric/take either a texture
|
||||
// or a flat colour
|
||||
// I think we can use an enum ColourSource with a function to fetch a specific colour depending on
|
||||
// if we have a texture/flat colour. and yeah.
|
||||
#[derive(Debug)]
|
||||
pub struct Texture {
|
||||
source: DynamicImage,
|
||||
@@ -48,7 +53,7 @@ impl Texture {
|
||||
}
|
||||
|
||||
fn _idx(&self, u: f32, v: f32) -> usize {
|
||||
let x: usize = (u * ((self.width - 1) as f32)) as usize; // TODO: check these calcs work
|
||||
let x: usize = (u * ((self.width - 1) as f32)) as usize;
|
||||
let y: usize = (v * ((self.height - 1) as f32)) as usize;
|
||||
|
||||
y * self.width as usize + x
|
||||
|
||||