Callbacks/Listeners?

Callbacks/Listeners?

Hi,
Just wondering if there a callback system avaliable for users to hook into? What Ibasically want is a callback that happens when ahkRigidbody moves/rotates/leaves the world so that i can modify the visualobject attached to the hkRigidbody appropriatly. If there is no callbacks, is there a Listener system? Right now I am having to iterate through all the rigid bodies in the hkWorld per frame and modifying the corrosponding visual objects for them.

Thanks

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

nothing....? Is my question not clear?Thanks

Iterating is the way to go. Callbacks would make sense if 2 objects are moving while 1.000 are 90% of the time still. But turns out in a physics engine everything ends up moving sooner or later.

Besides, iterating is probably more data- and code-cache friendlier than a callback would ever be.

Because you're the one in control of which objects are being created, it is often much better to put in your own list which objects you wish to iterate right after you've created them, instead of using hkWorld to get all bodies in the scene, that way you can skip updating those rigid bodies that were tagged as motion fixed; for free.

About the "998 objects may become still for a long time" problem, if you really will have that problem very often (because of the way your specific game works) Havok has the notion of "islands" and "activation". Everything that is tied together is called an "island". When the whole island becomes quiet, it gets "deactivated", until an external object (or you set a linear impulse or something in a deactivated object inside that island) wakes up/activates the whole island. While rigid bodies are deactivated, you will know for sure that you don't need to iterate through them to update their rendering position. You can use hkpEntity::addEntityActivationListener for that.

Take in mind though, the overhead of modifying your lists of rigid bodies to iterate when an object gets disabled may negate the performance boost of having fewer objects to iterate if this deactivation happens for only a few objects, or those objects get reactivated quickly afterwards, and very often.

For more information about the simulation islands and deactivation, I strongly suggest you take a good in depth read to the manual.

Cheers

Dark Sylinc

Matias N. Goldberg
Intel Havok Physics Innovation Contest Winner
* Most Innovative Use of Physics in a Game (2nd Place)
* Best Physics Knowledge Base Entry (2nd Place)

That was very helpful.
thanks

Leave a Comment

Please sign in to add a comment. Not a member? Join today