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