[solved] cant figure out why *no* collisions are detected

User avatar
squisher
Posts: 11
Joined: Wed Jul 30, 2008 6:08 pm

[solved] cant figure out why *no* collisions are detected

Post by squisher »

I'm at my wits end with this problem. Maybe a lost cause, but I'm throwing myself at the mercy of the forums, maybe someone can help?

I'm sending rigid bodies with sphere shapes through each other at a slow constant speed, and no collision is being detected in my simulation at all. It's really complicated code to debug, but the main issue seems to be that m_overlappingPairArray is always empty in btHashedOverlappingPairCache::processAllOverlappingPairs(..)

It's probably a symptom not a cause, but I just cant get any better debug info than that. This runs on a graphics-less server so I can't use any debug drawing.

This is how I create the world..

Code: Select all


static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,
    int partId0, int index0, const btCollisionObject* colObj1, int partId1, int index1)
{
    cout << "Clunk....!\n";
    return false;
}

namespace World
{
btDiscreteDynamicsWorld* world = 0;
btDefaultCollisionConfiguration* collisionConf = 0;
btAxisSweep3* sweep = 0;
btCollisionDispatcher* dispatcher = 0;
btSequentialImpulseConstraintSolver* solver = 0;

void create()
{
    gContactAddedCallback = collisionCallback;
    collisionConf = new btDefaultCollisionConfiguration;
    sweep = new btAxisSweep3(btVector3(-1000, -1000, -1000), btVector3(4000, 4000, 4000));
    dispatcher = new btCollisionDispatcher(collisionConf);
    solver = new btSequentialImpulseConstraintSolver;
    world = new btDiscreteDynamicsWorld(dispatcher, sweep, solver, collisionConf);
    assert(world);
    world->setGravity(btVector3(0,0,0));
    world->setInternalTickCallback(tick, 0);
}
}

// ...
void createMissile(btVector3 pos, btVector3 rot)
{
    btCollisionShape* shape = new btSphereShape(400);

    btTransform transform;
    transform.setIdentity();
    transform.setOrigin(pos);

    // rotation
    transform.setRotation(rot);

    // create the rigid body
    btVector3 localInertia(0,0,0);
    shape->calculateLocalInertia(8, localInertia);

    btDefaultMotionState* motionState = new btDefaultMotionState(transform);
    btRigidBody::btRigidBodyConstructionInfo rigidBodyConstructionInfo(mass, motionState, shape, localInertia);
    if (damping) {
        rigidBodyConstructionInfo.m_linearDamping = damping;
        rigidBodyConstructionInfo.m_angularDamping = damping;
    }
    btRigidBody* rigidBody = new btRigidBody(rigidBodyConstructionInfo);
    world->addRigidBody(rigidBody, 0, -1);

    rigidBody->setLinearVelocity(linearVelocity);
    rigidBody->setCollisionFlags(rigidBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
}

// ...

for (;;) { 
  world->stepSimulation(deltaTimeNS, 20, 1.f/60.f);
}
I know the code snippet doesn't compile but it should be most everything physics related I have. I am able to verify the speeds and positions are such that the objects are definitely crossing paths. I'm hoping at the very least someone can provide some good tips on how to debug the problem and see what's going wrong. Just stepping through the code is proving to be fruitless.. I don't know what to look for. Thanks in advance!

EDIT:
changed to

Code: Select all

world->addRigidBody(rigidBody, 1, -1);
to fix the problem! For some reason I had explicitly put the "default" arguments in, but assumed the default for the collision group was 0, but it should be 1!!
User avatar
Pyritie
Posts: 25
Joined: Thu Aug 11, 2011 6:42 pm

Re: [solved] cant figure out why *no* collisions are detecte

Post by Pyritie »

squisher wrote: EDIT:
changed to

Code: Select all

world->addRigidBody(rigidBody, 1, -1);
to fix the problem! For some reason I had explicitly put the "default" arguments in, but assumed the default for the collision group was 0, but it should be 1!!
heh yeah that'd be why. 0 is no collision, 1 is default, etc. Look in btCollisionFilterGroups (I think that's what it's called) to see what the others are