File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ struct hit_record {
22
22
material *mat_ptr;
23
23
double t;
24
24
bool front_face;
25
+
26
+ void set_face_normal (const ray& r, const vec3& outward_normal) {
27
+ front_face = dot (r.direction (), outward_normal) < 0 ;
28
+ normal = front_face ? outward_normal :-outward_normal;
29
+ }
25
30
};
26
31
27
32
class hittable {
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ struct hit_record {
33
33
double u;
34
34
double v;
35
35
bool front_face;
36
+
37
+ void set_face_normal (const ray& r, const vec3& outward_normal) {
38
+ front_face = dot (r.direction (), outward_normal) < 0 ;
39
+ normal = front_face ? outward_normal :-outward_normal;
40
+ }
36
41
};
37
42
38
43
class hittable {
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ struct hit_record {
33
33
double u;
34
34
double v;
35
35
bool front_face;
36
+
37
+ void set_face_normal (const ray& r, const vec3& outward_normal) {
38
+ front_face = dot (r.direction (), outward_normal) < 0 ;
39
+ normal = front_face ? outward_normal :-outward_normal;
40
+ }
36
41
};
37
42
38
43
class hittable {
You can’t perform that action at this time.
0 commit comments