Skip to main content
gamedev.net
🔒 Locked

Subtle collision response bug

Started by pTymN Mar 29, 2007 at 4:05 PM 0 replies 600+ views
Original Post
pTymN
pTymN
My collision detection engine reduces the distance that an object travels within a frame's interval if that object hits another object. The problem happens if two objects are going the same speed, one object following the other one. My collision engine is essentially reducing the speed of an object for the entire update interval instead of reducing the interval down to where the first two objects collide. I want to avoid an excessively expensive solution and was wondering if someone could help me work through this and come up with a clever enough algorithm to avoid having to break the frame down into intervals between collisions. Below is a diagram of what I've figured out so far. Visualizations help me conceptualize what is going on. I was able to think of a 1 dimensional scenario that describes the problem accurately. Your help is much appreciated.

Problem Scenario - Current resolution
~~~~~~~~~~~~~~~~---------------------

X   1               1           11
|    1               1            1
P   2 1             221         22 11 
o    2 1      --\     21    --\   22 1
s     2 1     --/      23   --/     22 
       2 1               3           
    444464          444444      444444
         2 

    Time ->
     
Objects 1 and 2 shouldn't have collided before object 1 hit object 4!

     
Problem Scenario - Alternative resolution
~~~~~~~~~~~~~~~~-------------------------

X   1               1           1
|    1               1           1
P   2 1             2 1         2 1 
o    2 1      --\    2 1    --\  2 1
s     2 1     --/     2 1   --/   2 11
       2 1             223         222  
    444464          444444      444444
         2 

    Time ->

Cost goes up because now I have to test the objects' motions in two parts,
before 2 collides with 4 and after. Also, objects will tend to stack up at the 
end of a frame.

Problem Scenario - Correct resolution
~~~~~~~~~~~~~~~~-------------------------

X   1               1           1
|    1               1           1
P   2 1             2 1         2 1 
o    2 1      --\    2 1 2  --\  2 1 1
s     2 1     --/     2 3   --/   2 12
       2 1             2 1         22  
    444464          444444      444444
         2 

    Time ->

This should have a pretty high performance penalty, because it is essentially
infinite subframe resolution.
 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.