Detecting a particle "smashed" by polygons

Please don't post Bullet support questions here, use the above forums instead.
yfan
Posts: 3
Joined: Fri May 30, 2008 7:46 pm

Detecting a particle "smashed" by polygons

Post by yfan »

In 2d physics of my game I have a level made from several moving polygons, among which a particle bounces. I am using a SAT collision detection, which returns a projection vectors for all collisions in given frame, stored in a particle struct. Having these vectors i calculate a final projection vector - which is simply a sum, which works great in most situations.

Although two special cases occur:
1) When particle collides with a side shared by two polygons overlapping (or sometimes three or four), a resulting projection is twice (trice (how do you spell it?), quad-..like :)) powerful as it should be.

2) Sometimes a particle is smashed between two (or more) polygons, where satisfying one projection vector, distorts the other one(s). Is it possible to detect a situation like that, only by comparing projection vectors? It seems evident on sketches I made, that one vector "negates" the other, but how do I solve this mathematically?

A brute resolution of the second one, would be detecting a collision once more at the end of projection, but it seems silly to me and i feel that there is a simple method resolving both of these problems at the same time, as I think these are connected. Any suggestions - or links to the readymade solutions - would be nice, as my math is at an arts-student level ;).
yfan
Posts: 3
Joined: Fri May 30, 2008 7:46 pm

Re: Detecting a particle "smashed" by polygons

Post by yfan »

I have a strange feeling, that my question falls in a dangerous line between "lol noob" and a math problem worth wrestling with. Feels both " :( " and " :) ", as it is a second forum, where I get practically no answer. I would appreciate any suggestions.
Oscar Civit Flores
Posts: 19
Joined: Fri Jan 20, 2006 2:24 pm
Location: Barcelona

Re: Detecting a particle "smashed" by polygons

Post by Oscar Civit Flores »

Hi yfan,

Handling multiple simultaneous collisions/contacts is never easy. If you're resolving collisions by projection in a Verlet+Relaxation way (based in Jakobsen's article maybe?) and you don't want to write a complex or expensive solution (like applying projections one by one and performing new collision tests), there's a "dirty trick" I've successfully used in the past: Instead of suming individual projection vectors, compute the *average* projection and use only that one to move the particle.)
This would solve the "twice-thrice" projection problem (1), but won't obviously solve multiple collisions (2) in a single frame. However, the average projection it tends to smooth wildly different collision normals/projection vectors, and will generally solve any multiple collision in a few frames.
The only counter-example to using the average projection vector also happens with your "sum of projections" approach, and happens when you have exatly opposite vectors that cancel each other. That's something you may live with, as in this case the projection will be 0 and the particle will move freely for 1 frame and will penetrate one of the colliding geometries deeper. The next frame you will detect this deeper penetration and find a meaningful projection vector.

Hope it helped,

Oscar

PD: Great that arts people are programming too :D
yfan
Posts: 3
Joined: Fri May 30, 2008 7:46 pm

Re: Detecting a particle "smashed" by polygons

Post by yfan »

My problem turned out to be far more specific and finally i am beginning to setting out with a solution using a concept of shared edges, and edges forming a line. It's a bit of a tricky solution, but unfortunately it cannot be solved using a restrained level design. Thanks anyway though :).