Double update phase

Topics: Developer Forum, User Forum
May 25, 2009 at 12:07 AM


I am new to Farseer Physics but already tried different things. I am developing a 2D game using XNA and I am trying to apply a special physics algorithm for fluids. This algorithm is, for the part where fluids can push bodies, like this :

1. foreach body
   2. save original body position and orientation
   3. advance body using V and w
   4. clear force and torque buffers
   5. foreach particle inside the body
      6. compute collision impulse I
      7. add I contribution to force and torque buffers
8. foreach body
   9. modify V with force and w with torque
   10. advance from original position using V and w
11. resolve collisions and contacts between bodies

There is another part where bodies push fluids, this one works very well thanks to your distance grid.

So, to apply this algorithm I need to do the whole simulation step once (in step 3), update force and torque buffers (step 7) and do the simulation again with the bodies in their original positions (step 10) but with the new forces. I already tried to restore the bodies to their original state after one simulation step using the _previous* fields in Body but it breaks the joints (in the dynamics angle joints sample for example). Do you have any insights on how I can achieve what I want? Thanks.

Remi Gillig.