I am looking for feedback and information on how one should handle instance data. I am using DirectX 11, but it's the theory I'm interesting in and not the actual implementation.
This is my current setup:
- Game class with Update() and Draw() methods.'
- An array with GameObjects
- GameObject has Update() to recalculate a transform matrix and Draw() to pass the matrix and a mesh name to a RenderManager
- RenderManager has a list of mesh names, each name has its own list of transform matrices (one matrix per instance to draw)
- For each name I loop through all matrices and copy their data to an array of type InstanceData
- This InstanceData array is a subresource of an ID3D11Buffer
- After all copying is done the buffer is updated with Map/Unmap and memcpy
- I then DrawIndexedInstanced() using the mesh VertexBuffer, IndexBuffer and the InstanceDataBuffer
This is what I came up with on my own using the knowledge I already had on the subject and looking up things when I needed to. Now I'm interested in hearing what I've done wrong and how to improve it. I'm interested in your opinions and any recommended reading on the subject.
I am mostly concerned with point number 5, which at the moment is a constant reorganizing of an array. How should I go about in improving this?
Thanks for reading