I’m trying to write an editor overtop a multi-threaded game engine. In theory, through the editor, the contents of the scene can be totally changed but I haven’t been able to come up with a good way for the engine to cope with the changes. (ie delete an entity while the renderer was drawing it). Additionally, I’m hesitant to write code to manage locks at every instance I use an entity or resource that can be potentially deleted. I imagine there has to be a relatively more elegant solution.
Does anyone have any ideas or strategies I can start looking at?
Thanks!
In addition to the two-stage process suggested by @lassevk you could use a Pipe structure to “push” commands to the renderer so that these changes gets the form of another work item for the render engine.
For example, say your engine follows a workflow like:
You could just add a new item to the workflow in the position 0, called Process Changes which pulls out the information from the Pipe and incorporates it to the scene.