is it possible to modify the mesh buffers from another thread? The geometry is already attached to the scene.
The separate thread should get the buffers from the mesh and update the vertex buffer with vb.updateData(newBuffer); after modifying it.
ah ok do you mean that my separate thread could copy the buffer from the mesh and modify it? After that, only the main thread swap/update the buffer of the mesh via vb.updateData(newBuffer);?
Is deep clone of the buffers necessary or is it okay to use something like buffer.duplicate() to create a new “view” of the buffer instead of to copy the whole data?
Why can’t the thread do the cloning? I could create another view of the buffer first and then copy the buffer. Each view has its own position/limit state of the buffer.
What is it that you are trying to do exactly? All of these clonings and duplications going on… usually it’s better just to regenerate rather than modify.
And to answer your question, no it’s not safe. You might get away with it most of the time but why bother? It’s not safe.
I have a lot of complex meshes. Rarely I want to modify a mesh but the duration to update the mesh is very important. I think its more efficient to update VBOs instead of creating a new one.
It takes too much time to do all the calculations on the mesh. For this reason I try to do all the calculations on another thread. There are some frame drops if I do the calculations on the main thread.
@alrik said:
I have a lot of complex meshes. Rarely I want to modify a mesh but the duration to update the mesh is very important. I think its more efficient to update VBOs instead of creating a new one.
It takes too much time to do all the calculations on the mesh. For this reason I try to do all the calculations on another thread. There are some frame drops if I do the calculations on the main thread.
So grab the data on the update loop, do your calculations on the other thread and then apply it again on the update loop, whats the problem?