I've seen plenty of AABB around here, and that's good and all, but a lot of my friends (not on these forums) can ONLY understand AABB. That's not a good thing, because AABB is very limited: it's great at what it does, but it's very, very terrible at what it's not meant to do. I decided to go ahead and create a reference implementation of the Separating Axis Theorem (SAT) collision detection method for one of my friends so he could translate it to XNA (note: that means this code is meant to translate easily, and isn't the best Lua. A rewrite is coming soon). SAT, unlike AABB, supports both non-axis aligned bounding boxes (!!) and arbitrary convex polygons (!!!), which means it's a lot better in cases where things can be rotated. I haven't implemented the circle-polygon case yet, so you'll have to forgive me for that, but this is a lot more powerful than AABB.
However, with more power comes less speed. This will be slower than AABB collision (especially since this is not optimized at all, see above). What I'm saying is simple: if your use case doesn't include arbitrary convex polygons (or, with convex decomp, arbitrary polygons) and rotation, don't use this. Use AABB instead.
If anyone is interested in actually using this, I intend to rewrite this form scratch to be better code than what it is now, be faster, and support arbitrary polygons via convex decomposition. Once I do that, I'll update this post and let you guys know.
If I'm doing anything wrong or silly here, please make sure to tell me. Anyways, without further ado, a screenshot or two and then the file itself:
I got them as close as I could without them colliding, to show that's it's nice+accurate.
Finally, a bit of info on the demo: To control the rate they turn at, press up+down. It'll tell you the speed coefficient and if they collide or not right above the square.
EDIT: Licensing. The current implementation, being Not-That-Great_lua(tm), is public domain. Go wild. Any future versions, if there are, will be MIT.
Showcase your libraries, tools and other projects that help your fellow love users.
1 post • Page 1 of 1
Users browsing this forum: No registered users and 22 guests