Creating Custom Collision Object

xerzi
Posts: 3
Joined: Thu Feb 02, 2012 3:58 pm

Creating Custom Collision Object

Post by xerzi »

I haven't found much documentation for this, I am wanting to create a custom class (much like btBvhTriangleMeshShape) and will be using convex polygons stored as edges. I've looked at how it was done but I am having some trouble understanding what Bullet is doing:

How are collisions between two different objects determined? I know there is a "m_shapetype" defined in btCollisionShape which I believe is than being used to determine what collision to use. Does that mean the m_shapetype is used to hardcode the upcast from btCollisionShape to btTriangleMeshShape, which than calls ProcessAllTriangles() ?

So all this would mean I'd need to write collision code for each native type, assuming only primitive types as this will be a static mesh for motion only. The way I see the btBvhTriangleMeshShape working is a "box" is created around the start point and end point, which is called to ProcessAllTriangle. Any triangles within this box are sent to the callback function where they are processed further based on the type of primitive.

I'd appreciate any insight or any documentation on how this is implemented.
CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Re: Creating Custom Collision Object

Post by CookieMonster »

You do not have to make your own collision algorithm for static triangle shapes. If you inherit btConcaveShape like in the heightfield class does, the engine will call processAllTriangles with an AABB for the section that it is interested in and use it for collisions.