I have a arbitrarily deep tree structure of bodies in box2d. When a parent body collides with anything, it should move its children along. On the other hand, if the child is moved due to a collision, the parent should not be touched. One body can be a parent to one body and a child to another at the same time.
Is there a way to implement this in Box2D? None of the joints seem to be able to represent this, since they're all symmetrical.
Yes. Algorithmically speaking, use conceptually nested worlds.
Here's some pseudo code for this. You'll need to fill in details like setting the bodies to be dynamic and what there densities should be. But hopefully the code shows a way to get this done: