26 template <
typename Real>
43 template <
typename Real>
52 std::array<Vector2<Real>, 2>
point;
67 static bool Clip(Real denom, Real numer, Real&
t0, Real&
t1);
71 template <
typename Real>
79 box.GetCenteredForm(boxCenter, boxExtent);
85 DoQuery(lineOrigin, line.direction, boxExtent, result);
89 template <
typename Real>
96 boxExtent[0] *
std::abs(lineDirection[1]) +
97 boxExtent[1] *
std::abs(lineDirection[0]);
98 result.intersect = (LHS <= RHS);
101 template <
typename Real>
109 box.GetCenteredForm(boxCenter, boxExtent);
115 DoQuery(lineOrigin, line.direction, boxExtent, result);
116 for (
int i = 0; i < result.numIntersections; ++i)
118 result.point[i] = line.origin + result.parameter[i] * line.direction;
123 template <
typename Real>
134 Real
t0 = -std::numeric_limits<Real>::max();
135 Real
t1 = std::numeric_limits<Real>::max();
136 if (Clip(+lineDirection[0], -lineOrigin[0] - boxExtent[0], t0, t1) &&
137 Clip(-lineDirection[0], +lineOrigin[0] - boxExtent[0], t0, t1) &&
138 Clip(+lineDirection[1], -lineOrigin[1] - boxExtent[1], t0, t1) &&
139 Clip(-lineDirection[1], +lineOrigin[1] - boxExtent[1], t0, t1))
141 result.intersect =
true;
144 result.numIntersections = 2;
145 result.parameter[0] =
t0;
146 result.parameter[1] =
t1;
150 result.numIntersections = 1;
151 result.parameter[0] =
t0;
152 result.parameter[1] =
t0;
157 result.intersect =
false;
158 result.numIntersections = 0;
161 template <
typename Real>
163 Real numer, Real&
t0, Real&
t1)
167 if (numer > denom*t1)
171 if (numer > denom*t0)
177 else if (denom < (Real)0)
179 if (numer > denom*t0)
183 if (numer > denom*t1)
191 return numer <= (Real)0;
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
std::array< Vector2< Real >, 2 > point
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Real DotPerp(Vector2< Real > const &v0, Vector2< Real > const &v1)
std::array< Real, 2 > parameter
Result operator()(Type0 const &primitive0, Type1 const &primitive1)