examples: fix path_tracing.v compilation, using (*ptr) = expression

pull/4561/head
Delyan Angelov 2020-04-23 12:19:04 +03:00
parent d5eafe79bd
commit fb97c2e01e
6 changed files with 12 additions and 20 deletions

View File

@ -12,7 +12,7 @@ pub mut:
unsafe {
mut e := &int(0)
e = a.data + y*a.maxx + x
*e = newval
(*e) = newval
}
}
[inline] pub fn (a &A2D) get(x,y int) int {

View File

@ -101,7 +101,7 @@ fn new_image(w int, h int) Image {
// write out a .ppm file
fn (image Image) save_as_ppm(file_name string) {
npixels := image.width * image.height
mut f_out := os.create(file_name) or { exit }
mut f_out := os.create(file_name) or { panic(err) }
f_out.writeln('P3')
f_out.writeln('${image.width} ${image.height}')
f_out.writeln('255')
@ -247,8 +247,8 @@ const(
struct Cache {
mut:
sin_tab [cache_len]f64
cos_tab [cache_len]f64
sin_tab [65536]f64
cos_tab [65536]f64
}
fn new_tabs() Cache {
@ -429,7 +429,7 @@ fn ray_trace(w int, h int, samps int, file_name string, scene_id int) Image {
r = r + radiance(Ray{cam.o+d.mult_s(140.0), d.norm()}, 0, scene_id).mult_s(samps1)
}
tmp_vec := Vec{clamp(r.x),clamp(r.y),clamp(r.z)}.mult_s(.25)
*ivec = *ivec + tmp_vec
(*ivec) = *ivec + tmp_vec
}
}
}

View File

@ -74,7 +74,7 @@ pub fn (x &AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
} else {
src = src[x.block_size..]
}
*dst = dst[x.block_size..]
(*dst) = dst[x.block_size..]
}
// Save the iv for the next crypt_blocks call.

View File

@ -63,13 +63,11 @@ pub fn (c mut Cipher) xor_key_stream(dst mut []byte, src []byte) {
if src.len == 0 {
return
}
if subtle.inexact_overlap(dst[..src.len], src) {
if subtle.inexact_overlap(dst, src) {
panic('crypto.rc4: invalid buffer overlap')
}
mut i := c.i
mut j := c.j
_ = dst[src.len-1]
*dst = dst[..src.len] // eliminate bounds check from loop
for k, v in src {
i += byte(1)
x := c.s[i]

View File

@ -4,15 +4,12 @@
module wyhash
pub fn rand_u64(seed &u64) u64 {
// QTODO
/*
mut seed0 := seed
unsafe{
mut seed1 := *seed0
seed1+=wyp0
*seed0 = seed1
seed1 += (wyp0)
(*seed0) = seed1
return wymum(seed1^wyp1, seed1)
}
*/
return 0
}

View File

@ -29,8 +29,6 @@ fn test_wyhash() {
}
fn test_rand_u64() {
// QTODO
/*
seed := u64(111)
mut rand_nos := []u64
for _ in 0..40 {
@ -40,6 +38,5 @@ fn test_rand_u64() {
}
rand_nos << rand_no
}
*/
assert true
}