18 template <
int N,
typename Real>
36 template <
int N,
typename Real>
42 result.sqrDistance = (Real)0;
43 for (
int i = 0; i < N; ++i)
45 if (box0.min[i] >= box1.max[i])
47 Real delta = box0.min[i] - box1.min[i];
48 result.sqrDistance += delta * delta;
49 result.closestPoints[0].min[i] = box0.min[i];
50 result.closestPoints[0].max[i] = box0.min[i];
51 result.closestPoints[1].min[i] = box1.max[i];
52 result.closestPoints[1].max[i] = box1.max[i];
54 else if (box1.min[i] >= box0.max[i])
56 Real delta = box1.min[i] - box0.max[i];
57 result.sqrDistance += delta * delta;
58 result.closestPoints[0].min[i] = box0.max[i];
59 result.closestPoints[0].max[i] = box0.max[i];
60 result.closestPoints[1].min[i] = box1.min[i];
61 result.closestPoints[1].max[i] = box1.min[i];
65 std::array<Real, 2> intr0 = { box0.min[i], box0.max[i] };
66 std::array<Real, 2> intr1 = { box1.min[i], box1.max[i] };
68 auto iiResult =
query(intr0, intr1);
69 for (
int j = 0; j < 2; ++j)
71 result.closestPoints[j].min[i] = iiResult.overlap[0];
72 result.closestPoints[j].max[i] = iiResult.overlap[1];
GLsizei GLsizei GLfloat distance
static Real Sqrt(Real const &x)
Result operator()(Type0 const &primitive0, Type1 const &primitive1)