Comparing axes in a SAT based collision resolution method

Started by
4 comments, last by makuto 11 years, 11 months ago
I've implemented a Separating Axis Theorem-based collision detection function (in C++) and am now dealing with resolving collisions. What I need to figure out is how to detect which axis is best to resolve the collision.
What would be a good way to compare several vectors to an inverted translation vector in order to determine which axis will result in the best possible collision (basically the axis closest to the translation vector)?

I think I could use something like each normal in the static object stored an angle (0-360, probably 9 bits, or an int, whatever) and the translation vector structure also contained an angle (for now it's limited to increments of 45 because of keyboard-based controls). The static angles would all be compared to the translation angle, and the closest static normal would be used as the resolution vector.

Is there anything more efficient/better to use to compare the vectors, or should I use a completely different method in order to resolve the collisions?

Want to get to know my work and I better? See my website: Au 79 Games

I wrote General Tips on the Process of Solo Game Development

Advertisement
What I need to figure out is how to detect which axis is best to resolve the collision.[/quote]
In SAT it's axis with minimal projection overlaping.
If there is a collision the objects have no separating axis. Maybe you want to find the direction along which two overlapping objects need to be displaced by the minimum amount to cease overlapping, but it's a mere hack.
For an exact collision response you have to compute the time of impact and the position of objects when they touch. At that time and place, the objects bounce, start deforming, etc.

Omae Wa Mou Shindeiru

In SAT it's axis with minimal projection overlaping.[/quote]
The reason why I don't do that is because when the objects near each other's corners the minimal axis becomes the axis on the wrong side of the shape, making a horrible tunneling effect.

I'm not really making an exact collision detection method, just a simple, versatile one for basic game collisions.

How difficult is it on the CPU to compute the time/position of impact? I'd imagine to use a method where it splits the total translation in half, sees if there is a collision or not, then splits a portion of that in half and so on.

Want to get to know my work and I better? See my website: Au 79 Games

I wrote General Tips on the Process of Solo Game Development

The reason why I don't do that is because when the objects near each other's corners the minimal axis becomes the axis on the wrong side of the shape, making a horrible tunneling effect.[/quote]
Then you definitelly need time prediction algorithm. The same SAT is good. I wrote a post long time ago - check it out
http://volgogradetzzz.blogspot.com/
Great tutorial! It ws a little hard to read, but your English is pretty good. Thanks for the help!

Want to get to know my work and I better? See my website: Au 79 Games

I wrote General Tips on the Process of Solo Game Development

This topic is closed to new replies.

Advertisement