The essence of the situation: There are two overlapping shapes; I want one to be "ethereal" in some sense. So I want the shapes to slide freely through one another. I allow this by returning false from shouldCollide(). But I want the "ethereal" shape to become "solid" when it stops overlapping the other shape. A custom ContactListener handles this--it changes something when the contact is removed, so that ContactFilter.shouldCollide() (which also has a custom implementation) will return true if it's called at any time after the two shapes have slid apart. So far, so good.
Here's the problem: Sometimes the shapes separate, so I want them to start colliding, but they don't separate far enough for their bounding boxes to separate. When they slide back together, they don't collide even though I want them to collide. Although shouldCollide()'s result changed, that didn't matter because shouldCollide() was never called.
If the shapes slide far apart and come back together, shouldCollide() is called when I expect, and my plan works.
How can I achieve the behavior I want, even when the shapes only separate slightly, with their bounding boxes still touching? (I think the bounding boxes are involved, anyway. I haven't proved it, but I've seen evidence of it.) I've tried making the "ethereal" shape a sensor, rather than relying on shouldCollide(), and then turning it into a non-sensor when it stops contacting the other shape. But that produces the same problem. The change in Shape.m_isSensor has no effect unless the bounding boxes separate. It's not good enough for the shapes to separate.
I'm sure I could hack around the problem if I tried, but it'd probably be ugly... if shouldCollide() were called every time the shapes were about to touch, and not just when their bounding boxes were about to touch, my program would work perfectly! Is there a nice way to achieve something like this?
Here's the problem: Sometimes the shapes separate, so I want them to start colliding, but they don't separate far enough for their bounding boxes to separate. When they slide back together, they don't collide even though I want them to collide. Although shouldCollide()'s result changed, that didn't matter because shouldCollide() was never called.
If the shapes slide far apart and come back together, shouldCollide() is called when I expect, and my plan works.
How can I achieve the behavior I want, even when the shapes only separate slightly, with their bounding boxes still touching? (I think the bounding boxes are involved, anyway. I haven't proved it, but I've seen evidence of it.) I've tried making the "ethereal" shape a sensor, rather than relying on shouldCollide(), and then turning it into a non-sensor when it stops contacting the other shape. But that produces the same problem. The change in Shape.m_isSensor has no effect unless the bounding boxes separate. It's not good enough for the shapes to separate.
I'm sure I could hack around the problem if I tried, but it'd probably be ugly... if shouldCollide() were called every time the shapes were about to touch, and not just when their bounding boxes were about to touch, my program would work perfectly! Is there a nice way to achieve something like this?