goat3d
annotate libs/vmath/ray.cc @ 27:4deb0b12fe14
wtf... corrupted heap?
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 29 Sep 2013 08:20:19 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@27 | 1 #include "ray.h" |
nuclear@27 | 2 #include "vector.h" |
nuclear@27 | 3 |
nuclear@27 | 4 scalar_t Ray::env_ior = 1.0; |
nuclear@27 | 5 |
nuclear@27 | 6 Ray::Ray() |
nuclear@27 | 7 { |
nuclear@27 | 8 ior = env_ior; |
nuclear@27 | 9 energy = 1.0; |
nuclear@27 | 10 time = 0; |
nuclear@27 | 11 iter = 0; |
nuclear@27 | 12 } |
nuclear@27 | 13 |
nuclear@27 | 14 Ray::Ray(const Vector3 &origin, const Vector3 &dir) |
nuclear@27 | 15 { |
nuclear@27 | 16 this->origin = origin; |
nuclear@27 | 17 this->dir = dir; |
nuclear@27 | 18 ior = env_ior; |
nuclear@27 | 19 energy = 1.0; |
nuclear@27 | 20 time = 0; |
nuclear@27 | 21 iter = 0; |
nuclear@27 | 22 } |
nuclear@27 | 23 |
nuclear@27 | 24 void Ray::transform(const Matrix4x4 &xform) |
nuclear@27 | 25 { |
nuclear@27 | 26 Matrix4x4 upper = xform; |
nuclear@27 | 27 upper[0][3] = upper[1][3] = upper[2][3] = upper[3][0] = upper[3][1] = upper[3][2] = 0.0; |
nuclear@27 | 28 upper[3][3] = 1.0; |
nuclear@27 | 29 |
nuclear@27 | 30 dir.transform(upper); |
nuclear@27 | 31 origin.transform(xform); |
nuclear@27 | 32 } |
nuclear@27 | 33 |
nuclear@27 | 34 Ray Ray::transformed(const Matrix4x4 &xform) const |
nuclear@27 | 35 { |
nuclear@27 | 36 Ray foo = *this; |
nuclear@27 | 37 foo.transform(xform); |
nuclear@27 | 38 return foo; |
nuclear@27 | 39 } |