De-boxed many uses of Hit and Material.
Use of generic parameter directly where possible in structures instead of Box'd values. Added Material implementations for Box<Material> and Arc<Material> to aid in the automatic conversion when necessary to use a Sized value for Material. Implement From trait for [f32;3] to Vec3 to make some APIs Into<Vec3> which is a bit nicer to use.
This commit is contained in:
@@ -246,14 +246,12 @@ mod tests {
|
||||
Box::new(Sphere::new(
|
||||
Vec3::new(0., 0., 0.),
|
||||
0.5,
|
||||
Box::new(Lambertian::new(Box::new(ConstantTexture::new(Vec3::new(
|
||||
0.1, 0.2, 0.5,
|
||||
))))),
|
||||
Lambertian::new(ConstantTexture::new(Vec3::new(0.1, 0.2, 0.5))),
|
||||
)),
|
||||
Box::new(Sphere::new(
|
||||
Vec3::new(1., 0., 0.),
|
||||
0.5,
|
||||
Box::new(Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2)),
|
||||
Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2),
|
||||
)),
|
||||
],
|
||||
0.,
|
||||
@@ -274,19 +272,17 @@ mod tests {
|
||||
Box::new(Sphere::new(
|
||||
Vec3::new(0., 0., 0.),
|
||||
0.5,
|
||||
Box::new(Lambertian::new(Box::new(ConstantTexture::new(Vec3::new(
|
||||
0.1, 0.2, 0.5,
|
||||
))))),
|
||||
Lambertian::new(ConstantTexture::new(Vec3::new(0.1, 0.2, 0.5))),
|
||||
)),
|
||||
Box::new(Sphere::new(
|
||||
Vec3::new(1., 0., 0.),
|
||||
0.5,
|
||||
Box::new(Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2)),
|
||||
Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2),
|
||||
)),
|
||||
Box::new(Sphere::new(
|
||||
Vec3::new(0., 1., 0.),
|
||||
0.5,
|
||||
Box::new(Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2)),
|
||||
Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2),
|
||||
)),
|
||||
],
|
||||
0.,
|
||||
|
||||
Reference in New Issue
Block a user