From b67ec03b8140a0a29d8ba0640530ea241e8a25d3 Mon Sep 17 00:00:00 2001 From: Steve Hollasch Date: Mon, 19 Aug 2024 12:04:23 -0700 Subject: [PATCH 1/2] Include hittable.h from material.h The prior version used a forward declaration of `hit_record`, which was insufficient since hittable.h lines referenced members of `hit_record`, and was unnecessary because hittable.h was included before material.h in practice. For this specific code, the inclusion is unnecessary, but is proper form. Resolves #1608 --- books/RayTracingInOneWeekend.html | 2 +- books/RayTracingTheNextWeek.html | 4 +--- books/RayTracingTheRestOfYourLife.html | 10 +++------- src/InOneWeekend/material.h | 2 +- src/TheNextWeek/material.h | 3 +-- src/TheRestOfYourLife/material.h | 3 +-- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/books/RayTracingInOneWeekend.html b/books/RayTracingInOneWeekend.html index 99dab9737..9fb74907f 100644 --- a/books/RayTracingInOneWeekend.html +++ b/books/RayTracingInOneWeekend.html @@ -2791,7 +2791,7 @@ #include "rtweekend.h" - class hit_record; + #include "hittable.h" class material { public: diff --git a/books/RayTracingTheNextWeek.html b/books/RayTracingTheNextWeek.html index a8c72bf66..f06ddb097 100644 --- a/books/RayTracingTheNextWeek.html +++ b/books/RayTracingTheNextWeek.html @@ -1346,13 +1346,11 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ #include "rtweekend.h" - + #include "hittable.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight #include "texture.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ - class hit_record; - ... class lambertian : public material { diff --git a/books/RayTracingTheRestOfYourLife.html b/books/RayTracingTheRestOfYourLife.html index f6e1256f2..de7f9af06 100644 --- a/books/RayTracingTheRestOfYourLife.html +++ b/books/RayTracingTheRestOfYourLife.html @@ -2286,14 +2286,12 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ #include "rtweekend.h" - + #include "hittable.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight #include "onb.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ #include "texture.h" - class hit_record; - class material { public: ... @@ -3329,11 +3327,10 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ #include "rtweekend.h" + #include "hittable.h" #include "onb.h" #include "texture.h" - class hit_record; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight class scatter_record { @@ -3370,6 +3367,7 @@ #include "rtweekend.h" + #include "hittable.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ delete #include "onb.h" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight @@ -3377,8 +3375,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ #include "texture.h" - class hit_record; - ... class lambertian : public material { diff --git a/src/InOneWeekend/material.h b/src/InOneWeekend/material.h index 80e792666..253beda49 100644 --- a/src/InOneWeekend/material.h +++ b/src/InOneWeekend/material.h @@ -13,7 +13,7 @@ #include "rtweekend.h" -class hit_record; +#include "hittable.h" class material { diff --git a/src/TheNextWeek/material.h b/src/TheNextWeek/material.h index 1b168879a..c1f0305d2 100644 --- a/src/TheNextWeek/material.h +++ b/src/TheNextWeek/material.h @@ -13,10 +13,9 @@ #include "rtweekend.h" +#include "hittable.h" #include "texture.h" -class hit_record; - class material { public: diff --git a/src/TheRestOfYourLife/material.h b/src/TheRestOfYourLife/material.h index 5914d4a5f..4e2c81051 100644 --- a/src/TheRestOfYourLife/material.h +++ b/src/TheRestOfYourLife/material.h @@ -13,11 +13,10 @@ #include "rtweekend.h" +#include "hittable.h" #include "pdf.h" #include "texture.h" -class hit_record; - class scatter_record { public: From 701a0e50edcde42c1fc553454f508d71d44600e4 Mon Sep 17 00:00:00 2001 From: Steve Hollasch Date: Mon, 19 Aug 2024 13:13:27 -0700 Subject: [PATCH 2/2] Update changelog for material.h include hittable.h --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index deece0ec7..7a196a9c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Change Log / Ray Tracing in One Weekend ### Common - Fix -- Big improvement to print version listing font size (#1595) and more compact line height for code listings in both print and browser. + - Change -- Include hittable.h from material.h; drop `hit_record` forward declaration (#1609) ### In One Weekend - Fix -- Fixed usage of the term "unit cube" for a cube of diameter two (#1555, #1603)