00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _Ray_h__
00009 #define _Ray_h__
00010
00011 #include "MathHelper.h"
00012 #include <stdint.h>
00013
00014 namespace FemViewer {
00015
00016 using namespace fvmath;
00017
00018 template<typename T>
00019 class IsectInfo
00020 {
00021 public:
00022 IsectInfo() {}
00023 CVec3<T> P, N;
00024 CVec3<T> dPdu, dPdv;
00025 T s, t;
00026 CVec3<T> worldToLocal(const Vec3<T> &v) {
00027 CVec3<T> sn(dPdu);
00028 (void)Normalize(sn);
00029 CVec3<T> tn = N * sn;
00030 return CVec3<T>(Dot(v, sn), Dot(v, tn), Dot(v, N));
00031 }
00032 };
00033
00034 template<typename T>
00035 class Ray {
00036 public:
00037 bool debug;
00038 mutable Vec3f color;
00039 CVec3<T> orig, dir;
00040 mutable T tmin, tmax;
00041 unsigned triangleId;
00042 CVec3<T> invdir;
00043 int sign[3];
00044 uint64_t id;
00045 Ray(Vec3<T> orig, Vec3<T> dir, T near = T(0), T far = std::numeric_limits<T>::max());
00046 CVec3<T> operator () (const T &t) const { return orig + dir * t; }
00047 };
00048
00049 }
00050
00051
00052 #endif