spherei_intersector.h 6.4 KB

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