using arrays to get best memory alignment and cache use, is it necessary?
- by Alberto Toglia
I'm all about performance these days cause I'm developing my first game engine. I'm no c++ expert but after some research I discovered the importance of the cache and the memory alignment.
Basically what I found is that it is recommended to have memory well aligned specially if you need to access them together, for example in a loop.
Now, In my project I'm doing my Game Object Manager, and I was thinking to have an array of GameObjects references. meaning I would have the actual memory of my objects one after the other.
static const size_t MaxNumberGameObjects = 20;
GameObject mGameObjects[MaxNumberGameObjects];
But, as I will be having a list of components per object -Component based design- (Mesh, RigidBody, Transformation, etc), will I be gaining something with the array at all?
Anyway, I have seen some people just using a simple std::map for storing game objects. So what do you guys think?
Am I better off using a pure component model?