CollisionObject scaling?

stephanh
Posts: 3
Joined: Sun Jun 10, 2007 9:03 am

CollisionObject scaling?

Post by stephanh »

Hi,

is it possible to apply a scale factor (ideally non-uniform) on a per-collisionobject basis?
I use mostly bvhtrianglemeshshapes and want to share them among several collisionobjects.

The only way i see so far is to have separate isntances of the shapes per object for different scale factors and use setLocalScale on the bvhtrianglemeshshapes.

Restricting scaling to uniform factors won't help, since btUniformScalingShape only supports convex shapes.

Are there any other options?
Thanks alot for your suggestions.

all the best,
stephan
reltham
Posts: 66
Joined: Fri Oct 12, 2007 6:28 pm
Location: San Diego

Re: CollisionObject scaling?

Post by reltham »

The only way to scale is at the shape level.

The only sharing I get when using meshes is the raw vertex/index data that is passed into btTriangleIndexVertexArray (which is then passed into the btBvhTriangleMeshShape). The bt objects are not very big, and they refer back to your raw vertex/index data.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: CollisionObject scaling?

Post by Erwin Coumans »

Reltham is right.

You can share mesh data by re-using the btTriangleIndexVertexArray among different btBvhTriangleMeshShape instances, and use a difference scaling for each btBvhTriangleMeshShape. btBvhTriangleMeshShape has very low memory usage.

As you already mentioned, for convex shapes you can use either setLocalScaling, or wrap it in a btUniformScalingShape.

Is there an issue with this?
Thanks,
Erwin
stephanh
Posts: 3
Joined: Sun Jun 10, 2007 9:03 am

Re: CollisionObject scaling?

Post by stephanh »

Thanks for the info. I had the impression that the bounding volume hierarchy is quite costly to build (hence the possibility to serialize). No issues, just a psychological barrier :).

PS: I had to look at the source code several times to determine memory ownership (btTriangleVertexIndexArray/MeshIface for bvhtriangleshape..etc) Some hints in the docs would help...