20 #if !defined(__MITSUBA_RENDER_TRIACCEL_H_)
21 #define __MITSUBA_RENDER_TRIACCEL_H_
28 static const uint32_t KNoTriangleFlag = 0xFFFFFFFF;
57 FINLINE
bool rayIntersect(
const Ray &ray,
Float mint,
Float maxt,
62 static const int waldModulo[4] = { 1, 2, 0, 1 };
68 for (
int j=0; j<3; j++) {
69 if (std::abs(N[j]) > std::abs(N[k]))
75 const Float n_k = N[k],
76 denom = b[u]*c[v] - b[v]*c[u];
96 FINLINE
bool TriAccel::rayIntersect(
const Ray &ray,
Float mint,
Float maxt,
100 static const MM_ALIGN16
int waldModulo[4] = { 1, 2, 0, 1 };
101 const int ku = waldModulo[k], kv = waldModulo[k+1];
103 const Float o_u = ray.o[ku], o_v = ray.o[kv], o_k = ray.o[k],
104 d_u = ray.d[ku], d_v = ray.d[kv], d_k = ray.d[k];
106 Float o_u, o_v, o_k, d_u, d_v, d_k;
138 #if defined(MTS_DEBUG_FP)
139 if (d_u * n_u + d_v * n_v + d_k == 0)
144 t = (n_d - o_u*n_u - o_v*n_v - o_k) /
145 (d_u * n_u + d_v * n_v + d_k);
147 if (t < mint || t > maxt)
151 const Float hu = o_u + t * d_u - a_u;
152 const Float hv = o_v + t * d_v - a_v;
155 u = hv * b_nu + hu * b_nv;
156 v = hu * c_nu + hv * c_nv;
157 return u >= 0 && v >= 0 && u+v <= 1.0f;
Float n_v
Definition: triaccel.h:40
uint32_t shapeIndex
Definition: triaccel.h:50
Float n_u
Definition: triaccel.h:39
TVector3< Float > Vector
Definition: fwd.h:113
Float b_nv
Definition: triaccel.h:46
Float c_nv
Definition: triaccel.h:49
Float a_u
Definition: triaccel.h:43
Float n_d
Definition: triaccel.h:41
uint32_t primIndex
Definition: triaccel.h:51
Float b_nu
Definition: triaccel.h:45
uint32_t k
Definition: triaccel.h:38
Pre-computed triangle representation based on Ingo Wald's TriAccel layout.
Definition: triaccel.h:37
Float c_nu
Definition: triaccel.h:48
TVector3< T > cross(const TVector3< T > &v1, const TVector3< T > &v2)
Definition: vector.h:617
T dot(const TQuaternion< T > &q1, const TQuaternion< T > &q2)
Definition: quat.h:348
Float a_v
Definition: triaccel.h:44