After doing some research on OBB collision checking I've come across some algorithms using Minkowski differences and a ton of results on the Separation Axis Theorem. I find them a little complicated , so I've thought about a simple test.
It is based on the assumption that two OBBs are colliding if and only if at least one of the vertices of any one OBBs is inside the other.
Am I missing something or does this overlook a large number of cases ?
If it does turn out to be right , then the collision test involves checking if there exists at least one vertex of an OBB which is inside the other.
So , would it work ?
Also , if it wouldn't I would like some suggestions on what I could use (I am looking for something simple).
Just to mention that the Point in Polygon algorithm might be helpful. Not sure if you already know about it or not. :+)
Thanks , it's good to know of such a general algorithm , I didn't knew about that :)
I was simply gonna rotate the point and check if it is inside the bounding box.
But would this work ? I wanna make sure that I'm not overlooking a case , although I couldn't imagine a case yet where my assumption won't stand.
I can think of one - the the entire object might have passed through the other one, so the vertexes are all 'outside', but there is a collision. For an example, look at this (bad) ASCII art:
/\
--/--\--
|/ \|
/ \
\ /
|\ /|
--\--/--
\/
Of course, this is unlikely to happen unless you have small objects moving at high speeds.
What about false positives? If you have complexer shapes (eg. star shapes), it's quite easy to draw scenarios for which the bounding boxes are overlapping despite there not being a collision. Even with convex hull type shapes only. Not sure if that's relevant here though...
I've implemented two collision detection algorithms for 2D one using GJK and the other used the separating axis theorem, they both have their plus and minuses it's been a while since i did it though so my memory might be a bit foggy. This video helped greatly with GJK, https://mollyrocket.com/849 , he explains it including 3D but you can just stop at the 2D part.
What you are basically trying to do with GJK is to find the triangle that houses the origin of the Minkowski difference. If you find the triangle that has the origin of the Minkowski difference then there is a collision. This only works with two convex hulls though.
Unless you are making a physics engine for the purpose of learning exactly how it works, i wouldn't waste your time with implementing your own.