Hello,
My engine uses a component based architecture where I have an array of GameObjects and a number of other arrays each storing a type of component.
Something like this:
struct GameObject
{
//indices to each of the game object components (-1 if component isnt used)
int components[NUM_COMPONENTS];
};
GameObject* gameObjects;
PositionComponent* positions;
ModelComponent* models;
In order to implement Level Streaming I load the level file (actually it's a world section for an open world game) in a different thread (core) and I need to resize each (or some, depending on the game objects of the level being loaded) of the arrays above to be able to store the new level objects.
Since the loading is done in a different thread I need some kind of synchronization with the main thread. But simply putting the main thread on hold while the new larger arrays are allocated and the memory from the old ones is copied causes the game to freeze for around second.
Any ideas on how to make it more efficient like distributing the time across a few frames or something?
Thanks!