rayzor

view src/vmathray.h @ 13:964f8ea5f095

missed quite a lot of things in my last commit apparently
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 12 Apr 2014 23:37:55 +0300
parents
children a9a948809c6f
line source
1 #ifndef VMATH_RAY_H_
2 #define VMATH_RAY_H_
4 #include "vmath.h"
5 #include "vmathmat.h"
7 class Ray {
8 public:
9 Vector3 pos, dir;
11 Ray() {}
12 Ray(const Vector3 &p, const Vector3 &d) : pos(p), dir(d) {}
13 };
15 inline Ray transform(const Matrix4x4 &m, const Ray &r)
16 {
17 Matrix4x4 rmat = m;
18 rmat[0][3] = rmat[1][3] = rmat[2][3] = rmat[3][0] = rmat[3][1] = rmat[3][2] = 0.0;
19 rmat[3][3] = 1.0;
21 return Ray(transform(m, r.pos), transform(rmat, r.dir));
22 }
24 #endif // VMATH_RAY_H_