Skip to content

Commit

Permalink
Wrap code listings in books to 96 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
hollasch committed Nov 5, 2019
1 parent f6343df commit 7275db1
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 119 deletions.
56 changes: 26 additions & 30 deletions books/RayTracingInOneWeekend.html
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,7 @@

class hittable {
public:
virtual bool hit(
const ray& r, double t_min, double t_max, hit_record& rec) const = 0;
virtual bool hit(const ray& r, double t_min, double t_max, hit_record& rec) const = 0;
};

#endif
Expand Down Expand Up @@ -735,15 +734,12 @@
public:
hittable_list() {}
hittable_list(hittable **l, int n) {list = l; list_size = n; }
virtual bool hit(
const ray& r, double tmin, double tmax, hit_record& rec) const;
virtual bool hit(const ray& r, double tmin, double tmax, hit_record& rec) const;
hittable **list;
int list_size;
};

bool hittable_list::hit(const ray& r, double t_min, double t_max,
hit_record& rec) const {

bool hittable_list::hit(const ray& r, double t_min, double t_max, hit_record& rec) const {
hit_record temp_rec;
bool hit_anything = false;
double closest_so_far = t_max;
Expand Down Expand Up @@ -951,9 +947,9 @@
vertical = vec3(0.0, 2.0, 0.0);
origin = vec3(0.0, 0.0, 0.0);
}

ray get_ray(double u, double v) {
return ray(origin,
lower_left_corner + u*horizontal + v*vertical - origin);
return ray(origin, lower_left_corner + u*horizontal + v*vertical - origin);
}

vec3 origin;
Expand Down Expand Up @@ -1247,8 +1243,8 @@
class material {
public:
virtual bool scatter(
const ray& r_in, const hit_record& rec, vec3& attenuation,
ray& scattered) const = 0;
const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered
) const = 0;
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Listing [material-initial]: <kbd>[material.h]</kbd> The material class]
Expand Down Expand Up @@ -1282,8 +1278,7 @@

class hittable {
public:
virtual bool hit(
const ray& r, double t_min, double t_max, hit_record& rec) const = 0;
virtual bool hit(const ray& r, double t_min, double t_max, hit_record& rec) const = 0;
};

#endif
Expand All @@ -1306,10 +1301,8 @@
class sphere: public hittable {
public:
sphere() {}
sphere(vec3 cen, double r, material *m)
: center(cen), radius(r), mat_ptr(m) {};
virtual bool hit(
const ray& r, double tmin, double tmax, hit_record& rec) const;
sphere(vec3 cen, double r, material *m) : center(cen), radius(r), mat_ptr(m) {};
virtual bool hit(const ray& r, double tmin, double tmax, hit_record& rec) const;
vec3 center;
double radius;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
Expand Down Expand Up @@ -1409,8 +1402,9 @@
class metal : public material {
public:
metal(const vec3& a) : albedo(a) {}
virtual bool scatter(const ray& r_in, const hit_record& rec,
vec3& attenuation, ray& scattered) const {
virtual bool scatter(
const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered
) const {
vec3 reflected = reflect(unit_vector(r_in.direction()), rec.normal);
scattered = ray(rec.p, reflected);
attenuation = albedo;
Expand Down Expand Up @@ -1622,8 +1616,9 @@
class dielectric : public material {
public:
dielectric(double ri) : ref_idx(ri) {}
virtual bool scatter(const ray& r_in, const hit_record& rec,
vec3& attenuation, ray& scattered) const {
virtual bool scatter(
const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered
) const {
vec3 outward_normal;
vec3 reflected = reflect(r_in.direction(), rec.normal);
double ni_over_nt;
Expand Down Expand Up @@ -1706,8 +1701,9 @@
class dielectric : public material {
public:
dielectric(double ri) : ref_idx(ri) {}
virtual bool scatter(const ray& r_in, const hit_record& rec,
vec3& attenuation, ray& scattered) const {
virtual bool scatter(
const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered
) const {
vec3 outward_normal;
vec3 reflected = reflect(r_in.direction(), rec.normal);
double ni_over_nt;
Expand Down Expand Up @@ -1825,8 +1821,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++

ray get_ray(double u, double v) {
return ray(origin,
lower_left_corner + u*horizontal + v*vertical - origin);
return ray(origin, lower_left_corner + u*horizontal + v*vertical - origin);
}

vec3 origin;
Expand Down Expand Up @@ -1904,8 +1899,7 @@
}

ray get_ray(double s, double t) {
return ray(origin,
lower_left_corner + s*horizontal + t*vertical - origin);
return ray(origin, lower_left_corner + s*horizontal + t*vertical - origin);
}

vec3 origin;
Expand Down Expand Up @@ -2010,9 +2004,11 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
vec3 rd = lens_radius*random_in_unit_disk();
vec3 offset = u * rd.x() + v * rd.y();
return ray(origin + offset,
lower_left_corner + s*horizontal + t*vertical
- origin - offset);

return ray(
origin + offset,
lower_left_corner + s*horizontal + t*vertical - origin - offset
);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
}

Expand Down
Loading

0 comments on commit 7275db1

Please sign in to comment.