Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LeoMaheo

Tricky problem with collision response

This topic is 5541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I think that I have an interesting problem with collision response. I have impemented a 3D game with collision detection and collision response between many bodies. Now on to the problem. First I''ll tell you about a real world scenario and then I''ll tell you what goes wrong in the computer simulation. --- The real world --- Imagine a light ball lying on a table. Let us drop a heavy ball exactly straight down on the light ball. What will happen is that the light ball won''t move at all and the heavy ball will bounce straight up again, as if it had hit the table (well, let''s forget about friction and dampening and assume that we really hit the light ball exactly from above so it won''t move at all -- quite impossible to do, but imagine). --- The computer world --- In my implementation it is impossible to represent the fact that the light ball actually touches the table. The light ball is instead considered to reside infinitesimally above the table. Now, the heavy ball falls straight down on the light ball. Since the light ball is placed infinitesimally above the table it will start to move downwards with approximately the same speed as the heavy ball. The momentum of the heavy ball will only change slightly since the heavy ball is very much much heavier than the light ball. Then, the light ball moves infinitesimally downwards, collides with the table and turns up again. Since the heavy ball is still moving downwards the light and the heavy ball now collide again. In this second collision the heavy ball changes it''s momentum approximately twice as much as it did in the first collision with the light ball, but it is so heavy so it continues downwards. The light ball will reverse and move downwards (twice as fast as the heavy ball) and hit the table and bounce up again. Now, the light ball hits the heavy ball and changes the momentum of the heavy ball (this time actually nearly four times more than in the very first collision), but the heavy ball is so heavy so it continues downwards despite of this third collision. So it goes on, the light ball bouncing between the heavy ball and the table and transferring a small bit of momentum in each bounce. The number of bounces required before the heavy ball bounces up again should be proportional to the logarithm of the ratio of the mass between the heavy ball and the light ball. Assume that despite this around 10 collisions between the light and the heavy ball are required in order to reverse the momentum of the heavy ball and make it bounce up again. This means that a total of 20 collisions must be executed (including collisions between the light ball and the table) and one also has to do lots of demanding collision detection. -------------------- Thus, the problem is that when many adjacent bodies collide in what in the real world would be an instantaneous collision, my implementation considers this as a serie of small collisions, each transferring a small amount of momentum, and the computations require far too much resources. My current solution to this problem is to consider the small ball as "fix" after a certain number of collision. That is, if the small ball bounces too many times between the heavy ball and the table, the small ball will be made temporarily immobile and the heavy ball will bounce only once more against the small ball and then reverse and continue moving straight upwards. I write to you because I am not satisfied with the above mentioned solution. For example, when the heavy ball does not hit exactly from above, this solution does not look very good since the light ball seems to be extremely heavy and the heavy ball seems to be very light. Does anyone know any solution to this problem? Does anyone know how this problem is solved in a good physics engine software library? (Perhaps one in some way could remember that the small ball has collided with the table many times and make the small ball immobile only in the direction given by the normal of the table plane? But this solution won''t work if four bodies touch each other in an even more complicated kind of collision - e.g. balls that are dropped in a pit will tend to touch each other since they will be "pressed" against each other by the walls of the pit) Thanks for any and all answers or comments. Keen regards, Magnus.

Share this post


Link to post
Share on other sites
Advertisement
Ive never really done this before so that being said this may be the furthest from the way you would actually ever want to do this.

But I think that in my physics engine anytime two objects collide and after the collision at the end of the frame they were not resolved as seperate I would keep a list(array, vector, whatever) of which surfaces are in contact with others. Then on the next frame when you find out any additional collisions and when you do the computations you do it between any colliding objects along with the sum of the forces acting on them from other objects they are in contact with. In this case it will have already be determined that the small ball is in contact with the table, and in previous frames their forces result in no movement. When the big ball and small ball are determined to be colliding you can check if the small ball abd big ball are in contact with anything else. Upon seeing the small ball is in contact with the table you take into consideration its current state as well as potential reactive forces into the equation as well. As you said keeping track of enough things would get way to computationally intensive (say pushing one ball at the end of 200,000 of them lined up) but you would just have to manage how many you tracked in the vector/array/whatever. YOu can also limit how many objects you go into this list for instance the big ball hits the small ball, the small ball is in contact with the table, the table is on the third floor of a building, the floor is held up by some beams... etc etc How complicated you get depends on your processing power and how interactive you want it to be.

// Full Sail Student with a passion for games
// This post in no way indicates my being awake when writing it

Share this post


Link to post
Share on other sites
yes, that kind of problems even causes headaches to the best of physics engines. THis is why stacking objects on top of each other is usually a bad idea. MathEngine use to bring the PS2 to its bloodied knees if you even thought about stacking objects. They solve contacts like these through a massive set of linear equations (LCP matrix, or whatever), and the PS2''s tiny cache can''t keep up. Lots of cache misses, cripple the performance (That''s how I understood it anyway). On the PC it was fine

All problems involving constrained mechanics is a royal pain in the butt. grrr

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!