20 #if !defined(__MITSUBA_CORE_RAY_H_)
21 #define __MITSUBA_CORE_RAY_H_
23 #include <mitsuba/mitsuba.h>
36 template <
typename _Po
intType,
typename _VectorType>
struct TRay {
39 typedef typename PointType::Scalar
Scalar;
53 maxt(std::numeric_limits<
Scalar>::infinity()), time(0) {
58 : o(ray.o), mint(ray.mint), d(ray.d), maxt(ray.maxt),
59 dRcp(ray.dRcp), time(ray.time) {
64 : o(ray.o), mint(mint), d(ray.d), maxt(maxt),
65 dRcp(ray.dRcp), time(ray.time) { }
69 maxt(std::numeric_limits<
Scalar>::infinity()), time(time) { }
74 maxt(std::numeric_limits<
Scalar>::infinity()), time(time) {
78 for (
int i=0; i<3; ++i)
79 dRcp[i] = (
Scalar) 1 / d[i];
87 Scalar time) : o(o), mint(mint), d(d), maxt(maxt), time(time) {
91 for (
int i=0; i<3; ++i)
92 dRcp[i] = (
Scalar) 1 / d[i];
110 for (
int i=0; i<3; ++i)
111 dRcp[i] = (
Scalar) 1 / dir[i];
128 std::ostringstream oss;
129 oss <<
"Ray[origin=" << o.toString() <<
", direction="
130 << d.toString() <<
", mint=" << mint
131 <<
", maxt=" << maxt <<
", time=" << time <<
"]";
146 : hasDifferentials(false) {
150 :
Ray(p, d, time), hasDifferentials(false) {
154 :
Ray(ray), hasDifferentials(false) {
158 :
Ray(ray), rxOrigin(ray.rxOrigin), ryOrigin(ray.ryOrigin),
159 rxDirection(ray.rxDirection), ryDirection(ray.ryDirection),
160 hasDifferentials(ray.hasDifferentials) {
164 rxOrigin = o + (rxOrigin - o) * amount;
165 ryOrigin = o + (ryOrigin - o) * amount;
166 rxDirection = d + (rxDirection - d) * amount;
167 ryDirection = d + (ryDirection - d) * amount;
171 rxOrigin = o + (rxOrigin - o) * amountUV.x;
172 ryOrigin = o + (ryOrigin - o) * amountUV.y;
173 rxDirection = d + (rxDirection - d) * amountUV.x;
174 ryDirection = d + (ryDirection - d) * amountUV.y;
208 hasDifferentials =
false;
213 std::ostringstream oss;
214 oss <<
"RayDifferential[" << endl
215 <<
" origin = " << o.toString() <<
"," << endl
216 <<
" direction = " << d.toString() <<
"," << endl
217 <<
" mint = " << mint <<
"," << endl
218 <<
" maxt = " << maxt <<
"," << endl
219 <<
" time = " << time <<
"," << endl
220 <<
" hasDifferentials = " << hasDifferentials <<
"," << endl
221 <<
" rxOrigin = " << rxOrigin.toString() <<
"," << endl
222 <<
" ryOrigin = " << ryOrigin.toString() <<
"," << endl
223 <<
" rxDirection = " << rxDirection.toString() <<
"," << endl
224 <<
" ryDirection = " << ryDirection.toString() << endl
void scaleDifferential(Float amount)
Definition: ray.h:163
#define Epsilon
Definition: constants.h:28
Float time
Time value associated with this ray.
Definition: ray.h:49
Scalar maxt
Maximum range for intersection tests.
Definition: ray.h:47
RayDifferential(const Ray &ray)
Definition: ray.h:153
TRay(const PointType &o, const VectorType &d, Scalar mint, Scalar maxt, Scalar time)
Construct a new ray.
Definition: ray.h:86
void operator=(const Ray &ray)
Definition: ray.h:196
std::string toString() const
Return a string representation of this ray.
Definition: ray.h:212
bool hasDifferentials
Definition: ray.h:143
MTS_EXPORT_CORE void restoreFPExceptions(bool state)
Restore floating point exceptions to the specified state.
_PointType PointType
Definition: ray.h:37
RayDifferential(const Point &p, const Vector &d, Float time)
Definition: ray.h:149
RayDifferential(const RayDifferential &ray)
Definition: ray.h:157
VectorType d
Ray direction.
Definition: ray.h:46
PointType o
Ray origin.
Definition: ray.h:44
Ray differential – enhances the basic ray class with information about the rays of adjacent pixels on...
Definition: ray.h:140
Simple n-dimensional ray data structure with minimum / maximum extent information.
Definition: ray.h:36
RayDifferential()
Definition: ray.h:145
Vector rxDirection
Definition: ray.h:142
TRay()
Construct a new ray.
Definition: ray.h:52
PointType::Scalar Scalar
Definition: ray.h:39
Point ryOrigin
Definition: ray.h:141
Point rxOrigin
Definition: ray.h:141
void scaleDifferentialUV(const Vector2 amountUV)
Definition: ray.h:170
Vector ryDirection
Definition: ray.h:142
void operator=(const RayDifferential &ray)
Definition: ray.h:177
std::string toString() const
Return a string representation of this ray.
Definition: ray.h:127
TRay(const PointType &o, const VectorType &d, Scalar time)
Construct a new ray.
Definition: ray.h:72
void setDirection(const VectorType &dir)
Set the direction and update the reciprocal.
Definition: ray.h:105
void setTime(Scalar tval)
Set the time.
Definition: ray.h:102
TRay(const PointType &o, Scalar time)
Construct a new ray, while not specifying a direction yet.
Definition: ray.h:68
TRay(const TRay &ray)
Copy constructor (1)
Definition: ray.h:57
TRay(const TRay &ray, Scalar mint, Scalar maxt)
Copy constructor (2)
Definition: ray.h:63
void setOrigin(const PointType &pos)
Set the origin.
Definition: ray.h:99
_VectorType VectorType
Definition: ray.h:38
VectorType dRcp
Componentwise reciprocals of the ray direction.
Definition: ray.h:48
Scalar mint
Minimum range for intersection tests.
Definition: ray.h:45
MTS_EXPORT_CORE bool disableFPExceptions()
Disable floating point exceptions.