Collision Response
I have been building a collision response engine in Java and sometimes it does some odd things. I would appreciate it if any of you could clue me in on to what exactly is going on. The link to the engine is
http://coolersite.greentreeworldmusic.co...pplet.html
http://coolersite.greentreeworldmusic.co...pplet.html
merrill541 Wrote:I have been building a collision response engine in Java and sometimes it does some odd things. I would appreciate it if any of you could clue me in on to what exactly is going on. The link to the engine is
http://coolersite.greentreeworldmusic.co...pplet.html
Well, I've noticed that the balls get stuck together quite often. They don't always stay stuck for long, but it looks like you aren't solving interpenetration before applying rebound force. It seems as though you are simply calculating the rebound needed, and then continuing without separating the balls beforehand. I would look into solving interpenetration.
Other than that, the demo looks great! I spent a good 20 minutes adding balls and trying to keep them from clumping. Nice work!
Building on what Talyn said, I'm guessing that either need to discard collisions that are already moving apart, or clamp your impulses so that you only push objects apart.
It looks to me like you are alternating between applying pushing and pulling impulses that cause the objects to stick to each other instead of only push apart.
It looks to me like you are alternating between applying pushing and pulling impulses that cause the objects to stick to each other instead of only push apart.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
I do have another version of the physics engine, the collision response is not as accurate but it never lets objects go together and it never applies huge amounts of force seemingly coming from nowhere. The link is
http://coolersite.greentreeworldmusic.co...plet2.html
http://coolersite.greentreeworldmusic.co...plet2.html
merrill541 Wrote:I do have another version of the physics engine, the collision response is not as accurate but it never lets objects go together and it never applies huge amounts of force seemingly coming from nowhere. The link is
http://coolersite.greentreeworldmusic.co...plet2.html
What is your method for this new one? It doesn't handle overlap well: it sticks all the balls that are created on top of one another in the upper left hand corner. Also, your coefficient of restitution (how much the balls stick together) seems to change for some balls. The detection seems to be much snappier on this one and the balls no longer clump together, so you're getting there! Keep up the good work.
Are you applying forces or impulses? An impulse is an instantaneous change in the velocity of an object, which is what you want for collision response. Your objects seem "soft," like it takes some time for the collision response to take affect (i.e. not instantaneous).
Also, it seems like you are not doing any sort of angular simulation. For true realism, it is necessary that you take angular effects into account in order to produce phenomena such as rolling, etc.
Also, it seems like you are not doing any sort of angular simulation. For true realism, it is necessary that you take angular effects into account in order to produce phenomena such as rolling, etc.
When you say angular simulation, do you mean rotation? If you do, I do plan on adding rotation to the objects but right now I have just been working on the x and y distance forces.
In answer to your first question, the way the forces work on these objects is that each object stores it's own force and every time I recalibrate the forces it changes it's own position. So when the objects collide I first change the position back to where it was before the forces were added to the position and then add my collision response forces.
This version is very simple and handles the collisions better because of that. All it does is when two objects collide it sets the objects force to 0 and then adds the force of the object it hit too itself. For example when one object is not moving and is hit by a moving object you will notice that the object that hit stops moving completely while in the other version it sometimes would bounce off at an angle or zoom off at incredible speeds.
I'm not really sure why it wouldn't handle overlap, unless when it changes the position of one it detects that it is overlapping another, which I haven't really made a solution for at this point.
In answer to your first question, the way the forces work on these objects is that each object stores it's own force and every time I recalibrate the forces it changes it's own position. So when the objects collide I first change the position back to where it was before the forces were added to the position and then add my collision response forces.
This version is very simple and handles the collisions better because of that. All it does is when two objects collide it sets the objects force to 0 and then adds the force of the object it hit too itself. For example when one object is not moving and is hit by a moving object you will notice that the object that hit stops moving completely while in the other version it sometimes would bounce off at an angle or zoom off at incredible speeds.
I'm not really sure why it wouldn't handle overlap, unless when it changes the position of one it detects that it is overlapping another, which I haven't really made a solution for at this point.
I'm not really clear on what you mean by how much the balls stick together, but the only thing that varies between the balls is how much of their force is sent back to them when they hit a wall (it is generated by a random number generator). Some of the balls will bounce only once or twice when you turn gravity on and some will seem to never stop bouncing.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Edge Collision Response Problem | Bachus | 9 | 5,530 |
Mar 21, 2008 03:34 PM Last Post: Skorche |
|
| Simple 2D collision response | Wowbagger | 1 | 4,248 |
Jul 30, 2007 03:02 PM Last Post: Skorche |
|
| Collision Response With Circles | Nick | 8 | 3,274 |
Nov 3, 2006 04:11 PM Last Post: Skorche |
|
| Collision Response Question | blobbo | 30 | 10,996 |
Oct 10, 2005 05:19 PM Last Post: Andrew |
|
| Help required with Math of Collision Detection/Response | blobbo | 7 | 4,038 |
May 6, 2005 02:38 PM Last Post: DoG |
|

