RayTracing / raytracing.github.io

Main Web Site (Online Books)
https://raytracing.github.io/
Creative Commons Zero v1.0 Universal
8.72k stars 856 forks source link

material.h should include hittable.h #1608

Closed hollasch closed 1 month ago

hollasch commented 1 month ago

Currently in material.h we have a forward declaration of class hit_record. However, this line is unnecessary because in main.cc, we include hittable.h (where hit_record is defined) before we include material.h. Further, the class declaration is insufficient, as there are multiple member dereferences throughout material.h, which requires the hit_record definition.

The solution to this is to include hittable.h in the beginning of material.h. The current situation likely came about as I wrestled with the potential circular dependency where material classes needed access to hit_record, and hit_record has a shared pointer to a material instance. The current class material declaration at the top of hittable.h should be sufficient to address this.

hollasch commented 1 month ago

Done.