Skip to content

Commit 2a87b64

Browse files
committed
SL-19887 Water cuts avatar's name bubble
1 parent ce02749 commit 2a87b64

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

indra/newview/llhudnametag.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,15 @@ void LLHUDNameTag::shift(const LLVector3& offset)
898898
mPositionAgent += offset;
899899
}
900900

901+
F32 LLHUDNameTag::getWorldHeight() const
902+
{
903+
const LLViewerCamera* camera = LLViewerCamera::getInstance();
904+
F32 height_meters = mLastDistance * (F32)tan(camera->getView() / 2.f);
905+
F32 height_pixels = camera->getViewHeightInPixels() / 2.f;
906+
F32 meters_per_pixel = height_meters / height_pixels;
907+
return mHeight * meters_per_pixel * gViewerWindow->getDisplayScale().mV[VY];
908+
}
909+
901910
//static
902911
void LLHUDNameTag::addPickable(std::set<LLViewerObject*> &pick_list)
903912
{

indra/newview/llhudnametag.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ class LLHUDNameTag : public LLHUDObject
127127
/*virtual*/ void markDead();
128128
friend class LLHUDObject;
129129
/*virtual*/ F32 getDistance() const { return mLastDistance; }
130-
S32 getLOD() { return mLOD; }
131-
BOOL getVisible() { return mVisible; }
130+
S32 getLOD() const { return mLOD; }
131+
BOOL getVisible() const { return mVisible; }
132132
BOOL getHidden() const { return mHidden; }
133133
void setHidden( BOOL hide ) { mHidden = hide; }
134134
void shift(const LLVector3& offset);
135+
F32 getWorldHeight() const;
135136

136137
BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, LLVector4a& intersection, BOOL debug_render = FALSE);
137138

indra/newview/llvoavatar.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3612,7 +3612,6 @@ void LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last)
36123612
local_camera_up.normalize();
36133613
local_camera_up = local_camera_up * inv_root_rot;
36143614

3615-
36163615
// position is based on head position, does not require mAvatarOffset here. - Nyx
36173616
LLVector3 avatar_ellipsoid(mBodySize.mV[VX] * 0.4f,
36183617
mBodySize.mV[VY] * 0.4f,
@@ -3634,6 +3633,25 @@ void LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last)
36343633
name_position += (local_camera_up * root_rot) - (projected_vec(local_camera_at * root_rot, camera_to_av));
36353634
name_position += pixel_up_vec * NAMETAG_VERTICAL_SCREEN_OFFSET;
36363635

3636+
const F32 water_height = getRegion()->getWaterHeight();
3637+
static const F32 WATER_HEIGHT_DELTA = 0.25f;
3638+
if (name_position[VZ] < water_height + WATER_HEIGHT_DELTA)
3639+
{
3640+
if (LLViewerCamera::getInstance()->getOrigin()[VZ] >= water_height)
3641+
{
3642+
name_position[VZ] = water_height;
3643+
}
3644+
else // both camera and HUD are below watermark
3645+
{
3646+
F32 name_world_height = mNameText->getWorldHeight();
3647+
F32 max_z_position = water_height - name_world_height;
3648+
if (name_position[VZ] > max_z_position)
3649+
{
3650+
name_position[VZ] = max_z_position;
3651+
}
3652+
}
3653+
}
3654+
36373655
mNameText->setPositionAgent(name_position);
36383656
}
36393657

0 commit comments

Comments
 (0)