See update V4 in post [#71]( [WIP] Octree in Pure ECS : BufferArray based with source code (U2020.1a - Entities 0.2) page-2#post-5285541) - Octree based on buffer arrays with source code [work in progress]
Upgrade form
Unity 2018.3.0b10 to 2020.1.0a15
See update V4 in post #26 - Octree based on buffer arrays with source code [work in progress]
__**https://www.youtube.com/watch?v=OlGUWbtUBsM**__
See update V3 in post #23 - Octree in Pure ECS : Raycast Stress Test of 500k Cubes V3
**See update V2 in post #20 **
Original Post
Eh. Not going to lie. This one is really tough one for me.
Freshly new to ECS + porting octree scripts from OOP, to Pure ECS, makes not any easier.
Multum of challenges. And testing is not easy at current ECS state. But feasible.
In past few days I managed so far, to make adding octree nodes systems, which grows and shrinks relevant branches of nodes (leafs).
Next, I need rewrite removing nodes (leafs), and merging.
I hoped to be further with that. But here we go.
Unity3d 2018.2 - Pure ECS - Adding Octree Test (T: 2.36 min)
See in video description for few more details, if interested. Similarly describing below.
Scene at the start displays only Classic OOP GameObjecst for references. Helps for debugging.
These GameObjects are not attached to ECS anyhow, other than ECS prefabs.
After starting the game, every created cube, is via Pure ECS.
Video shows adding new entity objects to octree, when clicking on cubes.
Octree grows or shrinks leafs respectively, to the entity node capacity of entity objects.
In the example, capacity per leaf is set to 4 and can be changed at octree initialization.
Current octree is base on point Octree, where raycast detection of near octree objects appears to work. But not shown on the video, as is not complete.
After finishing with removal of leafs for point octree, next stage will be to create boundary based octree, where raycast will test for collisions with leafs. So octree can be penetrated through, to find number of objects in entities nodes (leafs), that raycast penetrates.
If you survived till end, I hope you have found this somehow interesting.