summaryrefslogtreecommitdiff
path: root/indra/newview/llhudtext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llhudtext.cpp')
-rw-r--r--indra/newview/llhudtext.cpp69
1 files changed, 43 insertions, 26 deletions
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 736c0a5bcd..818474a0cb 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -58,7 +58,7 @@ const F32 MAX_DRAW_DISTANCE = 300.f;
std::set<LLPointer<LLHUDText> > LLHUDText::sTextObjects;
std::vector<LLPointer<LLHUDText> > LLHUDText::sVisibleTextObjects;
std::vector<LLPointer<LLHUDText> > LLHUDText::sVisibleHUDTextObjects;
-BOOL LLHUDText::sDisplayText = TRUE ;
+bool LLHUDText::sDisplayText = true ;
bool lltextobject_further_away::operator()(const LLPointer<LLHUDText>& lhs, const LLPointer<LLHUDText>& rhs) const
{
@@ -68,8 +68,8 @@ bool lltextobject_further_away::operator()(const LLPointer<LLHUDText>& lhs, cons
LLHUDText::LLHUDText(const U8 type) :
LLHUDObject(type),
- mOnHUDAttachment(FALSE),
-// mVisibleOffScreen(FALSE),
+ mOnHUDAttachment(false),
+// mVisibleOffScreen(false),
mWidth(0.f),
mHeight(0.f),
mFontp(LLFontGL::getFontSansSerifSmall()),
@@ -80,14 +80,14 @@ LLHUDText::LLHUDText(const U8 type) :
mTextAlignment(ALIGN_TEXT_CENTER),
mVertAlignment(ALIGN_VERT_CENTER),
// mLOD(0),
- mHidden(FALSE)
+ mHidden(false)
{
mColor = LLColor4(1.f, 1.f, 1.f, 1.f);
- mDoFade = TRUE;
+ mDoFade = true;
mFadeDistance = 8.f;
mFadeRange = 4.f;
- mZCompare = TRUE;
- mOffscreen = FALSE;
+ mZCompare = true;
+ mOffscreen = false;
mRadius = 0.1f;
LLPointer<LLHUDText> ptr(this);
sTextObjects.insert(ptr);
@@ -116,7 +116,7 @@ void LLHUDText::renderText()
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
- LLGLState gls_blend(GL_BLEND, TRUE);
+ LLGLState gls_blend(GL_BLEND, true);
LLColor4 shadow_color(0.f, 0.f, 0.f, 1.f);
F32 alpha_factor = 1.f;
@@ -138,8 +138,10 @@ void LLHUDText::renderText()
mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f));
// *TODO: make this a per-text setting
- LLColor4 bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor");
- bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor);
+ static LLCachedControl<F32> bubble_opacity(gSavedSettings, "ChatBubbleOpacity");
+ static LLUIColor nametag_bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor");
+ LLColor4 bg_color = nametag_bg_color;
+ bg_color.setAlpha(bubble_opacity * alpha_factor);
const S32 border_height = 16;
const S32 border_width = 16;
@@ -183,6 +185,15 @@ void LLHUDText::renderText()
LLVector3 render_position = mPositionAgent
+ (x_pixel_vec * screen_offset.mV[VX])
+ (y_pixel_vec * screen_offset.mV[VY]);
+ bool reset_buffers = false;
+ const F32 treshold = 0.000001f;
+ if (abs(mLastRenderPosition.mV[VX] - render_position.mV[VX]) > treshold
+ || abs(mLastRenderPosition.mV[VY] - render_position.mV[VY]) > treshold
+ || abs(mLastRenderPosition.mV[VZ] - render_position.mV[VZ]) > treshold)
+ {
+ reset_buffers = true;
+ mLastRenderPosition = render_position;
+ }
F32 y_offset = (F32)mOffsetY;
@@ -206,6 +217,11 @@ void LLHUDText::renderText()
for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment;
segment_iter != mTextSegments.end(); ++segment_iter )
{
+ if (reset_buffers)
+ {
+ segment_iter->mFontBufferText.reset();
+ }
+
const LLFontGL* fontp = segment_iter->mFont;
y_offset -= fontp->getLineHeight() - 1; // correction factor to match legacy font metrics
@@ -229,7 +245,7 @@ void LLHUDText::renderText()
}
text_color.mV[VALPHA] *= alpha_factor;
- hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment);
+ hud_render_text(segment_iter->getText(), render_position, &segment_iter->mFontBufferText, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment);
}
}
/// Reset the default color to white. The renderer expects this to be the default.
@@ -274,7 +290,7 @@ void LLHUDText::addLine(const std::string &text_utf8,
do
{
F32 max_pixels = HUD_TEXT_MAX_WIDTH_NO_BUBBLE;
- S32 segment_length = font->maxDrawableChars(iter->substr(line_length).c_str(), max_pixels, wline.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
+ S32 segment_length = font->maxDrawableChars(iter->substr(line_length).c_str(), max_pixels, static_cast<S32>(wline.length()), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
LLHUDTextSegment segment(iter->substr(line_length, segment_length), style, color, font);
mTextSegments.push_back(segment);
line_length += segment_length;
@@ -285,7 +301,7 @@ void LLHUDText::addLine(const std::string &text_utf8,
}
}
-void LLHUDText::setZCompare(const BOOL zcompare)
+void LLHUDText::setZCompare(const bool zcompare)
{
mZCompare = zcompare;
}
@@ -317,7 +333,7 @@ void LLHUDText::setAlpha(F32 alpha)
}
-void LLHUDText::setDoFade(const BOOL do_fade)
+void LLHUDText::setDoFade(const bool do_fade)
{
mDoFade = do_fade;
}
@@ -334,7 +350,7 @@ void LLHUDText::updateVisibility()
if (!mSourceObject)
{
// Beacons
- mVisible = TRUE;
+ mVisible = true;
if (mOnHUDAttachment)
{
sVisibleHUDTextObjects.push_back(LLPointer<LLHUDText> (this));
@@ -349,14 +365,14 @@ void LLHUDText::updateVisibility()
// Not visible if parent object is dead
if (mSourceObject->isDead())
{
- mVisible = FALSE;
+ mVisible = false;
return;
}
// for now, all text on hud objects is visible
if (mOnHUDAttachment)
{
- mVisible = TRUE;
+ mVisible = true;
sVisibleHUDTextObjects.push_back(LLPointer<LLHUDText> (this));
mLastDistance = mPositionAgent.mV[VX];
return;
@@ -369,7 +385,7 @@ void LLHUDText::updateVisibility()
if (dir_from_camera * LLViewerCamera::getInstance()->getAtAxis() <= 0.f)
{ //text is behind camera, don't render
- mVisible = FALSE;
+ mVisible = false;
return;
}
@@ -386,13 +402,14 @@ void LLHUDText::updateVisibility()
if (!mTextSegments.size() || (mDoFade && (mLastDistance > mFadeDistance + mFadeRange)))
{
- mVisible = FALSE;
+ mVisible = false;
return;
}
LLVector3 pos_agent_center = gAgent.getPosAgentFromGlobal(mPositionGlobal) - dir_from_camera;
F32 last_distance_center = (pos_agent_center - LLViewerCamera::getInstance()->getOrigin()).magVec();
- F32 max_draw_distance = gSavedSettings.getF32("PrimTextMaxDrawDistance");
+ static LLCachedControl<F32> prim_text_max_dist(gSavedSettings, "PrimTextMaxDrawDistance");
+ F32 max_draw_distance = prim_text_max_dist;
if(max_draw_distance < 0)
{
@@ -407,7 +424,7 @@ void LLHUDText::updateVisibility()
if(last_distance_center > max_draw_distance)
{
- mVisible = FALSE;
+ mVisible = false;
return;
}
@@ -421,21 +438,21 @@ void LLHUDText::updateVisibility()
(x_pixel_vec * mPositionOffset.mV[VX]) +
(y_pixel_vec * mPositionOffset.mV[VY]);
- mOffscreen = FALSE;
+ mOffscreen = false;
if (!LLViewerCamera::getInstance()->sphereInFrustum(render_position, mRadius))
{
// if (!mVisibleOffScreen)
// {
- mVisible = FALSE;
+ mVisible = false;
return;
// }
// else
// {
-// mOffscreen = TRUE;
+// mOffscreen = true;
// }
}
- mVisible = TRUE;
+ mVisible = true;
sVisibleTextObjects.push_back(LLPointer<LLHUDText> (this));
}
@@ -447,7 +464,7 @@ LLVector2 LLHUDText::updateScreenPos(LLVector2 &offset)
LLVector3 y_pixel_vec;
LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec);
// LLVector3 world_pos = mPositionAgent + (offset.mV[VX] * x_pixel_vec) + (offset.mV[VY] * y_pixel_vec);
-// if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(world_pos, screen_pos, FALSE) && mVisibleOffScreen)
+// if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(world_pos, screen_pos, false) && mVisibleOffScreen)
// {
// // bubble off-screen, so find a spot for it along screen edge
// LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(world_pos, screen_pos);