Sign in to follow this  
TheMac

Collision Detection basics with bullet

Recommended Posts

My understanding of collision detection is you define a shape outside of our mesh to check for collisions. Once the outside shape collides then the mesh its self is checked, is this correct? If you define a box shape in bullet to go around a tea pot, will you be able to say throw a rock through the handle without knocking over the tea pot? My problem is I was messing with bullet, but for fun I increased the size of my collision shape of my box to twice the size of the mesh, and now the meshes rest on the collision shape and not the actual mesh I am rendering. Why is this, and what am I missing? Thanks.

Share this post


Link to post
Share on other sites
The behavior you described (testing the large shape and then the more detailed shape) can only happen if you tell bullet about the detailed mesh. So if you haven't passed the mesh triangles to bullet then no, the rock will hit the teapot even though it appears it would pass through the handle.

Internally bullet is doing what you're describing. It first checks a very conservative shape around yours, before testing your shape. But if you've only told bullet that the shape is a box, then that is the collision resolution you will experience.

My point is that if you DO supply bullet the complete, complex mesh of the teapot, then it will automatically make the optimization of surround that mesh shape in a box and tests the box before it even attempts to test the mesh for collision.

So the question is, when supplying bullet the collision shape (refered to as primitive) for your teapot, are you supplying a box or a mesh?

Note that concave meshes such as a teapot are hell for a collision detection algorithm. Most times complex shapes are respresented as convex hulls, so again you would not be able to throw a rock through the handle, but if the rock were to pass under the spout for instance, it would likely miss the convex hull. A convex hull is kind of like taking shrink wrap or spandex and stretching it over your shape. It's very efficient to compute collision with this shape (such as a box).

Share this post


Link to post
Share on other sites
Quote:
My understanding of collision detection is you define a shape outside of our mesh to check for collisions. Once the outside shape collides then the mesh its self is checked, is this correct?
It depends on how you have set up your "mesh", see next.
Quote:
If you define a box shape in bullet to go around a tea pot, will you be able to say throw a rock through the handle without knocking over the tea pot?
No, you won't. If you define a box shape, then a box will be used for collision and nothing else. You seem to think that graphics and simulation are somewhat related; They are totaly independent of each other, it's your job to sync simulation with rendering. You created a shape, in Bullet it should be (the box) a btBoxShape, you assign it to a rigid body and ask for Bullet to simulate one step for you. It provides, then, information on the position of the object and its orientation. If you want to take this info and render a human body with it, no problem, the simulation is still goind on with a box internally. If you want to simulate an object with some weird shape, you have to tell Bullet what the shape looks like. For convex shapes, a btConvexHullShape will do, but for concave, like the teapot, shapes, you will have to use a btGImpactMeshShape, and you're better served looking at the demos that come in the package for that.

Share this post


Link to post
Share on other sites
Then on AAA titles how do they get so exact on there collision detection. If you are sniping someone and you shoot next to there head but not touch there head, how does CD normally take place? If the bullet passes through the sphere that is around the head, but doesn't hit the head, what processes take place?

Share this post


Link to post
Share on other sites
The head sphere is much less complex than a teapot and works exactly as we've described.

The user (software programmer) has given bullet a sphere to collision detect against in place of the head model. When the player shoots a bullet, a ray is passed through the scene and any object, including spheres, that it hits, is returned as a potential collision.

If the game code determines that a head sphere was hit, you die.

Games NEVER pass the entire character mesh to physics for collision detection. Often the character is surrounded in a cloud of spheres and capsules to approximate his body shape.

So all you'd need to do as a bullet user is pass these spheres and capsules to the physics engine, and when one of them is hit, determine what part of the character or teapot it was associated with.

so if you wanted to achieve the effect of rocks passing through your teapot handle, you'd have to either pass the entire teapot mesh to bullet, every single triangle. Or you'd have to create a bunch of spheres and boxes that approximated the teapots shape.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this