# Port Current Octree To Morton Code

**URL:** <https://forum.babylonjs.com/t/port-current-octree-to-morton-code/7897>\
**Category:** Feature requests\
**Created:** [January 7, 2020, 10:05am UTC](https://forum.babylonjs.com/t/port-current-octree-to-morton-code/7897 "2020-01-07T10:05:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [January 7, 2020, 10:05am UTC](https://forum.babylonjs.com/t/port-current-octree-to-morton-code/7897/1 "2020-01-07T10:05:08Z")

</div>

Maybe it would nice to port the current recursive implementation of the Octree to a Morton Code based one, that is more performant with max O(n) = log(n).  
Moreover, in order the Octree becomes more generic and usable by other “objects” than meshes, maybe it would be better that it doesn’t rely on meshes but only on vectors3 (min, max… in other words, what describes a BBox).  
It could then be used for other entities : particles, solid particles, points of clouds or logical ones in the user code.

Very good tuto about how to implement the Morton code in C++ in french here : [Octree optimisés gràce au code de Morton](https://pierre-benet.developpez.com/tutoriels/algorithme-3d/octree-morton/)  
An automatic translator should do the job as the article is really well written.

Another light implementation here for 3JS in JS : [Octree · GitHub](https://gist.github.com/yomotsu/a1736b5ce31c6c23e9b4)

I don’t want to break the existing Octree so I won’t code it, unfortunately

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [January 7, 2020, 4:32pm UTC](https://forum.babylonjs.com/t/port-current-octree-to-morton-code/7897/2 "2020-01-07T16:32:06Z")

</div>

> [@jerome](#):
>
> I don’t want to break the existing Octree so I won’t code it, unfortunately

Well the octrees are internal and mostly used by internal objects so I would not care too much about backward compat if we have a big perf gain
