llmanip.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llmanip.h"
00035 
00036 #include "llmath.h"
00037 #include "v3math.h"
00038 //#include "llquaternion.h"
00039 #include "llgl.h"
00040 #include "llprimitive.h"
00041 #include "llview.h"
00042 #include "llviewerimagelist.h"
00043 
00044 #include "llagent.h"
00045 #include "llviewercontrol.h"
00046 #include "lldrawable.h"
00047 #include "llfontgl.h"
00048 #include "llhudrender.h"
00049 #include "llselectmgr.h"
00050 #include "llui.h"
00051 #include "llviewercamera.h"
00052 #include "llviewerjoint.h"
00053 #include "llviewerobject.h"
00054 #include "llviewerwindow.h"
00055 #include "llvoavatar.h"
00056 #include "llworld.h"            // for gWorldPointer
00057 #include "llresmgr.h"
00058 #include "viewer.h"                     // for gFPS
00059 #include "pipeline.h"
00060 #include "llglheaders.h"
00061 
00062 // Local constants...
00063 const S32 VERTICAL_OFFSET = 50;
00064 
00065 F32             LLManip::sHelpTextVisibleTime = 2.f;
00066 F32             LLManip::sHelpTextFadeTime = 2.f;
00067 S32             LLManip::sNumTimesHelpTextShown = 0;
00068 S32             LLManip::sMaxTimesShowHelpText = 5;
00069 F32             LLManip::sGridMaxSubdivisionLevel = 32.f;
00070 F32             LLManip::sGridMinSubdivisionLevel = 1.f;
00071 LLVector2 LLManip::sTickLabelSpacing(60.f, 25.f);
00072 
00073 
00074 //static
00075 void LLManip::rebuild(LLViewerObject* vobj)
00076 {
00077         LLDrawable* drawablep = vobj->mDrawable;
00078         if (drawablep && drawablep->getVOVolume())
00079         {
00080                 
00081                 gPipeline.markRebuild(drawablep,LLDrawable::REBUILD_VOLUME, TRUE);
00082                 //gPipeline.markMoved(drawablep, FALSE);
00083                 //gPipeline.updateMoveNormalAsync(vobj->mDrawable);
00084 
00085                 drawablep->setState(LLDrawable::MOVE_UNDAMPED); // force to UNDAMPED
00086                 drawablep->updateMove();
00087         }
00088 }
00089 
00091 // LLManip
00092 
00093 
00094 LLManip::LLManip( const LLString& name, LLToolComposite* composite )
00095         :
00096         LLTool( name, composite ),
00097         mInSnapRegime(FALSE),
00098         mHighlightedPart(LL_NO_PART)
00099 {
00100 }
00101 
00102 void LLManip::getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal)
00103 {
00104         LLVector3 grid_origin;
00105         LLVector3 grid_scale;
00106         LLQuaternion grid_rotation;
00107 
00108         gSelectMgr->getGrid(grid_origin, grid_rotation, grid_scale);
00109 
00110         if (manip >= LL_X_ARROW && manip <= LL_Z_ARROW)
00111         {
00112                 LLVector3 arrow_axis;
00113                 getManipAxis(object, manip, arrow_axis);
00114 
00115                 LLVector3 cross = arrow_axis % gCamera->getAtAxis();
00116                 normal = cross % arrow_axis;
00117                 normal.normVec();
00118         }
00119         else if (manip >= LL_YZ_PLANE && manip <= LL_XY_PLANE)
00120         {
00121                 switch (manip)
00122                 {
00123                 case LL_YZ_PLANE:
00124                         normal = LLVector3::x_axis;
00125                         break;
00126                 case LL_XZ_PLANE:
00127                         normal = LLVector3::y_axis;
00128                         break;
00129                 case LL_XY_PLANE:
00130                         normal = LLVector3::z_axis;
00131                         break;
00132                 default:
00133                         break;
00134                 }
00135                 normal.rotVec(grid_rotation);
00136         }
00137         else
00138         {
00139                 normal.clearVec();
00140         }
00141 }
00142 
00143 
00144 BOOL LLManip::getManipAxis(LLViewerObject* object, EManipPart manip, LLVector3 &axis)
00145 {
00146         LLVector3 grid_origin;
00147         LLVector3 grid_scale;
00148         LLQuaternion grid_rotation;
00149 
00150         gSelectMgr->getGrid(grid_origin, grid_rotation, grid_scale);
00151 
00152         if (manip == LL_X_ARROW)
00153         {
00154                 axis = LLVector3::x_axis;
00155         }
00156         else if (manip == LL_Y_ARROW)
00157         {
00158                 axis = LLVector3::y_axis;
00159         }
00160         else if (manip == LL_Z_ARROW)
00161         {
00162                 axis = LLVector3::z_axis;
00163         }
00164         else
00165         {
00166                 return FALSE;
00167         }
00168 
00169         axis.rotVec( grid_rotation );
00170         return TRUE;
00171 }
00172 
00173 F32 LLManip::getSubdivisionLevel(const LLVector3 &reference_point, const LLVector3 &translate_axis, F32 grid_scale, S32 min_pixel_spacing)
00174 {
00175         //update current snap subdivision level
00176         LLVector3 cam_to_reference;
00177         if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
00178         {
00179                 cam_to_reference = LLVector3(1.f / gAgent.getAvatarObject()->mHUDCurZoom, 0.f, 0.f);
00180         }
00181         else
00182         {
00183                 cam_to_reference = reference_point - gCamera->getOrigin();
00184         }
00185         F32 current_range = cam_to_reference.normVec();
00186 
00187         F32 projected_translation_axis_length = (translate_axis % cam_to_reference).magVec();
00188         F32 subdivisions = llmax(projected_translation_axis_length * grid_scale / (current_range / gCamera->getPixelMeterRatio() * min_pixel_spacing), 0.f);
00189         subdivisions = llclamp((F32)pow(2.f, llfloor(log(subdivisions) / log(2.f))), 1.f / 32.f, 32.f);
00190 
00191         return subdivisions;
00192 }
00193 
00194 void LLManip::handleSelect()
00195 {
00196         mObjectSelection = gSelectMgr->getEditSelection();
00197 }
00198 
00199 void LLManip::handleDeselect()
00200 {
00201         mObjectSelection = NULL;
00202 }
00203 
00204 LLObjectSelectionHandle LLManip::getSelection()
00205 {
00206         return mObjectSelection;
00207 }
00208 
00209 BOOL LLManip::handleHover(S32 x, S32 y, MASK mask)
00210 {
00211         // We only handle the event if mousedown started with us
00212         if( hasMouseCapture() )
00213         {
00214                 if( mObjectSelection->isEmpty() )
00215                 {
00216                         // Somehow the object got deselected while we were dragging it.
00217                         // Release the mouse
00218                         setMouseCapture( FALSE );
00219                 }
00220 
00221                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLManip (active)" << llendl;
00222         }
00223         else
00224         {
00225                 lldebugst(LLERR_USER_INPUT) << "hover handled by LLManip (inactive)" << llendl;
00226         }
00227         gViewerWindow->setCursor(UI_CURSOR_ARROW);
00228         return TRUE;
00229 }
00230 
00231 
00232 BOOL LLManip::handleMouseUp(S32 x, S32 y, MASK mask)
00233 {
00234         BOOL    handled = FALSE;
00235         if( hasMouseCapture() )
00236         {
00237                 handled = TRUE;
00238                 setMouseCapture( FALSE );
00239         }
00240         return handled;
00241 }
00242 
00243 void LLManip::updateGridSettings()
00244 {
00245         sGridMaxSubdivisionLevel = gSavedSettings.getBOOL("GridSubUnit") ? (F32)gSavedSettings.getS32("GridSubdivision") : 1.f;
00246 }
00247 
00248 BOOL LLManip::getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal)
00249 {
00250         LLVector3d origin_double = gAgent.getPosGlobalFromAgent(origin);
00251         LLVector3d global_point;
00252         BOOL result = getMousePointOnPlaneGlobal(global_point, x, y, origin_double, normal);
00253         point = gAgent.getPosAgentFromGlobal(global_point);
00254         return result;
00255 }
00256 
00257 BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal)
00258 {
00259         if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
00260         {
00261                 BOOL result = FALSE;
00262                 F32 mouse_x = ((F32)x / gViewerWindow->getWindowWidth() - 0.5f) * gCamera->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom;
00263                 F32 mouse_y = ((F32)y / gViewerWindow->getWindowHeight() - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom;
00264 
00265                 LLVector3 origin_agent = gAgent.getPosAgentFromGlobal(origin);
00266                 LLVector3 mouse_pos = LLVector3(0.f, -mouse_x, mouse_y);
00267                 if (llabs(normal.mV[VX]) < 0.001f)
00268                 {
00269                         // use largish value that should be outside HUD manipulation range
00270                         mouse_pos.mV[VX] = 10.f;
00271                 }
00272                 else
00273                 {
00274                         mouse_pos.mV[VX] = (normal * (origin_agent - mouse_pos))
00275                                                                 / (normal.mV[VX]);
00276                         result = TRUE;
00277                 }
00278 
00279                 point = gAgent.getPosGlobalFromAgent(mouse_pos);
00280                 return result;
00281         }
00282         else
00283         {
00284                 return gViewerWindow->mousePointOnPlaneGlobal(
00285                                                                                 point, x, y, origin, normal );
00286         }
00287 
00288         //return FALSE;
00289 }
00290 
00291 // Given the line defined by mouse cursor (a1 + a_param*(a2-a1)) and the line defined by b1 + b_param*(b2-b1),
00292 // returns a_param and b_param for the points where lines are closest to each other.
00293 // Returns false if the two lines are parallel.
00294 BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param )
00295 {
00296         LLVector3 a1;
00297         LLVector3 a2;
00298 
00299         if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
00300         {
00301                 F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) * gCamera->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom;
00302                 F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeight()) - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom;
00303                 a1 = LLVector3(llmin(b1.mV[VX] - 0.1f, b2.mV[VX] - 0.1f, 0.f), -mouse_x, mouse_y);
00304                 a2 = a1 + LLVector3(1.f, 0.f, 0.f);
00305         }
00306         else
00307         {
00308                 a1 = gAgent.getCameraPositionAgent();
00309                 a2 = gAgent.getCameraPositionAgent() + LLVector3(gViewerWindow->mouseDirectionGlobal(x, y));
00310         }
00311 
00312         BOOL parallel = TRUE;
00313         LLVector3 a = a2 - a1;
00314         LLVector3 b = b2 - b1;
00315 
00316         LLVector3 normal;
00317         F32 dist, denom;
00318         normal = (b % a) % b;   // normal to plane (P) through b and (shortest line between a and b)
00319         normal.normVec();
00320         dist = b1 * normal;                     // distance from origin to P
00321 
00322         denom = normal * a; 
00323         if( (denom < -F_APPROXIMATELY_ZERO) || (F_APPROXIMATELY_ZERO < denom) )
00324         {
00325                 a_param = (dist - normal * a1) / denom;
00326                 parallel = FALSE;
00327         }
00328 
00329         normal = (a % b) % a;   // normal to plane (P) through a and (shortest line between a and b)
00330         normal.normVec();
00331         dist = a1 * normal;                     // distance from origin to P
00332         denom = normal * b; 
00333         if( (denom < -F_APPROXIMATELY_ZERO) || (F_APPROXIMATELY_ZERO < denom) )
00334         {
00335                 b_param = (dist - normal * b1) / denom;
00336                 parallel = FALSE;
00337         }
00338 
00339         return parallel;
00340 }
00341 
00342 LLVector3 LLManip::getSavedPivotPoint() const
00343 {
00344         return gSelectMgr->getSavedBBoxOfSelection().getCenterAgent();
00345 }
00346 
00347 LLVector3 LLManip::getPivotPoint()
00348 {
00349         if (mObjectSelection->getFirstObject() && mObjectSelection->getObjectCount() == 1 && mObjectSelection->getSelectType() != SELECT_TYPE_HUD)
00350         {
00351                 return mObjectSelection->getFirstObject()->getPivotPositionAgent();
00352         }
00353         return gSelectMgr->getBBoxOfSelection().getCenterAgent();
00354 }
00355 
00356 
00357 void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z)
00358 {
00359         LLVector3 grid_origin;
00360         LLQuaternion grid_rot;
00361         LLVector3 grid_scale;
00362         gSelectMgr->getGrid(grid_origin, grid_rot, grid_scale);
00363 
00364         const BOOL children_ok = TRUE;
00365         LLViewerObject* object = mObjectSelection->getFirstRootObject(children_ok);
00366         if (!object)
00367         {
00368                 return;
00369         }
00370 
00371         //LLVector3  center_agent  = gSelectMgr->getBBoxOfSelection().getCenterAgent();
00372         LLVector3  center_agent  = getPivotPoint();
00373 
00374         glPushMatrix();
00375         {
00376                 glTranslatef(center_agent.mV[VX], center_agent.mV[VY], center_agent.mV[VZ]);
00377 
00378                 F32 angle_radians, x, y, z;
00379 
00380                 grid_rot.getAngleAxis(&angle_radians, &x, &y, &z);
00381                 glRotatef(angle_radians * RAD_TO_DEG, x, y, z);
00382 
00383                 F32 region_size = gWorldPointer->getRegionWidthInMeters();
00384 
00385                 const F32 LINE_ALPHA = 0.33f;
00386 
00387                 LLGLSNoTexture gls_no_texture;
00388                 LLUI::setLineWidth(1.5f);
00389 
00390                 if (draw_x)
00391                 {
00392                         glColor4f(1.f, 0.f, 0.f, LINE_ALPHA);
00393                         glBegin(GL_LINES);
00394                         glVertex3f( -region_size, 0.f, 0.f );
00395                         glVertex3f(  region_size, 0.f, 0.f );
00396                         glEnd();
00397                 }
00398 
00399                 if (draw_y)
00400                 {
00401                         glColor4f(0.f, 1.f, 0.f, LINE_ALPHA);
00402                         glBegin(GL_LINES);
00403                         glVertex3f( 0.f, -region_size, 0.f );
00404                         glVertex3f( 0.f,  region_size, 0.f );
00405                         glEnd();
00406                 }
00407 
00408                 if (draw_z)
00409                 {
00410                         glColor4f(0.f, 0.f, 1.f, LINE_ALPHA);
00411                         glBegin(GL_LINES);
00412                         glVertex3f( 0.f, 0.f, -region_size );
00413                         glVertex3f( 0.f, 0.f,  region_size );
00414                         glEnd();
00415                 }
00416                 LLUI::setLineWidth(1.0f);
00417         }
00418         glPopMatrix();
00419 }
00420 
00421 void LLManip::renderXYZ(const LLVector3 &vec) 
00422 {
00423         const S32 PAD = 10;
00424         char feedback_string[128];              /*Flawfinder: ignore*/
00425         LLVector3 camera_pos = gCamera->getOrigin() + gCamera->getAtAxis();
00426         S32 vertical_offset = gViewerWindow->getWindowHeight() / 2 - VERTICAL_OFFSET;
00427         S32 window_center_x = gViewerWindow->getWindowWidth() / 2;
00428         S32 window_center_y = gViewerWindow->getWindowHeight() / 2;
00429 
00430         LLUUID image_id;
00431         image_id.set(gViewerArt.getString("rounded_square.tga"));
00432         LLViewerImage* imagep = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);
00433 
00434         glPushMatrix();
00435         {
00436                 gViewerWindow->setup2DRender();
00437                 const LLVector2& display_scale = gViewerWindow->getDisplayScale();
00438                 glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f);
00439                 glColor4f(0.f, 0.f, 0.f, 0.7f);
00440 
00441                 gl_draw_scaled_image_with_border(window_center_x - 115, 
00442                         window_center_y + vertical_offset - PAD, 
00443                         16, 
00444                         16, 
00445                         235,
00446                         PAD * 2 + 10, 
00447                         imagep, 
00448                         LLColor4(0.f, 0.f, 0.f, 0.7f) );
00449         }
00450         glPopMatrix();
00451 
00452         gViewerWindow->setup3DRender();
00453 
00454         {
00455                 LLLocale locale(LLLocale::USER_LOCALE);
00456                 LLGLDepthTest gls_depth(GL_FALSE);
00457                 LLGLEnable tex(GL_TEXTURE_2D);
00458                 // render drop shadowed text
00459                 snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]);                      /* Flawfinder: ignore */
00460                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *gResMgr->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE);
00461 
00462                 snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]);                      /* Flawfinder: ignore */
00463                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *gResMgr->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE);
00464                 
00465                 snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]);                      /* Flawfinder: ignore */
00466                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *gResMgr->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE);
00467 
00468                 // render text on top
00469                 snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]);                      /* Flawfinder: ignore */
00470                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *gResMgr->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f, (F32)vertical_offset, LLColor4(1.f, 0.5f, 0.5f, 1.f), FALSE);
00471 
00472                 glColor3f(0.5f, 1.f, 0.5f);
00473                 snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]);                      /* Flawfinder: ignore */
00474                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *gResMgr->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f, (F32)vertical_offset, LLColor4(0.5f, 1.f, 0.5f, 1.f), FALSE);
00475                 
00476                 glColor3f(0.5f, 0.5f, 1.f);
00477                 snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]);                      /* Flawfinder: ignore */
00478                 hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *gResMgr->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f, (F32)vertical_offset, LLColor4(0.5f, 0.5f, 1.f, 1.f), FALSE);
00479         }
00480 }
00481 
00482 void LLManip::renderTickText(const LLVector3& pos, const char* text, const LLColor4 &color)
00483 {
00484         const LLFontGL* big_fontp = gResMgr->getRes( LLFONT_SANSSERIF );
00485 
00486         BOOL hud_selection = mObjectSelection->getSelectType() == SELECT_TYPE_HUD;
00487         glMatrixMode(GL_MODELVIEW);
00488         glPushMatrix();
00489         LLVector3 render_pos = pos;
00490         if (hud_selection)
00491         {
00492                 F32 zoom_amt = gAgent.getAvatarObject()->mHUDCurZoom;
00493                 F32 inv_zoom_amt = 1.f / zoom_amt;
00494                 // scale text back up to counter-act zoom level
00495                 render_pos = pos * zoom_amt;
00496                 glScalef(inv_zoom_amt, inv_zoom_amt, inv_zoom_amt);
00497         }
00498 
00499         // render shadow first
00500         LLColor4 shadow_color = LLColor4::black;
00501         LLGLEnable tex(GL_TEXTURE_2D);
00502         shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
00503         gViewerWindow->setupViewport(1, -1);
00504         hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
00505         gViewerWindow->setupViewport();
00506         hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
00507 
00508         glPopMatrix();
00509 }
00510 
00511 void LLManip::renderTickValue(const LLVector3& pos, F32 value, const char* suffix, const LLColor4 &color)
00512 {
00513         LLLocale locale(LLLocale::USER_LOCALE);
00514 
00515         const LLFontGL* big_fontp = gResMgr->getRes( LLFONT_SANSSERIF );
00516         const LLFontGL* small_fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
00517 
00518         char val_string[128];           /*Flawfinder: ignore*/
00519         char fraction_string[128];              /*Flawfinder: ignore*/
00520         F32 val_to_print = llround(value, 0.001f);
00521         S32 fractional_portion = llround(fmodf(llabs(val_to_print), 1.f) * 100.f);
00522         if (val_to_print < 0.f)
00523         {
00524                 if (fractional_portion == 0)
00525                 {
00526                         snprintf(val_string, sizeof(val_string), "-%d%s", lltrunc(llabs(val_to_print)), suffix);                        /* Flawfinder: ignore */
00527                 }
00528                 else
00529                 {
00530                         snprintf(val_string, sizeof(val_string), "-%d", lltrunc(llabs(val_to_print)));                  /* Flawfinder: ignore */
00531                 }
00532         }
00533         else
00534         {
00535                 if (fractional_portion == 0)
00536                 {
00537                         snprintf(val_string, sizeof(val_string), "%d%s", lltrunc(llabs(val_to_print)), suffix);                 /* Flawfinder: ignore */
00538                 }
00539                 else
00540                 {
00541                         snprintf(val_string, sizeof(val_string), "%d", lltrunc(val_to_print));                  /* Flawfinder: ignore */
00542                 }
00543         }
00544 
00545         BOOL hud_selection = mObjectSelection->getSelectType() == SELECT_TYPE_HUD;
00546         glMatrixMode(GL_MODELVIEW);
00547         glPushMatrix();
00548         LLVector3 render_pos = pos;
00549         if (hud_selection)
00550         {
00551                 F32 zoom_amt = gAgent.getAvatarObject()->mHUDCurZoom;
00552                 F32 inv_zoom_amt = 1.f / zoom_amt;
00553                 // scale text back up to counter-act zoom level
00554                 render_pos = pos * zoom_amt;
00555                 glScalef(inv_zoom_amt, inv_zoom_amt, inv_zoom_amt);
00556         }
00557 
00558         LLColor4 shadow_color = LLColor4::black;
00559         shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
00560 
00561         LLGLEnable tex(GL_TEXTURE_2D);
00562         if (fractional_portion != 0)
00563         {
00564                 snprintf(fraction_string, sizeof(fraction_string), "%c%02d%s", gResMgr->getDecimalPoint(), fractional_portion, suffix);                 /* Flawfinder: ignore */
00565 
00566                 gViewerWindow->setupViewport(1, -1);
00567                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);
00568                 hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, shadow_color, hud_selection);
00569 
00570                 gViewerWindow->setupViewport();
00571                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
00572                 hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, color, hud_selection);
00573         }
00574         else
00575         {
00576                 gViewerWindow->setupViewport(1, -1);
00577                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);
00578                 gViewerWindow->setupViewport();
00579                 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
00580         }
00581         glPopMatrix();
00582 }
00583 
00584 LLColor4 LLManip::setupSnapGuideRenderPass(S32 pass)
00585 {
00586         static LLColor4 grid_color_fg = gColors.getColor("GridlineColor");
00587         static LLColor4 grid_color_bg = gColors.getColor("GridlineBGColor");
00588         static LLColor4 grid_color_shadow = gColors.getColor("GridlineShadowColor");
00589 
00590         LLColor4 line_color;
00591         F32 line_alpha = gSavedSettings.getF32("GridOpacity");
00592 
00593         switch(pass)
00594         {
00595         case 0:
00596                 // shadow
00597                 gViewerWindow->setupViewport(1, -1);
00598                 line_color = grid_color_shadow;
00599                 line_color.mV[VALPHA] *= line_alpha;
00600                 LLUI::setLineWidth(2.f);
00601                 break;
00602         case 1:
00603                 // hidden lines
00604                 gViewerWindow->setupViewport();
00605                 line_color = grid_color_bg;
00606                 line_color.mV[VALPHA] *= line_alpha;
00607                 LLUI::setLineWidth(1.f);
00608                 break;
00609         case 2:
00610                 // visible lines
00611                 line_color = grid_color_fg;
00612                 line_color.mV[VALPHA] *= line_alpha;
00613                 break;
00614         }
00615 
00616         return line_color;
00617 }

Generated on Thu Jul 1 06:08:49 2010 for Second Life Viewer by  doxygen 1.4.7