#ifndef COLLISION_H
#define COLLISION_H

/*
** A Collision stores all contacts between two physical bodies. Note that two bodies only have
** one collision, regardless of the number of contact points.
*/

#include "Contact.h"

namespace Salamander
{

class Body;
class Polygon;
class Line;

class Collision
{
	friend class Application;

	public:
		Collision(Body* body1, Body* body2);
		~Collision();

		std::vector<Contact> getContacts();
		void setContacts(std::vector<Contact> contacts);
		unsigned int getNumContacts();

		void performPrecomputation(double inv_ms);
		void performIteration();
		void performPostcomputation();

	private:
		// TODO PHYS : better encapulation for shape contacts
		void generateContacts();
		void generateBodyContacts();
		void generatePolygonPolygonContacts();
		void generatePolygonLineContacts();

	private:
		Body* body1_;
		Body* body2_;
		double friction_;
		std::vector<Contact> contacts_;
		
		typedef std::vector<Contact>::iterator ContactIterator;

		// TODO PHYS : debugging only
		Body* contactBody_;
		unsigned int contactFace_;
		Body* incidentBody_;
		unsigned int incidentFace_;

};


}

#endif