I don't need to perform any actual physics as in collision response. Just need to test If a group of N Bodies intersects a small group of triangles.
So far I have achieved this by creating a btTriangleMesh:
Code: Select all
{
btTriangleMesh *mTriMesh = new btTriangleMesh();
btVector3 v0(0,0,0);
btVector3 v1(0,5,0);
btVector3 v2(5,0,0);
btVector3 v3(5,5,0);
mTriMesh->addTriangle(v0,v1,v2);
mTriMesh->addTriangle(v1,v3,v2);
mCollisionShape = new btBvhTriangleMeshShape(mTriMesh,true);
//btCollisionShape *mTriMeshShape = new btBvhTriangleMeshShape(mTriMesh,true);
btScalar mass = 1;
btVector3 fallInertia(0,0,0);
WeaponObject->mCollisionShape->calculateLocalInertia(mass,fallInertia);
btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,mMotionState,mCollisionShape,fallInertia);
mRigidBody = new btRigidBody(fallRigidBodyCI);
PhysicsSystem::PhysicsSystemPTR->dynamicsWorld->addRigidBody(mRigidBody,CG_RAGDOLLSKELETAL,PhysicsSystem::CM_RAGDOLLSKELETAL);
mRigidBody->setActivationState(DISABLE_DEACTIVATION);
mRigidBody->setSleepingThresholds(0.0,0.0);
mRigidBody->setAngularFactor(0.0);
mRigidBody->setCollisionFlags( mRigidBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
mRigidBody->setGravity(btVector3(0,0,0));
}
Code: Select all
MyContactResultCallback result;
for(vector<GameRagdollBone* >::iterator DefenderBoneIter = Defender->mGameRagdoll->RagdollBones.begin();
DefenderBoneIter != Defender->mGameRagdoll->RagdollBones.end();
DefenderBoneIter++)
{
PhysicsSystem::PhysicsSystemPTR->dynamicsWorld->contactPairTest(mRigidBody,(*DefenderBoneIter)->RagdollBoneRigidBody,result);
if(result.m_connected)
{
cout << "double affirmative" << endl;
}
//else
//{
//cout << "NO GOOD SAM!!! THE PIE... is... BURN!NG!!?!?!? BUrNinAte" << endl;
//}
}
From what i read btTriangleMesh has to be static and is also probably overkill for what i need. It really is just testing vs 2 triangles.
But looking through the demos i cannot seem to find a solution.
I really just need something along the lines of:
Code: Select all
bool TestIfInsideTriangle(btRigidBody* target,btVector3& v1,btVector3& v2,btVector3& v3,)
{
...
}
I need a way to test if a btRigidBody intersects a pair of triangles but the triangles will need to change position(and shape) every physics step. The triangles won't need to interact with the rest of the world other than for this purpose.
Ty for all help in advance =D.
I think it goes without saying that erwin has done a great job with bullet. Ty tons =D.
edit: I realize that you can keep the triangle mesh the same and move the whole btRigidBody each frame. I should specify that i need to change the shape of the triangles each frame.