Convex shapes, such as btSphereShape, btConvexHullShape, etc have a notion of "inside" vs "outside" for collision, such that colliding objects are restricted/pushed to the outside of a convex shape. Is there a way (or rather, what would be the best way) to invert this behaviour so that, for example, I have a btSphereShape, but objects are contained within it, such that they collide with the internal walls of the shape, and if they try to move outside the shape, they are pushed back in?
Up until now I have used a concave mesh shape (which is really just a large ellipsoid) to contain other objects moving around inside it, but this gets expensive for collisions. So I'd like the efficiency of a simple convex shape instead, but one that has its outside/inside flipped (it "contains" objects rather than expels them). For a general convex shape, I imagine this would be as simple as ensuring that the object is on the inside (in the traditional sense) side of each hull face.
Note: I understand that the case where a body is completely outside such a "container" is ambiguous, as it would be triggered for collision with all such containers in the world, and be pulled in various directions, but in my case I just have a single container which is essentially my world, and thus it's a simpler situation.
Convex "container"
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Convex "container"
Hi dphil,
Once you 'invert' a convex shape it becomes a concave shape and collision detection becomes more complicated.
Instead of a concave triangle mesh (btBvhTriangleMeshShape/btGImpactShape) you could try approximating it with a btCompoundShape and convex parts.
Have you tried that?
Thanks,
Erwin
Once you 'invert' a convex shape it becomes a concave shape and collision detection becomes more complicated.
Instead of a concave triangle mesh (btBvhTriangleMeshShape/btGImpactShape) you could try approximating it with a btCompoundShape and convex parts.
Have you tried that?
Thanks,
Erwin
-
- Posts: 237
- Joined: Tue Jun 29, 2010 10:27 pm
Re: Convex "container"
Ok, I'll give it a try. Actually, since my mesh is convex and my entire simulation is contained inside it, would it be most efficient to represent each face as a btStaticPlaneShape? I would think this could be more efficient than multiple polyhedra comprising the mesh's surface, as plane collision detection is quite trivial.