Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


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.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!