18 template <
typename Real>
35 template <
typename Real>
57 Real rayParameter[2], segmentParameter[2];
65 template <
typename Real>
73 segment.GetCenteredForm(segOrigin, segDirection, segExtent);
78 auto llResult = llQuery(line0, line1);
79 if (llResult.numIntersections == 1)
82 if (llResult.line0Parameter[0] >= (Real)0
83 &&
std::abs(llResult.line1Parameter[0]) <= segExtent)
85 result.intersect =
true;
86 result.numIntersections = 1;
90 result.intersect =
false;
91 result.numIntersections = 0;
94 else if (llResult.numIntersections == std::numeric_limits<int>::max())
99 Real
t =
Dot(ray.direction, diff) + segExtent;
102 result.intersect =
true;
103 result.numIntersections = 2;
105 else if (t < (Real)0)
107 result.intersect =
false;
108 result.numIntersections = 0;
112 result.intersect =
true;
113 result.numIntersections = 1;
118 result.intersect =
false;
119 result.numIntersections = 0;
125 template <
typename Real>
133 segment.GetCenteredForm(segOrigin, segDirection, segExtent);
138 auto llResult = llQuery(line0, line1);
139 if (llResult.numIntersections == 1)
142 if (llResult.line0Parameter[0] >= (Real)0
143 &&
std::abs(llResult.line1Parameter[0]) <= segExtent)
145 result.intersect =
true;
146 result.numIntersections = 1;
147 result.rayParameter[0] = llResult.line0Parameter[0];
148 result.segmentParameter[0] = llResult.line1Parameter[0];
149 result.point[0] = llResult.point;
153 result.intersect =
false;
154 result.numIntersections = 0;
157 else if (llResult.numIntersections == std::numeric_limits<int>::max())
161 Real
t =
Dot(ray.direction, diff);
164 std::array<Real, 2> interval0 =
166 (Real)0, std::numeric_limits<Real>::max()
170 std::array<Real, 2> interval1 = { t - segExtent, t + segExtent };
174 auto iiResult = iiQuery(interval0, interval1);
175 if (iiResult.intersect)
177 result.intersect =
true;
178 result.numIntersections = iiResult.numIntersections;
179 for (
int i = 0; i < iiResult.numIntersections; ++i)
181 result.rayParameter[i] = iiResult.overlap[i];
182 result.segmentParameter[i] = iiResult.overlap[i] -
t;
183 result.point[i] = ray.origin +
184 result.rayParameter[i] * ray.direction;
189 result.intersect =
false;
190 result.numIntersections = 0;
195 result.intersect =
false;
196 result.numIntersections = 0;
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)