UpdateVelocityAxis static function

This commit is contained in:
docentYT
2026-02-03 00:14:12 +01:00
parent 0fdbc5cc42
commit 3ecfbd33ea

View File

@@ -132,6 +132,12 @@ TCamera::OnCommand( command_data const &Command ) {
return iscameracommand; return iscameracommand;
} }
static void UpdateVelocityAxis(double& velocity, double moverate, double deltatime)
{
velocity = clamp(velocity + moverate * 10.0 * deltatime, -std::abs(moverate), std::abs(moverate));
}
void TCamera::Update() void TCamera::Update()
{ {
// check for sent user commands // check for sent user commands
@@ -164,9 +170,9 @@ void TCamera::Update()
|| ( true == DebugCameraFlag ) ) { || ( true == DebugCameraFlag ) ) {
// ctrl is used for mirror view, so we ignore the controls when in vehicle if ctrl is pressed // ctrl is used for mirror view, so we ignore the controls when in vehicle if ctrl is pressed
// McZapkie-170402: poruszanie i rozgladanie we free takie samo jak w follow // McZapkie-170402: poruszanie i rozgladanie we free takie samo jak w follow
Velocity.x = clamp( Velocity.x + m_moverate.x * 10.0 * deltatime, -std::abs( m_moverate.x ), std::abs( m_moverate.x ) ); UpdateVelocityAxis(Velocity.x, m_moverate.x, deltatime);
Velocity.z = clamp( Velocity.z + m_moverate.z * 10.0 * deltatime, -std::abs( m_moverate.z ), std::abs( m_moverate.z ) ); UpdateVelocityAxis(Velocity.y, m_moverate.y, deltatime);
Velocity.y = clamp( Velocity.y + m_moverate.y * 10.0 * deltatime, -std::abs( m_moverate.y ), std::abs( m_moverate.y ) ); UpdateVelocityAxis(Velocity.z, m_moverate.z, deltatime);
} }
if( ( m_owner == nullptr ) if( ( m_owner == nullptr )
|| ( true == DebugCameraFlag ) ) { || ( true == DebugCameraFlag ) ) {