vphysics_bullet/Physics_PlayerController.cpp
void CPlayerController::MaxSpeed(const Vector &hlMaxVelocity) {
	btVector3 maxVel;
	ConvertPosToBull(hlMaxVelocity, maxVel);
	btVector3 available = maxVel;
	
	float maxVelLen = maxVel.length();
	maxVel.normalize();
	
	// Only if we're headed in the same direction as maxVelocity
	float dot = maxVel.dot(m_pObject->GetObject()->getLinearVelocity()); // Magnitude of our speed in the same direction as maxVel
	if (dot > 0) {
		maxVel *= dot * maxVelLen; // maxVel(normalized) *= dot(maxVel(norm), linVel) * len(maxVel)
		available -= maxVel; // Now subtract the magnitude of our current speed along the maxVelocity vector
	}
	
	m_maxSpeed = available.absolute();
}
// Purpose: Calculate the maximum speed we can accelerate.
Calculate the maximum speed we can accelerate.
Calculate the maximum speed we can accelerate .
void CPlayerController::MaxSpeed(const Vector &hlMaxVelocity) {
	btVector3 maxVel;
	ConvertPosToBull(hlMaxVelocity, maxVel);
	btVector3 available = maxVel;
	float maxVelLen = maxVel.length();
	maxVel.normalize();
	float dot = maxVel.dot(m_pObject->GetObject()->getLinearVelocity()); 
	if (dot > 0) {
		maxVel *= dot * maxVelLen; 
		available -= maxVel; 
	}
	m_maxSpeed = available.absolute();
}
void CPlayerController :: MaxSpeed ( const Vector & hlMaxVelocity ) { btVector3 maxVel ; ConvertPosToBull ( hlMaxVelocity , maxVel ) ; btVector3 available = maxVel ; float maxVelLen = maxVel . length ( ) ; maxVel . normalize ( ) ; float dot = maxVel . dot ( m_pObject -> GetObject ( ) -> getLinearVelocity ( ) ) ; if ( dot > 0 ) { maxVel *= dot * maxVelLen ; available -= maxVel ; } m_maxSpeed = available . absolute ( ) ; }
Purpose: Calculate the maximum speed we can accelerate.
Purpose : Calculate the maximum speed we can accelerate .
// Only if we're headed in the same direction as maxVelocity // Magnitude of our speed in the same direction as maxVel // maxVel(normalized) *= dot(maxVel(norm), linVel) * len(maxVel) // Now subtract the magnitude of our current speed along the maxVelocity vector