Could you save contact information along with the rest ? I mean, in some custom format of yours.
I shouldn't need to save contact information, I get it from the world and it's automatically updated by the world every tick. I just call body.getBodiesInContact or something like that. It works after world.update runs once, but not before.
I did this at one point, to update contacts without telling the World to step:
world.m_contactManager.collide();
I had to hack World to make the contact manager public. I wasn't ever stepping the World involved, though, so I don't know whether my hack is compatible with stepping. I suspect it is.
But if a full step across a zero-length time interval does the job for you and doesn't seem to ruin anything, then maybe you should just go with that, unless an expert chimes in here to say you shouldn't. The zero-duration update doesn't take too long, does it? I mean, if your world is simple enough for you to be simulating it in real time (which presumably you are doing at some point), then surely an occasional save/load action can afford to spend the time needed for a single simulation step.
Well, I haven't actually tried it with a 0-length update, because I'm not sure if it will work, or if it does, I'm not sure if it will work entirely, or break something else, because that seems like an edge-case that wouldn't be tested well.
I've just tried it in my program--instead of using stepSize, I used (random.nextBoolean() ? stepSize : 0). More or less. My simulation looked fine; only the frame rate appeared to be harmed.
The source code for World.step() shows why:
// Update contacts.
m_contactManager.collide();
// Integrate velocities, solve velocity constraints, and integrate positions.
if (step.dt > 0.0f) {
solve(step);
}
// Handle TOI events.
if (m_continuousPhysics && step.dt > 0.0f) {
solveTOI(step);
}
Collision always happens, but the big body-movement work in solve() only happens if the time step is positive. I don't know the intention here for certain, but it does look like somebody has prepared the way for you to use a zero-length time step to solve your problem.
(I'd shut up and let the experts explain, but this subforum is short on experts.)
Thank you. This sounds like exactly what I need.