btStridingMeshInterface example with mesh sharing

ngaloppo
Posts: 11
Joined: Wed Dec 06, 2006 1:59 am
Location: Chapel Hill, NC

btStridingMeshInterface example with mesh sharing

Post by ngaloppo »

Is there an example of class implementation of the btStridingMeshInterface that actually uses the concept of mesh sharing (graphics/physics/collision) in bullet? Specifically, I'm looking for an example on how to point the collision engine to specific OpenGL buffers on the GPU that can be changed by the user and/or physics engine, while the Bullet collision engine always uses the latest state of that buffer (e.g. just a triangle mesh).

Thanks!

--nico
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btStridingMeshInterface example with mesh sharing

Post by Erwin Coumans »

ngaloppo wrote:Is there an example of class implementation of the btStridingMeshInterface that actually uses the concept of mesh sharing (graphics/physics/collision) in bullet? Specifically, I'm looking for an example on how to point the collision engine to specific OpenGL buffers on the GPU that can be changed by the user and/or physics engine, while the Bullet collision engine always uses the latest state of that buffer (e.g. just a triangle mesh).

Thanks!

--nico
The mesh sharing can happen between physics engine, and graphics mesh in main memory.

See the Demos/VehicleDemo how to share existing index/vertex array from main memory (potentially graphics data).

If you really need GPU vertex data, you probably have to unlock/lock the data. In that case, you can implement such interface, by deriving from and implement the GPU -> main memory in getLockedVertexIndexBase (from GPU to main memory) and unLockVertexBase (unlocking, as there is no effect from physics to graphics).

Hope this helps,
Erwin
ngaloppo
Posts: 11
Joined: Wed Dec 06, 2006 1:59 am
Location: Chapel Hill, NC

Re: btStridingMeshInterface example with mesh sharing

Post by ngaloppo »

Erwin Coumans wrote: See the Demos/VehicleDemo how to share existing index/vertex array from main memory (potentially graphics data).

Hope this helps,
Erwin
Thanks! Very useful...

--nico