Skip to content

Commit efa1672

Browse files
committed
go: lazy compute bounce vector
1 parent f6b3ad1 commit efa1672

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,15 @@ func tracer(orig, dir vector.Vector) (st status, dist float64, bounce vector.Vec
223223

224224
if s < dist && s > 0.01 {
225225
dist = s
226-
bounce = p.Add(dir.Scale(dist)).Normalize()
226+
bounce = p // We can lazy compute bounce based on value of p
227227
st = hit
228228
}
229229
}
230230
}
231231

232+
if st == hit {
233+
bounce = bounce.Add(dir.Scale(dist)).Normalize()
234+
}
235+
232236
return
233237
}

0 commit comments

Comments
 (0)