summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2023-08-03 16:01:45 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2023-08-03 17:50:07 +0200
commit2a87b64d26fba502e6b8514084d91b1f79965fd1 (patch)
tree2f52613f3cd42c5a0142aa3c359fe0c24a17eaa6
parentce0274937f8f5446b38525bdc314259c16f13f3c (diff)
SL-19887 Water cuts avatar's name bubble
-rw-r--r--indra/newview/llhudnametag.cpp9
-rw-r--r--indra/newview/llhudnametag.h5
-rw-r--r--indra/newview/llvoavatar.cpp20
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<LLViewerObject*> &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);
}