   [SOLVED] efficient way of buffering logic in a multithreaded engine
  Hey. im not 100% sure if this is right forum to ask this but here goes.my engine has a separate rendering thread and logic thread and they share the same data. This of course causes various problems especialy with regards to multi-pass rendering.Ive implemented a way to buffer my logic and it works, the rendering thread is now able to finish its cycle using a consistent set of transformations BUT it is EXTREMELY slow.in my object class theres a matrix4x4 that stores a objects absolute position (world space) and its relitive position (object space). whenever an objects relitive position changes its and all of its childrens absolute positions gets updated.when drawing an object i send 1 complete matrix to the shaders(projection*camera space*the objects absolute position). Since i can easily have tens of thousends of objects in my scene this works realy well since only the objects that move has their absolute positions updated, the rest of the objects only gets their absolute positions updated once.Now, the method im using to buffer my logic unfortenetley involves looping through my entire scene graph in each logic step (100 Hz) and thats REALY bad, even when rendering my scene i only loop through a fraction of the scene graph since the greater majority of objects gets culled by my implementation of hierarchical frustum culling.im struggling to come up with a better method. it might be realy simple but im having a mental block on this.Any ideas?Thnx for reading all of this! :P[Edited by - EternityZA on June 23, 2009 3:03:53 AM]
  what I do is, when the logic thread needs to update any rendering data (E.g. a transform), it sends the render thread a message. Both threads have their own copy of the transform.n.b. The scene graph is not shared between both threads. The logic thread works on an entity graph and the render thread works on a scene graph. Nodes in the entity graph contain links to nodes in the scene graph.void LogicComponent::Update(){  this->absolute = ...  this->sceneGraphNode->SendMessage( PositionUpdated, this->absolute );}void SceneNode::PositionUpdated( const Matrix& mat ){  this->absolute = mat;}logic thread:  loop:    do updates, send messagesrender thread:  loop:    receive and process messages    render;  thnxOk i might understand what u mean (i think :P)just to clarify: does the rendering thread then only before it starts to render update the scene graph by processing all the messages from the logic thread?  this way preventing the scene graph from changing while rendering from it?am i understanding u correctly? i have a feeling i dont but this is the only way i can think of to keep the scene graph consistent while rednering from it.EDIT - soz i missed the last 2 lines of your post... THnx a lot it makes perfect sense :P   