InternalTickCallback

cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

InternalTickCallback

Post by cobolt_dink »

I guess I must not know how to program C++ because trying to do anything with the world parameter in the callback gives me a compile error.

Want to get the collision force but its zero in the collision callbacks, tried going through the collision manifold right after stepSimulation() like the Phya code does and its zero, last option is to go through the manifold in the tick callback to see if I can get the collision force.

This is in the header:

Code: Select all

static void InternalTickCallback(const btDynamicsWorld *world, btScalar timeStep);
And this is the function:

Code: Select all

void CPhysics::InternalTickCallback(const btDynamicsWorld *world, btScalar timeStep)
{
	const int numManifolds = world->getDispatcher()->getNumManifolds();
Which gives me this error: error C2662: 'btCollisionWorld::getDispatcher' : cannot convert 'this' pointer from 'const btDynamicsWorld' to 'btCollisionWorld &'. Changing to static or removing the modified doesn't help. The collision callbacks I don't have any problem getting data from the const members, what am I doing wrong with this?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: InternalTickCallback

Post by Erwin Coumans »

The const method for getDispatcher has recently been added, can you try out the latest Bullet 2.70 alpha?

We probably remove the 'const' from btDynamicsWorld, there is no reason for 'const' during the internal tick callback.

Hope this helps,
Erwin
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: InternalTickCallback

Post by cobolt_dink »

Now it fails here: btPersistentManifold* contactManifold = world->getDispatcher()->getManifoldByIndexInternal(i);

Assuming the getManifold function isn't const?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: InternalTickCallback

Post by Erwin Coumans »

It should work if you make it a const btPersistentManifold, like this:

Code: Select all

const btPersistentManifold* contactManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
Either this, or wait for the next Bullet version that uses a non-const btDynamicsWorld as argument for the tick callback.
Hope this helps,
Erwin
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: InternalTickCallback

Post by chunky »

And this is the function:

Code: Select all

void CPhysics::InternalTickCallback(const btDynamicsWorld *world, btScalar timeStep)
{
	const int numManifolds = world->getDispatcher()->getNumManifolds();
You're trying to pass a C++ method as a bare C function. You need to declare CPhysics::InternalTickCallback static, or just have it as a function on its own.

Your next question is answered here: http://www.bulletphysics.com/Bullet/php ... f=9&t=2321

Gary (-;
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: InternalTickCallback

Post by cobolt_dink »

What I did was went into the header changed the btDynamicsWorld to not be const anymore and it works. Though I only seem to be able to get the impulse inside of the tick callback. Its not really a big deal, but shouldn't that impulse be available in the contact callbacks too?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: InternalTickCallback

Post by Erwin Coumans »

cobolt_dink wrote:What I did was went into the header changed the btDynamicsWorld to not be const anymore and it works.
So it all works fine now, you get a valid non-zero 'appliedImpulse'?
Though I only seem to be able to get the impulse inside of the tick callback. Its not really a big deal, but shouldn't that impulse be available in the contact callbacks too
The contact callbacks happen before the constraint solver stage (which is where the impulse is applied).
Thanks,
Erwin
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: InternalTickCallback

Post by cobolt_dink »

chunky wrote:
And this is the function:

Code: Select all

void CPhysics::InternalTickCallback(const btDynamicsWorld *world, btScalar timeStep)
{
	const int numManifolds = world->getDispatcher()->getNumManifolds();
You're trying to pass a C++ method as a bare C function. You need to declare CPhysics::InternalTickCallback static, or just have it as a function on its own.

Your next question is answered here: http://www.bulletphysics.com/Bullet/php ... f=9&t=2321

Gary (-;
It is static, I posted the declaration of the function in my original post. I think my problem was trying to assign const declared data into non const variables.
cobolt_dink
Posts: 72
Joined: Fri Apr 04, 2008 6:07 pm

Re: InternalTickCallback

Post by cobolt_dink »

Erwin Coumans wrote:
cobolt_dink wrote:What I did was went into the header changed the btDynamicsWorld to not be const anymore and it works.
So it all works fine now, you get a valid non-zero 'appliedImpulse'?
Seems to be, the impulse returned looks like its linear velocity times mass. Though if I give the object a big mass like 1000 then the value returned is lower (though still a postive value). But physics engines generally don't like large differences in mass do they?