//----------------------------------------------------------------------------- // Purpose: Returns the magnitude of the entity's angular velocity. //----------------------------------------------------------------------------- void CPointVelocitySensor::SampleVelocity( void ) { if ( m_hTargetEntity == NULL ) return; Vector vecVelocity; if ( m_hTargetEntity->GetMoveType() == MOVETYPE_VPHYSICS ) { IPhysicsObject *pPhys = m_hTargetEntity->VPhysicsGetObject(); if ( pPhys != NULL ) { pPhys->GetVelocity( &vecVelocity, NULL ); } } else { vecVelocity = m_hTargetEntity->GetAbsVelocity(); } /* float flSpeed = VectorNormalize( vecVelocity ); float flDot = ( m_vecAxis != vec3_origin ) ? DotProduct( vecVelocity, m_vecAxis ) : 1.0f; */ // We want the component of the velocity vector in the direction of the axis, which since the // axis is normalized is simply their dot product (eg V . A = |V|*|A|*cos(theta) ) m_fPrevVelocity = ( m_vecAxis != vec3_origin ) ? DotProduct( vecVelocity, m_vecAxis ) : 1.0f; // if it's changed since the last frame, poke the output if ( m_fPrevVelocity != m_Velocity.Get() ) { m_Velocity.Set( m_fPrevVelocity, NULL, NULL ); } }