# DAABBCC - Dynamic Tree(aka AABB Tree) native extension for fast AABB collision detection

**URL:** <https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328>\
**Category:** The Defoldmine\
**Created:** [March 27, 2018, 10:51am UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328 "2018-03-27T10:51:39Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [October 19, 2022, 12:21pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/41 "2022-10-19T12:21:34Z")

</div>

I will check it, thanks for clarification! 😉

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [December 15, 2022, 1:25pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/42 "2022-12-15T13:25:28Z")

</div>

I had assumed (wrongly, I think) this would help me separate game objects from each other (similar to how dynamic collisions with a gravity of 0 would work). I’m guessing this is something I need to implement on my own, but I’m not sure how.

Can anyone point me in the right direction for how to do this?

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [December 15, 2022, 1:42pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/43 "2022-12-15T13:42:55Z")

</div>

> [@rayraytime](#):
>
> I had assumed (wrongly, I think) this would help me separate game objects from each other (similar to how dynamic collisions with a gravity of 0 would work). I’m guessing this is something I need to implement on my own, but I’m not sure how.

I’m not 100% sure what you mean but this extension nothing to do with dynamic collisions. It is just a fast AABB test. You can just check if two(or more) AABBs collide or not. When they collide it is up to you how to separate them. If you are moving your objects by using velocity then you can change it when collision occur.

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [December 15, 2022, 2:02pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/44 "2022-12-15T14:02:38Z")

</div>

> [@selimanac](#):
>
> I’m not 100% sure what you mean but this extension nothing to do with dynamic collisions. It is just a fast AABB test. You can just check if two(or more) AABBs collide or not. When they collide it is up to you how to separate them. If you are moving your objects by using velocity then you can change it when collision occur.

I was referencing dynamic collisions as an example of the type of behavior I want to replicate.

I got the tests working and I think I know how to detect when there’s an overlap/collision. My goal now is to separate them, but I’m not sure how to do that. Changing by velocity is one way. I’m not committed to any specific type of movement yet.

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [December 15, 2022, 2:12pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/45 "2022-12-15T14:12:20Z")

</div>

I think this is the behaviour desired:  
[https://raw.githubusercontent.com/Insality/crowd-runner-defold/main/media/game.gif](https://raw.githubusercontent.com/Insality/crowd-runner-defold/main/media/game.gif)

Taken from:  
[https://github.com/Insality/crowd-runner-defold](https://github.com/Insality/crowd-runner-defold)

Note I haven’t tested this myself!

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [December 15, 2022, 2:13pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/46 "2022-12-15T14:13:23Z")

</div>

> [@Alex\_8BitSkull](#):
>
> I think this is the behaviour desired:

Basically, yes. But I can recall this having a lot of jittering the last time I checked it out.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [December 15, 2022, 2:44pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/47 "2022-12-15T14:44:31Z")

</div>

Not sure how it was implemented on @Alex_8BitSkull suggested project but if you want a crowd(flock) control, you can use steering behaviors(separation).

> **[Boids (Flocks, Herds, and Schools: a Distributed Behavioral
Model)](http://www.red3d.com/cwr/boids/)**
>
> Background and update on BOIDS, the 1987 model of group motion in
> flocks, herds, schools and related phenomena. Includes a Java-based
> demonstration and many links to related research and
> applications.

[![](https://img.youtube.com/vi/fWqOdLI944M/maxresdefault.jpg "6.7: Group Steering Behaviors - The Nature of Code") ](https://www.youtube.com/watch?v=fWqOdLI944M&t=630)

And there are other algorithms which you can implement for increasing performance.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [March 30, 2024, 1:03pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/48 "2024-03-30T13:03:22Z")

</div>

Small update…  
2.1.2

- Internal Update Frequency added. Default value is set from game.project file (display.frequency).  
It is now possible to set a new internal(independent from Defold game loop) update frequency by using `aabb.update_frequency()`.
- Fixed [#9](https://github.com/selimanac/DAABBCC/issues/9#issue-1533854235)

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [June 17, 2024, 5:33pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/49 "2024-06-17T17:33:50Z")

</div>

Since it is a national holiday here, I decided to develop a few more simple/basic examples for DAABBCC (what a terrible name this is!). The first one is Breakout. A stupid Flappy Bird clone is on the way…

Test it: [https://selimanac.github.io/DAABBCC-Breakout-Example/](https://selimanac.github.io/DAABBCC-Breakout-Example/)

![DAABBCC Breakout](https://raw.githubusercontent.com/selimanac/DAABBCC-Breakout-Example/main/.github/breakout.png)

[https://github.com/selimanac/DAABBCC-Breakout-Example](https://github.com/selimanac/DAABBCC-Breakout-Example)

Assets by [Megacrash](https://megacrash.itch.io/).

This is not a historically or logically accurate Breakout clone. It may also contain bugs. This is just a simple example of how to use DAABBCC.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [June 19, 2024, 10:14am UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/50 "2024-06-19T10:14:50Z")

</div>

Here is the Flappybird example using DAABBCC

Test it here: [https://selimanac.github.io/DAABBCC-Flappybird-Example/](https://selimanac.github.io/DAABBCC-Flappybird-Example/)

 ![Screenshot 2024-06-19 at 12.14.38](https://forum-defold-uploads.b-cdn.net/original/3X/a/d/ad39737328f17f56e3a720317549ec36bcbfe7cc.jpeg)

[https://github.com/selimanac/DAABBCC-Flappybird-Example](https://github.com/selimanac/DAABBCC-Flappybird-Example)

I have time for a several more examples but don’t know what to do next yet. Any suggestions?

---

<div class="post-metadata">

**Author:** ![yeqwep](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/yeqwep/32/32639_2.png) [@yeqwep](https://forum.defold.com/u/yeqwep)\
**Post date:** [June 22, 2024, 11:27pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/51 "2024-06-22T23:27:49Z")

</div>

I made a very simple drag and drop example. DAABBCC is so cool!  
 ![a](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/3X/e/1/e1e0a67a843808296d03179beb1f3c092c686e94.gif)

[https://github.com/yeqwep/DAABBCC-DragAndDrop-Example](https://github.com/yeqwep/DAABBCC-DragAndDrop-Example)

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [June 23, 2024, 5:21am UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/52 "2024-06-23T05:21:24Z")

</div>

Nice! 🙂

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [August 4, 2024, 1:37pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/53 "2024-08-04T13:37:57Z")

</div>

Is it normal for this extension to not autocomplete in the editor?

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/5/3/537aa40f3ede92f7f6b19ba455210529d1d42ec2.png)

The extension is working. I am getting group ids returned. But the editor is showing errors and it’s not showing the functions when typing aabb.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [August 4, 2024, 1:55pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/54 "2024-08-04T13:55:25Z")

</div>

This project doesn’t have api definitions for Defold Editor. I’m not using the built-in editor and I’m not interesting in adding api definitions . Feel free to contribute and PR.  
PS: this has nothing to do with extension itself. It is going to work as expected.

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [August 4, 2024, 2:06pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/55 "2024-08-04T14:06:28Z")

</div>

Yes, it works great so far. Thank you. Getting used to it now.

I would contribute to the API if I could. A lack of time and skill with working with Defold APIs prevents me from doing so.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [August 4, 2024, 2:23pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/56 "2024-08-04T14:23:39Z")

</div>

> [@rayraytime](#):
>
> I would contribute to the API if I could. A lack of time and skill with working with Defold APIs prevents me from doing so.

It is incredibly easy, just a YAML file.  
Documentation is here: [https://defold.com/manuals/extensions-script-api/#auto-complete-for-native-extensions](https://defold.com/manuals/extensions-script-api/#auto-complete-for-native-extensions)

---

<div class="post-metadata">

**Author:** ![rayraytime](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@rayraytime](https://forum.defold.com/u/rayraytime)\
**Post date:** [August 4, 2024, 3:37pm UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/57 "2024-08-04T15:37:23Z")

</div>

Thanks. I can probably figure it out within a day or two. Seems simple enough.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [October 9, 2024, 6:13am UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/58 "2024-10-09T06:13:54Z")

</div>

### v3.0 released

#### Special thanks to [8BitSkull](https://forum.defold.com/u/alex_8bitskull/summary) for his support with DAABBCC.

[https://github.com/selimanac/defold-daabbcc](https://github.com/selimanac/defold-daabbcc)

## Discussions & Release Notes

> **[selimanac defold-daabbcc · Discussions](https://github.com/selimanac/defold-daabbcc/discussions)**
>
> Explore the GitHub Discussions forum for selimanac defold-daabbcc. Discuss code, ask questions & collaborate with the developer community.

## Documentation

> **[Home](https://github.com/selimanac/defold-daabbcc/wiki)**
>
> Dynamic Tree(aka AABB Tree) native extension for Defold Engine - selimanac/defold-daabbcc

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [October 9, 2024, 10:01am UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/59 "2024-10-09T10:01:35Z")

</div>

Wonderful work! Implemented in my current project and appears to be working great. 🥳

The migration document is missing one line:

```lua
Replace all aabb.query_sort() to daabbcc.query_aabb_sort()

```

I would have made the change myself but couldn’t see an edit button.

---

<div class="post-metadata">

**Author:** ![Alex\_8BitSkull](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alex_8bitskull/32/5424_2.png) [@Alex\_8BitSkull](https://forum.defold.com/u/Alex_8BitSkull)\
**Post date:** [October 17, 2024, 10:52am UTC](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328/60 "2024-10-17T10:52:51Z")

</div>

I got error:

```lua
Max Query Result Count reached: 32

```

I guess this means one single query yielded \>32 results? Can this max limit be changed somehow? If no, or if it’s a bad idea, can I choose how it is handled perhaps? I can imagine some circumstances where I don’t want this to cause an error, but rather stop listing query results when it exceeds 32.

[Previous page](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328.md?page=2)

[Next page](https://forum.defold.com/t/daabbcc-dynamic-tree-aka-aabb-tree-native-extension-for-fast-aabb-collision-detection/18328.md?page=4)
