#include "Salamander.h"
#include "Contact.h"

namespace Salamander
{

Contact::Contact()
{
	separation_ = -DBL_MAX;
}

Contact::~Contact()
{
}

bool Contact::updateSeparation(Vec2 overlap1, Vec2 overlap2, double& separation)
{
	// overlap1 is to the left of overlap2
	if(overlap1.x_ + overlap1.y_ < overlap2.x_ + overlap2.y_)
	{
		separation = overlap2.x_ - overlap1.y_;
	}
	else
	{
		separation = overlap1.x_ - overlap2.y_;
	}

	// update our member if this is a smaller separation
	if(separation >= separation_) 
	{
		separation_ = separation;
		return true;
	}

	return false;

}

}
