void FMixerSource::Update() { SCOPE_CYCLE_COUNTER(STAT_AudioUpdateSources); if (!WaveInstance || !MixerSourceVoice || Paused || !bInitialized) { return; } UpdatePitch(); UpdateVolume(); UpdateSpatialization(); UpdateEffects(); UpdateChannelMaps(); FSoundSource::DrawDebugInfo(); }
void CBoidBird::Update( float dt,SBoidContext &bc ) { if (m_physicsControlled) { UpdatePhysics(dt,bc); return; } if (m_dead) return; if (m_heading.IsZero()) m_heading = Vec3(1,0,0); m_lastThinkTime += dt; { if (bc.followPlayer && !m_spawnFromPt) { if (m_pos.GetSquaredDistance(bc.playerPos) > MAX_BIRDS_DISTANCE*MAX_BIRDS_DISTANCE) { float z = bc.MinHeight + (Boid::Frand()+1)/2.0f*(bc.MaxHeight - bc.MinHeight); m_pos = bc.playerPos + Vec3(Boid::Frand()*MAX_BIRDS_DISTANCE,Boid::Frand()*MAX_BIRDS_DISTANCE,z ); m_speed = bc.MinSpeed + ((Boid::Frand()+1)/2.0f) / (bc.MaxSpeed - bc.MinSpeed); m_heading = Vec3(Boid::Frand(),Boid::Frand(),0).GetNormalized(); } } if(m_status == Bird::TAKEOFF) { float timePassed = (gEnv->pTimer->GetFrameStartTime() - m_takeOffStartTime).GetSeconds(); if(m_playingTakeOffAnim && timePassed >= m_TakeOffAnimLength) { m_playingTakeOffAnim = false; PlayAnimationId(Bird::ANIM_FLY,true); } else if( timePassed > TAKEOFF_TIME) { SetStatus(Bird::FLYING); } } if(m_status == Bird::LANDING) { Vec3 vDist(m_landingPoint - m_pos); float dist2 = vDist.GetLengthSquared2D(); float dist = sqrt_tpl(dist2 + vDist.z*vDist.z); if(dist > 0.02f && m_pos.z > m_landingPoint.z) { //if(vDist.z < 3 && m_heading) vDist /= dist; float fInterpSpeed = 2+fabs(m_heading.Dot(vDist))*3.f; Interpolate(m_heading,vDist, fInterpSpeed, dt); m_heading.NormalizeSafe(); if(m_heading.z < vDist.z) { Interpolate(m_heading.z,vDist.z,3.0f,dt); m_heading.NormalizeSafe(); } bool wasLandDeceleratingAlready = m_landDecelerating; m_accel.zero(); m_landDecelerating = dist < bc.landDecelerationHeight; if(m_landDecelerating) { float newspeed= m_startLandSpeed* dist/3.f; if(m_speed > newspeed) m_speed = newspeed; if(m_speed < 0.2f) m_speed = 0.2f; if(!wasLandDeceleratingAlready) PlayAnimationId(Bird::ANIM_LANDING_DECELERATING, true); } else m_startLandSpeed = m_speed; } else Landed(bc); CalcMovementBird( dt,bc,true ); UpdatePitch(dt,bc); return; } if (m_status != Bird::ON_GROUND) { Think(dt,bc); // Calc movement with current velocity. CalcMovementBird( dt,bc,true ); } else { if(bc.walkSpeed > 0 && m_onGroundStatus == Bird::OGS_WALKING) ThinkWalk(dt,bc); CalcMovementBird( dt,bc,true ); } m_accel.Set(0,0,0); UpdatePitch(dt,bc); // Check if landing/on ground after think(). if ( m_status == Bird::LANDING ||(m_dying && m_status != Bird::ON_GROUND)) { float LandEpsilon = 0.5f; // Check if landed on water. if (m_pos.z-bc.waterLevel < LandEpsilon+0.1f && !m_dying) { //! From water immidiatly take off. //! Gives fishing effect. TakeOff(bc); } } m_actionTime += dt; if (m_status == Bird::ON_GROUND ) UpdateOnGroundAction(dt, bc); else { if(!bc.noLanding && m_actionTime > m_maxActionTime && !static_cast<CBirdsFlock*>(m_flock)->IsPlayerNearOrigin()) Land(); } } }