bool DoesLineAndBoxCollide( const CVector2< PointType >& p1, const CVector2< PointType >& p2, const CVector2< PointType >& rect_low, const CVector2< PointType >& rect_high ) { if( IsPointInsideRect( p1, rect_low, rect_high ) ) return true; if( IsPointInsideRect( p2, rect_low, rect_high ) ) return true; CVector2< PointType > result; typedef CVector2< PointType > vec2; if( LineIntersection( p1, p2, rect_low, vec2( rect_low.x, rect_high.y ), result ) ) return true; if( LineIntersection( p1, p2, vec2( rect_low.x, rect_high.y ), rect_high, result ) ) return true; if( LineIntersection( p1, p2, rect_high, vec2( rect_high.x, rect_low.x ), result ) ) return true; if( LineIntersection( p1, p2, vec2( rect_high.x, rect_low.x ), rect_low, result ) ) return true; return false; }
//private bool Substance::AmIOutOfRange() const { //範囲が設定されてないなら無視 if (m_idea->m_activeRange.Width() == 0) return false; //画面外なら if (!IsPointInsideRect(m_pos, m_idea->m_activeRange)) { return true; } else return false; }