Skip to content

Commit

Permalink
go: lazy compute bounce vector
Browse files Browse the repository at this point in the history
  • Loading branch information
kidoman committed Oct 3, 2013
1 parent f6b3ad1 commit efa1672
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Expand Up @@ -223,11 +223,15 @@ func tracer(orig, dir vector.Vector) (st status, dist float64, bounce vector.Vec

if s < dist && s > 0.01 {
dist = s
bounce = p.Add(dir.Scale(dist)).Normalize()
bounce = p // We can lazy compute bounce based on value of p
st = hit
}
}
}

if st == hit {
bounce = bounce.Add(dir.Scale(dist)).Normalize()
}

return
}

0 comments on commit efa1672

Please sign in to comment.