diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llhudtext.cpp | 127 |
1 files changed, 122 insertions, 5 deletions
diff --git a/linden/indra/newview/llhudtext.cpp b/linden/indra/newview/llhudtext.cpp index c45c284..c5e5419 100644 --- a/linden/indra/newview/llhudtext.cpp +++ b/linden/indra/newview/llhudtext.cpp | |||
@@ -120,6 +120,111 @@ LLHUDText::~LLHUDText() | |||
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render) | ||
124 | { | ||
125 | if (!mVisible || mHidden) | ||
126 | { | ||
127 | return FALSE; | ||
128 | } | ||
129 | |||
130 | // don't pick text that isn't bound to a viewerobject or isn't in a bubble | ||
131 | if (!mSourceObject || mSourceObject->mDrawable.isNull() || !mUseBubble) | ||
132 | { | ||
133 | return FALSE; | ||
134 | } | ||
135 | |||
136 | F32 alpha_factor = 1.f; | ||
137 | LLColor4 text_color = mColor; | ||
138 | if (mDoFade) | ||
139 | { | ||
140 | if (mLastDistance > mFadeDistance) | ||
141 | { | ||
142 | alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); | ||
143 | text_color.mV[3] = text_color.mV[3]*alpha_factor; | ||
144 | } | ||
145 | } | ||
146 | if (text_color.mV[3] < 0.01f) | ||
147 | { | ||
148 | return FALSE; | ||
149 | } | ||
150 | |||
151 | mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); | ||
152 | |||
153 | // scale screen size of borders down | ||
154 | //RN: for now, text on hud objects is never occluded | ||
155 | |||
156 | LLVector3 x_pixel_vec; | ||
157 | LLVector3 y_pixel_vec; | ||
158 | |||
159 | if (mOnHUDAttachment) | ||
160 | { | ||
161 | x_pixel_vec = LLVector3::y_axis / (F32)gViewerWindow->getWindowWidth(); | ||
162 | y_pixel_vec = LLVector3::z_axis / (F32)gViewerWindow->getWindowHeight(); | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); | ||
167 | } | ||
168 | |||
169 | LLVector3 width_vec = mWidth * x_pixel_vec; | ||
170 | LLVector3 height_vec = mHeight * y_pixel_vec; | ||
171 | |||
172 | LLCoordGL screen_pos; | ||
173 | LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); | ||
174 | |||
175 | LLVector2 screen_offset; | ||
176 | screen_offset = updateScreenPos(mPositionOffset); | ||
177 | |||
178 | LLVector3 render_position = mPositionAgent | ||
179 | + (x_pixel_vec * screen_offset.mV[VX]) | ||
180 | + (y_pixel_vec * screen_offset.mV[VY]); | ||
181 | |||
182 | |||
183 | if (mUseBubble) | ||
184 | { | ||
185 | LLVector3 bg_pos = render_position | ||
186 | + (F32)mOffsetY * y_pixel_vec | ||
187 | - (width_vec / 2.f) | ||
188 | - (height_vec); | ||
189 | //LLUI::translate(bg_pos.mV[VX], bg_pos.mV[VY], bg_pos.mV[VZ]); | ||
190 | |||
191 | LLVector3 v[] = | ||
192 | { | ||
193 | bg_pos, | ||
194 | bg_pos + width_vec, | ||
195 | bg_pos + width_vec + height_vec, | ||
196 | bg_pos + height_vec, | ||
197 | }; | ||
198 | |||
199 | if (debug_render) | ||
200 | { | ||
201 | gGL.begin(LLRender::LINE_STRIP); | ||
202 | gGL.vertex3fv(v[0].mV); | ||
203 | gGL.vertex3fv(v[1].mV); | ||
204 | gGL.vertex3fv(v[2].mV); | ||
205 | gGL.vertex3fv(v[3].mV); | ||
206 | gGL.vertex3fv(v[0].mV); | ||
207 | gGL.vertex3fv(v[2].mV); | ||
208 | gGL.end(); | ||
209 | } | ||
210 | |||
211 | LLVector3 dir = end-start; | ||
212 | F32 t = 0.f; | ||
213 | |||
214 | if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, NULL, NULL, &t, FALSE) || | ||
215 | LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, NULL, NULL, &t, FALSE) ) | ||
216 | { | ||
217 | if (t <= 1.f) | ||
218 | { | ||
219 | intersection = start + dir*t; | ||
220 | return TRUE; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | return FALSE; | ||
226 | } | ||
227 | |||
123 | void LLHUDText::render() | 228 | void LLHUDText::render() |
124 | { | 229 | { |
125 | if (!mOnHUDAttachment && sDisplayText) | 230 | if (!mOnHUDAttachment && sDisplayText) |
@@ -152,7 +257,15 @@ void LLHUDText::renderText(BOOL for_select) | |||
152 | return; | 257 | return; |
153 | } | 258 | } |
154 | 259 | ||
155 | LLGLState gls_tex(GL_TEXTURE_2D, for_select ? FALSE : TRUE); | 260 | if (for_select) |
261 | { | ||
262 | gGL.getTexUnit(0)->disable(); | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); | ||
267 | } | ||
268 | |||
156 | LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE); | 269 | LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE); |
157 | LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE); | 270 | LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE); |
158 | 271 | ||
@@ -261,7 +374,7 @@ void LLHUDText::renderText(BOOL for_select) | |||
261 | 374 | ||
262 | if (for_select) | 375 | if (for_select) |
263 | { | 376 | { |
264 | LLGLSNoTexture no_texture_state; | 377 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
265 | S32 name = mSourceObject->mGLName; | 378 | S32 name = mSourceObject->mGLName; |
266 | LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name); | 379 | LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name); |
267 | gGL.color4ubv(coloru.mV); | 380 | gGL.color4ubv(coloru.mV); |
@@ -271,7 +384,7 @@ void LLHUDText::renderText(BOOL for_select) | |||
271 | } | 384 | } |
272 | else | 385 | else |
273 | { | 386 | { |
274 | LLViewerImage::bindTexture(imagep->getImage()); | 387 | gGL.getTexUnit(0)->bind(imagep->getImage()); |
275 | 388 | ||
276 | gGL.color4fv(bg_color.mV); | 389 | gGL.color4fv(bg_color.mV); |
277 | gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); | 390 | gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); |
@@ -309,7 +422,7 @@ void LLHUDText::renderText(BOOL for_select) | |||
309 | } | 422 | } |
310 | LLUI::popMatrix(); | 423 | LLUI::popMatrix(); |
311 | 424 | ||
312 | LLImageGL::unbindTexture(0); | 425 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
313 | LLGLDepthTest gls_depth(mZCompare ? GL_TRUE : GL_FALSE, GL_FALSE); | 426 | LLGLDepthTest gls_depth(mZCompare ? GL_TRUE : GL_FALSE, GL_FALSE); |
314 | 427 | ||
315 | LLVector3 box_center_offset; | 428 | LLVector3 box_center_offset; |
@@ -317,7 +430,7 @@ void LLHUDText::renderText(BOOL for_select) | |||
317 | LLUI::translate(box_center_offset.mV[VX], box_center_offset.mV[VY], box_center_offset.mV[VZ]); | 430 | LLUI::translate(box_center_offset.mV[VX], box_center_offset.mV[VY], box_center_offset.mV[VZ]); |
318 | gGL.color4fv(bg_color.mV); | 431 | gGL.color4fv(bg_color.mV); |
319 | LLUI::setLineWidth(2.0); | 432 | LLUI::setLineWidth(2.0); |
320 | gGL.begin(LLVertexBuffer::LINES); | 433 | gGL.begin(LLRender::LINES); |
321 | { | 434 | { |
322 | if (outside_width) | 435 | if (outside_width) |
323 | { | 436 | { |
@@ -444,6 +557,10 @@ void LLHUDText::renderText(BOOL for_select) | |||
444 | } | 557 | } |
445 | /// Reset the default color to white. The renderer expects this to be the default. | 558 | /// Reset the default color to white. The renderer expects this to be the default. |
446 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 559 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
560 | if (for_select) | ||
561 | { | ||
562 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); | ||
563 | } | ||
447 | } | 564 | } |
448 | 565 | ||
449 | void LLHUDText::setStringUTF8(const std::string &wtext) | 566 | void LLHUDText::setStringUTF8(const std::string &wtext) |