11 #ifndef __UT_BoundingRectImpl_H__
12 #define __UT_BoundingRectImpl_H__
16 #define FASTBOX(idx) \
17 ray = T(1.0) / (v1(idx) - v0(idx)); \
18 positive = (ray > T(0.0)); \
19 t1 = (vals[idx][ positive] - v0(idx))*ray; \
20 if (t1 < tmax) { if (t1 < tmin) return 0; else tmax = t1; } \
21 t1 = (vals[idx][1-positive] - v0(idx))*ray; \
22 if (t1 > tmin) { if (t1 > tmax) return 0; else tmin = t1; }
66 if (v0eqv1 || v0eqv2 || v1eqv2)
75 cp0 =
cross(l01, v2 - v0);
76 cp1 =
cross(l12, v0 - v1);
77 cp2 =
cross(l20, v1 - v2);
80 if (cp0 == 0.0 || cp1 == 0.0 || cp2 == 0.0)
89 if (cp0 *
cross(l01, center - v0) >= 0.0 &&
90 cp1 *
cross(l12, center - v1) >= 0.0 &&
91 cp2 *
cross(l20, center - v2) >= 0.0)
102 T newx, newy, dx, dy;
109 else if(x > vals[0][1])
114 newx = ((x-vals[0][0]) < (vals[0][1]-x)) ? vals[0][0] : vals[0][1];
115 dx = (newx - x > 0.0) ? newx - x : x - newx;
121 else if(y > vals[1][1])
126 newy = ((y-vals[1][0]) < (vals[1][1]-y)) ? vals[1][0] : vals[1][1];
127 dy = (newy - y > 0.0) ? newy - y : y - newy;
137 if (touchx) *touchx = 1;
142 if (touchy) *touchy = 1;
148 if (touchy) *touchy = 1;
154 if (touchx) *touchx = 1;
158 if (touchy) *touchy = 1;
163 #define TESTFACE(face, min, face1) \
164 t = (vals[face][min] - o(face)) * invd(face); \
165 if (t >= (T)0 && t < tmin) \
167 t1 = o(face1) + t*d(face1); \
168 if (t1 >= vals[face1][0] && t1 <= vals[face1][1]) \
175 template <
typename T>
195 if (found == -1)
return 0;
197 if (dist) *dist = tmin;
198 if (xsect) *xsect = o + tmin*d;
205 #endif // __UT_BoundingRectImpl_H__
GA_API const UT_StringHolder dist
GLfloat GLfloat GLfloat v2
#define TESTFACE(face, min, face1)
int intersectRay(const UT_Vector2T< T > &orig, const UT_Vector2T< T > &dir, T tmax=1E17, T *distance=0, UT_Vector2T< T > *xsect=0) const
void project(T &x, T &y, int *touchx=0, int *touchy=0) const
int intersects(const UT_Vector2T< T > &v0, const UT_Vector2T< T > &v1, const UT_Vector2T< T > &v2) const
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool intersects(const Box< Vec3< T >> &b, const Line3< T > &r, Vec3< T > &ip) IMATH_NOEXCEPT
constexpr SYS_FORCE_INLINE bool isEqual(const UT_Vector2T &b, const T tolerance=SYS_FTOLERANCE) const noexcept
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)