From 6185fa58990488a1b6079da7fdcfde873f150acd Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Thu, 2 Apr 2020 13:07:45 -0400 Subject: [PATCH] Restore look at privacy and view options --- .../newview/app_settings/settings_alchemy.xml | 55 +++++++++++ indra/newview/llagentcamera.cpp | 13 ++- indra/newview/llhudeffectbeam.cpp | 3 +- indra/newview/llhudeffectlookat.cpp | 95 +++++++++++++++---- indra/newview/llhudeffectlookat.h | 25 +++-- indra/newview/llviewermenu.cpp | 5 +- 6 files changed, 160 insertions(+), 36 deletions(-) diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml index 12e22085f29..5494fdd1a16 100644 --- a/indra/newview/app_settings/settings_alchemy.xml +++ b/indra/newview/app_settings/settings_alchemy.xml @@ -211,6 +211,61 @@ <key>Value</key> <string>/tp2cam</string> </map> + <key>AlchemyLookAtShow</key> + <map> + <key>Comment</key> + <string>If true, avatar look at beacons will be displayed</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>AlchemyLookAtLines</key> + <map> + <key>Comment</key> + <string>Render a line from Look At beacon to the originating avatar</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>AlchemyLookAtNames</key> + <map> + <key>Comment</key> + <string>Render name of originating avatar under Look At beacon</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>AlchemyLookAtHideSelf</key> + <map> + <key>Comment</key> + <string>Hide own Look At beacon when Look At render is enabled</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>AlchemyLookAtPrivate</key> + <map> + <key>Comment</key> + <string>Disable broadcast of own look at to other users.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>AlchemyRainbowEffects</key> <map> <key>Comment</key> diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 857fef73138..1c600f5875f 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -2677,9 +2677,9 @@ void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, con if (mCameraAnimating) { - const F64 ANIM_METERS_PER_SECOND = 10.0; + const F64 ANIM_METERS_PER_SECOND = 50.0; const F64 MIN_ANIM_SECONDS = 0.5; - const F64 MAX_ANIM_SECONDS = 10.0; + const F64 MAX_ANIM_SECONDS = 1.0; F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND ); anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS ); setAnimationDuration( (F32)anim_duration ); @@ -2774,6 +2774,15 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) { + static LLCachedControl<bool> isPrivate(gSavedSettings, "AlchemyLookAtPrivate", false); + if (isPrivate) + { + if(!mLookAt || mLookAt->isDead()) + return FALSE; + + position.clearVec(); + return mLookAt->setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, position); + } if(object && object->isAttachment()) { LLViewerObject* parent = object; diff --git a/indra/newview/llhudeffectbeam.cpp b/indra/newview/llhudeffectbeam.cpp index d1d83e6e038..41b5390aedb 100644 --- a/indra/newview/llhudeffectbeam.cpp +++ b/indra/newview/llhudeffectbeam.cpp @@ -86,8 +86,7 @@ void LLHUDEffectBeam::packData(LLMessageSystem *mesgsys) // Pack the type-specific data. Uses a fun packed binary format. Whee! // 16 + 24 + 1 = 41 - U8 packed_data[41]; - memset(packed_data, 0, 41); + U8 packed_data[41] = {0}; if (mSourceObject) { htolememcpy(packed_data, mSourceObject->mID.mData, MVT_LLUUID, 16); diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index 6898dce7b10..232dc37ce30 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llhudeffectlookat.h" +#include <utility> #include "llrender.h" @@ -41,8 +42,9 @@ #include "llglheaders.h" #include "llxmltree.h" - -BOOL LLHUDEffectLookAt::sDebugLookAt = FALSE; +#include "llavatarnamecache.h" +#include "llhudrender.h" +#include "llviewercontrol.h" // packet layout const S32 SOURCE_AVATAR = 0; @@ -71,8 +73,8 @@ class LLAttention : mTimeout(0.f), mPriority(0.f) {} - LLAttention(F32 timeout, F32 priority, const std::string& name, LLColor3 color) : - mTimeout(timeout), mPriority(priority), mName(name), mColor(color) + LLAttention(F32 timeout, F32 priority, std::string name, LLColor3 color) : + mTimeout(timeout), mPriority(priority), mName(std::move(name)), mColor(color) { } F32 mTimeout, mPriority; @@ -239,7 +241,8 @@ static BOOL loadAttentions() LLHUDEffectLookAt::LLHUDEffectLookAt(const U8 type) : LLHUDEffect(type), mKillTime(0.f), - mLastSendTime(0.f) + mLastSendTime(0.f), + mDebugLookAt(gSavedSettings, "AlchemyLookAtShow", false) { clearLookAtTarget(); // parse the default sets @@ -264,8 +267,7 @@ void LLHUDEffectLookAt::packData(LLMessageSystem *mesgsys) LLHUDEffect::packData(mesgsys); // Pack the type-specific data. Uses a fun packed binary format. Whee! - U8 packed_data[PKT_SIZE]; - memset(packed_data, 0, PKT_SIZE); + U8 packed_data[PKT_SIZE] = {0}; if (mSourceObject) { @@ -359,8 +361,15 @@ void LLHUDEffectLookAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum) U8 lookAtTypeUnpacked = 0; htolememcpy(&lookAtTypeUnpacked, &(packed_data[LOOKAT_TYPE]), MVT_U8, 1); - mTargetType = (ELookAtType)lookAtTypeUnpacked; - + if ((U8)LOOKAT_NUM_TARGETS > lookAtTypeUnpacked) + { + mTargetType = (ELookAtType)lookAtTypeUnpacked; + } + else + { + mTargetType = LOOKAT_TARGET_NONE; + LL_DEBUGS("HUDEffect") << "Invalid target type: " << lookAtTypeUnpacked << LL_ENDL; + } if (mTargetType == LOOKAT_TARGET_NONE) { clearLookAtTarget(); @@ -491,8 +500,14 @@ void LLHUDEffectLookAt::setSourceObject(LLViewerObject* objectp) //----------------------------------------------------------------------------- void LLHUDEffectLookAt::render() { - if (sDebugLookAt && mSourceObject.notNull()) + if (mDebugLookAt && mSourceObject.notNull()) { + static LLCachedControl<bool> isOwnHidden(gSavedSettings, "AlchemyLookAtHideSelf", true); + static LLCachedControl<bool> isPrivate(gSavedSettings, "AlchemyLookAtPrivate", false); + + if ((isOwnHidden || isPrivate) && static_cast<LLVOAvatar*>(mSourceObject.get())->isSelf()) + return; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLGLDisable gls_stencil(GL_STENCIL_TEST); @@ -501,7 +516,7 @@ void LLHUDEffectLookAt::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.translatef(target.mV[VX], target.mV[VY], target.mV[VZ]); - gGL.scalef(0.3f, 0.3f, 0.3f); + gGL.scalef(0.1f, 0.1f, 0.1f); gGL.begin(LLRender::LINES); { LLColor3 color = (*mAttentions)[mTargetType].mColor; @@ -514,8 +529,59 @@ void LLHUDEffectLookAt::render() gGL.vertex3f(0.f, 0.f, -1.f); gGL.vertex3f(0.f, 0.f, 1.f); - } gGL.end(); + + static LLCachedControl<bool> lookAtLines(gSavedSettings, "AlchemyLookAtLines", false); + if(lookAtLines) + { + const std::string targname = (*mAttentions)[mTargetType].mName; + if(targname != "None" && targname != "Idle" && targname != "AutoListen") + { + LLVector3 dist = (mSourceObject->getWorldPosition() - mTargetPos) * 10; + gGL.vertex3f(0.f, 0.f, 0.f); + gGL.vertex3f(dist.mV[VX], dist.mV[VY], dist.mV[VZ] + 0.5f); + } + } + } + gGL.end(); gGL.popMatrix(); + + static LLCachedControl<U32> lookAtNames(gSavedSettings, "AlchemyLookAtNames", 0); + if(lookAtNames > 0) + { + std::string text; + LLAvatarName av_name; + LLAvatarNameCache::get(static_cast<LLVOAvatar*>(mSourceObject.get())->getID(), &av_name); + switch (lookAtNames) + { + case 1: // Display Name (user.name) + text = av_name.getCompleteName(); + break; + case 2: // Display Name + text = av_name.getDisplayName(); + break; + case 3: // First Last + text = av_name.getUserName(); + break; + default: //user.name + text = av_name.getAccountName(); + break; + } + + const LLFontGL* fontp = LLFontGL::getFontSansSerif(); + gGL.pushMatrix(); + hud_render_utf8text( + text, + target + LLVector3(0.f, 0.f, 0.15f), + *fontp, + LLFontGL::NORMAL, + LLFontGL::NO_SHADOW, + -0.5f * fontp->getWidthF32(text), + 0.0f, + (*mAttentions)[mTargetType].mColor, + FALSE + ); + gGL.popMatrix(); + } } } @@ -568,11 +634,6 @@ void LLHUDEffectLookAt::update() } } } - - if (sDebugLookAt) - { - ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->addDebugText((*mAttentions)[mTargetType].mName); - } } /** diff --git a/indra/newview/llhudeffectlookat.h b/indra/newview/llhudeffectlookat.h index fd057715b65..c1bc0b02a26 100644 --- a/indra/newview/llhudeffectlookat.h +++ b/indra/newview/llhudeffectlookat.h @@ -28,6 +28,7 @@ #define LL_LLHUDEFFECTLOOKAT_H #include "llhudeffect.h" +#include "llcontrol.h" class LLViewerObject; class LLVOAvatar; @@ -49,38 +50,35 @@ typedef enum e_lookat_type LOOKAT_NUM_TARGETS } ELookAtType; -class LLHUDEffectLookAt : public LLHUDEffect +class LLHUDEffectLookAt final : public LLHUDEffect { public: friend class LLHUDObject; - /*virtual*/ void markDead(); - /*virtual*/ void setSourceObject(LLViewerObject* objectp); + /*virtual*/ void markDead() override; + /*virtual*/ void setSourceObject(LLViewerObject* objectp) override; BOOL setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position); void clearLookAtTarget(); - ELookAtType getLookAtType() { return mTargetType; } - const LLVector3& getTargetPos() { return mTargetPos; } - const LLVector3d& getTargetOffset() { return mTargetOffsetGlobal; } + ELookAtType getLookAtType() const { return mTargetType; } + const LLVector3& getTargetPos() const { return mTargetPos; } + const LLVector3d& getTargetOffset() const { return mTargetOffsetGlobal; } bool calcTargetPosition(); protected: LLHUDEffectLookAt(const U8 type); ~LLHUDEffectLookAt(); - /*virtual*/ void update(); - /*virtual*/ void render(); - /*virtual*/ void packData(LLMessageSystem *mesgsys); - /*virtual*/ void unpackData(LLMessageSystem *mesgsys, S32 blocknum); + /*virtual*/ void update() override; + /*virtual*/ void render() override; + /*virtual*/ void packData(LLMessageSystem *mesgsys) override; + /*virtual*/ void unpackData(LLMessageSystem *mesgsys, S32 blocknum) override; // lookat behavior has either target position or target object with offset void setTargetObjectAndOffset(LLViewerObject *objp, LLVector3d offset); void setTargetPosGlobal(const LLVector3d &target_pos_global); -public: - static BOOL sDebugLookAt; - private: ELookAtType mTargetType; LLVector3d mTargetOffsetGlobal; @@ -90,6 +88,7 @@ class LLHUDEffectLookAt : public LLHUDEffect LLVector3 mTargetPos; F32 mLastSendTime; LLAttentionSet* mAttentions; + LLCachedControl<bool> mDebugLookAt; }; #endif // LL_LLHUDEFFECTLOOKAT_H diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 985a58a19aa..b3eea482c09 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1861,7 +1861,8 @@ class LLAdvancedToggleShowLookAt : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLHUDEffectLookAt::sDebugLookAt = !(LLHUDEffectLookAt::sDebugLookAt); + bool value = !gSavedSettings.getBOOL("AlchemyLookAtShow"); + gSavedSettings.setBOOL("AlchemyLookAtShow", value); return true; } }; @@ -1870,7 +1871,7 @@ class LLAdvancedCheckShowLookAt : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = LLHUDEffectLookAt::sDebugLookAt; + bool new_value = gSavedSettings.getBOOL("AlchemyLookAtShow"); return new_value; } }; -- GitLab