Skip to content

Commit f0ade8e

Browse files
committed
Headers assume implicit rtweekend.h include
Resolves #1628
1 parent 7fa2506 commit f0ade8e

36 files changed

+26
-123
lines changed

CHANGELOG.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ Change Log / Ray Tracing in One Weekend
22
====================================================================================================
33

44
# v4.0.1 (in progress)
5-
- Delete --
6-
- Change --
7-
- Fix --
8-
- New --
95

106
### Common
117
- Fix -- Big improvement to print version listing font size (#1595) and more compact line
@@ -14,6 +10,7 @@ Change Log / Ray Tracing in One Weekend
1410
- Fix -- Slight improvement to `rotate_y::hit()` function (#1484)
1511
- Fix -- Fixed possible bogus values from `random_unit_vector()` due to underflow (#1606)
1612
- Change -- Refactor sphere to use ray representation for animate center (#1621)
13+
- Change -- All headers assume implicit rtweekend.h include (#1628)
1714

1815
### In One Weekend
1916
- Fix -- Fixed usage of the term "unit cube" for a cube of diameter two (#1555, #1603)

books/RayTracingInOneWeekend.html

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,10 +1432,10 @@
14321432
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14331433
[Listing [rtweekend-initial]: <kbd>[rtweekend.h]</kbd> The rtweekend.h common header]
14341434

1435-
All main program files will include `rtweekend.h` first, so most other header files (where the bulk
1436-
of our code will reside) can assume these definitions are already available. Headers included inside
1437-
`rtweekend.h` still need to include any of their dependencies. We'll make some updates with this
1438-
assumption in mind.
1435+
Program files will include `rtweekend.h` first, so all other header files (where the bulk of our
1436+
code will reside) can implicitly assume that `rtweekend.h` has already been included. Header files
1437+
still need to explicitly include any other necessary header files. We'll make some updates with
1438+
these assumptions in mind.
14391439

14401440
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ delete
14411441
#include <iostream>
@@ -1766,8 +1766,6 @@
17661766
#ifndef CAMERA_H
17671767
#define CAMERA_H
17681768

1769-
#include "rtweekend.h"
1770-
17711769
#include "hittable.h"
17721770

17731771
class camera {
@@ -2028,13 +2026,26 @@
20282026
want to use this, you can obtain a random number with the conditions we need as follows:
20292027

20302028
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2029+
...
2030+
2031+
2032+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
20312033
#include <random>
2034+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2035+
2036+
...
2037+
20322038

2039+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
20332040
inline double random_double() {
20342041
static std::uniform_real_distribution<double> distribution(0.0, 1.0);
20352042
static std::mt19937 generator;
20362043
return distribution(generator);
20372044
}
2045+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2046+
2047+
...
2048+
20382049
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20392050
[Listing [random-double-alt]: <kbd>[rtweekend.h]</kbd> random_double(), alternate implementation]
20402051

@@ -2795,8 +2806,6 @@
27952806
#ifndef MATERIAL_H
27962807
#define MATERIAL_H
27972808

2798-
#include "rtweekend.h"
2799-
28002809
#include "hittable.h"
28012810

28022811
class material {
@@ -3064,9 +3073,6 @@
30643073
We need to modify the `ray_color()` function for all of our changes:
30653074

30663075
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
3067-
...
3068-
#include "rtweekend.h"
3069-
30703076
#include "hittable.h"
30713077
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
30723078
#include "material.h"

books/RayTracingTheNextWeek.html

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,6 @@
600600
#ifndef AABB_H
601601
#define AABB_H
602602

603-
#include "rtweekend.h"
604-
605603
class aabb {
606604
public:
607605
interval x, y, z;
@@ -675,11 +673,6 @@
675673
Finally, recall that some objects may be animated. Such objects should return their bounds over the
676674
entire range of motion, from time=0 to time=1.
677675

678-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
679-
...
680-
#include "rtweekend.h"
681-
682-
683676
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
684677
#include "aabb.h"
685678
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -827,10 +820,6 @@
827820
Now we'll update the `hittable_list` object, computing the bounds of its children. We'll update the
828821
bounding box incrementally as each new child is added.
829822

830-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
831-
#include "rtweekend.h"
832-
833-
834823
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
835824
#include "aabb.h"
836825
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -881,8 +870,6 @@
881870
#ifndef BVH_H
882871
#define BVH_H
883872

884-
#include "rtweekend.h"
885-
886873
#include "aabb.h"
887874
#include "hittable.h"
888875
#include "hittable_list.h"
@@ -946,8 +933,6 @@
946933
we haven't yet defined.
947934

948935
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
949-
#include "rtweekend.h"
950-
951936
#include "aabb.h"
952937
#include "hittable.h"
953938
#include "hittable_list.h"
@@ -1228,8 +1213,6 @@
12281213
#ifndef TEXTURE_H
12291214
#define TEXTURE_H
12301215

1231-
#include "rtweekend.h"
1232-
12331216
class texture {
12341217
public:
12351218
virtual ~texture() = default;
@@ -1337,8 +1320,6 @@
13371320
colors:
13381321

13391322
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1340-
#include "rtweekend.h"
1341-
13421323
#include "hittable.h"
13431324
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
13441325
#include "texture.h"
@@ -1825,10 +1806,6 @@
18251806
<div class='together'>
18261807
The `image_texture` class uses the `rtw_image` class:
18271808

1828-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1829-
#include "rtweekend.h"
1830-
1831-
18321809
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
18331810
#include "rtw_stb_image.h"
18341811
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -1968,8 +1945,6 @@
19681945
#ifndef PERLIN_H
19691946
#define PERLIN_H
19701947

1971-
#include "rtweekend.h"
1972-
19731948
class perlin {
19741949
public:
19751950
perlin() {
@@ -2023,10 +1998,6 @@
20231998
<div class='together'>
20241999
Now if we create an actual texture that takes these floats between 0 and 1 and creates grey colors:
20252000

2026-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2027-
#include "rtweekend.h"
2028-
2029-
20302001
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
20312002
#include "perlin.h"
20322003
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -2623,8 +2594,6 @@
26232594
#ifndef QUAD_H
26242595
#define QUAD_H
26252596

2626-
#include "rtweekend.h"
2627-
26282597
#include "hittable.h"
26292598

26302599
class quad : public hittable {
@@ -2817,6 +2786,7 @@
28172786
}
28182787

28192788
...
2789+
}
28202790
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28212791
[Listing [quad-plane2]: <kbd>[quad.h]</kbd> hit() method for the infinite plane]
28222792

@@ -2882,6 +2852,7 @@
28822852

28832853
set_bounding_box();
28842854
}
2855+
28852856
...
28862857

28872858
private:
@@ -3068,8 +3039,6 @@
30683039
vec3 normal;
30693040
double D;
30703041
};
3071-
3072-
#endif
30733042
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30743043
[Listing [quad-final]: <kbd>[quad.h]</kbd> Final quad class]
30753044

@@ -3522,8 +3491,6 @@
35223491
create a function that returns a box, by creating a `hittable_list` of six rectangles:
35233492

35243493
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
3525-
#include "rtweekend.h"
3526-
35273494
#include "hittable.h"
35283495
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
35293496
#include "hittable_list.h"
@@ -3989,8 +3956,6 @@
39893956
#ifndef CONSTANT_MEDIUM_H
39903957
#define CONSTANT_MEDIUM_H
39913958

3992-
#include "rtweekend.h"
3993-
39943959
#include "hittable.h"
39953960
#include "material.h"
39963961
#include "texture.h"
@@ -4103,8 +4068,6 @@
41034068
bigger (and dimmer so it doesn’t blow out the scene) for faster convergence:
41044069

41054070
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
4106-
#include "rtweekend.h"
4107-
41084071
#include "bvh.h"
41094072
#include "camera.h"
41104073
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight

books/RayTracingTheRestOfYourLife.html

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,8 +2276,6 @@
22762276
#ifndef ONB_H
22772277
#define ONB_H
22782278

2279-
#include "rtweekend.h"
2280-
22812279
class onb {
22822280
public:
22832281
onb(const vec3& n) {
@@ -2309,8 +2307,6 @@
23092307
We can rewrite our Lambertian material using this to get:
23102308

23112309
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2312-
#include "rtweekend.h"
2313-
23142310
#include "hittable.h"
23152311
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
23162312
#include "onb.h"
@@ -2730,8 +2726,6 @@
27302726
#ifndef PDF_H
27312727
#define PDF_H
27322728

2733-
#include "rtweekend.h"
2734-
27352729
#include "onb.h"
27362730

27372731

@@ -2800,8 +2794,6 @@
28002794
We can try this cosine PDF in the `ray_color()` function:
28012795

28022796
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2803-
#include "rtweekend.h"
2804-
28052797
#include "hittable.h"
28062798
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
28072799
#include "pdf.h"
@@ -2885,10 +2877,6 @@
28852877
---------------------------------------
28862878
Now we can try sampling directions toward a `hittable`, like the light.
28872879

2888-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2889-
#include "rtweekend.h"
2890-
2891-
28922880
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
28932881
#include "hittable_list.h"
28942882
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -3350,8 +3338,6 @@
33503338
We can redesign `material` and stuff all the new arguments into a class like we did for `hittable`:
33513339

33523340
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
3353-
#include "rtweekend.h"
3354-
33553341
#include "hittable.h"
33563342
#include "onb.h"
33573343
#include "texture.h"
@@ -3389,9 +3375,6 @@
33893375
The `lambertian` material becomes simpler:
33903376

33913377
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
3392-
#include "rtweekend.h"
3393-
3394-
33953378
#include "hittable.h"
33963379
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ delete
33973380
#include "onb.h"

src/InOneWeekend/camera.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
#include "hittable.h"
1715
#include "material.h"
1816

src/InOneWeekend/hittable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
class material;
1715

1816

src/InOneWeekend/hittable_list.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
#include "hittable.h"
1715

1816
#include <vector>

src/InOneWeekend/material.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
#include "hittable.h"
1715

1816

src/TheNextWeek/aabb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614

1715
class aabb {
1816
public:

src/TheNextWeek/bvh.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
#include "aabb.h"
1715
#include "hittable.h"
1816
#include "hittable_list.h"

src/TheNextWeek/camera.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
#include "hittable.h"
1715
#include "material.h"
1816

src/TheNextWeek/color.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "interval.h"
1515
#include "vec3.h"
1616

17+
1718
using color = vec3;
1819

1920

src/TheNextWeek/constant_medium.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "rtweekend.h"
15-
1614
#include "hittable.h"
1715
#include "material.h"
1816
#include "texture.h"

0 commit comments

Comments
 (0)