| 263 | */ |
| 264 | |
| 265 | BBox3fa boundSegmentNonlinear(MotionDerivativeCoefficients const& motionDerivCoeffs, |
| 266 | AffineSpace3fa const& xfm0, |
| 267 | AffineSpace3fa const& xfm1, |
| 268 | BBox3fa const& obbox0, |
| 269 | BBox3fa const& obbox1, |
| 270 | BBox3fa const& bbox0, |
| 271 | BBox3fa const& bbox1, |
| 272 | float tmin, |
| 273 | float tmax) |
| 274 | { |
| 275 | BBox3fa delta(Vec3fa(0.f), Vec3fa(0.f)); |
| 276 | float roots[32]; |
| 277 | unsigned int maxNumRoots = 32; |
| 278 | unsigned int numRoots; |
| 279 | const Interval1f interval(tmin, tmax); |
| 280 | |
| 281 | // loop over bounding box corners |
| 282 | for (int ii = 0; ii < 2; ++ii) |
| 283 | for (int jj = 0; jj < 2; ++jj) |
| 284 | for (int kk = 0; kk < 2; ++kk) |
| 285 | { |
| 286 | Vec3fa p0(ii == 0 ? obbox0.lower.x : obbox0.upper.x, |
| 287 | jj == 0 ? obbox0.lower.y : obbox0.upper.y, |
| 288 | kk == 0 ? obbox0.lower.z : obbox0.upper.z); |
| 289 | Vec3fa p1(ii == 0 ? obbox1.lower.x : obbox1.upper.x, |
| 290 | jj == 0 ? obbox1.lower.y : obbox1.upper.y, |
| 291 | kk == 0 ? obbox1.lower.z : obbox1.upper.z); |
| 292 | |
| 293 | // get extrema of motion of bounding box corner for each dimension |
| 294 | for (int dim = 0; dim < 3; ++dim) |
| 295 | { |
| 296 | MotionDerivative motionDerivative(motionDerivCoeffs, dim, p0, p1); |
| 297 | |
| 298 | numRoots = motionDerivative.findRoots(interval, bbox0.lower[dim] - bbox1.lower[dim], roots, maxNumRoots); |
| 299 | for (unsigned int r = 0; r < numRoots; ++r) { |
| 300 | float t = roots[r]; |
| 301 | const BBox3fa bt = lerp(bbox0, bbox1, t); |
| 302 | const Vec3fa pt = xfmPoint(slerp(xfm0, xfm1, t), lerp(p0, p1, t)); |
| 303 | delta.lower[dim] = std::min(delta.lower[dim], pt[dim] - bt.lower[dim]); |
| 304 | } |
| 305 | |
| 306 | numRoots = motionDerivative.findRoots(interval, bbox0.upper[dim] - bbox1.upper[dim], roots, maxNumRoots); |
| 307 | for (unsigned int r = 0; r < numRoots; ++r) { |
| 308 | float t = roots[r]; |
| 309 | const BBox3fa bt = lerp(bbox0, bbox1, t); |
| 310 | const Vec3fa pt = xfmPoint(slerp(xfm0, xfm1, t), lerp(p0, p1, t)); |
| 311 | delta.upper[dim] = std::max(delta.upper[dim], pt[dim] - bt.upper[dim]); |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | return delta; |
| 317 | } |
| 318 | |
| 319 | BBox3fa Instance::boundSegment(size_t itime, |
| 320 | BBox3fa const& obbox0, BBox3fa const& obbox1, |