Skip to content

Commit 6020add

Browse files
authored
Merge pull request #379 from RayTracing/fix-355
Tweak sphere-intersect code
2 parents ca4f501 + d5f8ff4 commit 6020add

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@
654654
</div>
655655

656656
Let’s revisit the ray-sphere equation:
657+
657658
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
658659
vec3 oc = r.origin() - center;
659660
auto a = dot(r.direction(), r.direction());
@@ -1764,6 +1765,7 @@
17641765
shared_ptr<material> mat_ptr;
17651766
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
17661767
};
1768+
17671769
bool sphere::hit(const ray& r, double t_min, double t_max, hit_record& rec) const {
17681770
vec3 oc = r.origin() - center;
17691771
auto a = r.direction().length_squared();
@@ -1885,9 +1887,11 @@
18851887
hit_record rec;
18861888
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
18871889
if (world.hit(r, 0.001, infinity, rec)) {
1890+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
18881891
// If we've exceeded the ray bounce limit, no more light is gathered.
18891892
if (depth <= 0)
18901893
return vec3(0,0,0);
1894+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
18911895
ray scattered;
18921896
vec3 attenuation;
18931897
if (rec.mat_ptr->scatter(r, rec, attenuation, scattered))
@@ -1905,8 +1909,7 @@
19051909
</div>
19061910

19071911
<div class='together'>
1908-
You will also need to modify the sphere class to have a material pointer to it. And add some
1909-
metal spheres:
1912+
Now let’s add some metal spheres to our scene:
19101913

19111914
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
19121915
int main() {

0 commit comments

Comments
 (0)