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