DAABBCC: Dynamic AABB Tree + Experimental Collision Detection


#1

Since there isn’t a build-in culling in Defold, I need a way to detect offscreen objects for my game called No Nation. I found that the best way of doing this for large amount of moving and static objects is to use dynamic bounding volume hierarchy. So I decided to build my own native extension for this purpose. Right now, I’m using this lib for triggering camera events, general dialogs, activating rooms, culling offscreen objects. I believe it can be used for different purposes like puzzle game logic… It is totally up to your imagination.

Basically, it is a broad-phase collision library and it provides an efficient way of detecting potential overlap between objects of arbitrary shape and size. It is suitable for large amount of moving and static objects(AABBs). DAABBCC is build on Lester Hedges’s AABB.cc library. All credits goes to him.

Also, DAABBCC contains experimental narow-phase collision detection with aabb manifold generation and raycasting to aabbs using Randy Gaul’s tinyc2 .

These looks so technical I know. But in fact, when you understand the main principles it is easy to use. I build a simple platformer game with it. You can examine source of it on Github. Please keep in mind; this little example is not about the gameplay or design. I believe there can be much better ways of using this lib than my terrible example.

If you want to test it, you can find it on itch.io

DAABBCC is not battle tested yet. It may contain memory leaks, performance drops… Also I don’t have a change to test it on different computers/platforms. I roughly tested on iPad 3, i7 mac and a i3 Linux, it works quite well so far.


Bump in Defold
#2

Small updates and a bug fixes

  • Small but important bug fixed in core aabb.cc library. That fix cause a ~25% speed gain. Speedup might be greater for situations where there are many slow moving, or static objects
  • A few bugs fixed in the platformer example source on Github.
  • RemoveAll is added. Now you can remove all AABBs from a tree.
    https://github.com/selimanac/DAABBCC#--removeall

Planning


#3

Aabb.cc lib is updated. tinyc2 is removed and latest cute_c2.h is added