bool Cube<pointType>::intersect(const pointType& ptStart,short axis,bool castForward) const { vec3_type pMax = _pMin + vec3_type(1,1,1)*_size; vec3_type pMin = _pMin; assert(axis<3); if (castForward) { if (ptStart[axis]>pMax[axis]) return false; } else { if (ptStart[axis]<pMin[axis]) return false; } short ax0 = (axis+1)>2 ? 0 :axis+1; short ax1 = (axis-1)<0 ? 2 :axis-1; return !( ptStart[ax0]<pMin[ax0] || ptStart[ax0]>pMax[ax0] || ptStart[ax1]<pMin[ax1] || ptStart[ax1]>pMax[ax1] ); }
bool Cube<pointType>::intersect(const Imath::Box<vec3_type>& box) const { vec3_type pMax = _pMin + vec3_type(1,1,1)*_size; vec3_type pMin = _pMin; vec3_type bMin = box.min; vec3_type bMax = box.max; bool bNotIntersect = bMin.x > pMax.x || bMin.y >pMax.y || bMin.z >pMax.z || bMax.x < pMin.x || bMax.y < pMin.y || bMax.z < pMin.z; return !bNotIntersect; }
int Cube<pointType>::intersect(const Imath::Plane3<T>& plane,T epsilon ) const { int nLocation = locatePoint( plane, _pMin, epsilon ) + locatePoint( plane, _pMin + vec3_type(0,_size,0),epsilon) + locatePoint( plane, _pMin + vec3_type(0,0,_size),epsilon) + locatePoint( plane, _pMin + vec3_type(0,_size,_size),epsilon) + locatePoint( plane, _pMin + vec3_type(_size,0,0),epsilon) + locatePoint( plane, _pMin + vec3_type(_size,_size,0),epsilon) + locatePoint( plane, _pMin + vec3_type(_size,0,_size),epsilon) + locatePoint( plane, _pMin + vec3_type(_size,_size,_size),epsilon); return (nLocation==-8) ? -1 : ( (nLocation == 8)? 1 : 0); }
bool Cube<pointType>::contains(const Cube& other) const { return contains(other._pMin) && contains(other._pMin + vec3_type(other._size,other._size,other._size)); }
RaySphereIntersectRec(typename Result::type result_ = Result::None, float_type t1_ = 0, const vec3_type& p1_ = vec3_type(), float_type t2_ = 0, const vec3_type& p2_ = vec3_type()) : result(result_), t1(t1_), t2(t2_), p1(p1_), p2(p2_) {}