2D collisions Native Extension

Sometime ago i made a ne for finding collisons in 2d.

I make it because i was working on bullet hell game, but defold have 1024 go max, what is small for bullet hell. Also i try some lua libs for collisions, but they was too slow. So i write my own. :sunglasses:
I want to share this ne, maybe someone need it.
This ne work only with rotated rects and circles. Also it finds only fact of collision, without any normals or distance.

8 Likes

Cool, thanks for sharing! Have you benchmarked it against DAABBCC?

2 Likes

No=)

2 Likes

I think daabbcc should be faster, because it use aabb algorithm. I use aabb for bounding boxes collision, then i use separating axis theorem for rects, because they can be rotated.
This ne use spartial hash. The cell size hardcoded in c++, sorry for that. Daabbcc use bvh. Never worked with bvh, so i can’t say what is better.

I can say that i worked with few thousands shapes, without problem, in pc.

1 Like

Also, i can scale collision shapes in runtime. As i know defold not fixed that bug ?)

2 Likes

Daabbcc is very cpu hungry because of my lazy code and my deficient c++ knowledge. I should definitely update it in near future for better handling(any contributions are welcome). Also maybe it would be nice to run that kind of math heavy stuff on different thread.

Looks like @d954mas 's 2d NE is much more optimised, scaling and rotating is a important parts of it. But as a user, It would be nice to have an simple examples of every function. Current project has a custom renderer and custom materials which doesn’t show up on macos.

2 Likes