Tweaking Contact Relative Velocity

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=11

Every 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.
You should add a bias to vt instead.
Ok, below is what I ended up with. I still get triangles that randomly change direction though. Obviously under certain circumstances I need to flip the direction of "vt" but I cannot fathom what that condition could be. And why only the triangles?!?

Code:
// Compute tangent force
float32 vt = b2Dot(dv, tangent);
         
int flip = (c->manifold->type == b2Manifold::e_faceB ? -1 : 1);
vt += c->fixtureA->m_conveyorBeltSpeed * flip;
vt -= c->fixtureB->m_conveyorBeltSpeed * flip;


Anyway thanks, close enough I guess.

Original thread: https://box2d.org/forum/viewtopic.php?t=5413