roundlinei_intersector.h 5.7 KB

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