aboutsummaryrefslogtreecommitdiff
path: root/hittable.go
diff options
context:
space:
mode:
authorNat Lasseter <user@4574.co.uk>2024-06-24 22:51:51 +0100
committerNat Lasseter <user@4574.co.uk>2024-06-24 22:51:51 +0100
commit3deef4d969dd50ddf540b80fe43ef16af5c17169 (patch)
tree456754a9bffb31471f2e64698afb8ee95aebca93 /hittable.go
parentd248e30d365d5e401d5cd372aa415fb2f9a39326 (diff)
Chapter 11
Diffstat (limited to 'hittable.go')
-rw-r--r--hittable.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/hittable.go b/hittable.go
index 42599ab..ac5e996 100644
--- a/hittable.go
+++ b/hittable.go
@@ -11,12 +11,14 @@ type HitRecord struct {
P Vec3
N Vec3
T float64
+ F bool
Mat Material
}
func (rec *HitRecord) SetFaceNormal(r Ray, out_n Vec3) {
- if r.Direction.Dot(out_n) < 0 {
- rec.N = out_n
+ rec.F = r.Direction.Dot(out_n) < 0;
+ if rec.F {
+ rec.N = out_n;
} else {
rec.N = out_n.Neg();
}