summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2024-09-12 06:00:00 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2024-09-12 16:34:39 +0200
commit33c8fd2acc1ed1c13429c963d431adc8f4d8100e (patch)
tree7b603535bd630b716c773afee6c6c08d4b28cdef /indra
parent0c7cb663fc108249e5477fd90978fc1f74fe7b7e (diff)
#2542 Buoyant Nametags
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llvoavatar.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 67bf93a155..929a29829d 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3689,21 +3689,22 @@ LLVector3 LLVOAvatar::idleCalcNameTagPosition(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)
+ // Avoid of crossing the name tag by the water surface
+ if (mNameText)
{
- if (LLViewerCamera::getInstance()->getOrigin()[VZ] >= water_height)
- {
- name_position[VZ] = water_height;
- }
- else if (mNameText) // both camera and HUD are below watermark
+ F32 water_height = getRegion()->getWaterHeight();
+ static const F32 WATER_HEIGHT_ABOVE_DELTA = 0.25;
+ if (name_position[VZ] < water_height + WATER_HEIGHT_ABOVE_DELTA)
{
- F32 name_world_height = mNameText->getWorldHeight();
- F32 max_z_position = water_height - name_world_height;
- if (name_position[VZ] > max_z_position)
+ F32 camera_height = LLViewerCamera::getInstance()->getOrigin()[VZ];
+ if (camera_height >= water_height)
{
- name_position[VZ] = max_z_position;
+ F32 name_world_height = mNameText->getWorldHeight();
+ static const F32 WATER_HEIGHT_BELOW_DELTA = 0.5;
+ if (name_position[VZ] + name_world_height > water_height - WATER_HEIGHT_BELOW_DELTA)
+ {
+ name_position[VZ] = water_height + WATER_HEIGHT_ABOVE_DELTA;
+ }
}
}
}