void Manifold::Initialize( void ) { // Calculate average restitution e = std::min( A->restitution, B->restitution ); // Calculate static and dynamic friction sf = std::sqrt( A->staticFriction * B->staticFriction ); df = std::sqrt( A->dynamicFriction * B->dynamicFriction ); for(uint32 i = 0; i < contact_count; ++i) { // Calculate radii from COM to contact Vec2 ra = contacts[i] - A->position; Vec2 rb = contacts[i] - B->position; Vec2 rv = B->velocity + Cross( B->angularVelocity, rb ) - A->velocity - Cross( A->angularVelocity, ra ); // Determine if we should perform a resting collision or not // The idea is if the only thing moving this object is gravity, // then the collision should be performed without any restitution if(rv.LenSqr( ) < (dt * gravity).LenSqr( ) + EPSILON) e = 0.0f; } }