607011 / impac-t

A Breakout/Bolo clone, improved with a physics engine
15 stars 11 forks source link

experiment with half open lines as boundaries to prevent stuck racket problem #16

Closed 607011 closed 9 years ago

607011 commented 9 years ago

See issue #7

607011 commented 9 years ago

Hint for solution:

The OneSidedPlatform test in the Box2D testbed uses the PreSolve() contact listener to reset the collision bit of a body by calling contact->SetEnabled(false):

void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
    b2Fixture* fixtureA = contact->GetFixtureA();
    b2Fixture* fixtureB = contact->GetFixtureB();
    if (fixtureA != m_platform && fixtureA != m_character)
        return;

    if (fixtureB != m_platform && fixtureB != m_character)
        return;

    b2Vec2 position = m_character->GetBody()->GetPosition();

    if (position.y < m_top + m_radius - 3.0f * b2_linearSlop) {
        contact->SetEnabled(false);
    }
}
607011 commented 9 years ago

Resolved with commit dd61e49f76133b1b433b04b2c7eb0340a99153eb