Beispiel #1
0
void CRagdoll::VPhysicsUpdate( IPhysicsObject *pPhysics )
{
    if ( m_lastUpdate == gpGlobals->curtime )
        return;
    m_lastUpdate = gpGlobals->curtime;
    m_allAsleep = RagdollIsAsleep( m_ragdoll );
    if ( m_allAsleep )
    {
        // NOTE: This is the bbox of the ragdoll's physics
        // It's not always correct to use for culling, but it sure beats
        // using the radius box!
        Vector origin = GetRagdollOrigin();
        RagdollComputeExactBbox( m_ragdoll, origin, m_mins, m_maxs );
        m_mins -= origin;
        m_maxs -= origin;
    }
    else
    {
        m_mins.Init(-m_radius,-m_radius,-m_radius);
        m_maxs.Init(m_radius,m_radius,m_radius);

        if ( m_ragdoll.pGroup->IsInErrorState() )
        {
            C_BaseEntity *pEntity = static_cast<C_BaseEntity *>(m_ragdoll.list[0].pObject->GetGameData());
            RagdollSolveSeparation( m_ragdoll, pEntity );
        }
    }

    // See if we should go to sleep...
    CheckSettleStationaryRagdoll();
}
void CRagdollProp::SetObjectCollisionBox( void )
{
	if ( m_allAsleep )
	{
		Vector fullMins, fullMaxs;
		RagdollComputeExactBbox( m_ragdoll, GetAbsOrigin(), fullMins, fullMaxs );
		SetCollisionBounds( fullMins - GetAbsOrigin(), fullMaxs - GetAbsOrigin() );
		SetAbsMins( fullMins );
		SetAbsMaxs( fullMaxs );
	}
	else
	{
		SetCollisionBounds( m_savedESMins, m_savedESMaxs );
		ComputeSurroundingBox();
	}
}