Detecting collisions from inside a mesh.

MrSiggler
Posts: 5
Joined: Thu Aug 02, 2012 1:07 pm

Detecting collisions from inside a mesh.

Post by MrSiggler »

Hey all.

I'm using a btBvhTriangleMeshShape as the body of a 2D tile map in my game. Now, this works for the dynamics side of things, the player moves freely inside the bounds of this mesh, hits the walls, walks on the floors, so forth.

I want to be able to act upon the player when it hits the level's body. I'm iterating through the manifolds each step to catch collisions, but the problem is that a manifold is created simply by being inside the mesh's boundaries, wether or not it's actually touching a triangle in the mesh body. Is there a way around this? Or is there a better way to represent a 2d mesh in this manner?

Many thanks!
MrSiggler
Posts: 5
Joined: Thu Aug 02, 2012 1:07 pm

Re: Detecting collisions from inside a mesh.

Post by MrSiggler »

What I ended up doing was using a compound body, using the box2d shape for each tile. This get's me the result i wanted, and is actually a little bit faster. My guess being as there's only one box per tile, instead of two triangles per tile when in the mesh.