linei_intersector.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright 2009-2021 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "linei.h"
  5. #include "line_intersector.h"
  6. #include "intersector_epilog.h"
  7. namespace embree
  8. {
  9. namespace isa
  10. {
  11. template<int M, bool filter>
  12. struct FlatLinearCurveMiIntersector1
  13. {
  14. typedef LineMi<M> Primitive;
  15. typedef CurvePrecalculations1 Precalculations;
  16. static __forceinline void intersect(const Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive& line)
  17. {
  18. STAT3(normal.trav_prims,1,1,1);
  19. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  20. Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
  21. const vbool<M> valid = line.valid();
  22. FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Intersect1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
  23. }
  24. static __forceinline bool occluded(const Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive& line)
  25. {
  26. STAT3(shadow.trav_prims,1,1,1);
  27. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  28. Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
  29. const vbool<M> valid = line.valid();
  30. return FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Occluded1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
  31. }
  32. static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& line)
  33. {
  34. return PrimitivePointQuery1<Primitive>::pointQuery(query, context, line);
  35. }
  36. };
  37. template<int M, bool filter>
  38. struct FlatLinearCurveMiMBIntersector1
  39. {
  40. typedef LineMi<M> Primitive;
  41. typedef CurvePrecalculations1 Precalculations;
  42. static __forceinline void intersect(const Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive& line)
  43. {
  44. STAT3(normal.trav_prims,1,1,1);
  45. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  46. Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time());
  47. const vbool<M> valid = line.valid();
  48. FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Intersect1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
  49. }
  50. static __forceinline bool occluded(const Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive& line)
  51. {
  52. STAT3(shadow.trav_prims,1,1,1);
  53. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  54. Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time());
  55. const vbool<M> valid = line.valid();
  56. return FlatLinearCurveIntersector1<M>::intersect(valid,ray,context,geom,pre,v0,v1,Occluded1EpilogM<M,filter>(ray,context,line.geomID(),line.primID()));
  57. }
  58. static __forceinline bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& line)
  59. {
  60. return PrimitivePointQuery1<Primitive>::pointQuery(query, context, line);
  61. }
  62. };
  63. template<int M, int K, bool filter>
  64. struct FlatLinearCurveMiIntersectorK
  65. {
  66. typedef LineMi<M> Primitive;
  67. typedef CurvePrecalculationsK<K> Precalculations;
  68. static __forceinline void intersect(const Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& line)
  69. {
  70. STAT3(normal.trav_prims,1,1,1);
  71. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  72. Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
  73. const vbool<M> valid = line.valid();
  74. FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Intersect1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
  75. }
  76. static __forceinline bool occluded(const Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& line)
  77. {
  78. STAT3(shadow.trav_prims,1,1,1);
  79. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  80. Vec4vf<M> v0,v1; line.gather(v0,v1,geom);
  81. const vbool<M> valid = line.valid();
  82. return FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Occluded1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
  83. }
  84. };
  85. template<int M, int K, bool filter>
  86. struct FlatLinearCurveMiMBIntersectorK
  87. {
  88. typedef LineMi<M> Primitive;
  89. typedef CurvePrecalculationsK<K> Precalculations;
  90. static __forceinline void intersect(const Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& line)
  91. {
  92. STAT3(normal.trav_prims,1,1,1);
  93. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  94. Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time()[k]);
  95. const vbool<M> valid = line.valid();
  96. FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Intersect1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
  97. }
  98. static __forceinline bool occluded(const Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& line)
  99. {
  100. STAT3(shadow.trav_prims,1,1,1);
  101. const LineSegments* geom = context->scene->get<LineSegments>(line.geomID());
  102. Vec4vf<M> v0,v1; line.gather(v0,v1,geom,ray.time()[k]);
  103. const vbool<M> valid = line.valid();
  104. return FlatLinearCurveIntersectorK<M,K>::intersect(valid,ray,k,context,geom,pre,v0,v1,Occluded1KEpilogM<M,K,filter>(ray,k,context,line.geomID(),line.primID()));
  105. }
  106. };
  107. }
  108. }