Verlet Integration (Olii?)

Started by
4 comments, last by Shael 19 years, 4 months ago
Hello, I've been working on getting a simple physics sim up and running using the verlet integration scheme, but Im having a bit of a problem. Objects seem to want to "blow up", especially squares, but triangles seem to work ok. It seems if any force is applied to any of the particles of the square or other objects(like a quick stickman I made) it seems to get really messed up. I've uploaded my code and two compiled versions of it, with force and without force. Your help is much appreciated. Thanks. http://darknight.bluewolf72.com/verlet.zip
Advertisement
Anyone at all ? I really need to get this working. :(
You need to look at the Constrain code in your stick constraint - there are some problems with it:

1. The loop is in the wrong place - the loop should be over ALL constraints (including non-penetration constraints). As it is the code above _should_ resolve the individual constraint immediately (but see below!), so after the first iteration it wouldn't do anything.

2. The integration of the points is in the wrong place - it should be outside the constraint loop. At the moment if a particle has no constraints it won't get updated at all, and if it is attached to 10 constraints it would get updated 10 times (etc).

3. I also noticed that you need to _set_ the force vector, not accumulate to it, since at the moment it constantly builds up over time, so will make things blow up anyway!
Ok, well I took your advice and did some changes and have gotten it a little better. But the square still blows up (just not as quick).

http://darknight.bluewolf72.com/Test.zip

"3. I also noticed that you need to _set_ the force vector, not accumulate to it, since at the moment it constantly builds up over time, so will make things blow up anyway!"

By that I take it you mean I should clear out the forces after each integration ?

I changed it to do that. I did the rest of what you said also, and the above test is the result. It works slightly better but it still blows up.

Any more suggestions ? Im thinking it might be something to do with the square creation.

*Edit* btw: the square works fine if you take out the diagonal constraints, but then it will just collapse of course *Edit*

[Edited by - Shael on December 4, 2004 9:40:32 PM]
your constraints are fine, there are just a couple of things...
- don't step the particles in the constraint code. All the particles should be stepped only once, before applying all the constraint.
- reset the force on particles at the end of the integration.

Everything is better with Metal.

Thanks guys. Working well now.

This topic is closed to new replies.

Advertisement