aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmanip.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llmanip.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llmanip.cpp71
1 files changed, 43 insertions, 28 deletions
diff --git a/linden/indra/newview/llmanip.cpp b/linden/indra/newview/llmanip.cpp
index 20d77e0..a1ff7c3 100644
--- a/linden/indra/newview/llmanip.cpp
+++ b/linden/indra/newview/llmanip.cpp
@@ -169,7 +169,7 @@ F32 LLManip::getSubdivisionLevel(const LLVector3 &reference_point, const LLVecto
169{ 169{
170 //update current snap subdivision level 170 //update current snap subdivision level
171 LLVector3 cam_to_reference; 171 LLVector3 cam_to_reference;
172 if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD) 172 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
173 { 173 {
174 cam_to_reference = LLVector3(1.f / gAgent.getAvatarObject()->mHUDCurZoom, 0.f, 0.f); 174 cam_to_reference = LLVector3(1.f / gAgent.getAvatarObject()->mHUDCurZoom, 0.f, 0.f);
175 } 175 }
@@ -186,12 +186,27 @@ F32 LLManip::getSubdivisionLevel(const LLVector3 &reference_point, const LLVecto
186 return subdivisions; 186 return subdivisions;
187} 187}
188 188
189void LLManip::handleSelect()
190{
191 mObjectSelection = gSelectMgr->getEditSelection();
192}
193
194void LLManip::handleDeselect()
195{
196 mObjectSelection = NULL;
197}
198
199LLObjectSelectionHandle LLManip::getSelection()
200{
201 return mObjectSelection;
202}
203
189BOOL LLManip::handleHover(S32 x, S32 y, MASK mask) 204BOOL LLManip::handleHover(S32 x, S32 y, MASK mask)
190{ 205{
191 // We only handle the event if mousedown started with us 206 // We only handle the event if mousedown started with us
192 if( hasMouseCapture() ) 207 if( hasMouseCapture() )
193 { 208 {
194 if( gSelectMgr->isEmpty() ) 209 if( mObjectSelection->isEmpty() )
195 { 210 {
196 // Somehow the object got deselected while we were dragging it. 211 // Somehow the object got deselected while we were dragging it.
197 // Release the mouse 212 // Release the mouse
@@ -236,7 +251,7 @@ BOOL LLManip::getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector
236 251
237BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal) 252BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal)
238{ 253{
239 if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD) 254 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
240 { 255 {
241 BOOL result = FALSE; 256 BOOL result = FALSE;
242 F32 mouse_x = ((F32)x / gViewerWindow->getWindowWidth() - 0.5f) * gCamera->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom; 257 F32 mouse_x = ((F32)x / gViewerWindow->getWindowWidth() - 0.5f) * gCamera->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom;
@@ -271,12 +286,12 @@ BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVect
271// Given the line defined by mouse cursor (a1 + a_param*(a2-a1)) and the line defined by b1 + b_param*(b2-b1), 286// Given the line defined by mouse cursor (a1 + a_param*(a2-a1)) and the line defined by b1 + b_param*(b2-b1),
272// returns a_param and b_param for the points where lines are closest to each other. 287// returns a_param and b_param for the points where lines are closest to each other.
273// Returns false if the two lines are parallel. 288// Returns false if the two lines are parallel.
274BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param ) const 289BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param )
275{ 290{
276 LLVector3 a1; 291 LLVector3 a1;
277 LLVector3 a2; 292 LLVector3 a2;
278 293
279 if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD) 294 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
280 { 295 {
281 F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) * gCamera->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom; 296 F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) * gCamera->getAspect() / gAgent.getAvatarObject()->mHUDCurZoom;
282 F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeight()) - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom; 297 F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeight()) - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom;
@@ -324,11 +339,11 @@ LLVector3 LLManip::getSavedPivotPoint() const
324 return gSelectMgr->getSavedBBoxOfSelection().getCenterAgent(); 339 return gSelectMgr->getSavedBBoxOfSelection().getCenterAgent();
325} 340}
326 341
327LLVector3 LLManip::getPivotPoint() const 342LLVector3 LLManip::getPivotPoint()
328{ 343{
329 if (gSelectMgr->getFirstObject() && gSelectMgr->getObjectCount() == 1 && gSelectMgr->getSelectType() != SELECT_TYPE_HUD) 344 if (mObjectSelection->getFirstObject() && mObjectSelection->getObjectCount() == 1 && mObjectSelection->getSelectType() != SELECT_TYPE_HUD)
330 { 345 {
331 return gSelectMgr->getFirstObject()->getPivotPositionAgent(); 346 return mObjectSelection->getFirstObject()->getPivotPositionAgent();
332 } 347 }
333 return gSelectMgr->getBBoxOfSelection().getCenterAgent(); 348 return gSelectMgr->getBBoxOfSelection().getCenterAgent();
334} 349}
@@ -341,10 +356,10 @@ void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z)
341 LLVector3 grid_scale; 356 LLVector3 grid_scale;
342 gSelectMgr->getGrid(grid_origin, grid_rot, grid_scale); 357 gSelectMgr->getGrid(grid_origin, grid_rot, grid_scale);
343 358
344 LLViewerObject* object = gSelectMgr->getFirstRootObject(); 359 LLViewerObject* object = mObjectSelection->getFirstRootObject();
345 if (!object) 360 if (!object)
346 { 361 {
347 object = gSelectMgr->getFirstObject(); 362 object = mObjectSelection->getFirstObject();
348 if (!object) 363 if (!object)
349 { 364 {
350 return; 365 return;
@@ -404,7 +419,7 @@ void LLManip::renderGuidelines(BOOL draw_x, BOOL draw_y, BOOL draw_z)
404void LLManip::renderXYZ(const LLVector3 &vec) 419void LLManip::renderXYZ(const LLVector3 &vec)
405{ 420{
406 const S32 PAD = 10; 421 const S32 PAD = 10;
407 char feedback_string[128]; 422 char feedback_string[128]; /*Flawfinder: ignore*/
408 LLVector3 camera_pos = gCamera->getOrigin() + gCamera->getAtAxis(); 423 LLVector3 camera_pos = gCamera->getOrigin() + gCamera->getAtAxis();
409 S32 vertical_offset = gViewerWindow->getWindowHeight() / 2 - VERTICAL_OFFSET; 424 S32 vertical_offset = gViewerWindow->getWindowHeight() / 2 - VERTICAL_OFFSET;
410 S32 window_center_x = gViewerWindow->getWindowWidth() / 2; 425 S32 window_center_x = gViewerWindow->getWindowWidth() / 2;
@@ -439,25 +454,25 @@ void LLManip::renderXYZ(const LLVector3 &vec)
439 LLGLDepthTest gls_depth(GL_FALSE); 454 LLGLDepthTest gls_depth(GL_FALSE);
440 LLGLEnable tex(GL_TEXTURE_2D); 455 LLGLEnable tex(GL_TEXTURE_2D);
441 // render drop shadowed text 456 // render drop shadowed text
442 sprintf(feedback_string, "X: %.3f", vec.mV[VX]); 457 snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]); /*Flawfinder: ignore*/
443 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); 458 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);
444 459
445 sprintf(feedback_string, "Y: %.3f", vec.mV[VY]); 460 snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]); /*Flawfinder: ignore*/
446 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); 461 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);
447 462
448 sprintf(feedback_string, "Z: %.3f", vec.mV[VZ]); 463 snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]); /*Flawfinder: ignore*/
449 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); 464 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);
450 465
451 // render text on top 466 // render text on top
452 sprintf(feedback_string, "X: %.3f", vec.mV[VX]); 467 snprintf(feedback_string, sizeof(feedback_string), "X: %.3f", vec.mV[VX]); /*Flawfinder: ignore*/
453 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); 468 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);
454 469
455 glColor3f(0.5f, 1.f, 0.5f); 470 glColor3f(0.5f, 1.f, 0.5f);
456 sprintf(feedback_string, "Y: %.3f", vec.mV[VY]); 471 snprintf(feedback_string, sizeof(feedback_string), "Y: %.3f", vec.mV[VY]); /*Flawfinder: ignore*/
457 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); 472 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);
458 473
459 glColor3f(0.5f, 0.5f, 1.f); 474 glColor3f(0.5f, 0.5f, 1.f);
460 sprintf(feedback_string, "Z: %.3f", vec.mV[VZ]); 475 snprintf(feedback_string, sizeof(feedback_string), "Z: %.3f", vec.mV[VZ]); /*Flawfinder: ignore*/
461 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); 476 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);
462 } 477 }
463} 478}
@@ -466,7 +481,7 @@ void LLManip::renderTickText(const LLVector3& pos, const char* text, const LLCol
466{ 481{
467 const LLFontGL* big_fontp = gResMgr->getRes( LLFONT_SANSSERIF ); 482 const LLFontGL* big_fontp = gResMgr->getRes( LLFONT_SANSSERIF );
468 483
469 BOOL hud_selection = gSelectMgr->getSelectType() == SELECT_TYPE_HUD; 484 BOOL hud_selection = mObjectSelection->getSelectType() == SELECT_TYPE_HUD;
470 glMatrixMode(GL_MODELVIEW); 485 glMatrixMode(GL_MODELVIEW);
471 glPushMatrix(); 486 glPushMatrix();
472 LLVector3 render_pos = pos; 487 LLVector3 render_pos = pos;
@@ -484,9 +499,9 @@ void LLManip::renderTickText(const LLVector3& pos, const char* text, const LLCol
484 LLGLEnable tex(GL_TEXTURE_2D); 499 LLGLEnable tex(GL_TEXTURE_2D);
485 shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f; 500 shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
486 gViewerWindow->setupViewport(1, -1); 501 gViewerWindow->setupViewport(1, -1);
487 hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, gSelectMgr->getSelectType() == SELECT_TYPE_HUD); 502 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);
488 gViewerWindow->setupViewport(); 503 gViewerWindow->setupViewport();
489 hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, color, gSelectMgr->getSelectType() == SELECT_TYPE_HUD); 504 hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
490 505
491 glPopMatrix(); 506 glPopMatrix();
492} 507}
@@ -498,34 +513,34 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const char* suffi
498 const LLFontGL* big_fontp = gResMgr->getRes( LLFONT_SANSSERIF ); 513 const LLFontGL* big_fontp = gResMgr->getRes( LLFONT_SANSSERIF );
499 const LLFontGL* small_fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); 514 const LLFontGL* small_fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
500 515
501 char val_string[128]; 516 char val_string[128]; /*Flawfinder: ignore*/
502 char fraction_string[128]; 517 char fraction_string[128]; /*Flawfinder: ignore*/
503 F32 val_to_print = llround(value, 0.001f); 518 F32 val_to_print = llround(value, 0.001f);
504 S32 fractional_portion = llround(fmodf(llabs(val_to_print), 1.f) * 100.f); 519 S32 fractional_portion = llround(fmodf(llabs(val_to_print), 1.f) * 100.f);
505 if (val_to_print < 0.f) 520 if (val_to_print < 0.f)
506 { 521 {
507 if (fractional_portion == 0) 522 if (fractional_portion == 0)
508 { 523 {
509 sprintf(val_string, "-%d%s", lltrunc(llabs(val_to_print)), suffix); 524 snprintf(val_string, sizeof(val_string), "-%d%s", lltrunc(llabs(val_to_print)), suffix); /*Flawfinder: ignore*/
510 } 525 }
511 else 526 else
512 { 527 {
513 sprintf(val_string, "-%d", lltrunc(llabs(val_to_print))); 528 snprintf(val_string, sizeof(val_string), "-%d", lltrunc(llabs(val_to_print))); /*Flawfinder: ignore*/
514 } 529 }
515 } 530 }
516 else 531 else
517 { 532 {
518 if (fractional_portion == 0) 533 if (fractional_portion == 0)
519 { 534 {
520 sprintf(val_string, "%d%s", lltrunc(llabs(val_to_print)), suffix); 535 snprintf(val_string, sizeof(val_string), "%d%s", lltrunc(llabs(val_to_print)), suffix); /*Flawfinder: ignore*/
521 } 536 }
522 else 537 else
523 { 538 {
524 sprintf(val_string, "%d", lltrunc(val_to_print)); 539 snprintf(val_string, sizeof(val_string), "%d", lltrunc(val_to_print)); /*Flawfinder: ignore*/
525 } 540 }
526 } 541 }
527 542
528 BOOL hud_selection = gSelectMgr->getSelectType() == SELECT_TYPE_HUD; 543 BOOL hud_selection = mObjectSelection->getSelectType() == SELECT_TYPE_HUD;
529 glMatrixMode(GL_MODELVIEW); 544 glMatrixMode(GL_MODELVIEW);
530 glPushMatrix(); 545 glPushMatrix();
531 LLVector3 render_pos = pos; 546 LLVector3 render_pos = pos;
@@ -544,7 +559,7 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const char* suffi
544 LLGLEnable tex(GL_TEXTURE_2D); 559 LLGLEnable tex(GL_TEXTURE_2D);
545 if (fractional_portion != 0) 560 if (fractional_portion != 0)
546 { 561 {
547 sprintf(fraction_string, "%c%d%s", gResMgr->getDecimalPoint(), fractional_portion, suffix); 562 snprintf(fraction_string, sizeof(fraction_string), "%c%d%s", gResMgr->getDecimalPoint(), fractional_portion, suffix); /*Flawfinder: ignore*/
548 563
549 gViewerWindow->setupViewport(1, -1); 564 gViewerWindow->setupViewport(1, -1);
550 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection); 565 hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);