Example #1
0
bool MapObject::Intersects(const MapObject& object) const
{
	//check if distance between objects is less than sum of furthest points
	float distance = Helpers::Vectors::GetLength(m_centrePoint + object.m_centrePoint);
	if(distance > (m_furthestPoint + object.m_furthestPoint)) return false;

	//check intersection if either object contains a point of the other
	for(auto& p : object.m_polypoints)
		if(Contains(p + object.GetPosition())) return true;

	for(auto& p : m_polypoints)
		if(object.Contains(p + GetPosition())) return true;

	return false;
}