00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef LUX_RAYDIFFERENTIAL_H
00025 #define LUX_RAYDIFFERENTIAL_H
00026
00027 #include "vector.h"
00028 #include "point.h"
00029 #include "normal.h"
00030 #include "ray.h"
00031
00032 namespace lux
00033 {
00034
00035 class RayDifferential : public Ray {
00036 public:
00037
00038 RayDifferential() { hasDifferentials = false; }
00039 RayDifferential(const Point &org, const Vector &dir)
00040 : Ray(org, dir) {
00041 hasDifferentials = false;
00042 }
00043 explicit RayDifferential(const Ray &ray) : Ray(ray) {
00044 hasDifferentials = false;
00045 }
00046
00047
00048 Ray rx, ry;
00049 bool hasDifferentials;
00050
00051
00052 };
00053
00054
00055 class DifferentialGeometry {
00056 public:
00057 DifferentialGeometry() { u = v = 0.; handle = NULL; }
00058
00059 DifferentialGeometry(
00060 const Point &P,
00061 const Vector &DPDU, const Vector &DPDV,
00062 const Normal &DNDU, const Normal &DNDV,
00063 float uu, float vv,
00064 const void *pr);
00065 DifferentialGeometry(
00066 const Point &P, const Normal &NN,
00067 const Vector &DPDU, const Vector &DPDV,
00068 const Normal &DNDU, const Normal &DNDV,
00069 float uu, float vv,
00070 const void *pr);
00071 void AdjustNormal(bool ro, bool swapsHandedness) {
00072
00073 if (ro ^ swapsHandedness) {
00074 nn.x = -nn.x;
00075 nn.y = -nn.y;
00076 nn.z = -nn.z;
00077 }
00078 }
00079 void ComputeDifferentials(const RayDifferential &r) const;
00080
00081 Point p;
00082 Normal nn;
00083 Vector dpdu, dpdv;
00084 Normal dndu, dndv;
00085 mutable Vector dpdx, dpdy;
00086 float u, v;
00087 const void* handle;
00088 mutable float dudx, dvdx, dudy, dvdy;
00089 float time;
00090
00091
00092
00093 union {
00094 float triangleBaryCoords[3];
00095 };
00096 };
00097
00098 }
00099
00100 #endif //LUX_RAYDIFFERENTIAL_H