Collision on single side of a triangle face

arunm
Posts: 3
Joined: Wed Jul 28, 2010 12:16 pm

Collision on single side of a triangle face

Post by arunm »

Hi,

We recently working on a 3d game and we integrated bullet physics for our collision detection purpose & basic physics. I used a btCapsuleShapeZ collider for my playable character and for mesh I used btBvhTriangleMeshShape.

Collision is working great... thanks to bullet community. But recently we found a problem like the collider is colliding on both sides of a triangle (front and back). How can I make it to collide only on front side. Is there any flag i need to set ?.


Bellow mentioned is our create collision mesh function.

void physicsEngine::createCollisionMesh(gxColMesh* colMesh)
{
btTriangleIndexVertexArray* indexVertexArray = new btTriangleIndexVertexArray(colMesh->m_nTris, colMesh->m_psziGLTriLst, 3*sizeof(int), colMesh->m_nVerts, (float*)colMesh->m_psziGLVertexLst, 3*sizeof(float));

m_pszIndexVertexArrayList.push_back(indexVertexArray);


btBvhTriangleMeshShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArray, true, m_cAABBMin, m_cAABBMax);
m_pszCollisionShapes.push_back(trimeshShape);

/// Create Dynamic Objects
btTransform startTransform;
startTransform.setIdentity();

btVector3 localInertia(0,0,0);
startTransform.setOrigin(btVector3(0, 0, 0));


//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(0,myMotionState,trimeshShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);

body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);//STATIC_OBJECT);
//enable custom material callback
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);

m_pDynamicsWorld->addRigidBody(body);
}

Please help....

thanks in advance.
arun
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision on single side of a triangle face

Post by Erwin Coumans »

Bullet 2.x only has double-sided collisions with triangle meshes, but we could consider adding single sided triangle meshes in the future.

Why do you want this feature exactly?
Thanks,
Erwin
arunm
Posts: 3
Joined: Wed Jul 28, 2010 12:16 pm

Re: Collision on single side of a triangle face

Post by arunm »

hi Erwin,

Thanks for your quick response.

We are making a sports bike game which has to do stunts on air. In order to jump from the edge of the ground, we have protrude the edge of the ground by adding an additional polygon which will be slightly slanted from the ground edge.

Please see the attachment (I scaled the collision mesh to make it viewable).

The red polygon is used as a collision mesh and the rigid-body will jump when it sweep through it. The problem is when the rigid-body wants to come back it collides at the back-side of the triangle too (not at the edge of the triangle).


Is there any alternative for this. Or if i want to make any changes, then where should i make those changes.

regards,
arun
You do not have the required permissions to view the files attached to this post.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Collision on single side of a triangle face

Post by sparkprime »

Seems like an odd way to achieve the behaviour you want. Your bikes will hover in mid air if they become stationary. Why not trigger a jump impulse instead?