cleanup: replace C for loops with range

This commit is contained in:
spaceface777 2020-02-24 17:55:16 +01:00 committed by GitHub
parent 5918946feb
commit ef8c1203b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 168 additions and 170 deletions

View file

@ -409,7 +409,7 @@ fn ray_trace(w int, h int, samps int, file_name string, scene_id int) Image {
// OpenMP injection point! #pragma omp parallel for schedule(dynamic, 1) shared(c)
for y:=0; y < h; y++ {
eprint("\rRendering (${samps * 4} spp) ${(100.0 * f64(y)) / (f64(h) - 1.0):5.2f}%")
for x := 0; x < w; x++ {
for x in 0..w {
i := (h - y - 1) * w + x
mut ivec := &image.data[i]
@ -417,7 +417,7 @@ fn ray_trace(w int, h int, samps int, file_name string, scene_id int) Image {
for sy := 0; sy < 2; sy ++ {
for sx := 0; sx < 2; sx ++ {
r = Vec{0,0,0}
for s := 0; s < samps; s++ {
for s in 0..samps {
r1 := v_2 * rand_f64()
dx := if r1 < v_1 { math.sqrt(r1) - v_1 } else { v_1 - math.sqrt(v_2 - r1) }