conelinei_intersector.h 5.9 KB

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