Skip to content

Commit a7844ad

Browse files
committed
Merge remote-tracking branch 'origin/dev-patch' into dev-patch
2 parents 2710a1d + 2e602f3 commit a7844ad

File tree

10 files changed

+17
-32
lines changed

10 files changed

+17
-32
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Change Log -- Ray Tracing in One Weekend
77
- Fix: Added `fmin` to book text for `cos_theta` of `refract` (#732)
88
- Fix: Standardized naming for ray-t and time parameters (#746)
99
- Fix: `random_unit_vector()` was incorrect (#697)
10+
- Fix: Synchronize text and copies of `hittable.h`
11+
- Fix: Synchronize copies of `hittable_list.h`, `material.h`, `sphere.h`
1012

1113
### In One Weekend
1214

books/RayTracingInOneWeekend.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,6 @@
19581958

19591959
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
19601960
#include "rtweekend.h"
1961-
#include "ray.h"
19621961

19631962
class material;
19641963
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++

src/InOneWeekend/hittable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
//==============================================================================================
1313

1414
#include "rtweekend.h"
15-
#include "ray.h"
16-
1715

1816
class material;
1917

src/TheNextWeek/hittable.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
class material;
2020

21+
2122
struct hit_record {
2223
point3 p;
2324
vec3 normal;
@@ -135,8 +136,8 @@ rotate_y::rotate_y(shared_ptr<hittable> p, double angle) : ptr(p) {
135136

136137

137138
bool rotate_y::hit(const ray& r, double t_min, double t_max, hit_record& rec) const {
138-
point3 origin = r.origin();
139-
vec3 direction = r.direction();
139+
auto origin = r.origin();
140+
auto direction = r.direction();
140141

141142
origin[0] = cos_theta*r.origin()[0] - sin_theta*r.origin()[2];
142143
origin[2] = sin_theta*r.origin()[0] + cos_theta*r.origin()[2];
@@ -149,8 +150,8 @@ bool rotate_y::hit(const ray& r, double t_min, double t_max, hit_record& rec) co
149150
if (!ptr->hit(rotated_r, t_min, t_max, rec))
150151
return false;
151152

152-
point3 p = rec.p;
153-
vec3 normal = rec.normal;
153+
auto p = rec.p;
154+
auto normal = rec.normal;
154155

155156
p[0] = cos_theta*rec.p[0] + sin_theta*rec.p[2];
156157
p[2] = -sin_theta*rec.p[0] + cos_theta*rec.p[2];

src/TheNextWeek/hittable_list.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "hittable.h"
1717

18+
#include <memory>
1819
#include <vector>
1920

2021

src/TheNextWeek/material.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
#include "texture.h"
1818

1919

20-
double schlick(double cosine, double ref_idx) {
21-
auto r0 = (1-ref_idx) / (1+ref_idx);
22-
r0 = r0*r0;
23-
return r0 + (1-r0)*pow((1 - cosine),5);
24-
}
25-
26-
2720
class material {
2821
public:
2922
virtual color emitted(double u, double v, const point3& p) const {

src/TheNextWeek/sphere.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
#include "hittable.h"
1717

1818

19-
class sphere : public hittable {
19+
class sphere : public hittable {
2020
public:
2121
sphere() {}
22+
2223
sphere(point3 cen, double r, shared_ptr<material> m)
2324
: center(cen), radius(r), mat_ptr(m) {};
2425

src/TheRestOfYourLife/hittable_list.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "hittable.h"
1717

18+
#include <memory>
1819
#include <vector>
1920

2021

@@ -59,17 +60,12 @@ bool hittable_list::bounding_box(double time0, double time1, aabb& output_box) c
5960
if (objects.empty()) return false;
6061

6162
aabb temp_box;
62-
bool first_true = objects[0]->bounding_box(time0, time1, temp_box);
63-
64-
if (!first_true)
65-
return false;
66-
67-
output_box = temp_box;
63+
bool first_box = true;
6864

6965
for (const auto& object : objects) {
70-
if (!object->bounding_box(time0, time1, temp_box))
71-
return false;
72-
output_box = surrounding_box(output_box, temp_box);
66+
if (!object->bounding_box(time0, time1, temp_box)) return false;
67+
output_box = first_box ? temp_box : surrounding_box(output_box, temp_box);
68+
first_box = false;
7369
}
7470

7571
return true;

src/TheRestOfYourLife/material.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
#include "texture.h"
1818

1919

20-
double schlick(double cosine, double ref_idx) {
21-
auto r0 = (1-ref_idx) / (1+ref_idx);
22-
r0 = r0*r0;
23-
return r0 + (1-r0)*pow((1 - cosine),5);
24-
}
25-
26-
2720
struct scatter_record {
2821
ray specular_ray;
2922
bool is_specular;

src/TheRestOfYourLife/sphere.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
#include "onb.h"
1818

1919

20-
class sphere : public hittable {
20+
class sphere : public hittable {
2121
public:
2222
sphere() {}
23+
2324
sphere(point3 cen, double r, shared_ptr<material> m)
2425
: center(cen), radius(r), mat_ptr(m) {};
2526

0 commit comments

Comments
 (0)