favreau / bullet

Automatically exported from code.google.com/p/bullet
0 stars 0 forks source link

New feature :Duplicating collision shapes #567

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I haven't had the need to do it in the past
but getting to a point where I actually
need to duplicate an entire collision shape
(for various reasons, particles instancing, fracturing,etc.)
Doesn't seem to be any easy way in bullet as of now
(I guess duplicating isn't a very good thing..)
but might something that would be interesting
to consider maybe for bullet 3.x 

Francois

Original issue reported on code.google.com by francois...@gmail.com on 14 Nov 2011 at 12:42

GoogleCodeExporter commented 9 years ago
We can consider it for Bullet 3.x indeed.

Just curious: why can't you use instancing? It is better to share shapes, 
instead of duplication?

Original comment by erwin.coumans on 14 Nov 2011 at 6:14

GoogleCodeExporter commented 9 years ago
I use this in the context of instancing rigid bodies
from a particle system within maya.
I do use instancing of the same shape if the scale of the instance
isn't changed per particle, and from what I can see in the code, the scale
on the collision shape gets baked in, even if I put a compound shape above
setScale gets passed down to the lower collision shape.
Is there any way of sharing the shapes and applying different scales to them ?

Francois

Original comment by francois...@gmail.com on 14 Nov 2011 at 8:05

GoogleCodeExporter commented 9 years ago
There are various way of instancing collision shapes. It depends on whether you 
have uniform or non-uniform scaling.

btUniformScalingShape can instance a convex shape (btConvexHullShape), with 
uniform scaling
btScaledBvhTriangleMeshShape can wrap a concave triangle mesh with non-uniform 
scaling

I would not bother trying to instance primitive shapes (btBoxShape, 
btSphereShape etc), it is not worth the memory savings.

Original comment by erwin.coumans on 14 Nov 2011 at 10:58

GoogleCodeExporter commented 9 years ago
I just looked at btUniformScalingShape and I don't think it will work
for me, because of this :
void    btUniformScalingShape::setLocalScaling(const btVector3& scaling) 
{
         m_childConvexShape->setLocalScaling(scaling);
}

which basically will scale down the original shape.
But what I want is to be able to have 2 instances of the same
shape at different scales...

Ideally the best would be to have this btUniformScalingShape
but one that doesn't send the scale down to the original shape.

Does that make sense ?

Original comment by francois...@gmail.com on 15 Nov 2011 at 12:12

GoogleCodeExporter commented 9 years ago

You should not call that setLocalScaling because that is non-uniform scaling.

The btUniformScalingShape allows to have multiple instances of the underlying 
child shape with different UNIFORM scaling. The constructor takes the uniform 
scale factor.

The btScaledBvhTriangleMeshShape does this for static concave triangle meshes.

Original comment by erwin.coumans on 15 Nov 2011 at 7:19

GoogleCodeExporter commented 9 years ago

Another option is to use btConvexPointCloudShape instead of btConvexHullShape. 
btConvexPointCloudShape doesn't own/delete its vertices and each can have its 
own local scaling.

Are you concerned about instancing shapes, other then 
btConvexHullShape/btBvhTriangleMeshShape?

Thanks,
Erwin

Original comment by erwin.coumans on 15 Nov 2011 at 8:14

GoogleCodeExporter commented 9 years ago
Well I'm also instancing compound objects , so not sure how
that would work.
The non-scaling collision shapes you mentioned only hold one shape right ?
Just wondering if it'd be possible to implement a compound shape that doesn't
send the scale down to the child shapes ?

Francois

Original comment by majestik...@gmail.com on 15 Nov 2011 at 9:40

GoogleCodeExporter commented 9 years ago
For compound objects this is currently not possible indeed.

You might be able to customize Bullet yourself if you know more details about 
the contents of the btCompoundShape. 

What are typical child shape types of your compound shapes? 
Are you using recursive btCompoundShape?

Original comment by erwin.coumans on 15 Nov 2011 at 11:47

GoogleCodeExporter commented 9 years ago
I think I might try and implement a new btScaledShape or something that
holds the scale on the child shape.

Most the of shapes underneath the compound will very likely be convex hulls, 
although, changing the shape is only a parameter away for whoever uses it, so I
cannot guarantee that, i.e. have to support pretty much all the collision shapes
bullet has.

We don't support compounds within compounds though, so that simplifies the 
problem
quite a bit :)

F

Original comment by majestik...@gmail.com on 23 Nov 2011 at 3:01

GoogleCodeExporter commented 9 years ago
This is not planned for Bullet 2.x.

Once Bullet 3.x is out, we will reconsider it.

Original comment by erwin.coumans on 29 Feb 2012 at 4:26