//------------------------------------------------------------------------ void CVehicleMovementVTOL::Update(const float deltaTime) { FUNCTION_PROFILER( GetISystem(), PROFILE_GAME ); CVehicleMovementHelicopter::Update(deltaTime); CryAutoCriticalSection lk(m_lock); if (m_pWingsAnimation) { m_pWingsAnimation->SetTime(m_wingsAnimTime); } IActorSystem* pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem(); assert(pActorSystem); IActor* pActor = pActorSystem->GetActor(m_actorId); if (pActor && pActor->IsClient()) { float turbulence = m_turbulence; if (m_pAltitudeLimitVar) { float altitudeLimit = m_pAltitudeLimitVar->GetFVal(); float currentHeight = m_pEntity->GetWorldPos().z; if (!iszero(altitudeLimit)) { float altitudeLowerOffset; if (m_pAltitudeLimitLowerOffsetVar) { float r = 1.0f - min(1.0f, max(0.0f, m_pAltitudeLimitLowerOffsetVar->GetFVal())); altitudeLowerOffset = r * altitudeLimit; if (currentHeight >= altitudeLowerOffset) { if (currentHeight > altitudeLowerOffset) { float zone = altitudeLimit - altitudeLowerOffset; turbulence += (currentHeight - altitudeLowerOffset) / (zone); } } } } } if (turbulence > 0.0f) { static_cast<CActor*>(pActor)->CameraShake(0.50f * turbulence, 0.0f, 0.05f, 0.04f, Vec3(0.0f, 0.0f, 0.0f), 10, "VTOL_Update_Turbulence"); } float enginePowerRatio = m_enginePower / m_enginePowerMax; if (enginePowerRatio > 0.0f) { float rpmScaleDesired = 0.2f; rpmScaleDesired += abs(m_forwardAction) * 0.8f; rpmScaleDesired += abs(m_strafeAction) * 0.4f; rpmScaleDesired += abs(m_turnAction) * 0.25f; rpmScaleDesired = min(1.0f, rpmScaleDesired); Interpolate(m_rpmScale, rpmScaleDesired, 1.0f, deltaTime); } float turnParamGoal = min(1.0f, abs(m_turnAction)) * 0.6f; turnParamGoal *= (min(1.0f, max(0.0f, m_speedRatio)) + 1.0f) * 0.50f; turnParamGoal += turnParamGoal * m_boost * 0.25f; Interpolate(m_soundParamTurn, turnParamGoal, 0.5f, deltaTime); SetSoundParam(eSID_Run, "turn", m_soundParamTurn); float damage = GetSoundDamage(); if (damage > 0.1f) { //if (ISound* pSound = GetOrPlaySound(eSID_Damage, 5.f, m_enginePos)) //SetSoundParam(pSound, "damage", damage); } } }
//------------------------------------------------------------------------ void CVehicleMovementStdBoat::UpdateRunSound(const float deltaTime) { Vec3 localAccel(ZERO); m_measureSpeedTimer+=deltaTime; if(m_measureSpeedTimer > 0.25f) { Vec3 accel = (m_statusDyn.v - m_lastMeasuredVel) * (1.f/m_measureSpeedTimer); Matrix33 worldTM(!m_statusPos.q); localAccel = worldTM * accel; m_lastMeasuredVel = m_statusDyn.v; m_measureSpeedTimer = 0.f; } if(m_pVehicle->IsProbablyDistant()) return; float soundSpeedRatio = ms_engineSoundIdleRatio + (1.f-ms_engineSoundIdleRatio) * m_speedRatio; SetSoundParam(eSID_Run, "speed", soundSpeedRatio); SetSoundParam(eSID_Ambience, "speed", soundSpeedRatio); //SetSoundParam(eSID_Run, "boost", Boosting() ? 1.f : 0.f); float acceleration = min(1.f, abs(localAccel.y) / m_accel*max(1.f, m_accelCoeff)); if(acceleration > 0.5f) { if(ISound *pSound = GetOrPlaySound(eSID_Acceleration, 2.f)) SetSoundParam(pSound, "acceleration", acceleration); } float damage = GetSoundDamage(); if(damage > 0.1f) { if(ISound *pSound = GetOrPlaySound(eSID_Damage, 5.f, m_enginePos)) SetSoundParam(pSound, "damage", damage); } // rpm dropdown for waves if(m_rpmPitchDir != 0) { float speed = (m_rpmPitchDir > 0) ? 0.1f : -0.8f; // quick down, slow up m_waveSoundPitch += deltaTime * speed; if(m_waveSoundPitch < -m_waveSoundAmount) // dropdown amount { m_waveSoundPitch = -m_waveSoundAmount; m_rpmPitchDir = 1; } else if(m_waveSoundPitch > 0.f) { m_waveSoundPitch = 0.f; m_rpmPitchDir = 0; } } if(m_rpmPitchSpeed>0.f) { const float maxPedal = (!m_inWater) ? 1.f : Boosting() ? 0.8f : 0.7f; // pitch rpm with pedal float pedal = GetEnginePedal(); pedal = sgnnz(pedal)*max(ms_engineSoundIdleRatio, min(maxPedal, abs(pedal))); // clamp "pedal" to [0.2..0.7] range float delta = pedal - m_rpmScaleSgn; m_rpmScaleSgn = max(-1.f, min(1.f, m_rpmScaleSgn + sgn(delta)*min(abs(delta), m_rpmPitchSpeed*deltaTime))); // skip transition around 0 when on pedal (sounds more realistic) if(abs(GetEnginePedal()) > 0.001f && abs(delta) > 0.001f && sgn(m_rpmScaleSgn) != sgn(delta) && abs(m_rpmScaleSgn) <= 0.3f) m_rpmScaleSgn = sgn(delta)*0.3f; // for normal driving, rpm is clamped at max defined by sound dept m_rpmScale = abs(m_rpmScaleSgn); m_rpmScale = min(1.f, max(ms_engineSoundIdleRatio, m_rpmScale + m_waveSoundPitch)); SetSoundParam(eSID_Run, "rpm_scale", m_rpmScale); SetSoundParam(eSID_Ambience, "rpm_scale", m_rpmScale); } }