Callbacks every internal tick?

chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Callbacks every internal tick?

Post by chunky »

I'm experimenting with a few things, and something that would be really useful to me would be the ability to call a callback every time the simulation steps internally.

Looking through, the source, I found this line:
///CallbackTriggers();
At what seemed an appropriate place to do a callback in both btDiscreteDynamicsWorld::internalSingleStepSimulation and btContinuousDynamicsWorld::internalSingleStepSimulation, but I saw no indication of an actual implementation. Is this something that I could usefully implement myself, or is there an implementation of getting callbacks each tick somewhere that I'm missing?

Thank-you very much,
Gary (-;
User avatar
detox
Posts: 12
Joined: Wed Nov 22, 2006 6:52 pm
Location: Ohio, USA

Re: Callbacks every internal tick?

Post by detox »

Hi,

I have been thinking about something similar too. Currently I use timers in my main loop to fix my render framerate at 50Hz. I update all my per-frame material and gfx effects, update the bullet world, and then render a frame. Character control and input capturing is on another timer, a little slower, about 30Hz. NPC AI decision making is on a much slower timer. As you can see I have a lot of timers floating around.

It would be nice if I could use Bullet's internal timer, which is locked in at 60Hz I believe, to signal my main loop that it's time to do the bullet world update and all the per-frame stuff. I haven't looked around as much as you. Let me know if you find anything already in there. If not we shouldn't have too much trouble patching something in.

It just seems a little silly to me for me to have a separate timer in my mainloop to update the bullet world when there is already one running in the bullet guts.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Callbacks every internal tick?

Post by Erwin Coumans »

Good idea, let's see if we can add some callback for upcoming 2.68.

See http://code.google.com/p/bullet/issues/detail?id=46 for progress on this.
Thanks,
Erwin
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: Callbacks every internal tick?

Post by chunky »

It's a bit mickey mouse, but this works great for me:
http://chunkyks.com/bulletinternaltickc ... 7.patch.gz
or there's a nongzipped version here [but the usual disclaimer about newlines and text files applies:
http://chunkyks.com/bulletinternaltickc ... 4-07.patch


Sorry, I did this a day or two after I started this thread, and totally forgot to paste it here

Gary (-;
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Callbacks every internal tick?

Post by Erwin Coumans »

It has been included in Bullet 2.68 beta 2, can you please test it?

Thanks for the contribution,
Erwin
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: Callbacks every internal tick?

Post by chunky »

Works For Me(TM)

Thank-you very much,
Gary (-;