diff options
Diffstat (limited to 'hittable.go')
-rw-r--r-- | hittable.go | 10 |
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; |