#ifndef _PHYSICS_COLLISIONS_ #define _PHYSICS_COLLISIONS_ #include #include class Body; class Polygon; class Circle; class Collisions { public: class Contact { public: Body* body[2]; float penetration; float approachSpeed; wgd::Vector2D normal; wgd::Vector2D position; wgd::Vector3D offset[2]; float inverseMass[2]; float angularComponent[2]; bool isEdge[2]; int featureID[2]; void init (Body* b1, Body* b2); void recalculate (); void calculateVelocities (); void swapBodies (); }; static void init (); static void resolve (); static void draw (); static bool check (Body* b1, Body* b2); static bool checkBounds (Body* b1, Body* b2); static bool check (Circle* c1, Circle* c2); private: static std::vector contacts; static void resolveVelocities (Contact& data); static void resolvePenetration (Contact& data, float* moveLinear, float* moveAngular); static void updateVelocities (std::vector::iterator& here); static void updatePenetrations (std::vector::iterator& here, float* moveLinear, float* moveAngular); }; #endif