41 const auto s = input.p1 - location;
45 const auto raySegment = input.p2 - input.p1;
46 const auto c =
Dot(s, raySegment);
58 const auto fraction =
Real{a / rr};
61 if ((fraction >=
Real{0}) && (fraction <= input.maxFraction))
78 const auto p1 = input.p1;
79 const auto pDelta = input.p2 - input.p1;
80 for (
auto i = decltype(pDelta.max_size()){0}; i < pDelta.max_size(); ++i)
82 const auto p1i = p1[i];
83 const auto pdi = pDelta[i];
84 const auto range = aabb.ranges[i];
89 if ((p1i < range.GetMin()) || (p1i > range.GetMax()))
96 const auto reciprocalOfPdi =
Real{1} / pdi;
97 auto t1 =
Real{(range.GetMin() - p1i) * reciprocalOfPdi};
98 auto t2 =
Real{(range.GetMax() - p1i) * reciprocalOfPdi};
112 tmax = std::min(tmax, t2);
122 if ((tmin < 0) || (tmin > input.maxFraction))
134 const auto vertexCount = proxy.GetVertexCount();
135 assert(vertexCount > 0);
137 const auto radius = proxy.GetVertexRadius();
138 auto v0 = proxy.GetVertex(0);
139 if (vertexCount == 1)
165 const auto ray0 = transformedInput.p1;
166 const auto ray = transformedInput.p2 - transformedInput.p1;
169 auto normalFound = GetInvalid<UnitVec>();
171 for (
auto i = decltype(vertexCount){0}; i < vertexCount; ++i)
173 const auto circleResult =
RayCast(radius, v0, transformedInput);
174 if (circleResult.has_value() && (minT > circleResult->fraction))
176 minT = circleResult->fraction;
177 normalFound = circleResult->normal;
180 const auto v1 = proxy.GetVertex(
GetModuloNext(i, vertexCount));
181 const auto edge = v1 - v0;
182 const auto ray_cross_edge =
Cross(ray, edge);
186 const auto normal = proxy.GetNormal(i);
187 const auto offset = normal * radius;
188 const auto v0off = v0 + offset;
189 const auto q_sub_p = v0off - ray0;
191 const auto reciprocalRayCrossEdge =
Real{1} / ray_cross_edge;
194 const auto t =
Cross(q_sub_p, edge) * reciprocalRayCrossEdge;
197 const auto u =
Cross(q_sub_p, ray) * reciprocalRayCrossEdge;
199 if ((t >= 0) && (t <= 1) && (u >= 0) && (u <= 1))
205 normalFound = normal;
221 if (minT <= input.maxFraction)
237 const auto abs_v =
abs(v);
242 while (!
empty(stack))
244 const auto index = stack.
top();
251 const auto aabb = tree.
GetAABB(index);
261 const auto separation =
abs(
Dot(v, input.
p1 - center)) -
Dot(abs_v, extents);
262 if (separation > 0_m)
270 stack.
push(branchData.child1);
271 stack.
push(branchData.child2);
277 const auto value = callback(leafData.fixture, leafData.childIndex, input);
297 fixture->
GetBody()->GetTransformation());
298 if (output.has_value())
300 const auto fraction = output->fraction;
301 assert(fraction >= 0 && fraction <= 1);
316 const auto point = input.
p1 + (input.
p2 - input.
p1) * fraction;
317 const auto opcode = callback(fixture, index, point, output->normal);