Skip to content

Commit 69fe1ba

Browse files
committed
perlin::turb() now requires both parameters
The original version defaulted the `depth` parameter to 7. This was the second instance of default parameters in the book source. The first was for the time value in the `ray` constructor, which we addressed by implementing two constructors. Generally, we're leaning away from using default parameter values in the interest of simplicity and clarity.
1 parent 5222ccc commit 69fe1ba

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ then.
1010
- Fix - Fix references from `random_in_hemisphere()` to `random_on_hemisphere()` (#1198)
1111

1212
### In One Weekend
13-
- Update reference to "Fundamentals of Interactive Computer Graphics" to "Computer Graphics:
14-
Principles and Practice". This is the name used by newer editions of the book.
13+
- Change - Update reference to "Fundamentals of Interactive Computer Graphics" to "Computer
14+
Graphics: Principles and Practice". This is the name used by newer editions of the book.
1515

1616
### The Next Week
17+
- Change - `perlin::turb()` no longer defaults the value for the depth parameter.
1718

1819
### The Rest of Your Life
1920

books/RayTracingTheNextWeek.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,7 @@
23062306
...
23072307
public:
23082308
...
2309-
double turb(const point3& p, int depth=7) const {
2309+
double turb(const point3& p, int depth) const {
23102310
auto accum = 0.0;
23112311
auto temp_p = p;
23122312
auto weight = 1.0;
@@ -2335,7 +2335,7 @@
23352335
color value(double u, double v, const point3& p) const override {
23362336
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
23372337
auto s = scale * p;
2338-
return color(1,1,1) * noise.turb(s);
2338+
return color(1,1,1) * noise.turb(s, 7);
23392339
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
23402340
}
23412341

@@ -2373,7 +2373,7 @@
23732373
color value(double u, double v, const point3& p) const override {
23742374
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
23752375
auto s = scale * p;
2376-
return color(1,1,1) * 0.5 * (1 + sin(s.z() + 10*noise.turb(s)));
2376+
return color(1,1,1) * 0.5 * (1 + sin(s.z() + 10*noise.turb(s, 7)));
23772377
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
23782378
}
23792379

src/TheNextWeek/perlin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class perlin {
5555
return perlin_interp(c, u, v, w);
5656
}
5757

58-
double turb(const point3& p, int depth=7) const {
58+
double turb(const point3& p, int depth) const {
5959
auto accum = 0.0;
6060
auto temp_p = p;
6161
auto weight = 1.0;

src/TheNextWeek/texture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class noise_texture : public texture {
7777

7878
color value(double u, double v, const point3& p) const override {
7979
auto s = scale * p;
80-
return color(1,1,1)*0.5*(1 + sin(s.z() + 10*noise.turb(s)));
80+
return color(1,1,1)*0.5*(1 + sin(s.z() + 10*noise.turb(s, 7)));
8181
}
8282

8383
private:

src/TheRestOfYourLife/perlin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class perlin {
5555
return perlin_interp(c, u, v, w);
5656
}
5757

58-
double turb(const point3& p, int depth=7) const {
58+
double turb(const point3& p, int depth) const {
5959
auto accum = 0.0;
6060
auto temp_p = p;
6161
auto weight = 1.0;

src/TheRestOfYourLife/texture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class noise_texture : public texture {
7777

7878
color value(double u, double v, const point3& p) const override {
7979
auto s = scale * p;
80-
return color(1,1,1)*0.5*(1 + sin(s.z() + 10*noise.turb(s)));
80+
return color(1,1,1)*0.5*(1 + sin(s.z() + 10*noise.turb(s, 7)));
8181
}
8282

8383
private:

0 commit comments

Comments
 (0)