Skip to content

Commit 99097b6

Browse files
committed
curves: simplify sweep intersector unstable tests and flatness check
In curve_intersector_sweep.h: - Replace m < 0.2f*length(W) with the equivalent squared form m*m < 0.04f*dot(W,W) to avoid a sqrt in the per-subdivision well-behavedness check. - Reuse the already cached local dir variable in unstable-angle tests instead of reconstructing Vec3fa(ray.dir) repeatedly. These are arithmetic-equivalent changes intended to lower instruction pressure in the recursive sweep intersector path used by round curves.
1 parent c03932b commit 99097b6

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

kernels/geometry/curve_intersector_sweep.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ namespace embree
246246
const vboolx valid_inner = cylinder_inner.intersect(org,dir,tc_inner,u_inner0,Ng_inner0,u_inner1,Ng_inner1);
247247

248248
/* at the unstable area we subdivide deeper */
249-
const vboolx unstable0 = (!valid_inner) | (abs(dot(Vec3vfx(Vec3fa(ray.dir)),Ng_inner0)) < 0.3f);
250-
const vboolx unstable1 = (!valid_inner) | (abs(dot(Vec3vfx(Vec3fa(ray.dir)),Ng_inner1)) < 0.3f);
249+
const vboolx unstable0 = (!valid_inner) | (abs(dot(Vec3vfx(dir),Ng_inner0)) < 0.3f);
250+
const vboolx unstable1 = (!valid_inner) | (abs(dot(Vec3vfx(dir),Ng_inner1)) < 0.3f);
251251

252252
/* subtract the inner interval from the current hit interval */
253253
BBox<vfloatx> tp0, tp1;
@@ -348,8 +348,7 @@ namespace embree
348348
const Vec3ff dQ2 = abs(3.0f*(P3-P2) - W);
349349
const Vec3ff max_dQ = max(dQ0,dQ1,dQ2);
350350
const float m = max(max_dQ.x,max_dQ.y,max_dQ.z); //,max_dQ.w);
351-
const float l = length(Vec3f(W));
352-
const bool well_behaved = m < 0.2f*l;
351+
const bool well_behaved = m*m < 0.04f*dot(Vec3f(W),Vec3f(W));
353352

354353
if (!well_behaved && stack.depth < max_depth) {
355354
stack.push();
@@ -415,8 +414,8 @@ namespace embree
415414
}
416415

417416
/* at the unstable area we subdivide deeper */
418-
const bool unstable0 = valid0 && ((!valid_inner) | (abs(dot(Vec3fa(ray.dir),Ng_inner0)) < 0.3f));
419-
const bool unstable1 = valid1 && ((!valid_inner) | (abs(dot(Vec3fa(ray.dir),Ng_inner1)) < 0.3f));
417+
const bool unstable0 = valid0 && ((!valid_inner) | (abs(dot(dir,Ng_inner0)) < 0.3f));
418+
const bool unstable1 = valid1 && ((!valid_inner) | (abs(dot(dir,Ng_inner1)) < 0.3f));
420419

421420
if ((unstable0 | unstable1) && (stack.depth < max_depth)) {
422421
stack.push();

0 commit comments

Comments
 (0)