So I'm trying to create a simple multi-threaded game engine for the game I want to write. So far, everything has worked without any problems, I even know what steps I have to take to finish it.
There is only one thing I don't know (well, technically, I know a solution for it, but I'm hoping there is something more elegant and faster): Basically, I have a seperate thread for every part of my engine - Graphics, Input, Physics, Audio, etc.
The physics thread has a complete scene node structure of the world, where it simulates everything. However, I now have to get this structure over to my graphics thread, with the least overhead possible. Ideally, it should only transfer the parts which changed since the last update.
I have components in place for transfering this data, only problem is generating it.
So far, I have thought of two different approaches:
- copy the whole structure for every update - very simple, but possibly time and memory intensife (I don't have experience with large engines - would this be viable?)
- Keep track of which parts of the scene changed by marking the scene nodes with some flags, and then only copying over the changed parts
Approach one would copy a big amount of memory, but without much processing power, approach two would do the reverse: plenty of processing power, less memory copied.
Is there some general answer which approach would be faster in a typical gaming environment?