From 2a87b64d26fba502e6b8514084d91b1f79965fd1 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 3 Aug 2023 16:01:45 +0200 Subject: [PATCH 1/5] SL-19887 Water cuts avatar's name bubble --- indra/newview/llhudnametag.cpp | 9 +++++++++ indra/newview/llhudnametag.h | 5 +++-- indra/newview/llvoavatar.cpp | 20 +++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index ab6a64157c..a45246eedc 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -898,6 +898,15 @@ void LLHUDNameTag::shift(const LLVector3& offset) mPositionAgent += offset; } +F32 LLHUDNameTag::getWorldHeight() const +{ + const LLViewerCamera* camera = LLViewerCamera::getInstance(); + F32 height_meters = mLastDistance * (F32)tan(camera->getView() / 2.f); + F32 height_pixels = camera->getViewHeightInPixels() / 2.f; + F32 meters_per_pixel = height_meters / height_pixels; + return mHeight * meters_per_pixel * gViewerWindow->getDisplayScale().mV[VY]; +} + //static void LLHUDNameTag::addPickable(std::set &pick_list) { diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h index 361e4d4f4b..592ab5518f 100644 --- a/indra/newview/llhudnametag.h +++ b/indra/newview/llhudnametag.h @@ -127,11 +127,12 @@ public: /*virtual*/ void markDead(); friend class LLHUDObject; /*virtual*/ F32 getDistance() const { return mLastDistance; } - S32 getLOD() { return mLOD; } - BOOL getVisible() { return mVisible; } + S32 getLOD() const { return mLOD; } + BOOL getVisible() const { return mVisible; } BOOL getHidden() const { return mHidden; } void setHidden( BOOL hide ) { mHidden = hide; } void shift(const LLVector3& offset); + F32 getWorldHeight() const; BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a& intersection, BOOL debug_render = FALSE); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 305c489cc8..250366dbea 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3612,7 +3612,6 @@ void LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last) local_camera_up.normalize(); local_camera_up = local_camera_up * inv_root_rot; - // position is based on head position, does not require mAvatarOffset here. - Nyx LLVector3 avatar_ellipsoid(mBodySize.mV[VX] * 0.4f, mBodySize.mV[VY] * 0.4f, @@ -3634,6 +3633,25 @@ void LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last) name_position += (local_camera_up * root_rot) - (projected_vec(local_camera_at * root_rot, camera_to_av)); name_position += pixel_up_vec * NAMETAG_VERTICAL_SCREEN_OFFSET; + const F32 water_height = getRegion()->getWaterHeight(); + static const F32 WATER_HEIGHT_DELTA = 0.25f; + if (name_position[VZ] < water_height + WATER_HEIGHT_DELTA) + { + if (LLViewerCamera::getInstance()->getOrigin()[VZ] >= water_height) + { + name_position[VZ] = water_height; + } + else // both camera and HUD are below watermark + { + F32 name_world_height = mNameText->getWorldHeight(); + F32 max_z_position = water_height - name_world_height; + if (name_position[VZ] > max_z_position) + { + name_position[VZ] = max_z_position; + } + } + } + mNameText->setPositionAgent(name_position); } From a26573fefe2a3599c1c920722dec519c9481dc64 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 3 Aug 2023 20:40:40 +0300 Subject: [PATCH 2/5] SL-18049 Part 1; Allow voice to be enabled in second instance --- indra/newview/llappviewer.cpp | 9 +-- indra/newview/llpanelvolumepulldown.cpp | 31 +++++---- indra/newview/llpanelvolumepulldown.h | 2 +- indra/newview/llvoiceclient.cpp | 10 +++ indra/newview/llvoiceclient.h | 2 + indra/newview/llvoicevivox.cpp | 64 +++++++++++++------ indra/newview/llvoicevivox.h | 3 + .../default/xui/en/panel_volume_pulldown.xml | 13 +++- 8 files changed, 94 insertions(+), 40 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e70fcb6e86..e9ba0550b0 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2945,13 +2945,14 @@ bool LLAppViewer::initConfiguration() if (mSecondInstance) { - // This is the second instance of SL. Turn off voice support, + // This is the second instance of SL. Mute voice, // but make sure the setting is *not* persisted. - LLControlVariable* disable_voice = gSavedSettings.getControl("CmdLineDisableVoice"); - if(disable_voice) + // Also see LLVivoxVoiceClient::voiceEnabled() + LLControlVariable* enable_voice = gSavedSettings.getControl("EnableVoiceChat"); + if(enable_voice) { const BOOL DO_NOT_PERSIST = FALSE; - disable_voice->setValue(LLSD(TRUE), DO_NOT_PERSIST); + enable_voice->setValue(LLSD(FALSE), DO_NOT_PERSIST); } } diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp index 6f11e76a72..17975a6e6d 100644 --- a/indra/newview/llpanelvolumepulldown.cpp +++ b/indra/newview/llpanelvolumepulldown.cpp @@ -40,6 +40,7 @@ #include "llfloaterreg.h" #include "llfloaterpreference.h" #include "llsliderctrl.h" +#include "llvoicevivox.h" ///---------------------------------------------------------------------------- /// Class LLPanelVolumePulldown @@ -50,7 +51,7 @@ LLPanelVolumePulldown::LLPanelVolumePulldown() { mCommitCallbackRegistrar.add("Vol.setControlFalse", boost::bind(&LLPanelVolumePulldown::setControlFalse, this, _2)); mCommitCallbackRegistrar.add("Vol.SetSounds", boost::bind(&LLPanelVolumePulldown::onClickSetSounds, this)); - mCommitCallbackRegistrar.add("Vol.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelVolumePulldown::updateMediaAutoPlayCheckbox, this, _1)); + mCommitCallbackRegistrar.add("Vol.updateCheckbox", boost::bind(&LLPanelVolumePulldown::updateCheckbox, this, _1, _2)); mCommitCallbackRegistrar.add("Vol.GoAudioPrefs", boost::bind(&LLPanelVolumePulldown::onAdvancedButtonClick, this, _2)); buildFromFile( "panel_volume_pulldown.xml"); } @@ -90,19 +91,27 @@ void LLPanelVolumePulldown::setControlFalse(const LLSD& user_data) control->set(LLSD(FALSE)); } -void LLPanelVolumePulldown::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl) +void LLPanelVolumePulldown::updateCheckbox(LLUICtrl* ctrl, const LLSD& user_data) { - std::string name = ctrl->getName(); + std::string control_name = user_data.asString(); + if (control_name == "MediaAutoPlay") + { + std::string name = ctrl->getName(); - // Disable "Allow Media to auto play" only when both - // "Streaming Music" and "Media" are unchecked. STORM-513. - if ((name == "enable_music") || (name == "enable_media")) - { - bool music_enabled = getChild("enable_music")->get(); - bool media_enabled = getChild("enable_media")->get(); + // Disable "Allow Media to auto play" only when both + // "Streaming Music" and "Media" are unchecked. STORM-513. + if ((name == "enable_music") || (name == "enable_media")) + { + bool music_enabled = getChild("enable_music")->get(); + bool media_enabled = getChild("enable_media")->get(); - getChild("media_auto_play_combo")->setEnabled(music_enabled || media_enabled); - } + getChild("media_auto_play_combo")->setEnabled(music_enabled || media_enabled); + } + } + else if (control_name == "VoiceChat") + { + LLVivoxVoiceClient::unmuteVoiceInstance(); + } } void LLPanelVolumePulldown::onClickSetSounds() diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h index e907bb0c78..3243d2e968 100644 --- a/indra/newview/llpanelvolumepulldown.h +++ b/indra/newview/llpanelvolumepulldown.h @@ -43,7 +43,7 @@ class LLPanelVolumePulldown : public LLPanelPulldown void onClickSetSounds(); // Disables "Allow Media to auto play" check box only when both // "Streaming Music" and "Media" are unchecked. Otherwise enables it. - void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl); + void updateCheckbox(LLUICtrl* ctrl, const LLSD& user_data); void onAdvancedButtonClick(const LLSD& user_data); }; diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 150b556284..fab6ec3755 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -555,6 +555,16 @@ void LLVoiceClient::setVoiceEnabled(bool enabled) } } +void LLVoiceClient::unmuteVoiceInstance() +{ + LLVivoxVoiceClient::unmuteVoiceInstance(); +} + +bool LLVoiceClient::isMutedVoiceInstance() +{ + return LLVivoxVoiceClient::isMutedVoiceInstance(); +} + void LLVoiceClient::updateMicMuteLogic() { // If not configured to use PTT, the mic should be open (otherwise the user will be unable to speak). diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index aa67502908..7788efb8e1 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -403,6 +403,8 @@ public: void toggleUserPTTState(void); void inputUserControlState(bool down); // interpret any sort of up-down mic-open control input according to ptt-toggle prefs void setVoiceEnabled(bool enabled); + static void unmuteVoiceInstance(); + static bool isMutedVoiceInstance(); void setUsePTT(bool usePTT); void setPTTIsToggle(bool PTTIsToggle); diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 3725510b6a..c89fe81a85 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -277,6 +277,7 @@ static void killGateway() bool LLVivoxVoiceClient::sShuttingDown = false; bool LLVivoxVoiceClient::sConnected = false; +bool LLVivoxVoiceClient::sVoiceInstanceMuted = false; LLPumpIO *LLVivoxVoiceClient::sPump = nullptr; LLVivoxVoiceClient::LLVivoxVoiceClient() : @@ -354,6 +355,7 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() : sShuttingDown = false; sConnected = false; sPump = nullptr; + sVoiceInstanceMuted = LLAppViewer::instance()->isSecondInstance(); mSpeakerVolume = scale_speaker_volume(0); @@ -951,32 +953,52 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() // cause SLVoice's bind() call to fail with EADDRINUSE. We expect // that eventually the OS will time out previous ports, which is // why we cycle instead of incrementing indefinitely. - U32 portbase = gSavedSettings.getU32("VivoxVoicePort"); - static U32 portoffset = 0; + + static LLCachedControl portbase(gSavedSettings, "VivoxVoicePort"); + static LLCachedControl host(gSavedSettings, "VivoxVoiceHost"); + static LLCachedControl loglevel(gSavedSettings, "VivoxDebugLevel"); + static LLCachedControl log_folder(gSavedSettings, "VivoxLogDirectory"); + static LLCachedControl shutdown_timeout(gSavedSettings, "VivoxShutdownTimeout"); static const U32 portrange = 100; - std::string host(gSavedSettings.getString("VivoxVoiceHost")); - U32 port = portbase + portoffset; + static U32 portoffset = 0; + U32 port = 0; + + if (LLAppViewer::instance()->isSecondInstance()) + { + // Ideally need to know amount of instances and + // to increment instance_offset on EADDRINUSE. + // But for now just use rand + static U32 instance_offset = portrange * ll_rand(20); + port = portbase + portoffset + portrange; + } + else + { + // leave main thread with exclusive port set + port = portbase + portoffset; + } portoffset = (portoffset + 1) % portrange; params.args.add("-i"); - params.args.add(STRINGIZE(host << ':' << port)); + params.args.add(STRINGIZE(host() << ':' << port)); - std::string loglevel = gSavedSettings.getString("VivoxDebugLevel"); - if (loglevel.empty()) - { - loglevel = "0"; - } params.args.add("-ll"); - params.args.add(loglevel); - - std::string log_folder = gSavedSettings.getString("VivoxLogDirectory"); - - if (log_folder.empty()) + if (loglevel().empty()) { - log_folder = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ""); + params.args.add("0"); + } + else + { + params.args.add(loglevel); } params.args.add("-lf"); - params.args.add(log_folder); + if (log_folder().empty()) + { + params.args.add(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "")); + } + else + { + params.args.add(log_folder); + } // set log file basename and .log params.args.add("-lp"); @@ -992,8 +1014,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() LLFile::rename(new_log, old_log); } - std::string shutdown_timeout = gSavedSettings.getString("VivoxShutdownTimeout"); - if (!shutdown_timeout.empty()) + if (!shutdown_timeout().empty()) { params.args.add("-st"); params.args.add(shutdown_timeout); @@ -1016,7 +1037,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() sGatewayPtr = LLProcess::create(params); - mDaemonHost = LLHost(host.c_str(), port); + mDaemonHost = LLHost(host().c_str(), port); } else { @@ -5624,7 +5645,8 @@ bool LLVivoxVoiceClient::voiceEnabled() { return gSavedSettings.getBOOL("EnableVoiceChat") && !gSavedSettings.getBOOL("CmdLineDisableVoice") && - !gNonInteractive; + !gNonInteractive && + !sVoiceInstanceMuted; } void LLVivoxVoiceClient::setLipSyncEnabled(BOOL enabled) diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index e3ab99c675..9a4023422b 100644 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -172,6 +172,8 @@ public: //@{ virtual bool voiceEnabled(); virtual void setVoiceEnabled(bool enabled); + static void unmuteVoiceInstance() { sVoiceInstanceMuted = false; } + static bool isMutedVoiceInstance() { return sVoiceInstanceMuted; } virtual BOOL lipSyncEnabled(); virtual void setLipSyncEnabled(BOOL enabled); virtual void setMuteMic(bool muted); // Set the mute state of the local mic. @@ -917,6 +919,7 @@ private: // This variables can last longer than vivox in coroutines so we need them as static static bool sShuttingDown; static bool sConnected; + static bool sVoiceInstanceMuted; // Second+ instance of viewer starts muted static LLPumpIO* sPump; LLEventMailDrop mVivoxPump; diff --git a/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml b/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml index b4eb1ade94..c7be790406 100644 --- a/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml +++ b/indra/newview/skins/default/xui/en/panel_volume_pulldown.xml @@ -199,7 +199,8 @@ top_delta="2" width="350"> + function="Vol.updateCheckbox" + parameter="MediaAutoPlay"/> + function="Vol.updateCheckbox" + parameter="MediaAutoPlay"/> + width="110" + > + + From 08484cec5ac1933fdc689ddd3dcbca72229f8118 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 3 Aug 2023 22:42:37 +0300 Subject: [PATCH 3/5] SL-18049 Part 2; Added a button to preferences to enable sound when possible --- indra/newview/llpanelvoicedevicesettings.cpp | 27 +++++++++++++++++-- indra/newview/llpanelvoicedevicesettings.h | 2 ++ .../default/xui/en/panel_sound_devices.xml | 26 ++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp index 28631e2b7b..5e1cf801b9 100644 --- a/indra/newview/llpanelvoicedevicesettings.cpp +++ b/indra/newview/llpanelvoicedevicesettings.cpp @@ -70,11 +70,14 @@ BOOL LLPanelVoiceDeviceSettings::postBuild() mCtrlInputDevices = getChild("voice_input_device"); mCtrlOutputDevices = getChild("voice_output_device"); + mRetryBtn = getChild("retry_btn"); mCtrlInputDevices->setCommitCallback( boost::bind(&LLPanelVoiceDeviceSettings::onCommitInputDevice, this)); mCtrlOutputDevices->setCommitCallback( boost::bind(&LLPanelVoiceDeviceSettings::onCommitOutputDevice, this)); + mRetryBtn->setCommitCallback( + boost::bind(&LLPanelVoiceDeviceSettings::onCommitRetry, this)); mLocalizedDeviceNames[DEFAULT_DEVICE] = getString("default_text"); mLocalizedDeviceNames["No Device"] = getString("name_no_device"); @@ -108,11 +111,25 @@ void LLPanelVoiceDeviceSettings::draw() // let user know that volume indicator is not yet available bool is_in_tuning_mode = LLVoiceClient::getInstance()->inTuningMode(); - getChildView("wait_text")->setVisible( !is_in_tuning_mode && mUseTuningMode); + bool voice_enabled = LLVoiceClient::getInstance()->voiceEnabled(); + if (voice_enabled) + { + getChildView("wait_text")->setVisible( !is_in_tuning_mode && mUseTuningMode); + getChildView("muted_text")->setVisible(FALSE); + mRetryBtn->setVisible(FALSE); + } + else + { + getChildView("wait_text")->setVisible(FALSE); + getChildView("muted_text")->setVisible(TRUE); + + static LLCachedControl voice_enabled(gSavedSettings, "EnableVoiceChat"); + mRetryBtn->setVisible(!voice_enabled || LLVoiceClient::isMutedVoiceInstance()); + } LLPanel::draw(); - if (is_in_tuning_mode) + if (is_in_tuning_mode && voice_enabled) { const S32 num_bars = 5; F32 voice_power = LLVoiceClient::getInstance()->tuningGetEnergy() / LLVoiceClient::OVERDRIVEN_POWER_LEVEL; @@ -339,3 +356,9 @@ void LLPanelVoiceDeviceSettings::onInputDevicesClicked() { LLVoiceClient::getInstance()->refreshDeviceLists(false); // fill in the pop up menus again if needed. } + +void LLPanelVoiceDeviceSettings::onCommitRetry() +{ + gSavedSettings.setBOOL("EnableVoiceChat", TRUE); + LLVoiceClient::unmuteVoiceInstance(); +} diff --git a/indra/newview/llpanelvoicedevicesettings.h b/indra/newview/llpanelvoicedevicesettings.h index 355bc02b05..6b85d4e540 100644 --- a/indra/newview/llpanelvoicedevicesettings.h +++ b/indra/newview/llpanelvoicedevicesettings.h @@ -55,12 +55,14 @@ protected: void onCommitOutputDevice(); void onOutputDevicesClicked(); void onInputDevicesClicked(); + void onCommitRetry(); F32 mMicVolume; std::string mInputDevice; std::string mOutputDevice; class LLComboBox *mCtrlInputDevices; class LLComboBox *mCtrlOutputDevices; + class LLButton *mRetryBtn; BOOL mDevicesUpdated; bool mUseTuningMode; std::map mLocalizedDeviceNames; diff --git a/indra/newview/skins/default/xui/en/panel_sound_devices.xml b/indra/newview/skins/default/xui/en/panel_sound_devices.xml index 3dbb7fb7fc..bcb38a46cc 100644 --- a/indra/newview/skins/default/xui/en/panel_sound_devices.xml +++ b/indra/newview/skins/default/xui/en/panel_sound_devices.xml @@ -122,7 +122,7 @@ layout="topleft" left_pad="5" name="wait_text" - top_delta="-1" + top_delta="2" width="110"> Please wait @@ -132,7 +132,7 @@ layout="topleft" left_delta="0" name="bar0" - top_delta="-2" + top_delta="-5" width="20" /> + + Muted + +