Пример #1
0
	Collision Collider::IsColliding(const Collider& other) {
		Collision col;
		
		if (m_type == ColliderType::AABB && other.m_type == ColliderType::AABB)
			col =  AABBvsAABB(other);
		else if (m_type == ColliderType::Circle && other.m_type == ColliderType::Circle)
			col = CirclevsCircle(other);
		else if ((m_type == ColliderType::Circle && other.m_type == ColliderType::AABB) ||
				 (m_type == ColliderType::AABB && other.m_type == ColliderType::Circle))
			col = AABBvsCircle(other);

		return col;
	}
Пример #2
0
void Sim::collide() {

	contact->circle = ball;

	for (int i = 0; i < 4; i++) {

		if (inside(red[i].position.x - 1000, red[i].position.x + 1000, ball->position.x)) {
			for (int j = 0; j < red[i].size; j++) {

				contact->axis = red[i];
				contact->player = j;

				if (AABBvsCircle(contact)) resolveCollision(contact);
			}
		}



		if (inside(blu[i].position.x - 1000, blu[i].position.x + 1000, ball->position.x)) {
			for (int j = 0; j < blu[i].size; j++) {

				contact->axis = blu[i];
				contact->player = j;

				if (AABBvsCircle(contact)) resolveCollision(contact);
			}
		}

	}

	contactboundary->circle = ball;
	for (int i = 0; i < 6; i++) {
		contactboundary->box = &boundary[i];

		if (boundaryVsCircle(contactboundary)) resolveCollisionBoundary(contactboundary);
	}

}
Пример #3
0
bool CirclevsAABB(Object* a, Object* b)
{
	return AABBvsCircle(b, a);
}