diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-04-29 07:43:28 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-04-29 07:56:09 +0300 |
commit | 1b68f71348ecf3983b76b40d7940da8377f049b7 (patch) | |
tree | 2974eddaef130a067c26033d60a59fc790365b3d /indra/newview/lltoolfocus.cpp | |
parent | af4ea94efc1999f3b19fd8d643d0331f0b77e265 (diff) |
#824 Process source files in bulk: replace tabs with spaces, convert CRLF to LF, and trim trailing whitespaces as needed
Diffstat (limited to 'indra/newview/lltoolfocus.cpp')
-rw-r--r-- | indra/newview/lltoolfocus.cpp | 614 |
1 files changed, 307 insertions, 307 deletions
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp index 4e94895a3e..e34e0cce50 100644 --- a/indra/newview/lltoolfocus.cpp +++ b/indra/newview/lltoolfocus.cpp @@ -1,25 +1,25 @@ -/** +/** * @file lltoolfocus.cpp * @brief A tool to set the build focus point. * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -27,7 +27,7 @@ #include "llviewerprecompiledheaders.h" // File includes -#include "lltoolfocus.h" +#include "lltoolfocus.h" // Library includes #include "v3math.h" @@ -67,20 +67,20 @@ const S32 SLOP_RANGE = 4; // LLToolCamera::LLToolCamera() -: LLTool(std::string("Camera")), - mAccumX(0), - mAccumY(0), - mMouseDownX(0), - mMouseDownY(0), - mOutsideSlopX(FALSE), - mOutsideSlopY(FALSE), - mValidClickPoint(FALSE), +: LLTool(std::string("Camera")), + mAccumX(0), + mAccumY(0), + mMouseDownX(0), + mMouseDownY(0), + mOutsideSlopX(FALSE), + mOutsideSlopY(FALSE), + mValidClickPoint(FALSE), mClickPickPending(false), - mValidSelection(FALSE), - mMouseSteering(FALSE), - mMouseUpX(0), - mMouseUpY(0), - mMouseUpMask(MASK_NONE) + mValidSelection(FALSE), + mMouseSteering(FALSE), + mMouseUpX(0), + mMouseUpY(0), + mMouseUpMask(MASK_NONE) { } @@ -90,171 +90,171 @@ LLToolCamera::~LLToolCamera() // virtual void LLToolCamera::handleSelect() { - if (gFloaterTools) - { - gFloaterTools->setStatusText("camera"); - // in case we start from tools floater, we count any selection as valid - mValidSelection = gFloaterTools->getVisible(); - } + if (gFloaterTools) + { + gFloaterTools->setStatusText("camera"); + // in case we start from tools floater, we count any selection as valid + mValidSelection = gFloaterTools->getVisible(); + } } // virtual void LLToolCamera::handleDeselect() { -// gAgent.setLookingAtAvatar(FALSE); - - // Make sure that temporary selection won't pass anywhere except pie tool. - MASK override_mask = gKeyboard ? gKeyboard->currentMask(TRUE) : 0; - if (!mValidSelection && (override_mask != MASK_NONE || (gFloaterTools && gFloaterTools->getVisible()))) - { - LLMenuGL::sMenuContainer->hideMenus(); - LLSelectMgr::getInstance()->validateSelection(); - } +// gAgent.setLookingAtAvatar(FALSE); + + // Make sure that temporary selection won't pass anywhere except pie tool. + MASK override_mask = gKeyboard ? gKeyboard->currentMask(TRUE) : 0; + if (!mValidSelection && (override_mask != MASK_NONE || (gFloaterTools && gFloaterTools->getVisible()))) + { + LLMenuGL::sMenuContainer->hideMenus(); + LLSelectMgr::getInstance()->validateSelection(); + } } BOOL LLToolCamera::handleMouseDown(S32 x, S32 y, MASK mask) { - // Ensure a mouseup - setMouseCapture(TRUE); + // Ensure a mouseup + setMouseCapture(TRUE); - // call the base class to propogate info to sim - LLTool::handleMouseDown(x, y, mask); + // call the base class to propogate info to sim + LLTool::handleMouseDown(x, y, mask); - mAccumX = 0; - mAccumY = 0; + mAccumX = 0; + mAccumY = 0; - mOutsideSlopX = FALSE; - mOutsideSlopY = FALSE; + mOutsideSlopX = FALSE; + mOutsideSlopY = FALSE; - mValidClickPoint = FALSE; + mValidClickPoint = FALSE; // Sometimes Windows issues down and up events near simultaneously // without giving async pick a chance to trigged // Ex: mouse from numlock emulation mClickPickPending = true; - // If mouse capture gets ripped away, claim we moused up - // at the point we moused down. JC - mMouseUpX = x; - mMouseUpY = y; - mMouseUpMask = mask; + // If mouse capture gets ripped away, claim we moused up + // at the point we moused down. JC + mMouseUpX = x; + mMouseUpY = y; + mMouseUpMask = mask; - gViewerWindow->hideCursor(); + gViewerWindow->hideCursor(); - gViewerWindow->pickAsync(x, y, mask, pickCallback, /*BOOL pick_transparent*/ FALSE, /*BOOL pick_rigged*/ FALSE, /*BOOL pick_unselectable*/ TRUE); + gViewerWindow->pickAsync(x, y, mask, pickCallback, /*BOOL pick_transparent*/ FALSE, /*BOOL pick_rigged*/ FALSE, /*BOOL pick_unselectable*/ TRUE); - return TRUE; + return TRUE; } void LLToolCamera::pickCallback(const LLPickInfo& pick_info) { LLToolCamera* camera = LLToolCamera::getInstance(); - if (!camera->mClickPickPending) - { - return; - } + if (!camera->mClickPickPending) + { + return; + } camera->mClickPickPending = false; camera->mMouseDownX = pick_info.mMousePt.mX; camera->mMouseDownY = pick_info.mMousePt.mY; - gViewerWindow->moveCursorToCenter(); + gViewerWindow->moveCursorToCenter(); - // Potentially recenter if click outside rectangle - LLViewerObject* hit_obj = pick_info.getObject(); + // Potentially recenter if click outside rectangle + LLViewerObject* hit_obj = pick_info.getObject(); - // Check for hit the sky, or some other invalid point - if (!hit_obj && pick_info.mPosGlobal.isExactlyZero()) - { + // Check for hit the sky, or some other invalid point + if (!hit_obj && pick_info.mPosGlobal.isExactlyZero()) + { camera->mValidClickPoint = FALSE; - return; - } - - // check for hud attachments - if (hit_obj && hit_obj->isHUDAttachment()) - { - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (!selection->getObjectCount() || selection->getSelectType() != SELECT_TYPE_HUD) - { + return; + } + + // check for hud attachments + if (hit_obj && hit_obj->isHUDAttachment()) + { + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + if (!selection->getObjectCount() || selection->getSelectType() != SELECT_TYPE_HUD) + { camera->mValidClickPoint = FALSE; - return; - } - } - - if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() ) - { - BOOL good_customize_avatar_hit = FALSE; - if( hit_obj ) - { - if (isAgentAvatarValid() && (hit_obj == gAgentAvatarp)) - { - // It's you - good_customize_avatar_hit = TRUE; - } - else if (hit_obj->isAttachment() && hit_obj->permYouOwner()) - { - // It's an attachment that you're wearing - good_customize_avatar_hit = TRUE; - } - } - - if( !good_customize_avatar_hit ) - { + return; + } + } + + if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() ) + { + BOOL good_customize_avatar_hit = FALSE; + if( hit_obj ) + { + if (isAgentAvatarValid() && (hit_obj == gAgentAvatarp)) + { + // It's you + good_customize_avatar_hit = TRUE; + } + else if (hit_obj->isAttachment() && hit_obj->permYouOwner()) + { + // It's an attachment that you're wearing + good_customize_avatar_hit = TRUE; + } + } + + if( !good_customize_avatar_hit ) + { camera->mValidClickPoint = FALSE; - return; - } - - if( gMorphView ) - { - gMorphView->setCameraDrivenByKeys( FALSE ); - } - } - //RN: check to see if this is mouse-driving as opposed to ALT-zoom or Focus tool - else if (pick_info.mKeyMask & MASK_ALT || - (LLToolMgr::getInstance()->getCurrentTool()->getName() == "Camera")) - { - LLViewerObject* hit_obj = pick_info.getObject(); - if (hit_obj) - { - // ...clicked on a world object, so focus at its position - if (!hit_obj->isHUDAttachment()) - { - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - gAgentCamera.setFocusGlobal(pick_info); - } - } - else if (!pick_info.mPosGlobal.isExactlyZero()) - { - // Hit the ground - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - gAgentCamera.setFocusGlobal(pick_info); - } - - BOOL zoom_tool = gCameraBtnZoom && (LLToolMgr::getInstance()->getBaseTool() == LLToolCamera::getInstance()); - if (!(pick_info.mKeyMask & MASK_ALT) && - !LLFloaterCamera::inFreeCameraMode() && - !zoom_tool && - gAgentCamera.cameraThirdPerson() && - gViewerWindow->getLeftMouseDown() && - !gSavedSettings.getBOOL("FreezeTime") && - (hit_obj == gAgentAvatarp || - (hit_obj && hit_obj->isAttachment() && LLVOAvatar::findAvatarFromAttachment(hit_obj)->isSelf()))) - { - LLToolCamera::getInstance()->mMouseSteering = TRUE; - } - - } + return; + } + + if( gMorphView ) + { + gMorphView->setCameraDrivenByKeys( FALSE ); + } + } + //RN: check to see if this is mouse-driving as opposed to ALT-zoom or Focus tool + else if (pick_info.mKeyMask & MASK_ALT || + (LLToolMgr::getInstance()->getCurrentTool()->getName() == "Camera")) + { + LLViewerObject* hit_obj = pick_info.getObject(); + if (hit_obj) + { + // ...clicked on a world object, so focus at its position + if (!hit_obj->isHUDAttachment()) + { + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(pick_info); + } + } + else if (!pick_info.mPosGlobal.isExactlyZero()) + { + // Hit the ground + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(pick_info); + } + + BOOL zoom_tool = gCameraBtnZoom && (LLToolMgr::getInstance()->getBaseTool() == LLToolCamera::getInstance()); + if (!(pick_info.mKeyMask & MASK_ALT) && + !LLFloaterCamera::inFreeCameraMode() && + !zoom_tool && + gAgentCamera.cameraThirdPerson() && + gViewerWindow->getLeftMouseDown() && + !gSavedSettings.getBOOL("FreezeTime") && + (hit_obj == gAgentAvatarp || + (hit_obj && hit_obj->isAttachment() && LLVOAvatar::findAvatarFromAttachment(hit_obj)->isSelf()))) + { + LLToolCamera::getInstance()->mMouseSteering = TRUE; + } + + } camera->mValidClickPoint = TRUE; - if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() ) - { - gAgentCamera.setFocusOnAvatar(FALSE, FALSE); - - LLVector3d cam_pos = gAgentCamera.getCameraPositionGlobal(); + if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() ) + { + gAgentCamera.setFocusOnAvatar(FALSE, FALSE); - gAgentCamera.setCameraPosAndFocusGlobal( cam_pos, pick_info.mPosGlobal, pick_info.mObjectID); - } + LLVector3d cam_pos = gAgentCamera.getCameraPositionGlobal(); + + gAgentCamera.setCameraPosAndFocusGlobal( cam_pos, pick_info.mPosGlobal, pick_info.mObjectID); + } } @@ -263,35 +263,35 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info) // if a modal dialog pops up during Alt-Zoom. JC void LLToolCamera::releaseMouse() { - // Need to tell the sim that the mouse button is up, since this - // tool is no longer working and cursor is visible (despite actual - // mouse button status). - LLTool::handleMouseUp(mMouseUpX, mMouseUpY, mMouseUpMask); - - gViewerWindow->showCursor(); - - //for the situation when left click was performed on the Agent - if (!LLFloaterCamera::inFreeCameraMode()) - { - LLToolMgr::getInstance()->clearTransientTool(); - } - - mMouseSteering = FALSE; - mValidClickPoint = FALSE; - mOutsideSlopX = FALSE; - mOutsideSlopY = FALSE; + // Need to tell the sim that the mouse button is up, since this + // tool is no longer working and cursor is visible (despite actual + // mouse button status). + LLTool::handleMouseUp(mMouseUpX, mMouseUpY, mMouseUpMask); + + gViewerWindow->showCursor(); + + //for the situation when left click was performed on the Agent + if (!LLFloaterCamera::inFreeCameraMode()) + { + LLToolMgr::getInstance()->clearTransientTool(); + } + + mMouseSteering = FALSE; + mValidClickPoint = FALSE; + mOutsideSlopX = FALSE; + mOutsideSlopY = FALSE; } BOOL LLToolCamera::handleMouseUp(S32 x, S32 y, MASK mask) { - // Claim that we're mousing up somewhere - mMouseUpX = x; - mMouseUpY = y; - mMouseUpMask = mask; + // Claim that we're mousing up somewhere + mMouseUpX = x; + mMouseUpY = y; + mMouseUpMask = mask; - if (hasMouseCapture()) - { + if (hasMouseCapture()) + { // Do not move camera if we haven't gotten a pick if (!mClickPickPending) { @@ -323,156 +323,156 @@ BOOL LLToolCamera::handleMouseUp(S32 x, S32 y, MASK mask) } } - // calls releaseMouse() internally - setMouseCapture(FALSE); - } - else - { - releaseMouse(); - } + // calls releaseMouse() internally + setMouseCapture(FALSE); + } + else + { + releaseMouse(); + } - return TRUE; + return TRUE; } BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask) { - S32 dx = gViewerWindow->getCurrentMouseDX(); - S32 dy = gViewerWindow->getCurrentMouseDY(); - - if (hasMouseCapture() && mValidClickPoint) - { - mAccumX += llabs(dx); - mAccumY += llabs(dy); - - if (mAccumX >= SLOP_RANGE) - { - mOutsideSlopX = TRUE; - } - - if (mAccumY >= SLOP_RANGE) - { - mOutsideSlopY = TRUE; - } - } - - if (mOutsideSlopX || mOutsideSlopY) - { - if (!mValidClickPoint) - { - LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [invalid point]" << LL_ENDL; - gViewerWindow->setCursor(UI_CURSOR_NO); - gViewerWindow->showCursor(); - return TRUE; - } - - if (gCameraBtnOrbit || - mask == MASK_ORBIT || - mask == (MASK_ALT | MASK_ORBIT)) - { - // Orbit tool - if (hasMouseCapture()) - { - const F32 RADIANS_PER_PIXEL = 360.f * DEG_TO_RAD / gViewerWindow->getWorldViewWidthScaled(); - - if (dx != 0) - { - gAgentCamera.cameraOrbitAround( -dx * RADIANS_PER_PIXEL ); - } - - if (dy != 0) - { - gAgentCamera.cameraOrbitOver( -dy * RADIANS_PER_PIXEL ); - } - - gViewerWindow->moveCursorToCenter(); - } - LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [active]" << LL_ENDL; - } - else if ( gCameraBtnPan || - mask == MASK_PAN || - mask == (MASK_PAN | MASK_ALT) ) - { - // Pan tool - if (hasMouseCapture()) - { - LLVector3d camera_to_focus = gAgentCamera.getCameraPositionGlobal(); - camera_to_focus -= gAgentCamera.getFocusGlobal(); - F32 dist = (F32) camera_to_focus.normVec(); - - // Fudge factor for pan - F32 meters_per_pixel = 3.f * dist / gViewerWindow->getWorldViewWidthScaled(); - - if (dx != 0) - { - gAgentCamera.cameraPanLeft( dx * meters_per_pixel ); - } - - if (dy != 0) - { - gAgentCamera.cameraPanUp( -dy * meters_per_pixel ); - } - - gViewerWindow->moveCursorToCenter(); - } - LL_DEBUGS("UserInput") << "hover handled by LLToolPan" << LL_ENDL; - } - else if (gCameraBtnZoom) - { - // Zoom tool - if (hasMouseCapture()) - { - - const F32 RADIANS_PER_PIXEL = 360.f * DEG_TO_RAD / gViewerWindow->getWorldViewWidthScaled(); - - if (dx != 0) - { - gAgentCamera.cameraOrbitAround( -dx * RADIANS_PER_PIXEL ); - } - - const F32 IN_FACTOR = 0.99f; - - if (dy != 0 && mOutsideSlopY ) - { - if (mMouseSteering) - { - gAgentCamera.cameraOrbitOver( -dy * RADIANS_PER_PIXEL ); - } - else - { - gAgentCamera.cameraZoomIn( pow( IN_FACTOR, dy ) ); - } - } - - gViewerWindow->moveCursorToCenter(); - } - - LL_DEBUGS("UserInput") << "hover handled by LLToolZoom" << LL_ENDL; - } - } - - if (gCameraBtnOrbit || - mask == MASK_ORBIT || - mask == (MASK_ALT | MASK_ORBIT)) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA); - } - else if ( gCameraBtnPan || - mask == MASK_PAN || - mask == (MASK_PAN | MASK_ALT) ) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPAN); - } - else - { - gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN); - } - - return TRUE; + S32 dx = gViewerWindow->getCurrentMouseDX(); + S32 dy = gViewerWindow->getCurrentMouseDY(); + + if (hasMouseCapture() && mValidClickPoint) + { + mAccumX += llabs(dx); + mAccumY += llabs(dy); + + if (mAccumX >= SLOP_RANGE) + { + mOutsideSlopX = TRUE; + } + + if (mAccumY >= SLOP_RANGE) + { + mOutsideSlopY = TRUE; + } + } + + if (mOutsideSlopX || mOutsideSlopY) + { + if (!mValidClickPoint) + { + LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [invalid point]" << LL_ENDL; + gViewerWindow->setCursor(UI_CURSOR_NO); + gViewerWindow->showCursor(); + return TRUE; + } + + if (gCameraBtnOrbit || + mask == MASK_ORBIT || + mask == (MASK_ALT | MASK_ORBIT)) + { + // Orbit tool + if (hasMouseCapture()) + { + const F32 RADIANS_PER_PIXEL = 360.f * DEG_TO_RAD / gViewerWindow->getWorldViewWidthScaled(); + + if (dx != 0) + { + gAgentCamera.cameraOrbitAround( -dx * RADIANS_PER_PIXEL ); + } + + if (dy != 0) + { + gAgentCamera.cameraOrbitOver( -dy * RADIANS_PER_PIXEL ); + } + + gViewerWindow->moveCursorToCenter(); + } + LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [active]" << LL_ENDL; + } + else if ( gCameraBtnPan || + mask == MASK_PAN || + mask == (MASK_PAN | MASK_ALT) ) + { + // Pan tool + if (hasMouseCapture()) + { + LLVector3d camera_to_focus = gAgentCamera.getCameraPositionGlobal(); + camera_to_focus -= gAgentCamera.getFocusGlobal(); + F32 dist = (F32) camera_to_focus.normVec(); + + // Fudge factor for pan + F32 meters_per_pixel = 3.f * dist / gViewerWindow->getWorldViewWidthScaled(); + + if (dx != 0) + { + gAgentCamera.cameraPanLeft( dx * meters_per_pixel ); + } + + if (dy != 0) + { + gAgentCamera.cameraPanUp( -dy * meters_per_pixel ); + } + + gViewerWindow->moveCursorToCenter(); + } + LL_DEBUGS("UserInput") << "hover handled by LLToolPan" << LL_ENDL; + } + else if (gCameraBtnZoom) + { + // Zoom tool + if (hasMouseCapture()) + { + + const F32 RADIANS_PER_PIXEL = 360.f * DEG_TO_RAD / gViewerWindow->getWorldViewWidthScaled(); + + if (dx != 0) + { + gAgentCamera.cameraOrbitAround( -dx * RADIANS_PER_PIXEL ); + } + + const F32 IN_FACTOR = 0.99f; + + if (dy != 0 && mOutsideSlopY ) + { + if (mMouseSteering) + { + gAgentCamera.cameraOrbitOver( -dy * RADIANS_PER_PIXEL ); + } + else + { + gAgentCamera.cameraZoomIn( pow( IN_FACTOR, dy ) ); + } + } + + gViewerWindow->moveCursorToCenter(); + } + + LL_DEBUGS("UserInput") << "hover handled by LLToolZoom" << LL_ENDL; + } + } + + if (gCameraBtnOrbit || + mask == MASK_ORBIT || + mask == (MASK_ALT | MASK_ORBIT)) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA); + } + else if ( gCameraBtnPan || + mask == MASK_PAN || + mask == (MASK_PAN | MASK_ALT) ) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPAN); + } + else + { + gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN); + } + + return TRUE; } void LLToolCamera::onMouseCaptureLost() { - releaseMouse(); + releaseMouse(); } |