Members - Reputation: 122
Posted 16 November 2008 - 11:29 PM
Members - Reputation: 122
Posted 17 November 2008 - 04:16 AM
Thanks for the link. The page is a bit confusing on what the algorithm is trying to accomplish. Is it just trying to find out if the shapes overlap? I.E. that the origin is in the minkowski difference? Can you determine the penetration depth from it easier than with GJK/EPA?
Thanks again :)
Members - Reputation: 294
Posted 17 November 2008 - 04:32 PM
The best description of the algorithm I've found is the gem itself in GPG7, though you can also take a look at the source. I don't have time to do an overview right now, but the xenocollide forums have scattered tidbits about how it works.
Note that the usual implementation will give you a 'pretty good' approximation of the penetration vector, but for unusual shapes (large flat boxes and such) it will sometimes produce something less than perfect. Usually this doesn't matter in games, especially with continuous detection since things never get too deep into penetration.
It's also fast- fast enough to be used as the primary collision detection system alone, even. That and the ease of implementation of MPR are why I chose it over EPA.
GDNet+ - Reputation: 1330
Posted 18 November 2008 - 04:15 AM
Original post by PhysicsNoob
Yea I am having quite a few problems with it when the collision is very small. In particular I seem to get an infinite loop when the shapes collide at or close to a vertex. I will give SAT a try tomorrow.
Yes, that's what I would get, if the shapes were barely touching sometimes the computation would explode (floats would overflow, resulting in garbage values), my code was already to complex and had too many "special case" code paths I didn't want to maintain in the future to add even more, so I scraped it.
IMO, GJK is mathematically sound, and simple in that mathematical sense, but it is too hard to properly implement with limited floating point precision, there are too many gotchas, that said, Bullet does it [smile].
Members - Reputation: 2360
Posted 18 November 2008 - 06:02 PM
He goes through the 2 point and 3 point cases very thoroughly and his code for the 4 point case is online here.
I've implemented this method and had no problems with precision using 32 bit floats. In order to avoid the infinite loop problem, I just clamped the maximum number of iterations to something like 20 which is plenty. If the limit is reached then there is no collision.
Members - Reputation: 1968
Posted 18 November 2008 - 08:55 PM
Some of the numerical problems with GJK can be solved by solving in object instead of Minkowski space, but then it is hard to detect penetration. Also when using GJK/EPA you need a third algorithm to jump in when EPA fails (what can actually happen when you don't terminate with a 4D simplex). So I agree it is a mess and since you only find one contact point per frame you need to use an incremental manifold and will suffer from tunneling issues where objects can rotate out of the world at contact if you don't work around this. Personally I also prefer SAT, but GJK/EPA seems faster, but much less robust. So it is a question what quality you expect. Personally I think we should do less, but more higher quality physics in games.