#### Archived

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

# Collision detection problem: been plaguing me for weeks :(

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

## Recommended Posts

##### Share on other sites
Do you you queue up your collisions?

Like, if multiple walls are hit, is each collision registered and delt with?

And, how do you calculate your objects position after a series of collisions have been detected.

##### Share on other sites
yeah, queue up your collisions, from nearest to farthest, process them one by one. I sort them by order of time, and I also store overlaps in the list, with a time value negative, and the value being the overlap depth. That way, all my overlaps are staisfied first.

I might change this system later on, it seems a bit extreme

##### Share on other sites
I''m not sure queueing the collisions would work with the particular model i''m using. If two collisions are registered, the farthest one will usually be on the opposite side of the wall that registered the nearest. Like so:

       /    +-2-----    |/    1   /|  / | /  |o   |

If I bounce the ball for the first collision, then the second one won''t matter anymore:

 \        \ +-2-----   \|     1   /|  / | /  |o   |

Now (2) is no longer on the path of the ball.

##### Share on other sites
I thought the point was obvious.

If you hit 2 walls at the same time(where they intersect), you need the info from both walls. That''s why your model is failing.

##### Share on other sites
quote:
Original post by Tokage
I''m not sure queueing the collisions would work with the particular model i''m using. If two collisions are registered, the farthest one will usually be on the opposite side of the wall that registered the nearest. Like so:

       /    +-2-----    |/    1   /|  / | /  |o   |

If I bounce the ball for the first collision, then the second one won''t matter anymore:

 \        \ +-2-----   \|     1   /|  / | /  |o   |

Now (2) is no longer on the path of the ball.

that''s right.
When you process a collision, you need to remove all collisions involving mobile objects (objects that will change path from it) from the queue, and if those collisions involve other mobile objects, you need to re-process collisions for those objects as well.

Basically, all you need to keep is the first collision happening to each mobiles in the world. You do not need to store later collisions for each of them. So each objects has one collision report, and all those reports are sorted by overlap then time. Also, it can happen that two objects share the same collision report, obviously.

say you have objects
A
B
C
D
E
F

and the static geometry S

and when you detect collisions you found that

A (A, S, -0.1f)
B (B, E, 0.1f)
C (C, D, -0.05f)
D (D, C, -0.05f)
E (E, A, -0.01f)
F (F, S, 0.5f)

A overlaps the static geometry with depth of 10 cm, B collides with E at time 0.1 sec, C overlaps with D with a depth of 5cm, F collides with static geometry at time 0.5 sec. Each object has its own collision report. Each report stores the indices of both objects, and the time/overlap amount.

you sort the collision reports and you get

(A, S, -0.1f)
(C, D, -0.05f)
(D, C, -0.05f)
(E, A, -0.01f)
(B, E, 0.1f)
(F, S, 0.5f)

so you process first report. A collide with S, which does not move after the collision is processed (static geometry). A on the other hand will react, so you must remove all collision reports that involve A, and store a list of objects that need to be retested for collision.

the list become

(C, D, -0.05f)
(D, C, -0.05f)
(B, E, 0.1f)
(F, S, 0.5f)

and objects to test again are A, E.

you found that E then collide with A at time 0.3f
then you have.

A (A, E, 0.3f)
E (E, A, 0.3f)

you insert those two in the list and you have

(C, D, -0.05f)
(D, C, -0.05f)
(B, E, 0.1f)
(A, E, 0.3f)
(E, A, 0.3f)
(F, S, 0.5f)

Now you process the (C, D), you need to test only C and D again (they are mobiles). You found that neither C or D collide after the collision is processed. The list becomes

(B, E, 0.1f)
(A, E, 0.3f)
(E, A, 0.3f)
(F, S, 0.5f)

so you work your way up until the list is empty.

Now, I''m not sure if this system works if you are using time scales. I tried it with displacement vectors and it works fine. Displacement vectors have the advantage that they do not rely on all the objects having the same timeframe, Like you would have to do (move ALL objects to the time of collisoin, test all objects again).

so, basically, the system I use works with distance to intersection, which works for both overlap and impacts, and objects closest (or deeply embedded) to each other are processed first.

1. 1
2. 2
3. 3
4. 4
Rutin
11
5. 5

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007712
• ### Who's Online (See full list)

There are no registered users currently online

×