equal
deleted
inserted
replaced
56 |
56 |
57 #ifndef NO_SIMD |
57 #ifndef NO_SIMD |
58 mfloat4 Sphere::intersect_packet(const RayPacket &rays, mfloat4 &dists) const |
58 mfloat4 Sphere::intersect_packet(const RayPacket &rays, mfloat4 &dists) const |
59 { |
59 { |
60 VectorPacket V = rays.o - VectorPacket(center); |
60 VectorPacket V = rays.o - VectorPacket(center); |
61 register mfloat4 d = msub(mZero, dot(V, rays.dir)); |
61 mfloat4 d = msub(mZero, dot(V, rays.dir)); |
62 register mfloat4 Det = msub(mmul(d, d), msub(dot(V,V), mset1(sqr_radius))); |
62 mfloat4 Det = msub(mmul(d, d), msub(dot(V,V), mset1(sqr_radius))); |
63 register mfloat4 t1, t2, mask; |
63 mfloat4 t1, t2, mask; |
64 |
64 |
65 mask = mcmpgt(Det, mZero); |
65 mask = mcmpgt(Det, mZero); |
66 if (!mmovemask(mask)) |
66 if (!mmovemask(mask)) |
67 return mask; |
67 return mask; |
68 |
68 |
139 |
139 |
140 bool Box::intersect(const Ray &ray, Float &dist) const |
140 bool Box::intersect(const Ray &ray, Float &dist) const |
141 { |
141 { |
142 register Float tnear = -Inf; |
142 register Float tnear = -Inf; |
143 register Float tfar = Inf; |
143 register Float tfar = Inf; |
144 register Float t1, t2; |
144 register Float t1, t2, t; |
145 |
145 |
146 for (int i = 0; i < 3; i++) |
146 for (int i = 0; i < 3; i++) |
147 { |
147 { |
148 if (ray.dir[i] == 0) { |
148 if (ray.dir[i] == 0) { |
149 /* ray is parallel to these planes */ |
149 /* ray is parallel to these planes */ |
155 /* compute the intersection distance of the planes */ |
155 /* compute the intersection distance of the planes */ |
156 t1 = (L[i] - ray.o[i]) / ray.dir[i]; |
156 t1 = (L[i] - ray.o[i]) / ray.dir[i]; |
157 t2 = (H[i] - ray.o[i]) / ray.dir[i]; |
157 t2 = (H[i] - ray.o[i]) / ray.dir[i]; |
158 |
158 |
159 if (t1 > t2) |
159 if (t1 > t2) |
160 swap(t1, t2); |
160 { |
|
161 t = t1; |
|
162 t1 = t2; |
|
163 t2 = t; |
|
164 } |
161 |
165 |
162 if (t1 > tnear) |
166 if (t1 > tnear) |
163 tnear = t1; /* want largest Tnear */ |
167 tnear = t1; /* want largest Tnear */ |
164 if (t2 < tfar) |
168 if (t2 < tfar) |
165 tfar = t2; /* want smallest Tfar */ |
169 tfar = t2; /* want smallest Tfar */ |
214 H.z > bbox.L.z && L.z < bbox.H.z); |
218 H.z > bbox.L.z && L.z < bbox.H.z); |
215 } |
219 } |
216 |
220 |
217 const Vector Box::normal(const Vector &P) const |
221 const Vector Box::normal(const Vector &P) const |
218 { |
222 { |
219 register Vector l = P - L; |
223 Vector l = P - L; |
220 register Vector h = H - P; |
224 Vector h = H - P; |
221 |
225 |
222 if (l.x < h.x) |
226 if (l.x < h.x) |
223 h.x = -1; |
227 h.x = -1; |
224 else |
228 else |
225 { |
229 { |
314 #endif |
318 #endif |
315 #ifdef TRI_BARI_PRE |
319 #ifdef TRI_BARI_PRE |
316 int u = (k + 1) % 3; |
320 int u = (k + 1) % 3; |
317 int v = (k + 2) % 3; |
321 int v = (k + 2) % 3; |
318 |
322 |
319 Float krec = 1.0 / N[k]; |
323 Float krec = 1.0f / N[k]; |
320 nu = N[u] * krec; |
324 nu = N[u] * krec; |
321 nv = N[v] * krec; |
325 nv = N[v] * krec; |
322 nd = dot(N, A->P) * krec; |
326 nd = dot(N, A->P) * krec; |
323 |
327 |
324 // first line equation |
328 // first line equation |