void CGravControllerPoint::DetachEntity( void ) { CBaseEntity *pEntity = m_attachedEntity; if ( pEntity ) { IPhysicsObject *pPhys = GetPhysObjFromPhysicsBone( pEntity, m_attachedPhysicsBone ); if ( pPhys ) { // on the odd chance that it's gone to sleep while under anti-gravity pPhys->Wake(); pPhys->SetDamping( NULL, &m_saveDamping ); pPhys->SetMass( m_saveMass ); } } m_attachedEntity = NULL; m_attachedPhysicsBone = 0; if ( physenv ) { physenv->DestroyMotionController( m_controller ); } m_controller = NULL; // UNDONE: Does this help the networking? m_targetPosition = vec3_origin; m_worldPosition = vec3_origin; }
void CGrabController::DetachEntity( void ) { CBaseEntity *pEntity = GetAttached(); if ( pEntity ) { IPhysicsObject *pPhys = pEntity->VPhysicsGetObject(); if ( pPhys ) { // on the odd chance that it's gone to sleep while under anti-gravity pPhys->Wake(); pPhys->SetDamping( NULL, &m_saveRotDamping ); PhysClearGameFlags( pPhys, FVPHYSICS_PLAYER_HELD ); } } m_attachedEntity = NULL; physenv->DestroyMotionController( m_controller ); m_controller = NULL; }
void CGrabController::DetachEntity( bool bClearVelocity ) { Assert(!PhysIsInCallback()); CBaseEntity *pEntity = GetAttached(); if ( pEntity ) { // Restore the LS blocking state pEntity->SetBlocksLOS( m_bCarriedEntityBlocksLOS ); IPhysicsObject *pList[VPHYSICS_MAX_OBJECT_LIST_COUNT]; int count = pEntity->VPhysicsGetObjectList( pList, ARRAYSIZE(pList) ); for ( int i = 0; i < count; i++ ) { IPhysicsObject *pPhys = pList[i]; if ( !pPhys ) continue; // on the odd chance that it's gone to sleep while under anti-gravity pPhys->EnableDrag( true ); pPhys->Wake(); pPhys->SetMass( m_savedMass[i] ); pPhys->SetDamping( NULL, &m_savedRotDamping[i] ); PhysClearGameFlags( pPhys, FVPHYSICS_PLAYER_HELD ); if ( bClearVelocity ) { PhysForceClearVelocity( pPhys ); } else { ClampPhysicsVelocity( pPhys, player_walkspeed.GetFloat() * 1.5f, 2.0f * 360.0f ); } } } m_attachedEntity = NULL; physenv->DestroyMotionController( m_controller ); m_controller = NULL; }