#ifndef JOINT_H
#define JOINT_H

namespace Salamander
{

/*
** Constrains objects together
*/

class Joint
{
	// collision performs the contact between two bodies, and therefore
	// needs access to our private members
friend class Collision;
friend class Application;

public:
	Joint();
	Joint(Body* body1, Body* body2, Vec2& anchor, double bias = 0.2f, double softness = 0.0f);
	~Joint();

public:
	// get & set
	Body* getBody(unsigned int i);
	bool setBody(unsigned int i, Body* body);

	// other methods
	void performPrecomputation(double inv_ms);
	void performIteration();

private:
	Mat2 transform_;
	Vec2 localAnchor1_;
	Vec2 localAnchor2_;
	Vec2 rotation1_;
	Vec2 rotation2_;
	Vec2 bias_;
	Vec2 accImpulse_;
	Body* body1_;
	Body* body2_;
	double biasFactor_;
	double softness_;

};
}

#endif	// JOINT_H