There must be a solution for this! Ever have that feeling, but can't figure it out? Well, here's one for anyone who wants to prove they're a genius.
I'll assume you know about the GJK algorithm. Essentially it determines whether the volumes of two convex 3D objects overlap, by finding out whether the "Minkowski sum" of objectA and -objectB includes the origin (0,0,0). Wonderful algorithm, very clever, and made much more practical by some other smart folks who tack on the notion of "support functions".
Well, that's great! So now, thanks to GJK, we know whether two objects overlap or not.
So, let's say you have a big honking mothership that contains a big tube or rectangular box-shape room open to outer space. You know... a "landing bay" where small spacecraft fly in and land, or take off and fly out.
So you've got this convex object (the cylinder or rectangular box), and you need to know when some other object (small spacecraft) enters the "landing bay".
Why would you need to know that? Well, for one thing, that small spacecraft just "collided" with the mothership. You see, to be a shape that works in GJK, the mothership (or each section) must be "convex" (which simply means, no "craters" or "insets"). So a solid cylinder is convex, a solid box is convex, even a disk or triangle is convex. But you can't have "holes" or "insets" like that "landing bay" and still qualify as "convex".
Well, one lucky thing is, the way GJK works (or at least GJK algorithms), is that they simply assume any "hole" or "inset" is filled in solid. So as far as a GJK test is concerned, that opening in your mothership doesn't exist... the whole end of the mothership where you put the "landing bay" is solid. Which is okay... good enough to handle most collisions of most objects with most places on your mothership.
But... you really do need to allow spacecraft to fly into your "landing bay", and you really can't afford some 10x or 20x or 100x slower routine that works on concave objects too.
No, you want to solve this problem as elegantly as GJK solved the problem for convex objects.
So you have a "really brilliant idea"! You'll just make up a simple rule and apply GJK twice! Your rule is this. If an object is in collision with the mothership, then look to see if that object is also in collision with your "landing bay". And if it is... then ignore the GJK collision with the mothership! Brilliant! You ignore the collision with the mothership AND the "landing bay" as long as the object is in collision with the cylinder or rectangular box that is your "landing bay". In other words, if an object is in collision with the "landing bay", it is not in collision with the mothership. This lets objects fly into your mothership, and oh so nicely defeats the convex limitation of GJK.
!!!! OOPS !!!!
That sounded right, and is in fact close to right... but isn't quite right. Why? Well, consider the case of a newbie pilot who flies into the "landing bay" too low. The top half of his spacecraft does collide with the "landing bay" cylinder or box, but the bottom half of his spaceship smashes into the side of the mothership. So that rule... that "in collision with the convex shape that is the "landing bay" is not sufficient.
In fact, the appropriate test is "the object needs to be completely contained by the landing bay".
Hmmmm. This is a different test. The classic "collision test" tells us whether ANY part of an object overlaps another object. What we need is a "contained test" that tells us whether ALL parts of an object overlaps (is contained by) another object.
And so there you have your "genius question".
Find a similarly elegant and efficient way to tweak the GJK algorithm to detect "fully overlapping" instead of "at least barely overlapping"... and you win your IQ 180 badge. Actually, no need to limit yourself to GJK or Minkowski land... ANY fast and efficient routine will suffice. Add 5 more points for an algorithm faster than GJK. You can still assume the objects are convex. But if your routine works on non-convex objects and still remains fast and efficient, well then! Add another 20 points!
After I thought up this basic idea... but before I realized the "oops" part, I just felt there has to be an equivalent test for "full overlap". Yet my supposed genius label fell off after a couple hours of repeatingly thinking "I found it"... but then realizing "no, that doesn't quite work" time and time again.
So, I surrender to superior intelligence (sounds like something outta StarTrek II vaguely). Show me up! And prove you're a bonafide genius in the process.
And if you do... I suspect you'll become famous in the world of 3D games, graphics and simulations, because this is a nasty problem.
-----
PS: I have an idea myself, which is a little clever, but probably too "brute force", and thus probably too slow. It involves walking from vertex to whichever adjacent vertex on each of the two objects reduces distance-squared between the vertices until you cannot progress (a bit like the final simplex in GJK), watching the dot product of the normals of the vertex-pairs along the way. But that's only the first stage... and I haven't perfected the second stage yet. I only mention this to say... I don't think this is the direction the "genius solution" will take. Somewhat clever maybe, but too brute force by the endgame. Plus, unlike my engine, not all 3D engines know what are the 4~6 neighbor vertices, in which case performance will suffer even more.
So, there is the genius challenge. Anyone up to this?