The terrain chunks are stored in btBvhTriangleMeshShape(s) and are added/removed like such:
dynamicsWorld->removeRigidBody(chunk);
dynamicsWorld->addRigidBody(chunk); // severe lag
Any advice is greatly appreciated

Hello!benelot wrote:Hi,
Unfortunately a heightfield is not suitable for a voxel terrain system such as this: http://http.developer.nvidia.com/GPUGem ... 1fig01.jpgbenelot wrote:First of all, have you considered to use btheightfieldterrainshape? It could serve as a single chunk and is probably very suited for terrains Have you had any experiences with it?
Indeed. I have tried scaling the size of the chunks (to make fewer but larger chunks) and that does speed things up, but it is nowhere near the speed that it should be and rebuilding large chunks on my end is not efficient in the least.benelot wrote:The issue you are experiencing is strange indeed. The way you are adding and removing chunks is the way you should do it.
I should also mention that what I am doing is a bit more complicated than what I described in the OP. This is a multiplayer game that requires determinacy, and the only way to achieve that with Bullet Physics is -apparently- to reset bullet physics each cycle (you can read about that adventure in this thread).benelot wrote:Does it boil down to add, remove and readd the trianglemeshshape or does the issue go further?
I imagine it would be fairly straightforward to provoke by instancing some large meshes and adding/removing them each cycle.benelot wrote:Can you build a simple version running in the example browser that shows your issue so that we can debug into it?
I'm working on a voxel game myself. I am using a triangle mesh rigid body instead of a compound body. Is the compound body more efficient?hyyou wrote:I am also facing that same problem as OP, at the exact same lines of code.
In my case, "chunk" is a compound body - compose of many child shapes.
If I want to add/remove a single child shape from the compound body, or change collision mask, I will have to remove and add the whole body back.
It is also performance bottleneck of my program now.
My best solution is to limit size/complexity of the "chunk", but it is not practical.
You use mesh, so you have to modify mesh's shape if terrain is modified, right?I am using a triangle mesh rigid body instead of a compound body.