• entries
235
509
• views
172598

Torqued

136 views

Well, despite being my day off yesterday, I spent about 5 hours working on the physics some more. I decided to try to integrate
some ideas from some of oliii's excellent sample code. His Cube3D demo does a fairly convincing job of cubes bouncing off each other and some triangles, including angular momentum.

The long and short of it was that I just had a devil of a time getting to work as well as my old code. Undoubtedly this is because I understand my code better, and is in no way a knock on oliii's stuff. It certainly handled more cases than my code, but for the life of me I couldn't get the spherical boulder to rotate. The capsules rotated ok, but the sphere was a non-starter.

Just now I saved off that work, and went back to my old scheme. While integrating it back in, I fixed a couple of bugs with the
mass implementation, and whaddya know - now the mass and linear momentum work perfectly. The main remaining artifact right now is an occasional lack of falling over for the capsules.

Now capsules will tend to fall over when there is any impulse applied if they are on the ground, simply due to the angular impulse being computed by :

( Point of Contact - Center of Mass ) X Impulse

Since the point of contact can be far from the center of mass, and does not match the contact normal on the cylindrical part of the capsule, this tends to make the capsule lay flat.

The problem is that there is an additional factor I am not taking into account - gravity. Gravity applies a downward force at the center of mass, so if a capsule is exactly upright, there is no net torque, and so it can balance.

If the capsule is tilted off-center, or on an incline, it will experience a net torque due to gravity, and begin to rotate to lay on its side.

Right now I'm not handling torque, but I suppose I should for capsules. Another trick I am considering is to use some ideas from Jakobsen. The reason all those verlet demos have rotation is because when you have one of the stick particles moved out of collision, often the other one is not moved. This violates the length constraint, so it adjusts the length of the stick again, which together with the original move effectively gives a rotation of the object.

I don't want to switch to verlet for the integration method, but I can still use projection & relaxation to make the capsules react well.

Right now they are working great except for the gravity problem shown above, so hopefully that will be sorted out soon, one way or another.

There are no comments to display.

Create an account

Register a new account