Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

On my Phenom II desktop machine (about 3 years old) with 8GB of RAM, it seems that I can only throw around a hundred or two boxes before it starts to go slow. I'm using the built-in DbvtBroadphase.

Is this about right, or am I missing something?

One thing that can't possibly be right though is that it takes several minutes to delete all the bodies (the RigidBodies, to be exact), spending nearly all of its time in HeapFree.

By the way I'm using BulletSharp, but I'm only making one call to the native API each frame -- which suggests that it's not the fault of the wrapper that it's so slow, unless there's something really weird going on with it.

Edit: It seems that there's a threshold point after which the program's memory consumption just starts skyrocketing. Something's leaking. Still, I'd be interested to know what to expect in a normal situation.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Look at the benchmark demo in the bullet installation folder: bullet/Demos/Benchmarks. I just checked benchmark 4, it creates 960 bodies and collides them, you can adjust the numbers in the demo of course. All timings and statistics are rendered on the screen in the demo, answering all your questions.

Just run a quick test using that demo on my machine: 400 bodies colliding with less than 6ms per simulation call, change this function in BenchmarkDemo.cpp to get 400 bodies:

void    BenchmarkDemo::createTest4()
{
    setCameraDistance(btScalar(50.));

    int size = 8;
    const float cubeSize = 1.5f;
    float spacing = cubeSize;
    btVector3 pos(0.0f, cubeSize * 2, 0.0f);
    float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f;

    btConvexHullShape* convexHullShape = new btConvexHullShape();

    btScalar scaling(1);

    convexHullShape->setLocalScaling(btVector3(scaling,scaling,scaling));

    for (int i=0;i<TaruVtxCount;i++)
    {
        btVector3 vtx(TaruVtx[i*3],TaruVtx[i*3+1],TaruVtx[i*3+2]);
        convexHullShape->addPoint(vtx*btScalar(1./scaling));
    }

    //this will enable polyhedral contact clipping, better quality, slightly slower
    //convexHullShape->initializePolyhedralFeatures();

    btTransform trans;
    trans.setIdentity();

    float mass = 1.f;
    btVector3 localInertia(0,0,0);
    convexHullShape->calculateLocalInertia(mass,localInertia);
    int counter = 0;
    for(int k=0;k<25;k++) {
        for(int j=0;j<2;j++) {
            pos[2] = offset + (float)j * (cubeSize * 2.0f + spacing);
            for(int i=0;i<size;i++) {
                pos[0] = offset + (float)i * (cubeSize * 2.0f + spacing);
                trans.setOrigin(pos);
                localCreateRigidBody(mass,trans,convexHullShape);   
                ++counter;
            }
        }
        offset -= 0.05f * spacing * (size-1);
        spacing *= 1.01f;
        pos[1] += (cubeSize * 2.0f + spacing);
    }
}
share|improve this answer
    
Thanks, not sure why I never thought to check the demos. –  Rei Miyasaka Jul 16 '12 at 22:51
    
I would love to hear the results of the benchmark –  ManicQin Jul 17 '12 at 7:50
    
@ManicQin I said it in my answer: 400 bodies -> less than 6 ms per simulation step on a 2 year old PC, don't have the CPU details available right now –  Maik Semder Jul 17 '12 at 17:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.