Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Apr 02, 2012 10:42 am 
Offline

Joined: Mon Apr 02, 2012 10:22 am
Posts: 6
Hi all,

What is the best strategy to update a mesh inside a btBvhTriangleMeshShape?

Let me explain a bit. We have a ground made of voxels. They are not rendered as cube. The ground is split into chunks (16x16x<world height>).
For each chunk we create a static rigid body with a shape in Bullet using btTriangleIndexVertexArray, btIndexedMesh and btBvhTriangleMeshShape.
One of our game's features is that the ground is modifiable in real-time (i.e. you can add or remove voxels).
At the moment, to update a chunk in Bullet, we remove the rigid body from the world, we delete the rigid body and the shape and we re-create them with the new mesh.
For us, it seems definitively not efficient. But maybe we have missed something. If there any way to update the content of a btBvhTriangleMeshShape without delete it, it would be great.

Thank you for your answer.


Top
 Profile  
 
PostPosted: Mon Apr 02, 2012 10:47 am 
Offline

Joined: Wed Jan 07, 2009 11:43 am
Posts: 99
Location: London
I haven't tried it in this case, but BvhTriangleMesh has methods : refitTree and partialRefitTree that may do what you need without having to remove and re-create the RigidBody.


Top
 Profile  
 
PostPosted: Mon Apr 02, 2012 12:26 pm 
Offline

Joined: Mon Apr 02, 2012 10:22 am
Posts: 6
Thank you xexuxjy. But how do you add or remove triangles in the shape?


Top
 Profile  
 
PostPosted: Mon Apr 02, 2012 1:29 pm 
Offline

Joined: Wed Jan 07, 2009 11:43 am
Posts: 99
Location: London
Again just guessing, but you should be able to lock your underlying btTriangleIndexVertexArray object and use the getLockedVertexIndexBase method to then manipulate your dataset (add/remove vertices) then unlock them and call the recalc from earlier. You could also write your own implementation of the StridingMeshInterface as that underlies most of these calls.

If you've got any specific demo code you could post to show what you're trying to achieve I could maybe help more.


Top
 Profile  
 
PostPosted: Mon Apr 02, 2012 3:20 pm 
Offline

Joined: Mon Apr 02, 2012 10:22 am
Posts: 6
Thanks again xexuxjy.
I will study your solutions.
And come, eventually, with more specific questions.


Top
 Profile  
 
PostPosted: Mon Apr 02, 2012 10:56 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3746
Location: California, USA
The btBvhTriangleMeshShape can only refit existing triangles with updated vertex positions (see Bullet/Demos/ConcaveDemo), so you cannot add/remove triangles (change the topology).

If you need a concave collision shape with adding/removing triangles, you could try using btCompoundShape, with triangles as child shapes? Likely more efficient then rebuilding the BVH (btCompoundShape uses the incrementally updated btDbvt). Alternatively, some work could be done to replace the btOptimizedBVH by btDbvt, adding a btDbvtTriangleMeshShape.

Thanks,
Erwin


Top
 Profile  
 
PostPosted: Tue Apr 03, 2012 10:10 am 
Offline

Joined: Mon Apr 02, 2012 10:22 am
Posts: 6
Hi Erwin,

Thank you for this details.
I will try that, and give you some feedback.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Pacha and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group