InternalTickCallback never gets called

Krones
Posts: 10
Joined: Tue Sep 22, 2009 4:46 pm

InternalTickCallback never gets called

Post by Krones »

Hi!
I've been having trouble with setInternalTickCallback.
If I do something like the following:

Code: Select all

dynamicsWorld_ = new btDiscreteDynamicsWorld(dispatcher_,
            broadphase_, solver_, collisionConfiguration_);
dynamicsWorld_->setInternalTickCallback(&TickCallback);
where

Code: Select all

static void TickCallback(btDynamicsWorld *colWorld1, btScalar tS) {
    printf("It's like a clock inside my head: %i\n", tS);
}
and step the simulation at some other point of the code with

Code: Select all

dynamicsWorld_->stepSimulation(dt, 5, 0.001);
where dt is the time since last call (around 5ms).

I notice the callback doesn't get called at all, though all the rest of the simulation is perfectly normal.
What could I be doing wrong?
Thanks
Krones
Krones
Posts: 10
Joined: Tue Sep 22, 2009 4:46 pm

Re: InternalTickCallback never gets called

Post by Krones »

The following doesn't work for me:

Code: Select all

#include "btBulletCollisionCommon.h"
#include "btBulletDynamicsCommon.h"
#include <iostream>

    btDefaultCollisionConfiguration* collisionConfiguration_;
    btCollisionDispatcher* dispatcher_;
    btAxisSweep3* broadphase_;
    btSequentialImpulseConstraintSolver* solver_;
    btDiscreteDynamicsWorld* dynamicsWorld_;

void foo(btDynamicsWorld *w, btScalar s) {
    std::cout << "foo!" << std::endl; //never gets called
}

void start_p(){
    btVector3 worldAabbMin(-1000, -1000, -1000);
    btVector3 worldAabbMax(1000, 1000, 1000);
    int maxProxies = 1024;

    collisionConfiguration_ = new btDefaultCollisionConfiguration();
    dispatcher_ = new btCollisionDispatcher(collisionConfiguration_);
    broadphase_ = new btAxisSweep3(worldAabbMin,
            worldAabbMax, maxProxies);
    solver_ = new btSequentialImpulseConstraintSolver();
    dynamicsWorld_ = new btDiscreteDynamicsWorld(dispatcher_,
            broadphase_, solver_, collisionConfiguration_);
    dynamicsWorld_->setInternalTickCallback(&foo); //setting the callback
    dynamicsWorld_->stepSimulation(1);
}

int main(){
 start_p();
 dynamicsWorld_->stepSimulation(1, 2, 0.5);
 return 0;
}
It compiles okay, but though I step I step the world I get no output.
Could someone give me some light with that?
Krones
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: InternalTickCallback never gets called

Post by Erwin Coumans »

I just compiled and run your demo, and it calls the callback 3 times, printing 'foo'.

Anyone can reproduce this issue?
Thanks,
Erwin
Krones
Posts: 10
Joined: Tue Sep 22, 2009 4:46 pm

Re: InternalTickCallback never gets called

Post by Krones »

I'm using Bullet 2.75 Physics SDK with Unix line endings, SVN revision 1776, on Debian Linux (etch/sid), over a x86-64 (AMD Phenom X3), compiled with g++ 4.4.2 without any particular compiling options set (cmake ., make, make install).
To compile the demo, I used 'g++ -g -O0 -lbulletdynamics -lbulletmath -lbulletcollision tst.cpp'.
Is there any way I could contribute to help solving this issue, or anything I can do to get this fixed on my side?
Thanks
Krones
Krones
Posts: 10
Joined: Tue Sep 22, 2009 4:46 pm

Re: InternalTickCallback never gets called

Post by Krones »

Downloading and compiling the other version of bullet available (the one without unix endlines) and using the following compiling options seems to solve the problem:
g++ tst.cpp /usr/local/lib/libBulletDynamics.a /usr/local/lib/libBulletCollision.a /usr/local/lib/libLinearMath.a
Thanks
Krones