Collision Response

Member
Posts: 40
Joined: 2008.10
Post: #1
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
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #2
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!

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 40
Joined: 2008.10
Post: #4
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
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #5
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.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2007.03
Post: #6
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.
Quote this message in a reply
Member
Posts: 40
Joined: 2008.10
Post: #7
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.
Quote this message in a reply
Member
Posts: 40
Joined: 2008.10
Post: #8
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Edge Collision Response Problem Bachus 9 6,509 Mar 21, 2008 03:34 PM
Last Post: Skorche
  Simple 2D collision response Wowbagger 1 4,737 Jul 30, 2007 03:02 PM
Last Post: Skorche
  Collision Response With Circles Nick 8 3,667 Nov 3, 2006 04:11 PM
Last Post: Skorche
  Collision Response Question blobbo 30 12,376 Oct 10, 2005 05:19 PM
Last Post: Andrew
  Help required with Math of Collision Detection/Response blobbo 7 4,436 May 6, 2005 02:38 PM
Last Post: DoG