mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: fix path_tracing.v compilation, using (*ptr) = expression
This commit is contained in:
parent
d5eafe79bd
commit
fb97c2e01e
@ -12,7 +12,7 @@ pub mut:
|
|||||||
unsafe {
|
unsafe {
|
||||||
mut e := &int(0)
|
mut e := &int(0)
|
||||||
e = a.data + y*a.maxx + x
|
e = a.data + y*a.maxx + x
|
||||||
*e = newval
|
(*e) = newval
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[inline] pub fn (a &A2D) get(x,y int) int {
|
[inline] pub fn (a &A2D) get(x,y int) int {
|
||||||
|
@ -101,7 +101,7 @@ fn new_image(w int, h int) Image {
|
|||||||
// write out a .ppm file
|
// write out a .ppm file
|
||||||
fn (image Image) save_as_ppm(file_name string) {
|
fn (image Image) save_as_ppm(file_name string) {
|
||||||
npixels := image.width * image.height
|
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('P3')
|
||||||
f_out.writeln('${image.width} ${image.height}')
|
f_out.writeln('${image.width} ${image.height}')
|
||||||
f_out.writeln('255')
|
f_out.writeln('255')
|
||||||
@ -247,8 +247,8 @@ const(
|
|||||||
|
|
||||||
struct Cache {
|
struct Cache {
|
||||||
mut:
|
mut:
|
||||||
sin_tab [cache_len]f64
|
sin_tab [65536]f64
|
||||||
cos_tab [cache_len]f64
|
cos_tab [65536]f64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_tabs() Cache {
|
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)
|
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)
|
tmp_vec := Vec{clamp(r.x),clamp(r.y),clamp(r.z)}.mult_s(.25)
|
||||||
*ivec = *ivec + tmp_vec
|
(*ivec) = *ivec + tmp_vec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ pub fn (x &AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
|
|||||||
} else {
|
} else {
|
||||||
src = src[x.block_size..]
|
src = src[x.block_size..]
|
||||||
}
|
}
|
||||||
*dst = dst[x.block_size..]
|
(*dst) = dst[x.block_size..]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the iv for the next crypt_blocks call.
|
// Save the iv for the next crypt_blocks call.
|
||||||
|
@ -63,13 +63,11 @@ pub fn (c mut Cipher) xor_key_stream(dst mut []byte, src []byte) {
|
|||||||
if src.len == 0 {
|
if src.len == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if subtle.inexact_overlap(dst[..src.len], src) {
|
if subtle.inexact_overlap(dst, src) {
|
||||||
panic('crypto.rc4: invalid buffer overlap')
|
panic('crypto.rc4: invalid buffer overlap')
|
||||||
}
|
}
|
||||||
mut i := c.i
|
mut i := c.i
|
||||||
mut j := c.j
|
mut j := c.j
|
||||||
_ = dst[src.len-1]
|
|
||||||
*dst = dst[..src.len] // eliminate bounds check from loop
|
|
||||||
for k, v in src {
|
for k, v in src {
|
||||||
i += byte(1)
|
i += byte(1)
|
||||||
x := c.s[i]
|
x := c.s[i]
|
||||||
|
@ -4,15 +4,12 @@
|
|||||||
module wyhash
|
module wyhash
|
||||||
|
|
||||||
pub fn rand_u64(seed &u64) u64 {
|
pub fn rand_u64(seed &u64) u64 {
|
||||||
// QTODO
|
|
||||||
/*
|
|
||||||
mut seed0 := seed
|
mut seed0 := seed
|
||||||
unsafe{
|
unsafe{
|
||||||
mut seed1 := *seed0
|
mut seed1 := *seed0
|
||||||
seed1+=wyp0
|
seed1 += (wyp0)
|
||||||
*seed0 = seed1
|
(*seed0) = seed1
|
||||||
return wymum(seed1^wyp1, seed1)
|
return wymum(seed1^wyp1, seed1)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,7 @@ fn test_wyhash() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_rand_u64() {
|
fn test_rand_u64() {
|
||||||
// QTODO
|
|
||||||
/*
|
|
||||||
seed := u64(111)
|
seed := u64(111)
|
||||||
mut rand_nos := []u64
|
mut rand_nos := []u64
|
||||||
for _ in 0..40 {
|
for _ in 0..40 {
|
||||||
@ -39,7 +37,6 @@ fn test_rand_u64() {
|
|||||||
assert rand_no != r
|
assert rand_no != r
|
||||||
}
|
}
|
||||||
rand_nos << rand_no
|
rand_nos << rand_no
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
assert true
|
assert true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user