void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er, const LLVector3 &up_direction, const LLVector3 &point_of_interest) { // do not update if avatar didn't move if (!LLViewerJoystick::getInstance()->getCameraNeedsUpdate()) { return; } LLVector3 last_position; LLVector3 last_axis; last_position = getOrigin(); last_axis = getAtAxis(); mLastPointOfInterest = point_of_interest; // constrain to max distance from avatar LLVector3 camera_offset = center - gAgent.getPositionAgent(); LLViewerRegion * regp = gAgent.getRegion(); F32 water_height = (NULL != regp) ? regp->getWaterHeight() : 0.f; LLVector3 origin = center; if (origin.mV[2] > water_height) { origin.mV[2] = llmax(origin.mV[2], water_height+0.20f); } else { origin.mV[2] = llmin(origin.mV[2], water_height-0.20f); } setOriginAndLookAt(origin, up_direction, point_of_interest); mVelocityDir = center - last_position ; F32 dpos = mVelocityDir.normVec() ; LLQuaternion rotation; rotation.shortestArc(last_axis, getAtAxis()); F32 x, y, z; F32 drot; rotation.getAngleAxis(&drot, &x, &y, &z); mVelocityStat.addValue(dpos); mAngularVelocityStat.addValue(drot); mAverageSpeed = mVelocityStat.getMeanPerSec() ; mAverageAngularSpeed = mAngularVelocityStat.getMeanPerSec() ; mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect())); // update pixel meter ratio using default fov, not modified one mPixelMeterRatio = getViewHeightInPixels()/ (2.f*tanf(mCameraFOVDefault*0.5)); // update screen pixel area mScreenPixelArea =(S32)((F32)getViewHeightInPixels() * ((F32)getViewHeightInPixels() * getAspect())); }
void audio_update_wind(bool force_update) { #ifdef kAUDIO_ENABLE_WIND // // Extract height above water to modulate filter by whether above/below water // LLViewerRegion* region = gAgent.getRegion(); if (region) { static F32 last_camera_water_height = -1000.f; LLVector3 camera_pos = gAgentCamera.getCameraPositionAgent(); F32 camera_water_height = camera_pos.mV[VZ] - region->getWaterHeight(); // // Don't update rolloff factor unless water surface has been crossed // if (force_update || (last_camera_water_height * camera_water_height) < 0.f) { static const LLCachedControl<F32> audio_level_rolloff("AudioLevelRolloff",1); if (camera_water_height < 0.f) { gAudiop->setRolloffFactor(audio_level_rolloff * LL_ROLLOFF_MULTIPLIER_UNDER_WATER); } else { gAudiop->setRolloffFactor(audio_level_rolloff); } } // this line rotates the wind vector to be listener (agent) relative // unfortunately we have to pre-translate to undo the translation that // occurs in the transform call gRelativeWindVec = gAgent.getFrameAgent().rotateToLocal(gWindVec - gAgent.getVelocity()); // don't use the setter setMaxWindGain() because we don't // want to screw up the fade-in on startup by setting actual source gain // outside the fade-in. static const LLCachedControl<bool> mute_audio("MuteAudio",false); static const LLCachedControl<bool> mute_ambient("MuteAmbient",false); static const LLCachedControl<F32> audio_level_master("AudioLevelMaster", 1.0f); static const LLCachedControl<F32> audio_level_ambient("AudioLevelAmbient",1.0f); F32 master_volume = mute_audio ? 0.f : (F32)audio_level_master; F32 ambient_volume = mute_ambient ? 0.f : (F32)audio_level_ambient; F32 wind_volume = master_volume * ambient_volume; gAudiop->mMaxWindGain = wind_volume; last_camera_water_height = camera_water_height; gAudiop->updateWind(gRelativeWindVec, camera_water_height); } #endif }
void audio_update_wind(bool force_update) { #ifdef kAUDIO_ENABLE_WIND // // Extract height above water to modulate filter by whether above/below water // LLViewerRegion* region = gAgent.getRegion(); if (region) { static F32 last_camera_water_height = -1000.f; LLVector3 camera_pos = gAgentCamera.getCameraPositionAgent(); F32 camera_water_height = camera_pos.mV[VZ] - region->getWaterHeight(); // // Don't update rolloff factor unless water surface has been crossed // if (force_update || (last_camera_water_height * camera_water_height) < 0.f) { static LLUICachedControl<F32> rolloff("AudioLevelRolloff", 1.0f); if (camera_water_height < 0.f) { gAudiop->setRolloffFactor(rolloff * LL_ROLLOFF_MULTIPLIER_UNDER_WATER); } else { gAudiop->setRolloffFactor(rolloff); } } // Scale down the contribution of weather-simulation wind to the // ambient wind noise. Wind velocity averages 3.5 m/s, with gusts to 7 m/s // whereas steady-state avatar walk velocity is only 3.2 m/s. // Without this the world feels desolate on first login when you are // standing still. static LLUICachedControl<F32> wind_level("AudioLevelWind", 0.5f); LLVector3 scaled_wind_vec = gWindVec * wind_level; // Mix in the avatar's motion, subtract because when you walk north, // the apparent wind moves south. LLVector3 final_wind_vec = scaled_wind_vec - gAgent.getVelocity(); // rotate the wind vector to be listener (agent) relative gRelativeWindVec = gAgent.getFrameAgent().rotateToLocal( final_wind_vec ); // don't use the setter setMaxWindGain() because we don't // want to screw up the fade-in on startup by setting actual source gain // outside the fade-in. static LLCachedControl<bool> MuteAudio(gSavedSettings,"MuteAudio"); static LLCachedControl<bool> MuteAmbient(gSavedSettings,"MuteAmbient"); static LLCachedControl<F32> AudioLevelMaster(gSavedSettings,"AudioLevelMaster"); static LLCachedControl<F32> AudioLevelAmbient(gSavedSettings,"AudioLevelAmbient"); F32 master_volume = MuteAudio ? 0.f : AudioLevelMaster; F32 ambient_volume = MuteAmbient ? 0.f : AudioLevelAmbient; F32 max_wind_volume = master_volume * ambient_volume; const F32 WIND_SOUND_TRANSITION_TIME = 2.f; // amount to change volume this frame F32 volume_delta = (LLFrameTimer::getFrameDeltaTimeF32() / WIND_SOUND_TRANSITION_TIME) * max_wind_volume; if (force_update) { // initialize wind volume (force_update) by using large volume_delta // which is sufficient to completely turn off or turn on wind noise volume_delta = 1.f; } // mute wind when not flying if (gAgent.getFlying()) { // volume increases by volume_delta, up to no more than max_wind_volume gAudiop->mMaxWindGain = llmin(gAudiop->mMaxWindGain + volume_delta, max_wind_volume); } else { // volume decreases by volume_delta, down to no less than 0 gAudiop->mMaxWindGain = llmax(gAudiop->mMaxWindGain - volume_delta, 0.f); } last_camera_water_height = camera_water_height; gAudiop->updateWind(gRelativeWindVec, camera_water_height); } #endif }