Skip to content

Commit 4d65783

Browse files
committed
Remove unused operator<< & const-medium debug code
When I created issue #1495, I must have been in the middle of a code progression, because it appeared to me that vec3::operator<< was unused. Turns out it _is_ used, in debug code for the `constant_medium::hit()` function. This code was created as a clean-up for the original scattered debug statements in this function. On review, however, this appears a bit odd, as the text does not mention the debuggability option (it's off by default), and no other code in the books has debug print code. Looking at it again, I think it should be removed, and readers are free to add whatever debug code they need at any stage in development. Resolves #1495
1 parent 3412059 commit 4d65783

File tree

6 files changed

+0
-48
lines changed

6 files changed

+0
-48
lines changed

books/RayTracingTheNextWeek.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,10 +4044,6 @@
40444044
{}
40454045

40464046
bool hit(const ray& r, interval ray_t, hit_record& rec) const override {
4047-
// Print occasional samples when debugging. To enable, set enableDebug true.
4048-
const bool enableDebug = false;
4049-
const bool debugging = enableDebug && random_double() < 0.00001;
4050-
40514047
hit_record rec1, rec2;
40524048

40534049
if (!boundary->hit(r, interval::universe, rec1))
@@ -4056,8 +4052,6 @@
40564052
if (!boundary->hit(r, interval(rec1.t+0.0001, infinity), rec2))
40574053
return false;
40584054

4059-
if (debugging) std::clog << "\nt_min=" << rec1.t << ", t_max=" << rec2.t << '\n';
4060-
40614055
if (rec1.t < ray_t.min) rec1.t = ray_t.min;
40624056
if (rec2.t > ray_t.max) rec2.t = ray_t.max;
40634057

@@ -4077,12 +4071,6 @@
40774071
rec.t = rec1.t + hit_distance / ray_length;
40784072
rec.p = r.at(rec.t);
40794073

4080-
if (debugging) {
4081-
std::clog << "hit_distance = " << hit_distance << '\n'
4082-
<< "rec.t = " << rec.t << '\n'
4083-
<< "rec.p = " << rec.p << '\n';
4084-
}
4085-
40864074
rec.normal = vec3(1,0,0); // arbitrary
40874075
rec.front_face = true; // also arbitrary
40884076
rec.mat = phase_function;

src/InOneWeekend/vec3.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ using point3 = vec3;
7373

7474
// Vector Utility Functions
7575

76-
inline std::ostream& operator<<(std::ostream& out, const vec3& v) {
77-
return out << v.e[0] << ' ' << v.e[1] << ' ' << v.e[2];
78-
}
79-
8076
inline vec3 operator+(const vec3& u, const vec3& v) {
8177
return vec3(u.e[0] + v.e[0], u.e[1] + v.e[1], u.e[2] + v.e[2]);
8278
}

src/TheNextWeek/constant_medium.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class constant_medium : public hittable {
3131
{}
3232

3333
bool hit(const ray& r, interval ray_t, hit_record& rec) const override {
34-
// Print occasional samples when debugging. To enable, set enableDebug true.
35-
const bool enableDebug = false;
36-
const bool debugging = enableDebug && random_double() < 0.00001;
37-
3834
hit_record rec1, rec2;
3935

4036
if (!boundary->hit(r, interval::universe, rec1))
@@ -43,8 +39,6 @@ class constant_medium : public hittable {
4339
if (!boundary->hit(r, interval(rec1.t+0.0001, infinity), rec2))
4440
return false;
4541

46-
if (debugging) std::clog << "\nt_min=" << rec1.t << ", t_max=" << rec2.t << '\n';
47-
4842
if (rec1.t < ray_t.min) rec1.t = ray_t.min;
4943
if (rec2.t > ray_t.max) rec2.t = ray_t.max;
5044

@@ -64,12 +58,6 @@ class constant_medium : public hittable {
6458
rec.t = rec1.t + hit_distance / ray_length;
6559
rec.p = r.at(rec.t);
6660

67-
if (debugging) {
68-
std::clog << "hit_distance = " << hit_distance << '\n'
69-
<< "rec.t = " << rec.t << '\n'
70-
<< "rec.p = " << rec.p << '\n';
71-
}
72-
7361
rec.normal = vec3(1,0,0); // arbitrary
7462
rec.front_face = true; // also arbitrary
7563
rec.mat = phase_function;

src/TheNextWeek/vec3.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ using point3 = vec3;
7373

7474
// Vector Utility Functions
7575

76-
inline std::ostream& operator<<(std::ostream& out, const vec3& v) {
77-
return out << v.e[0] << ' ' << v.e[1] << ' ' << v.e[2];
78-
}
79-
8076
inline vec3 operator+(const vec3& u, const vec3& v) {
8177
return vec3(u.e[0] + v.e[0], u.e[1] + v.e[1], u.e[2] + v.e[2]);
8278
}

src/TheRestOfYourLife/constant_medium.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class constant_medium : public hittable {
3131
{}
3232

3333
bool hit(const ray& r, interval ray_t, hit_record& rec) const override {
34-
// Print occasional samples when debugging. To enable, set enableDebug true.
35-
const bool enableDebug = false;
36-
const bool debugging = enableDebug && random_double() < 0.00001;
37-
3834
hit_record rec1, rec2;
3935

4036
if (!boundary->hit(r, interval::universe, rec1))
@@ -43,8 +39,6 @@ class constant_medium : public hittable {
4339
if (!boundary->hit(r, interval(rec1.t+0.0001, infinity), rec2))
4440
return false;
4541

46-
if (debugging) std::clog << "\nt_min=" << rec1.t << ", t_max=" << rec2.t << '\n';
47-
4842
if (rec1.t < ray_t.min) rec1.t = ray_t.min;
4943
if (rec2.t > ray_t.max) rec2.t = ray_t.max;
5044

@@ -64,12 +58,6 @@ class constant_medium : public hittable {
6458
rec.t = rec1.t + hit_distance / ray_length;
6559
rec.p = r.at(rec.t);
6660

67-
if (debugging) {
68-
std::clog << "hit_distance = " << hit_distance << '\n'
69-
<< "rec.t = " << rec.t << '\n'
70-
<< "rec.p = " << rec.p << '\n';
71-
}
72-
7361
rec.normal = vec3(1,0,0); // arbitrary
7462
rec.front_face = true; // also arbitrary
7563
rec.mat = phase_function;

src/TheRestOfYourLife/vec3.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ using point3 = vec3;
7373

7474
// Vector Utility Functions
7575

76-
inline std::ostream& operator<<(std::ostream& out, const vec3& v) {
77-
return out << v.e[0] << ' ' << v.e[1] << ' ' << v.e[2];
78-
}
79-
8076
inline vec3 operator+(const vec3& u, const vec3& v) {
8177
return vec3(u.e[0] + v.e[0], u.e[1] + v.e[1], u.e[2] + v.e[2]);
8278
}

0 commit comments

Comments
 (0)