22 template <
typename Real>
36 template <
typename Real>
67 Real DdD, radius,
p, fmin, fmax, MTwoUF, MTwoRF, tmp;
71 D[2] =
Dot(diff, frustum.dVector);
72 for (i = 0; i < 3; ++i)
74 C[i] =
Dot(axis[i], frustum.dVector);
80 if (D[2] + radius < frustum.dMin
81 || D[2] - radius > frustum.dMax)
83 result.intersect =
false;
88 for (i = 0; i < 3; ++i)
90 A[i] =
Dot(axis[i], frustum.rVector);
91 RC[i] = frustum.rBound*C[i];
92 NA[i] = frustum.dMin*A[i];
93 NAmRC[i] = NA[i] - RC[i];
95 D[0] =
Dot(diff, frustum.rVector);
100 ND[0] = frustum.dMin*D[0];
101 RD[2] = frustum.rBound*D[2];
103 MTwoRF = frustum.GetMTwoRF();
104 if (DdD + radius < MTwoRF || DdD > radius)
106 result.intersect =
false;
111 for (i = 0; i < 3; ++i)
113 NApRC[i] = NA[i] + RC[i];
119 DdD = -(ND[0] + RD[2]);
120 if (DdD + radius < MTwoRF || DdD > radius)
122 result.intersect =
false;
127 for (i = 0; i < 3; ++i)
129 B[i] =
Dot(axis[i], frustum.uVector);
130 UC[i] = frustum.uBound*C[i];
131 NB[i] = frustum.dMin*B[i];
132 NBmUC[i] = NB[i] - UC[i];
134 D[1] =
Dot(diff, frustum.uVector);
139 ND[1] = frustum.dMin*D[1];
140 UD[2] = frustum.uBound*D[2];
142 MTwoUF = frustum.GetMTwoUF();
143 if (DdD + radius < MTwoUF || DdD > radius)
145 result.intersect =
false;
150 for (i = 0; i < 3; ++i)
152 NBpUC[i] = NB[i] + UC[i];
158 DdD = -(ND[1] + UD[2]);
159 if (DdD + radius < MTwoUF || DdD > radius)
161 result.intersect =
false;
166 for (i = 0; i < 3; ++i)
170 NC[i] = frustum.dMin*C[i];
174 fmin *= frustum.GetDRatio();
179 fmax *= frustum.GetDRatio();
181 DdD = A[i] * D[0] + B[i] * D[1] + C[i] * D[2];
182 if (DdD + extent[i] < fmin || DdD - extent[i] > fmax)
184 result.intersect =
false;
190 for (i = 0; i < 3; ++i)
196 fmin *= frustum.GetDRatio();
201 fmax *= frustum.GetDRatio();
203 DdD = C[i] * D[1] - B[i] * D[2];
205 extent[0] *
std::abs(B[i] * C[0] - B[0] * C[i]) +
206 extent[1] *
std::abs(B[i] * C[1] - B[1] * C[i]) +
207 extent[2] *
std::abs(B[i] * C[2] - B[2] * C[i]);
208 if (DdD + radius < fmin || DdD - radius > fmax)
210 result.intersect =
false;
216 for (i = 0; i < 3; ++i)
222 fmin *= frustum.GetDRatio();
227 fmax *= frustum.GetDRatio();
229 DdD = -C[i] * D[0] + A[i] * D[2];
231 extent[0] *
std::abs(A[i] * C[0] - A[0] * C[i]) +
232 extent[1] *
std::abs(A[i] * C[1] - A[1] * C[i]) +
233 extent[2] *
std::abs(A[i] * C[2] - A[2] * C[i]);
234 if (DdD + radius < fmin || DdD - radius > fmax)
236 result.intersect =
false;
242 for (i = 0; i < 3; ++i)
244 Real fRB = frustum.rBound*B[i];
245 Real fUA = frustum.uBound*A[i];
246 RBpUA[i] = fRB + fUA;
247 RBmUA[i] = fRB - fUA;
249 for (i = 0; i < 3; ++i)
251 p = frustum.rBound*
std::abs(NBmUC[i]) +
253 tmp = -frustum.dMin*RBmUA[i];
257 fmin *= frustum.GetDRatio();
262 fmax *= frustum.GetDRatio();
264 DdD = D[0] * NBmUC[i] - D[1] * NAmRC[i] - D[2] * RBmUA[i];
266 for (j = 0; j < 3; j++)
268 radius += extent[j] *
std::abs(A[j] * NBmUC[i] -
269 B[j] * NAmRC[i] - C[j] * RBmUA[i]);
271 if (DdD + radius < fmin || DdD - radius > fmax)
273 result.intersect =
false;
279 for (i = 0; i < 3; ++i)
281 p = frustum.rBound*
std::abs(NBpUC[i]) +
283 tmp = -frustum.dMin*RBpUA[i];
287 fmin *= frustum.GetDRatio();
292 fmax *= frustum.GetDRatio();
294 DdD = D[0] * NBpUC[i] - D[1] * NAmRC[i] - D[2] * RBpUA[i];
296 for (j = 0; j < 3; ++j)
298 radius += extent[j] *
std::abs(A[j] * NBpUC[i] -
299 B[j] * NAmRC[i] - C[j] * RBpUA[i]);
301 if (DdD + radius < fmin || DdD - radius > fmax)
303 result.intersect =
false;
309 for (i = 0; i < 3; ++i)
311 p = frustum.rBound*
std::abs(NBmUC[i]) +
313 tmp = frustum.dMin*RBpUA[i];
317 fmin *= frustum.GetDRatio();
322 fmax *= frustum.GetDRatio();
324 DdD = D[0] * NBmUC[i] - D[1] * NApRC[i] + D[2] * RBpUA[i];
326 for (j = 0; j < 3; ++j)
328 radius += extent[j] *
std::abs(A[j] * NBmUC[i] -
329 B[j] * NApRC[i] + C[j] * RBpUA[i]);
331 if (DdD + radius < fmin || DdD - radius > fmax)
333 result.intersect =
false;
339 for (i = 0; i < 3; ++i)
341 p = frustum.rBound*
std::abs(NBpUC[i]) +
343 tmp = frustum.dMin*RBmUA[i];
347 fmin *= frustum.GetDRatio();
352 fmax *= frustum.GetDRatio();
354 DdD = D[0] * NBpUC[i] - D[1] * NApRC[i] + D[2] * RBmUA[i];
356 for (j = 0; j < 3; ++j)
358 radius += extent[j] *
std::abs(A[j] * NBpUC[i] -
359 B[j] * NApRC[i] + C[j] * RBmUA[i]);
361 if (DdD + radius < fmin || DdD - radius > fmax)
363 result.intersect =
false;
368 result.intersect =
true;
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)