• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
PhysicsNoob

GJK algorithm

12 posts in this topic

Hello I am trying to implement the GJK algorithm. I have got it working for when the objects are not intersecting, but I am having problems getting anything meaningful when the objects are intersecting. Is the GJK algorithm useful for determining anything about collision contact points when the objects are overlapping? I have googled around a bit and keep seeing something called the EPA algorithm, does anyone know of any papers or explanations of EPA? Thanks!
0

Share this post


Link to post
Share on other sites
That's one gripe I have with GJK. However, I like the xenocollide approach.

The EPA is a bit of a pain, I never even tried to implement it.
0

Share this post


Link to post
Share on other sites

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 :)
0

Share this post


Link to post
Share on other sites
yeah, it's trying to find if the origin is in the minkowski difference.

hmm actually, this algo still seems to require an EPA to find the collision info :/

I'm also confused by their explanation of the contact manifold.
0

Share this post


Link to post
Share on other sites
ok thanks :)

I have found a nice explanation of EPA in Collision Detection in Interactive 3D Environments by Bergen for those interested.
0

Share this post


Link to post
Share on other sites
MPR can actually be used in 'replacement' of EPA if you'd like. I use a set of implementations that provide contact location, depth, normal, and also a conservative distance estimation in my engine to complement GJK. I use these with the persistent manifold concept commonly employed by GJK-based methods.

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.
0

Share this post


Link to post
Share on other sites
I gave up on GJK when trying to get EPA working, too much precision errors in the algorithm itself too.

Loop up Bullet, Erwin Coumans seems to have gotten it right in it.

Personally, I much prefer SAT.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
Quote:
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].
0

Share this post


Link to post
Share on other sites
my thoughts exactly on GJK. It's too fiddly, although on principle, it looks good.
0

Share this post


Link to post
Share on other sites
Casey from Molly Rocket Games gives an excellent presentation on GJK here.

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.
0

Share this post


Link to post
Share on other sites
Casey doesn't show GJK, but only a boolean operation whether two objects intersect. GJK is an algorithm to find the closest points between *disjoint* convex polyhedra. I think Gino called this GJK-SAT in his book (s. also Christers post). Still some of the ideas like the simplex solving can be used with GJK as well. The termination condition doesn't work though.

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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0