Mid-Material save point

I get lazy with commits when following guided material. There's a design
challenge to approach, now. I'm saving here so I can revert changes in
case it goes sideways.

Materials are proving to be a little complicated in Rust semantics. The
Ray Tracing in a Weekend book uses shared_ptr's, but Rust doesn't really
like that. I'm doing references with lifetime annotations. Hopefully I
can get that the right way around to work out.

The materials themselves look like reasonable candidates for describing
as Enums. This takes away the ability to add new ones by simply impl'ing
a trait, but that was never gonna happen anyway. The code would be
modified and recompiled. There's no difference in maintenance cost if
that's a new struct impl'ing a trait, or adding enum members.
This commit is contained in:
2023-06-03 09:48:54 -05:00
commit 5cc0b49cd9
8 changed files with 830 additions and 0 deletions

13
src/material.rs Normal file
View File

@@ -0,0 +1,13 @@
use crate::ray::Ray;
use crate::hittable::HitRecord;
use crate::Vec3;
pub struct Material;
pub Scatter {
fn scatter(
ray_in: Ray, rec: HitRecord, attenuation: Vec3, scattered: Ray
) -> bool;
}