(Irrlicht+Irrbullet) Collision Detection

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jorgerosa
Competition winner
Posts: 117
Joined: Wed Jun 30, 2010 8:44 am
Location: Portugal
Contact:

(Irrlicht+Irrbullet) Collision Detection

Post by jorgerosa »

Im using Bullet v.3 + irrBullet v.0.1.8 + irrlicht v.1.8.1

Code: Select all

// Adding BOX N.1:
ISceneNode* nodeBox1 = smgr->addMeshSceneNode(smgr->getMesh("box1.obj"));
ICollisionShape* shape1 = new IBoxShape(nodeBox1, 80, false);
IRigidBody* body1 = physicsworld->addRigidBody(shape1);
body1->setName("box1");
body1->getAttributes()->addBool("box1", true);
body1->setCcdValues(0.001f, 0.001f);
body1->setActivationState(EAS_DISABLE_DEACTIVATION);
 
 
// Adding BOX N.2:
ISceneNode* nodeBox2 = smgr->addMeshSceneNode(smgr->getMesh("box2.obj"));
ICollisionShape* shape2 = new IBoxShape(nodeBox2, 80, false);
IRigidBody* body2 = physicsworld->addRigidBody(shape2);
body2->setName("box2");
body2->getAttributes()->addBool("box2", true);
body2->setCcdValues(0.001f, 0.001f);
body2->setActivationState(EAS_DISABLE_DEACTIVATION);
 
 
 
// In main loop, the collision check:
physicsworld->stepSimulation(frameDeltaTime*0.0100f, 120);
 
for(int i=0; i<physicsworld->getNumManifolds(); i++){
   ICollisionCallbackInformation* info = physicsworld->getCollisionCallback(i);
   IAttributes* body0 = info->getBody0()->getAttributes();
   IAttributes* body1 = info->getBody1()->getAttributes();
 
   if(body0->existsAttribute("box1") && body1->existsAttribute("box2")){ cout << "These 2 boxes collided!" << endl; };
   if(body0->existsAttribute("box2") && body1->existsAttribute("box1")){ cout << "These 2 boxes collided!" << endl; };
 
   info->getPointer()->clearManifold();
   delete info;
};
PROBLEM: I´m using the above code, and sometimes it detects the collision between that 2 boxes... BUT... sometimes not!...
Of course I need that collision detection to be constant... Am I missing something here?...
Note: I have no tunneling effects here, even when boxes are falling at high speeds, collisions are always perfect, only the above functions fails sometimes
Post Reply