Original Post
Hi all, This is a bit of a follow up of the following post : http://www.gamedev.net/community/forums/topic.asp?topic_id=367668 After seeing this post, I went back to my application and changed my Euler integrator for a RK4 integrator. I'm doing cloth simulation with point mass and when using the same Force and dampening for the spring as my Euler simulation, my RK4 becomes so unstable that I eventually lose my cloth. I also use the same time step for both my RK4 and Euler implementation. To make sure that my integrator was working properly, I compiled jjd's code(provided in the post referenced on top) and compared result in a free fall. Beside double vs float, the result of the free fall are similar. On a free fall, the simulation seems to fail on the introduction of small errors on x and z, caused by draging force acting on the particles. I would have thought that the integrator and calculating Hooke force with damping would easily take care of those errors. But they quickly get exagerated and the simulation gets out of control. Locking a point mass in position (or two for simulating a flag), makes the simulation much harder to debug, which is why I'm just currently dealing with free fall. I have to say that I can make it work, even with RK4, by bringing down the force of the spring and by bring up the dampening. Since RK4 should be more stable then Euler, I wouldn't expect that I had to do this though. My Euler simulation is the same except for the integration, how can it be more stable then RK4? On a free fall, the acceleration is constant. Using the integrator provided by jjd as an example, the result for the position in K2 and K3 is always the same, is this the expected result? All the example of derive function always seems to discard the time and use a constant acceleration. When I first started the implementation of RK4 on my cloth, I would recalculate the Hooke force between each node after a step (So calculate RK1 for all pointmass, then recalculate Hooke force, then calculate RK2...). I'm not sure that was the right approach, it just seemed like a very expensive operation to do. So when I changed this, I changed it so that I would perform the full RK4 calculation on each point mass. Before, my force would be different between each step (r1 to rk2 to rk3), so was my acceleration of course. But now, I calculate my Hooke force and then run the integrator, which means the acceleration is constant for every step and K2.pos == k3.pos, which seems pointless. Can anyone point me in the right direction for applying RK4 to cloth...anything beside going with verlet (that's my next project). Thanks, Shadx