Hello,
So I’ve seen many users struggling about collisions or faster implementation of it. And i’ve also seen that almost everyone creates a custom engine that best suits their need. So i came up with the idea of providing a fast collision api, so every time people write their engine they can skip this part of the process, but it also provides support for many other things like Curves, Line, Segment, handles rotation, any polygons, circles, rectangle… Which allows you to do raytracing, or draw from the shape i created by getiing a list of points and many other things.
I’m still working on it. Yet i have implemented Line, Segment, Circle, Rectangle, Polygon, RegularPolygon (optimized polygon), Vector, Point and also a FastMath class that i built with the code that i found here ( mainly Riven’s code so thank you ). Only detects collision for now. Almost everyting is documented.
So here’s the link to the lib : https://www.dropbox.com/s/d8692tv9rw3alhe/leSpace2D.jar?dl=0 ( Source code is included, i implemented SAT from another thread which i can’t find back haha)
Then what’s the problem ? Hum i have a really decent processor i7 - 4 cores and i’d like to know the speed of the algorithm on your computer.
Here’s a link to the test class i used : http://pastebin.com/0f5cELmu
Here’s my output using Circle (longer to create but faster for collisions) ( Intersection calls : 12.5 x 10^8; Contains call : 25 x 10^8 ):
USING 50 000 ENTITIES
[INSTANCIATION] Done in 409 ms.
[INTERSECTION] Done in 8 892 ms. With 212 587 696 shape(s) intersection.
[CONTAINS] Done in 24 641 ms. With 35 814 199 shape(s) inside over shapes.
Here’s my output using Rectangle : ( Intersection calls : 12.5 x 10^8; Contains call : 25 x 10^8 )
USING 50 000 ENTITIES
[INSTANCIATION] Done in 14 ms.
[INTERSECTION] Done in 132 767 ms. With 895 420 123 shape(s) intersection.
[CONTAINS] Done in 129 783 ms. With 172 029 124 shape(s) inside over shapes.