- Home /
Data structure with 1 bilion possibilities but only around 200 actual objects
Hi, i wonder if you can help me.
I want to divide my scene into a lot of small cubes. Lets say 1000 x 1000 x 1000. But i will deal with only a couple hundreds of them... all others will be empty. In addition i don't want to iterate through that couple hundred to find the one... i have three nice intigers which i belive i can use to point that object. My first thing was just three dimensional array int[1000,1000,1000] which i would access by those three intigers nicely like object = array[2,5,7]. But this array would be really big and i don't need it entirely. List would force me to iterate to find the object. Dictionary, i think it also iterate through keys to find the object.
Do you know some way to manage it optimally?
Thanks in advance and have a nice day!
Answer by xxmariofer · Apr 21, 2021 at 08:40 AM
the most optimally way of doing is using an array, and there is nothing more optimal, but you are right, working with a 1 billion size array.
You are expecting to add 1 billion gameobjects to an scene? because even using DOTS seems too much.
Its imposible to give you the perfect solution or advice without knowing why yoyu need the cubes and why only a couple hundres are not empty.
You should check some tutorials on how minecraft load cubes with "chunks" https://www.youtube.com/watch?v=t4Rw2v5iQl0
I am building 3d heatmap and every position has to be registered in one of those cubes. That's why i need to cover all the scene box with those and i will probably use only a couple hundred.
I understand your issue, I once did something "similar" but nothing near the 1 billion objects. I started using objects, but it was imposible to handle and i changed to particles, the performance benefit was inmesive. I used a 3d camera and created a pointcloud map. there are some assets (that i have never used) that look promising and more visually appealing, check this video
https://www.youtube.com/watch?v=Z6gDH7cy7_M
in the description you will find an asset
Your answer
Follow this Question
Related Questions
LoadImageIntoTexture function on webplayer 0 Answers
How To Disable, Not Deactivate All GameObjects In Array 1 Answer
How to instantiate a random object from an array? 3 Answers
AudioClip Import Order Randomized? 4 Answers
Problem with 2+ of the same scripts on the same object and functions 1 Answer