aboutsummaryrefslogtreecommitdiff
path: root/hittable.go
diff options
context:
space:
mode:
authorNat Lasseter <user@4574.co.uk>2024-07-03 11:20:22 +0100
committerNat Lasseter <user@4574.co.uk>2024-07-03 11:20:22 +0100
commit7ee9e31e40353daa24d0a7ef325acc9878095325 (patch)
tree6cfdea5fff05d27f9fb0e69b930a450de3858af9 /hittable.go
parent9e67a8260fee8f8a423a3131bcf13db3b9de6922 (diff)
Refactor Hittables typeHEADmain
Diffstat (limited to 'hittable.go')
-rw-r--r--hittable.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/hittable.go b/hittable.go
index 73e2e3c..b31b205 100644
--- a/hittable.go
+++ b/hittable.go
@@ -69,18 +69,16 @@ func (s Sphere) Hit(r Ray, ray_t Interval) (rec HitRecord) {
//Hittables < Hittable
-type Hittables struct {
- Objects []Hittable
-}
+type Hittables []Hittable
-func (l *Hittables) Add(o Hittable) {
- l.Objects = append(l.Objects, o);
+func (l Hittables) Add(o Hittable) Hittables {
+ return append(l, o);
}
func (l Hittables) Hit(r Ray, ray_t Interval) (rec HitRecord) {
closest_so_far := ray_t.Max;
- for _, o := range l.Objects {
+ for _, o := range l {
temp_rec := o.Hit(r, Interval{ray_t.Min, closest_so_far});
if temp_rec.Valid {
rec = temp_rec;