Skip to content

Commit 134b8d4

Browse files
committed
Merge branch 'dev-patch' into dev-minor
2 parents f0a3002 + 3b3ee40 commit 134b8d4

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Change Log -- Ray Tracing in One Weekend
1414
----------------------------------------------------------------------------------------------------
1515
# v3.1.2 (in progress)
1616

17+
### _The Rest of Your Life_
18+
- Fix: Missing closing parenthesis in listing 10 (#603)
19+
- Fix: Tiny improvements to the lambertian::scatter() development (#604)
20+
- Fix: Correct geometry type and unit vector method in `ray_color()`, listing 20 (#606)
21+
1722

1823
----------------------------------------------------------------------------------------------------
1924
# v3.1.1 (2020-05-16)

books/RayTracingTheRestOfYourLife.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@
777777

778778
shared_ptr<hittable> box2 = make_shared<box>(point3(0,0,0), point3(165,165,165), white);
779779
box2 = make_shared<rotate_y>(box2, -18);
780-
box2 = make_shared<translate>(box2, vec3(130,0,65);
780+
box2 = make_shared<translate>(box2, vec3(130,0,65));
781781
world.add(box2);
782782

783783
point3 lookfrom(278, 278, -800);
@@ -857,8 +857,8 @@
857857
virtual bool scatter(
858858
const ray& r_in, const hit_record& rec, color& alb, ray& scattered, double& pdf
859859
) const {
860-
point3 target = rec.p + rec.normal + random_unit_vector();
861-
scattered = ray(rec.p, unit_vector(target-rec.p), r_in.time());
860+
auto direction = rec.normal + random_unit_vector();
861+
scattered = ray(rec.p, unit_vector(direction), r_in.time());
862862
alb = albedo->value(rec.u, rec.v, rec.p);
863863
pdf = dot(rec.normal, scattered.direction()) / pi;
864864
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -928,13 +928,17 @@
928928
randomly from the hemisphere above the surface. This would be $p(direction) = \frac{1}{2\pi}$.
929929

930930
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
931-
bool scatter(
931+
virtual bool scatter(
932932
const ray& r_in, const hit_record& rec, color& alb, ray& scattered, double& pdf
933933
) const {
934-
vec3 direction = random_in_hemisphere(rec.normal);
934+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
935+
auto direction = random_in_hemisphere(rec.normal);
936+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
935937
scattered = ray(rec.p, unit_vector(direction), r_in.time());
936938
alb = albedo->value(rec.u, rec.v, rec.p);
939+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
937940
pdf = 0.5 / pi;
941+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
938942
return true;
939943
}
940944
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1292,13 +1296,13 @@
12921296
We can rewrite our Lambertian material using this to get:
12931297

12941298
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1295-
bool scatter(
1299+
virtual bool scatter(
12961300
const ray& r_in, const hit_record& rec, color& alb, ray& scattered, double& pdf
12971301
) const {
12981302
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
12991303
onb uvw;
13001304
uvw.build_from_w(rec.normal);
1301-
vec3 direction = uvw.local(random_cosine_direction());
1305+
auto direction = uvw.local(random_cosine_direction());
13021306
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
13031307
scattered = ray(rec.p, unit_vector(direction), r_in.time());
13041308
alb = albedo->value(rec.u, rec.v, rec.p);
@@ -1393,10 +1397,10 @@
13931397
return emitted;
13941398

13951399
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1396-
auto on_light = vec3(random_double(213,343), 554, random_double(227,332));
1400+
auto on_light = point3(random_double(213,343), 554, random_double(227,332));
13971401
auto to_light = on_light - rec.p;
13981402
auto distance_squared = to_light.length_squared();
1399-
to_light.make_unit_vector();
1403+
to_light = unit_vector(to_light);
14001404

14011405
if (dot(to_light, rec.normal) < 0)
14021406
return emitted;
@@ -1952,7 +1956,9 @@
19521956
lambertian(shared_ptr<texture> a) : albedo(a) {}
19531957

19541958
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1955-
bool scatter(const ray& r_in, const hit_record& rec, scatter_record& srec) const {
1959+
virtual bool scatter(
1960+
const ray& r_in, const hit_record& rec, scatter_record& srec
1961+
) const {
19561962
srec.is_specular = false;
19571963
srec.attenuation = albedo->value(rec.u, rec.v, rec.p);
19581964
srec.pdf_ptr = new cosine_pdf(rec.normal);

books/acknowledgments.md.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- Jason Stone
4242
- Jean Buckley
4343
- Joey Cho
44+
- Kaan Eraslan
4445
- Lorenzo Mancini
4546
- Marcus Ottosson
4647
- Matthew Heimlich

0 commit comments

Comments
 (0)