本文整理汇总了C++中IPhysicsObject::EnableCollisions方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicsObject::EnableCollisions方法的具体用法?C++ IPhysicsObject::EnableCollisions怎么用?C++ IPhysicsObject::EnableCollisions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicsObject
的用法示例。
在下文中一共展示了IPhysicsObject::EnableCollisions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTakeDamage
int CNPC_BaseTurret::OnTakeDamage( const CTakeDamageInfo &info )
{
int retVal = 0;
if (!m_takedamage)
return 0;
switch( m_lifeState )
{
case LIFE_ALIVE:
retVal = OnTakeDamage_Alive( info );
if ( m_iHealth <= 0 )
{
IPhysicsObject *pPhysics = VPhysicsGetObject();
if ( pPhysics )
{
pPhysics->EnableCollisions( false );
}
Event_Killed( info );
Event_Dying();
}
return retVal;
break;
case LIFE_DYING:
return OnTakeDamage_Dying( info );
default:
case LIFE_DEAD:
return OnTakeDamage_Dead( info );
}
}
示例2: InputDisable
void CFuncVehicleClip::InputDisable( inputdata_t &data )
{
IPhysicsObject *pPhys = VPhysicsGetObject();
if ( pPhys )
{
pPhys->EnableCollisions( false );
}
AddSolidFlags( FSOLID_NOT_SOLID );
}
示例3: InputEnable
void CFuncVehicleClip::InputEnable( inputdata_t &data )
{
IPhysicsObject *pPhys = VPhysicsGetObject();
if ( pPhys )
{
pPhys->EnableCollisions( true );
}
RemoveSolidFlags( FSOLID_NOT_SOLID );
}
示例4: TurnOn
void CFuncWallToggle::TurnOn( void )
{
IPhysicsObject *pPhys = VPhysicsGetObject();
if ( pPhys )
{
pPhys->EnableCollisions( true );
}
RemoveSolidFlags( FSOLID_NOT_SOLID );
RemoveEffects( EF_NODRAW );
}
示例5: TurnOff
void CFuncWallToggle::TurnOff( void )
{
IPhysicsObject *pPhys = VPhysicsGetObject();
if ( pPhys )
{
pPhys->EnableCollisions( false );
}
AddSolidFlags( FSOLID_NOT_SOLID );
AddEffects( EF_NODRAW );
}
示例6: CreateVPhysics
bool CFuncBrush::CreateVPhysics( void )
{
IPhysicsObject *pPhys = VPhysicsInitShadow( false, false );
if ( pPhys )
{
int contents = modelinfo->GetModelContents( GetModelIndex() );
if ( ! (contents & (MASK_SOLID|MASK_PLAYERSOLID|MASK_NPCSOLID)) )
{
// leave the physics shadow there in case it has crap constrained to it
// but disable collisions with it
pPhys->EnableCollisions( false );
}
}
return true;
}
示例7: RagdollDestroy
CRagdoll::~CRagdoll( void )
{
for ( int i = 0; i < m_ragdoll.listCount; i++ )
{
IPhysicsObject *pObject = m_ragdoll.list[i].pObject;
if ( pObject )
{
g_pPhysSaveRestoreManager->ForgetModel( m_ragdoll.list[i].pObject );
// Disable collision on all ragdoll parts before calling RagdollDestroy
// (which might cause touch callbacks on the ragdoll otherwise, which is
// very bad for a half deleted ragdoll).
pObject->EnableCollisions( false );
}
}
RagdollDestroy( m_ragdoll );
}
示例8: StartDismount
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAI_PassengerBehaviorZombie::StartDismount( void )
{
// Leap off the vehicle
int nSequence = FindExitSequence();
Assert( nSequence != -1 );
SetTransitionSequence( nSequence );
GetOuter()->SetIdealActivity( ACT_SCRIPT_CUSTOM_MOVE );
// This removes the NPC from the vehicle's handling and fires all necessary outputs
m_hVehicle->RemovePhysicsChild( GetOuter() );
m_hVehicle->NPC_RemovePassenger( GetOuter() );
m_hVehicle->NPC_FinishedExitVehicle( GetOuter(), (IsPassengerHostile()==false) );
// Detach from the parent
GetOuter()->SetParent( NULL );
GetOuter()->SetMoveType( MOVETYPE_STEP );
GetMotor()->SetYawLocked( false );
QAngle vecAngles = GetAbsAngles();
vecAngles.z = 0.0f;
GetOuter()->SetAbsAngles( vecAngles );
// HACK: Will this work?
IPhysicsObject *pPhysObj = GetOuter()->VPhysicsGetObject();
if ( pPhysObj != NULL )
{
pPhysObj->EnableCollisions( true );
}
// Clear this
m_PassengerIntent = PASSENGER_INTENT_NONE;
SetPassengerState( PASSENGER_STATE_EXITING );
// Get the velocity
Vector vecUp, vecJumpDir;
GetOuter()->GetVectors( &vecJumpDir, NULL, &vecUp );
// Move back and up
vecJumpDir *= random->RandomFloat( -400.0f, -500.0f );
vecJumpDir += vecUp * 150.0f;
GetOuter()->SetAbsVelocity( vecJumpDir );
}
示例9: OnTouch
//.........这里部分代码省略.........
if ( pBAnim )
pBAnim->Ignite( 10.0f, false );
}
#endif
}
else
CalculateBulletDamageForce( &dmgInfo, m_iAmmoType, vecDir, touchtr.endpos, 1.0f );
dmgInfo.SetDamagePosition( touchtr.endpos );
ent->DispatchTraceAttack( dmgInfo, vecDir, &touchtr );
ApplyMultiDamage();
}
#ifdef CLIENT_DLL
if ( ent->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS )
return false;
//Decals and such
if ( !( touchtr.surface.flags & SURF_SKY ) && !touchtr.allsolid )
{
IPredictionSystem::SuppressEvents( false );
if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) )
{
UTIL_ImpactTrace( &touchtr, DMG_BULLET );
}
if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )
PlayImpactSound( touchtr.m_pEnt, touchtr, touchtr.endpos, touchtr.surface.surfaceProps );
IPredictionSystem::SuppressEvents( !prediction->IsFirstTimePredicted() );
}
#endif
}
if ( pTraceFilter && m_iType != DHL_PROJECTILE_TYPE_COMBATKNIFE )
{
PenetrationData_t nPenetrationData = DHLShared::TestPenetration( touchtr, m_pShooter, pTraceFilter,
m_iTimesPenetrated, m_flDistanceTravelled, m_iAmmoType );
if ( nPenetrationData.m_bShouldPenetrate )
{
m_flDistanceTravelled += GetLocalOrigin().DistTo( nPenetrationData.m_vecNewBulletPos );
MoveProjectileToPosition( nPenetrationData.m_vecNewBulletPos );
m_iTimesPenetrated++;
return true; //Keep going - but don't do anything else in this frame of PhysicsSimulate()
}
}
//We're done unless what we hit was breakable glass
if ( ent->GetCollisionGroup() != COLLISION_GROUP_BREAKABLE_GLASS )
{
#ifdef CLIENT_DLL
m_bCollided = true;
AddEffects( EF_NODRAW );
if ( m_pTrail ) //NULL pointer here sometimes somehow...
m_pTrail->AddEffects( EF_NODRAW );
#else
EntityMessageBegin( this );
WRITE_BYTE( MSG_NOTIFY_REMOVAL );
MessageEnd();
if ( touchtr.DidHitWorld() && m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE && !( touchtr.surface.flags & SURF_SKY ) )
{
CBaseCombatWeapon* pKnifeEnt = assert_cast<CBaseCombatWeapon*>(CreateEntityByName( "weapon_combatknife" ));
if ( pKnifeEnt )
{
pKnifeEnt->AddSpawnFlags( SF_NORESPAWN ); //Needed for weapon spawn & VPhysics setup to work correctly
pKnifeEnt->SetAbsOrigin( touchtr.endpos );
QAngle angles = vec3_angle;
Vector vecKnifeDir = touchtr.startpos - touchtr.endpos;
VectorAngles( vecKnifeDir, angles );
angles[PITCH] -= 15.0f; //Correct for the .mdl being offset a bit
pKnifeEnt->SetLocalAngles( angles );
DispatchSpawn( pKnifeEnt );
//Spawns vphys object and sets it up, essentially a copy of CWeaponHL2MPBase::FallInit()
pKnifeEnt->VPhysicsDestroyObject();
//Using SOLID_VPHYSICS instead of SOLID_BBOX (as ordinary weapons do) helps resolve some of the client side collision oddities
Assert( pKnifeEnt->VPhysicsInitNormal( SOLID_VPHYSICS, FSOLID_NOT_STANDABLE | FSOLID_TRIGGER, true ) );
pKnifeEnt->SetPickupTouch(); //Sets up automagic removal after time
IPhysicsObject* pKnifePhys = pKnifeEnt->VPhysicsGetObject();
if ( pKnifePhys )
{
//Knives are solid to bullets...the only way to make them non-solid to bullets is to do SetSolid( SOLID_NONE ) or AddSolidFlags( FSOLID_NOT_SOLID )
//which breaks the +use pickup even with FSOLID_TRIGGER set. Let's just call it a feature :)
pKnifePhys->EnableMotion( false );
pKnifePhys->EnableCollisions( false );
}
if ( IsOnFire() )
pKnifeEnt->Ignite( 10.0f, false );
}
}
//SetThink( &CDHLProjectile::SUB_Remove );
//SetNextThink( gpGlobals->curtime + 0.1 );
//SUB_Remove();
//SetMoveType( MOVETYPE_NONE );
m_flRemoveAt = gpGlobals->curtime + 0.1f; //Give the notification message a head start so that the client will have time to react
#endif
}
}
return true;
}