Skip to content

Commit 501325b

Browse files
committed
Added set_face_normal function to src
1 parent 264d757 commit 501325b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/InOneWeekend/hittable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ struct hit_record {
2222
material *mat_ptr;
2323
double t;
2424
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+
}
2530
};
2631

2732
class hittable {

src/TheNextWeek/hittable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ struct hit_record {
3333
double u;
3434
double v;
3535
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+
}
3641
};
3742

3843
class hittable {

src/TheRestOfYourLife/hittable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ struct hit_record {
3333
double u;
3434
double v;
3535
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+
}
3641
};
3742

3843
class hittable {

0 commit comments

Comments
 (0)