42 enum Classification {
MMM,
MMP,
MPM,
MPP,
PMM,
PMP,
PPM,
PPP,
POO,
MOO,
OPO,
OMO,
OOP,
OOM,
OMM,
OMP,
OPM,
OPP,
MOM,
MOP,
POM,
POP,
MMO,
MPO,
PMO,
PPO};
76 set(origin, direction);
88 return Ray(point, direction);
94 return Ray(m_origin + m_direction * distance, m_direction);
100 return Ray(m_origin + bumpDirection * distance, m_direction);
107 float t = m_direction.
dot(point - m_origin);
111 return m_origin + m_direction * t;
161 float& w0,
float& w1,
float& w2)
const;
179 const Point3& vert2)
const {
193 return intersectionTime(vert0, vert1, vert2, vert1 - vert0, vert2 - vert0, w0, w1, w2);
222 float iOutside)
const;
234 #define EPSILON 0.000001
235 #define CROSS(dest,v1,v2) \
236 dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
237 dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \
238 dest[2]=v1[0]*v2[1]-v1[1]*v2[0];
240 #define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
242 #define SUB(dest,v1,v2) \
243 dest[0]=v1[0]-v2[0]; \
244 dest[1]=v1[1]-v2[1]; \
260 float tvec[3], pvec[3], qvec[3];
263 CROSS(pvec, m_direction, edge2);
266 const float det =
DOT(edge1, pvec);
273 SUB(tvec, m_origin, vert0);
277 if ((u < 0.0f) || (u > det)) {
283 CROSS(qvec, tvec, edge1);
286 v =
DOT(m_direction, qvec);
287 if ((v < 0.0f) || (u + v > det)) {
294 const float t =
DOT(edge2, qvec);
322 float tvec[3], pvec[3], qvec[3];
325 CROSS(pvec, m_direction, edge2);
328 const float det =
DOT(edge1, pvec);
335 SUB(tvec, m_origin, vert0);
339 if ((u < 0.0f) || (u > det)) {
345 CROSS(qvec, tvec, edge1);
348 v =
DOT(m_direction, qvec);
349 if ((v < 0.0f) || (u + v > det)) {
354 float t =
DOT(edge2, qvec);
357 const float inv_det = 1.0f / det;
float finf()
Definition: g3dmath.cpp:71
float c_zy
Definition: Ray.h:50
float c_xy
Definition: Ray.h:50
void deserialize(class BinaryInput &b)
Definition: Ray.cpp:137
void serialize(class BinaryOutput &b) const
Definition: Ray.cpp:131
float c_xz
Definition: Ray.h:50
float intersectionTime(const Point3 &vert0, const Point3 &vert1, const Point3 &vert2, float &w0, float &w1, float &w2) const
Definition: Ray.h:185
Ray(const Point3 &origin, const Vector3 &direction)
Definition: Ray.h:75
Definition: Intersect.h:27
Point3 closestPoint(const Point3 &point) const
Returns the closest point on the Ray to point.
Definition: Ray.h:106
Classification classification
Definition: Ray.h:44
#define SUB(dest, v1, v2)
Definition: Ray.h:242
float ibyk
Definition: Ray.h:47
#define DOT(v1, v2)
Definition: Ray.h:240
float __fastcall dot(const Vector3 &rkVector) const
Definition: Vector3.h:771
An arbitrary (oriented) 3D box, useful as a bounding box.
Definition: Box.h:35
Ray reflect(const Vector3 &newOrigin, const Vector3 &normal) const
Definition: Ray.cpp:155
const Vector3 & edge02() const
Definition: Triangle.h:81
static const Vector3 & unitX()
Definition: Vector3.cpp:121
static const Vector3 & zero()
Definition: Vector3.cpp:119
Ray bumpedRay(float distance, const Vector3 &bumpDirection) const
Definition: Ray.h:99
float intersectionTime(const Point3 &vert0, const Point3 &vert1, const Point3 &vert2) const
Definition: Ray.h:176
float jbyi
Definition: Ray.h:47
static Ray fromOriginAndDirection(const Point3 &point, const Vector3 &direction)
Definition: Ray.h:87
#define CROSS(dest, v1, v2)
Definition: Ray.h:235
void set(const Point3 &origin, const Vector3 &direction)
Definition: Ray.cpp:18
Classification
Definition: Ray.h:42
Ray()
Definition: Ray.h:70
const Vector3 & invDirection() const
Definition: Ray.h:66
float c_yx
Definition: Ray.h:50
const Vector3 & edge01() const
Definition: Triangle.h:76
float c_yz
Definition: Ray.h:50
Vector3 m_invDirection
Definition: Ray.h:34
float c_zx
Definition: Ray.h:50
Point3 intersection(const class Plane &plane) const
Definition: Ray.cpp:164
float kbyj
Definition: Ray.h:47
Point3 m_origin
Definition: Ray.h:28
const Point3 & origin() const
Definition: Ray.h:56
float jbyk
Definition: Ray.h:47
Definition: BinaryOutput.h:52
#define EPSILON
Definition: Ray.h:234
float ibyj
Definition: Ray.h:47
float intersectionTime(const Triangle &triangle) const
Definition: Ray.h:199
float distance(const Point3 &point) const
Definition: Ray.h:118
float kbyi
Definition: Ray.h:47
const Point3 & vertex(int n) const
Definition: Triangle.h:70
Definition: Triangle.h:34
Ray bumpedRay(float distance) const
Definition: Ray.h:93
const Vector3 & direction() const
Definition: Ray.h:61
Ray refract(const Vector3 &newOrigin, const Vector3 &normal, float iInside, float iOutside) const
Definition: Ray.cpp:144
float intersectionTime(const class Sphere &sphere, bool solid=false) const
Definition: Ray.cpp:179
Vector3 m_direction
Definition: Ray.h:31