Simple Collisions

drivehappy
Posts: 1
Joined: Sat Nov 29, 2008 3:02 am

Simple Collisions

Post by drivehappy »

My question is similiar to the first one posted here. I'm certain this is something easy and I'm just missing it.

I currently have set up a simple btCollisionWorld:

Code: Select all

    collisionConfiguration = new btDefaultCollisionConfiguration();
    dispatcher = new btCollisionDispatcher(collisionConfiguration);
    dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE, GIMPACT_SHAPE_PROXYTYPE, new btBoxBoxCollisionAlgorithm::CreateFunc);
    broadphase = new btDbvtBroadphase();
    collisionWorld = new btCollisionWorld(dispatcher, broadphase, collisionConfiguration);
A function to create new collision objects, pCollisionShape is created beforehand as BOX:

Code: Select all

    uBasis.setIdentity();
    pCollisionObject->getWorldTransform().setBasis(uBasis);
    pCollisionObject->getWorldTransform().setIdentity();
    pCollisionObject->getWorldTransform().setOrigin(btVector3(0, 0, 0));
    pCollisionObject->setCollisionShape(pCollisionShape);
    collisionWorld->addCollisionObject(pCollisionObject);
And my update function, where CollisionEvent is my own wrapper for handling the contact points to my code higher up:

Code: Select all

    if (collisionWorld) {
        collisionWorld->performDiscreteCollisionDetection();

        int numManifolds = collisionWorld->getDispatcher()->getNumManifolds();
        //s_printf("%i collisions\n", numManifolds);
    
        for (int i=0; i<numManifolds; i++) {
            btPersistentManifold *contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
            CollisionEvent *pNewCollision = new CollisionEvent(contactManifold);

            m_uCollisionEventList.push_back(pNewCollision);
        }
    }
My problem lies around the use of the BroadPhase/AABB I believe, at least from what I've gathered from reading the manual and above post. I have several boundary planes that enclose an area, some are rotated via:

Code: Select all

void PhysicsManager::setCollisionShapeRotation(unsigned int _nId, gmtl::Vec3f _nAxis, float _nAngle)
{
    btCollisionObject *pObject = getCollisionObject(_nId);

    btVector3 nAxis = btVector3(_nAxis[gmtl::Xelt], _nAxis[gmtl::Yelt], _nAxis[gmtl::Zelt]);
    newRotation.setRotation(nAxis, (btScalar)_nAngle);
    pObject->getWorldTransform().setRotation(newRotation);
}
I cannot explicitly see the collisionBox, I don't have the DebugDrawer setup as I didn't want to open another can of worms as I use Ogre, yet my player object enters what seems to be the AABB of a rotated boundary plane and collision is detected. Correct me if I'm wrong, but I assume that the broadphase correctly checks the AABB of both my player's BOX and the boundary plane's BOX, yet I thought btBoxBoxCollisionAlgorithm::CreateFunc should continue further and check the transforms of the btCollisionObject.