Torqued

Published August 22, 2005
Advertisement
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.
Previous Entry Angular Response
Next Entry Fast Capsules
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

1.2 Almost ready...

1114 views

Sound Paths

1332 views

Stately Progress

1134 views

State Lines

1284 views

Pulsing

867 views

Return to The Ship!

1008 views

Cameras & Boxes

1125 views
Advertisement