本文整理汇总了C++中IPhysicsObject::SetGameData方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicsObject::SetGameData方法的具体用法?C++ IPhysicsObject::SetGameData怎么用?C++ IPhysicsObject::SetGameData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicsObject
的用法示例。
在下文中一共展示了IPhysicsObject::SetGameData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TransferPhysicsObject
// UNDONE: Is this worth it?, just recreate the object instead? (that happens when this returns false anyway)
// recreating works, but is more expensive and won't inherit properties (velocity, constraints, etc)
bool TransferPhysicsObject( CBaseEntity *pFrom, CBaseEntity *pTo )
{
IPhysicsObject *pVPhysics = pFrom->VPhysicsGetObject();
if ( !pVPhysics || pVPhysics->IsStatic() )
return false;
// clear out the pointer so it won't get deleted
pFrom->VPhysicsSwapObject( NULL );
// remove any AI behavior bound to it
pVPhysics->RemoveShadowController();
// transfer to the new owner
pTo->VPhysicsSetObject( pVPhysics );
pVPhysics->SetGameData( (void *)pTo );
pTo->VPhysicsUpdate( pVPhysics );
// may have been temporarily disabled by the old object
pVPhysics->EnableMotion( true );
pVPhysics->EnableGravity( true );
// Update for the new entity solid type
pVPhysics->RecheckCollisionFilter();
return true;
}