12 #ifndef __VGEO_Ray_H__
13 #define __VGEO_Ray_H__
24 #define VGEO_RAY_VECTORIZED 1
49 #if !VGEO_RAY_VECTORIZED
58 #if !VGEO_RAY_VECTORIZED
69 float &tmin,
float &tmax)
const
71 #if !VGEO_RAY_VECTORIZED
72 getRangeAxis<0>(box, tmin, tmax);
73 getRangeAxis<1>(box, tmin, tmax);
74 getRangeAxis<2>(box, tmin, tmax);
80 int sign0 = mySign[0];
81 int sign1 = mySign[1];
82 int sign2 = mySign[2];
83 v4uf t1(box.vals[0][sign0 ], box.vals[1][sign1 ], box.vals[2][sign2 ], tmax);
84 v4uf t2(box.vals[0][sign0^1], box.vals[1][sign1^1], box.vals[2][sign2^1], tmin);
91 float tmaxlocal = vmin(tmaxtemp, tmaxtemp.
swizzle<1,1,1,1>())[0];
92 float tminlocal = vmax(tmintemp, tmintemp.
swizzle<1,1,1,1>())[0];
95 return tminlocal <= tmaxlocal;
99 int sign0 = mySign[0];
100 int sign1 = mySign[1];
101 int sign2 = mySign[2];
102 UT_Vector3 t1(box.vals[0][sign0 ], box.vals[1][sign1 ], box.vals[2][sign2 ]);
103 UT_Vector3 t2(box.vals[0][sign0^1], box.vals[1][sign1^1], box.vals[2][sign2^1]);
108 tmin =
SYSmax(tmin, t2(0), t2(1), t2(2));
109 tmax =
SYSmin(tmax, t1(0), t1(1), t1(2));
117 #if !VGEO_RAY_VECTORIZED
120 {
return *
reinterpret_cast<const UT_Vector3*
>(&myP); }
124 #if !VGEO_RAY_VECTORIZED
127 {
return *
reinterpret_cast<const UT_Vector3*
>(&myID); }
142 if (myMaxD < 0) computeN();
150 void save(std::ostream &os)
const;
153 void dump()
const { save(std::cerr); }
156 #if !VGEO_RAY_VECTORIZED
174 #if !VGEO_RAY_VECTORIZED
177 float &tmin,
float &tmax)
const
179 int sign = mySign[axis];
180 float t1 = (box.
vals[axis][
sign] - myP(axis)) * myID(axis);
181 float t2 = (box.
vals[axis][sign^1] - myP(axis)) * myID(axis);
182 tmax = t1 < tmax ? t1 : tmax;
183 tmin = t2 > tmin ? t2 : tmin;
186 void computeN()
const;
void translate(VGEO_Ray &newRay, const UT_Vector3 &t) const
Construct a translated version of this ray.
void dump() const
Dump the ray to stderr.
SYS_FORCE_INLINE UT_Vector3 getPt(const float &t) const
void itranslate(VGEO_Ray &newRay, const UT_Vector3 &t) const
SYS_FORCE_INLINE const int * getSign() const
IMATH_HOSTDEVICE constexpr int sign(T a) IMATH_NOEXCEPT
GA_API const UT_StringHolder transform
SYS_FORCE_INLINE const UT_Vector3 & getID() const
const UT_Vector3 & getN2() const
SYS_FORCE_INLINE const UT_Vector3 & getD() const
SYS_FORCE_INLINE const UT_Vector3 & getP() const
SYS_FORCE_INLINE bool getBoxRange(const UT_BoundingBox &box, float &tmin, float &tmax) const
VGEO_Ray(const UT_Vector3 &P, const UT_Vector3 &D)
SYS_FORCE_INLINE v4uf swizzle() const
const UT_Vector3 & getN1() const