注意上面的例子,我们进行 物理和图形在平行的。这个是被推荐的方法,因为它使事情简单,和是最predictiable在CPU负载,特别是在多线程模拟,是最有效的方法模拟。
然而,能有原因(如非常变化的帧率,低的帧率或者运行物理在一个十分低的频率)减弱物理和帧率和运行物理异步的。为了做这个,一些函数在hkpWorld被提供。有hkpWorld::setFrameTimeMarker(), hkpWorld::isSimulationAtMarker()和hkpWorld::isSimulationAtPsi()。请注意用异步前进在你的游戏引擎是有挑战的,和只背推荐位高级用户。
这个代码你能设置世界异步的:
world->setFrameTimeMarker( frameDeltaTime ); world->advanceTime(); while ( !world->isSimulationAtMarker() ) { HK_ASSERT( 0x11179564, world->isSimulationAtPsi() ); { // Interact from game to physics } world->stepDeltaTime( physicsDeltaTime ); if (world->isSimulationAtPsi() ) { // Interact with physics: physics data to game data } }