Skip to content

Commit

Permalink
rename to world and objects
Browse files Browse the repository at this point in the history
  • Loading branch information
matsumotosan committed Sep 18, 2023
1 parent 3443c60 commit 9d85328
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions geometry/hittable.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ func (hr *HitRecord) SetFaceNormal(ray Ray, outward_normal Vec3) {
}
}

type Hittable interface { Hit(ray Ray, interval Interval, record *HitRecord) bool }
type Object interface { Hit(ray Ray, interval Interval, record *HitRecord) bool }

type HittableList struct { Objects []Hittable }
type World struct { Objects []Object }

func (hl *HittableList) Clear() { hl.Objects = []Hittable{} }
func (hl *World) Clear() { hl.Objects = []Object{} }

func (hl *HittableList) Add(h Hittable) { hl.Objects = append(hl.Objects, h) }
func (hl *World) Add(h Object) { hl.Objects = append(hl.Objects, h) }

func (hl *HittableList) Hit(ray Ray, ray_t Interval, record *HitRecord) bool {
func (hl *World) Hit(ray Ray, ray_t Interval, record *HitRecord) bool {
temp_rec := HitRecord{}
hit := false
closest := ray_t.Max
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
image_height := int(float64(image_width) / aspect_ratio)

// Create world
world := geometry.HittableList{}
world := geometry.World{}
world.Add(geometry.Sphere{Center: geometry.Vec3{0, 0, -1}, Radius: 0.5})
world.Add(geometry.Sphere{Center: geometry.Vec3{0, -100.5, -1}, Radius: 100})

Expand Down Expand Up @@ -77,7 +77,7 @@ func main() {
}


func RayColor(ray geometry.Ray, world geometry.HittableList) color.RGBA {
func RayColor(ray geometry.Ray, world geometry.World) color.RGBA {
record := geometry.HitRecord{}

if world.Hit(ray, geometry.Interval{Min: 0, Max: 999999}, &record) {
Expand Down

0 comments on commit 9d85328

Please sign in to comment.