Problems with collision and fast objects
Posted: Mon Aug 20, 2012 11:17 am
Hi everybody!
I am having some problems with object passing though other objects. This happens mostly with fast objects. I saw some other post on the forum about this subject, and based also on my observations, it does seem that the collision check would take place between two time steps and this is why it is skipped.
Things get more complicated when you consider two scenarios that make you game run slower: running on older machines and capturing video with some program, like with FRAPS.
Collision issues are very rare when your game is capable of maintaining a very steady framerate of above 100. But when running on a machine that only manages 20-40 FPS, fast objects pass though other objects almost as a rule. I managed to solve this partially by making TimeStepSettings.TimeStepDuration = 1 / 120.0f and calling Update(dt) version, with the time delta between frames.
This does work when running while FRAPS is capturing, but it makes everything very floaty, even when the framerate under FRAPS on a strong machine is the same as the framerate without FRAPS on a weaker machine. This situation has been improved by calling Update(dt /2); Update(dt / 2), but calling update twice still does not behave that great. Raising time step duration more makes all physics very slow.
So I was wondering if there is a way to handle varying framerate better and enforce collisions more? Even if this greatly impacts performance. I don't need a lot of objects on the move. I did not manage to get a set of parameters that works well for anything except medium ranges. Throwing an object from close range towards a wall will pass thought the wall in 95% of the cases, and throwing the object very far will cause it to clip though the floor. At medium range it works pretty good.
This could be due to my ForceUpdater.Gravity value, which is almost 1000. The way the world is set up, 1 meter is about 100 units, and this was a good value that did not cause physics to behave floaty.
And another question: for collision meshes created from vertex data, like terrain, I suspect is is better to chunk the terrain into a lot of small pieces that fit perfectly in axis-aligned boxes (for performance). Am I right?
Thank you!
I am having some problems with object passing though other objects. This happens mostly with fast objects. I saw some other post on the forum about this subject, and based also on my observations, it does seem that the collision check would take place between two time steps and this is why it is skipped.
Things get more complicated when you consider two scenarios that make you game run slower: running on older machines and capturing video with some program, like with FRAPS.
Collision issues are very rare when your game is capable of maintaining a very steady framerate of above 100. But when running on a machine that only manages 20-40 FPS, fast objects pass though other objects almost as a rule. I managed to solve this partially by making TimeStepSettings.TimeStepDuration = 1 / 120.0f and calling Update(dt) version, with the time delta between frames.
This does work when running while FRAPS is capturing, but it makes everything very floaty, even when the framerate under FRAPS on a strong machine is the same as the framerate without FRAPS on a weaker machine. This situation has been improved by calling Update(dt /2); Update(dt / 2), but calling update twice still does not behave that great. Raising time step duration more makes all physics very slow.
So I was wondering if there is a way to handle varying framerate better and enforce collisions more? Even if this greatly impacts performance. I don't need a lot of objects on the move. I did not manage to get a set of parameters that works well for anything except medium ranges. Throwing an object from close range towards a wall will pass thought the wall in 95% of the cases, and throwing the object very far will cause it to clip though the floor. At medium range it works pretty good.
This could be due to my ForceUpdater.Gravity value, which is almost 1000. The way the world is set up, 1 meter is about 100 units, and this was a good value that did not cause physics to behave floaty.
And another question: for collision meshes created from vertex data, like terrain, I suspect is is better to chunk the terrain into a lot of small pieces that fit perfectly in axis-aligned boxes (for performance). Am I right?
Thank you!