goat3d
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/vmath/ray.cc Sun Sep 29 08:20:19 2013 +0300 1.3 @@ -0,0 +1,39 @@ 1.4 +#include "ray.h" 1.5 +#include "vector.h" 1.6 + 1.7 +scalar_t Ray::env_ior = 1.0; 1.8 + 1.9 +Ray::Ray() 1.10 +{ 1.11 + ior = env_ior; 1.12 + energy = 1.0; 1.13 + time = 0; 1.14 + iter = 0; 1.15 +} 1.16 + 1.17 +Ray::Ray(const Vector3 &origin, const Vector3 &dir) 1.18 +{ 1.19 + this->origin = origin; 1.20 + this->dir = dir; 1.21 + ior = env_ior; 1.22 + energy = 1.0; 1.23 + time = 0; 1.24 + iter = 0; 1.25 +} 1.26 + 1.27 +void Ray::transform(const Matrix4x4 &xform) 1.28 +{ 1.29 + Matrix4x4 upper = xform; 1.30 + upper[0][3] = upper[1][3] = upper[2][3] = upper[3][0] = upper[3][1] = upper[3][2] = 0.0; 1.31 + upper[3][3] = 1.0; 1.32 + 1.33 + dir.transform(upper); 1.34 + origin.transform(xform); 1.35 +} 1.36 + 1.37 +Ray Ray::transformed(const Matrix4x4 &xform) const 1.38 +{ 1.39 + Ray foo = *this; 1.40 + foo.transform(xform); 1.41 + return foo; 1.42 +}