diff options
Diffstat (limited to 'thirdparty/embree/kernels/geometry/curve_intersector_distance.h')
-rw-r--r-- | thirdparty/embree/kernels/geometry/curve_intersector_distance.h | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/thirdparty/embree/kernels/geometry/curve_intersector_distance.h b/thirdparty/embree/kernels/geometry/curve_intersector_distance.h index 748a9511a5..80e1760289 100644 --- a/thirdparty/embree/kernels/geometry/curve_intersector_distance.h +++ b/thirdparty/embree/kernels/geometry/curve_intersector_distance.h @@ -45,15 +45,56 @@ namespace embree vfloat<M> vv; vfloat<M> vt; }; - + template<typename NativeCurve3fa> + struct DistanceCurveHit<NativeCurve3fa,1> + { + enum { M = 1 }; + + __forceinline DistanceCurveHit() {} + + __forceinline DistanceCurveHit(const vbool<M>& valid, const vfloat<M>& U, const vfloat<M>& V, const vfloat<M>& T, const int i, const int N, + const NativeCurve3fa& curve3D) + : U(U), V(V), T(T), i(i), N(N), curve3D(curve3D), valid(valid) {} + + __forceinline void finalize() + { + vu = (vfloat<M>(step)+U+vfloat<M>(float(i)))*(1.0f/float(N)); + vv = V; + vt = T; + } + + __forceinline Vec2f uv () const { return Vec2f(vu,vv); } + __forceinline float t () const { return vt; } + __forceinline Vec3fa Ng() const { return curve3D.eval_du(vu); } + + public: + vfloat<M> U; + vfloat<M> V; + vfloat<M> T; + int i, N; + NativeCurve3fa curve3D; + + public: + vbool<M> valid; + vfloat<M> vu; + vfloat<M> vv; + vfloat<M> vt; + }; + + template<typename NativeCurve3fa, int W = VSIZEX> struct DistanceCurve1Intersector1 { + using vboolx = vbool<W>; + using vintx = vint<W>; + using vfloatx = vfloat<W>; + using Vec4vfx = Vec4vf<W>; + template<typename Epilog> - __forceinline bool intersect(const CurvePrecalculations1& pre,Ray& ray, - IntersectContext* context, + __forceinline bool intersect(const CurvePrecalculations1& pre, Ray& ray, + RayQueryContext* context, const CurveGeometry* geom, const unsigned int primID, - const Vec3fa& v0, const Vec3fa& v1, const Vec3fa& v2, const Vec3fa& v3, + const Vec3ff& v0, const Vec3ff& v1, const Vec3ff& v2, const Vec3ff& v3, const Epilog& epilog) { const int N = geom->tessellationRate; @@ -65,8 +106,8 @@ namespace embree /* evaluate the bezier curve */ vboolx valid = vfloatx(step) < vfloatx(float(N)); - const Vec4vfx p0 = curve2D.template eval0<VSIZEX>(0,N); - const Vec4vfx p1 = curve2D.template eval1<VSIZEX>(0,N); + const Vec4vfx p0 = curve2D.template eval0<W>(0,N); + const Vec4vfx p1 = curve2D.template eval1<W>(0,N); /* approximative intersection with cone */ const Vec4vfx v = p1-p0; @@ -86,19 +127,19 @@ namespace embree /* update hit information */ bool ishit = false; if (unlikely(any(valid))) { - DistanceCurveHit<NativeCurve3fa,VSIZEX> hit(valid,u,0.0f,t,0,N,curve3D); + DistanceCurveHit<NativeCurve3fa,W> hit(valid,u,0.0f,t,0,N,curve3D); ishit = ishit | epilog(valid,hit); } - if (unlikely(VSIZEX < N)) + if (unlikely(W < N)) { /* process SIMD-size many segments per iteration */ - for (int i=VSIZEX; i<N; i+=VSIZEX) + for (int i=W; i<N; i+=W) { /* evaluate the bezier curve */ vboolx valid = vintx(i)+vintx(step) < vintx(N); - const Vec4vfx p0 = curve2D.template eval0<VSIZEX>(i,N); - const Vec4vfx p1 = curve2D.template eval1<VSIZEX>(i,N); + const Vec4vfx p0 = curve2D.template eval0<W>(i,N); + const Vec4vfx p1 = curve2D.template eval1<W>(i,N); /* approximative intersection with cone */ const Vec4vfx v = p1-p0; @@ -117,7 +158,7 @@ namespace embree /* update hit information */ if (unlikely(any(valid))) { - DistanceCurveHit<NativeCurve3fa,VSIZEX> hit(valid,u,0.0f,t,i,N,curve3D); + DistanceCurveHit<NativeCurve3fa,W> hit(valid,u,0.0f,t,i,N,curve3D); ishit = ishit | epilog(valid,hit); } } |