blob: 20cc42e99cab61b0fb4d197deaea104ccfe4475d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
type ray {
orig: vec3 # point
dir: vec3
}
# A little different from the constructor at https://raytracing.github.io/books/RayTracingInOneWeekend.html
# We immediately normalize the direction vector so we don't have to keep doing
# so.
fn initialize-ray _self: (addr ray), o: (addr vec3), d: (addr vec3) {
var self/esi: (addr ray) <- copy _self
var dest/eax: (addr vec3) <- get self, orig
copy-object o, dest
dest <- get self, dir
vec3-unit d, dest
}
fn ray-at _self: (addr ray), t: float, out: (addr vec3) {
var self/esi: (addr ray) <- copy _self
var src/eax: (addr vec3) <- get self, dir
copy-object src, out
vec3-scale-up out, t
src <- get self, orig
vec3-add-to out, src
}
|