Precomputing trajectory and collision

Hi,

I am trying to precompute the trajectory of a ball going through a world of dynamic and static objects. You can see a video here to understand what I mean. On the video, there is a white/gray line showing the trajectory. I did it the following easy way:
- Running the simulation multiple times in a row and saving the position of the launched ball each frame. Then I reset every thing that moved during this simulation.

It's working but it's extremely slow. Here are a few ideas to optimize that I already had (and tried for most of them):

- Set all dynamic objects as static to speed up the computations. I tried it, it speeds things up but of course, the collision response is wrong.
- Precomputing the trajectory without any collisions. Then use this trajectory to simplify the world update (no need to update the main ball). I am not sure this will speed anything as the collision detection is what is taking time. It would probably require many hacks in the box2d engine.
- Doing it in multiple frames : some objects are moving across the screen, it would give wrong results
- Using raycast : tried it: if my ball is hitting an object on its side, the precomputed trajectory doesn't get it as rays have no width.

So, do you guys have any ideas on other things I could try to achieve this?

Thanks for your help!

Dave.
Do the trajectory need to be exact or can it be approximate?

If it has to be exact, you're pretty much forced to make a deep copy of the entire Box2d state each time due to chaotic behaviors.
I do need exact evaluation.
I'm doing it using Box2D.XNA and most of the time is spent in ContactManager.FindNewContacts (and DynamicTree.Rebalance inside it).
I might simple make a shorter evaluation and stop evaluation as soon as I find a contact. It's really not as good gameplay-wise but it's better than nothing.

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