Spurious crashes - Switching to enums

Segfaults and stack overflows. I get overflows when running in either
debug or release. Segmentation faults when hooked up to GDB. I think it
may be related to the copying of uninitialized trait objects, but I
don't know.

I've decided the trait-based interface just isn't worth this. I'll
rearrange the materials into an Enum and a big match block.
This commit is contained in:
2023-06-04 09:19:25 -05:00
parent 5cc0b49cd9
commit d1bde8a1a8
4 changed files with 16 additions and 17 deletions

View File

@@ -3,11 +3,9 @@ use crate::ray::Ray;
use crate::hittable::HitRecord;
use crate::Vec3;
pub struct Material;
pub Scatter {
pub trait Material {
fn scatter(
ray_in: Ray, rec: HitRecord, attenuation: Vec3, scattered: Ray
&self, ray_in: Ray, rec: HitRecord, attenuation: Vec3, scattered: Ray
) -> bool;
}