Managing visible objects / sync create and delete of objects
Posted: Sun Oct 04, 2015 5:44 am
While trying to create a simple procedural space scene in Unity3D (see e.g. https://forums.inovaestudios.com/t/proc ... -to/765/97 ) I always reach a point at terms of how to create and delete objects where I wonder what is the right route to go. I guess (or I am sure) Josh must have had a similar issue where he obviously took the right decision when looking at how Limit Theory looks at it current state.
When you create a procedural universe, you likely use noise functions like simplex noise to decide where to create asteroids, planets, suns, etc. All kind of objects.
You do these checks around the current player position, until a certain distance where things should stream in when the player moves.
As you need to check a lot with those resource-expensive noise functions, you want to check positions only once, and likely in a separate background thread. And, you want create these objects only once of course, you dont want to create a sun a second time at a position where you already create one beforehand due to some noise result.
Summarising: You need a good strategy how to check the area around the player, keep track of the objects already created, find a good strategy when to delete objects and create new ones only if missing in the current scene. I find this really complicated when using background threads that check positions with noise functions, when at the same time you somewhen need to delete (in a different main trhread, of Unity3D in my case) objects if they get out of range. Exceptions within lists where you keep track of the objects are not unlikely, also not to bounce between creation and deletion of objects.
I hope Josh will somewhen give an inside view of how he manages the creation and deletion of objects in the background. If there is a core thread of function responsible for this, or if every object manages itself, etc.
When you create a procedural universe, you likely use noise functions like simplex noise to decide where to create asteroids, planets, suns, etc. All kind of objects.
You do these checks around the current player position, until a certain distance where things should stream in when the player moves.
As you need to check a lot with those resource-expensive noise functions, you want to check positions only once, and likely in a separate background thread. And, you want create these objects only once of course, you dont want to create a sun a second time at a position where you already create one beforehand due to some noise result.
Summarising: You need a good strategy how to check the area around the player, keep track of the objects already created, find a good strategy when to delete objects and create new ones only if missing in the current scene. I find this really complicated when using background threads that check positions with noise functions, when at the same time you somewhen need to delete (in a different main trhread, of Unity3D in my case) objects if they get out of range. Exceptions within lists where you keep track of the objects are not unlikely, also not to bounce between creation and deletion of objects.
I hope Josh will somewhen give an inside view of how he manages the creation and deletion of objects in the background. If there is a core thread of function responsible for this, or if every object manages itself, etc.