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;
};
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