I'm hacking the contact solver to change "relative velocity at contact" to provide
conveyor belt functionality, and need help figuring out why a few objects wont go in the right direction of the
conveyor belt / suddenly change direction for no reason. Here's a demo (if it's not the "
conveyor belt" demo then cache is preventing reloading):
http://www.sideroller.com/wck/?f=11Every once in a while one of the triangles will go in the wrong direction.
And here's the hack:
Code:
// Relative velocity at contact
b2Vec2 dv = vB + b2Cross(wB, ccp->rB) - vA - b2Cross(wA, ccp->rA);
int flip = (c->manifold->type == b2Manifold::e_faceB ? -1 : 1);
dv.x += c->fixtureA->m_conveyorBeltSpeed * tangent.x * flip;
dv.y += c->fixtureA->m_conveyorBeltSpeed * tangent.y * flip;
dv.x -= c->fixtureB->m_conveyorBeltSpeed * tangent.x * flip;
dv.y -= c->fixtureB->m_conveyorBeltSpeed * tangent.y * flip;
Is there something else I should take into account to flip the effect? I figured taking into account the manifold type (faceA, faceB) would be allI needed.