diff options
Diffstat (limited to 'indra/newview/lltoolselect.cpp')
-rw-r--r-- | indra/newview/lltoolselect.cpp | 137 |
1 files changed, 61 insertions, 76 deletions
diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 3f4c823d40..7c604a04bf 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -2,30 +2,25 @@ * @file lltoolselect.cpp * @brief LLToolSelect class implementation * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -34,6 +29,7 @@ #include "lltoolselect.h" #include "llagent.h" +#include "llagentcamera.h" #include "llviewercontrol.h" #include "lldrawable.h" #include "llmanip.h" @@ -47,17 +43,16 @@ #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "llviewerwindow.h" -#include "llvoavatar.h" +#include "llvoavatarself.h" #include "llworld.h" // Globals -LLToolSelect *gToolSelect = NULL; -extern BOOL gAllowSelectAvatar; +//extern BOOL gAllowSelectAvatar; const F32 SELECTION_ROTATION_TRESHOLD = 0.1f; LLToolSelect::LLToolSelect( LLToolComposite* composite ) -: LLTool( "Select", composite ), +: LLTool( std::string("Select"), composite ), mIgnoreGroup( FALSE ) { } @@ -65,62 +60,49 @@ LLToolSelect::LLToolSelect( LLToolComposite* composite ) // True if you selected an object. BOOL LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) { - BOOL handled = FALSE; - - // didn't click in any UI object, so must have clicked in the world - LLViewerObject* object = NULL; - - // You must hit the body for this tool to think you hit the object. - object = gObjectList.findObject( gLastHitObjectID ); - - if (object) - { - mSelectObjectID = object->getID(); - handled = TRUE; - } - else - { - mSelectObjectID.setNull(); - } + // do immediate pick query + mPick = gViewerWindow->pickImmediate(x, y, TRUE); // Pass mousedown to agent LLTool::handleMouseDown(x, y, mask); - return handled; + return mPick.getObject().notNull(); } -BOOL LLToolSelect::handleDoubleClick(S32 x, S32 y, MASK mask) -{ - //RN: double click to toggle individual/linked picking??? - return LLTool::handleDoubleClick(x, y, mask); -} // static -LLSafeHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObject *object, MASK mask, BOOL ignore_group, BOOL temp_select) +LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pick, BOOL ignore_group, BOOL temp_select, BOOL select_root) { + LLViewerObject* object = pick.getObject(); + if (select_root) + { + object = object->getRootEdit(); + } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); // *NOTE: These settings must be cleaned up at bottom of function. - if (temp_select || gAllowSelectAvatar) + if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); - gSelectMgr->setForceSelection(TRUE); + LLSelectMgr::getInstance()->setForceSelection(TRUE); } - BOOL extend_select = (mask == MASK_SHIFT) || (mask == MASK_CONTROL); + BOOL extend_select = (pick.mKeyMask == MASK_SHIFT) || (pick.mKeyMask == MASK_CONTROL); // If no object, check for icon, then just deselect if (!object) { - if (gLastHitHUDIcon && gLastHitHUDIcon->getSourceObject()) + LLHUDIcon* last_hit_hud_icon = pick.mHUDIcon; + + if (last_hit_hud_icon && last_hit_hud_icon->getSourceObject()) { - LLFloaterScriptDebug::show(gLastHitHUDIcon->getSourceObject()->getID()); + LLFloaterScriptDebug::show(last_hit_hud_icon->getSourceObject()->getID()); } else if (!extend_select) { - gSelectMgr->deselectAll(); + LLSelectMgr::getInstance()->deselectAll(); } } else @@ -133,22 +115,22 @@ LLSafeHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObje { if ( ignore_group ) { - gSelectMgr->deselectObjectOnly(object); + LLSelectMgr::getInstance()->deselectObjectOnly(object); } else { - gSelectMgr->deselectObjectAndFamily(object, TRUE, TRUE); + LLSelectMgr::getInstance()->deselectObjectAndFamily(object, TRUE, TRUE); } } else { if ( ignore_group ) { - gSelectMgr->selectObjectOnly(object, SELECT_ALL_TES); + LLSelectMgr::getInstance()->selectObjectOnly(object, SELECT_ALL_TES); } else { - gSelectMgr->selectObjectAndFamily(object); + LLSelectMgr::getInstance()->selectObjectAndFamily(object); } } } @@ -157,35 +139,35 @@ LLSafeHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObje // Save the current zoom values because deselect resets them. F32 target_zoom; F32 current_zoom; - gSelectMgr->getAgentHUDZoom(target_zoom, current_zoom); + LLSelectMgr::getInstance()->getAgentHUDZoom(target_zoom, current_zoom); // JC - Change behavior to make it easier to select children // of linked sets. 9/3/2002 if( !already_selected || ignore_group) { // ...lose current selection in favor of just this object - gSelectMgr->deselectAll(); + LLSelectMgr::getInstance()->deselectAll(); } if ( ignore_group ) { - gSelectMgr->selectObjectOnly(object, SELECT_ALL_TES); + LLSelectMgr::getInstance()->selectObjectOnly(object, SELECT_ALL_TES); } else { - gSelectMgr->selectObjectAndFamily(object); + LLSelectMgr::getInstance()->selectObjectAndFamily(object); } // restore the zoom to the previously stored values. - gSelectMgr->setAgentHUDZoom(target_zoom, current_zoom); + LLSelectMgr::getInstance()->setAgentHUDZoom(target_zoom, current_zoom); } - if (!gAgent.getFocusOnAvatar() && // if camera not glued to avatar - LLVOAvatar::findAvatarFromAttachment(object) != gAgent.getAvatarObject() && // and it's not one of your attachments - object != gAgent.getAvatarObject()) // and it's not you + if (!gAgentCamera.getFocusOnAvatar() && // if camera not glued to avatar + LLVOAvatar::findAvatarFromAttachment(object) != gAgentAvatarp && // and it's not one of your attachments + object != gAgentAvatarp) // and it's not you { // have avatar turn to face the selected object(s) - LLVector3d selection_center = gSelectMgr->getSelectionCenterGlobal(); + LLVector3d selection_center = LLSelectMgr::getInstance()->getSelectionCenterGlobal(); selection_center = selection_center - gAgent.getPositionGlobal(); LLVector3 selection_dir; selection_dir.setVec(selection_center); @@ -204,7 +186,7 @@ LLSafeHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObje if (!already_selected) { LLViewerObject* root_object = (LLViewerObject*)object->getRootEdit(); - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); // this is just a temporary selection LLSelectNode* select_node = selection->findNode(root_object); @@ -213,9 +195,12 @@ LLSafeHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObje select_node->setTransient(TRUE); } - for (S32 i = 0; i < (S32)root_object->mChildList.size(); i++) + LLViewerObject::const_child_list_t& child_list = root_object->getChildren(); + for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); + iter != child_list.end(); iter++) { - select_node = selection->findNode(root_object->mChildList[i]); + LLViewerObject* child = *iter; + select_node = selection->findNode(child); if (select_node) { select_node->setTransient(TRUE); @@ -227,22 +212,21 @@ LLSafeHandle<LLObjectSelection> LLToolSelect::handleObjectSelection(LLViewerObje } //if(!object) // Cleanup temp select settings above. - if (temp_select || gAllowSelectAvatar) + if (temp_select ||LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); - gSelectMgr->setForceSelection(FALSE); + LLSelectMgr::getInstance()->setForceSelection(FALSE); } - return gSelectMgr->getSelection(); + return LLSelectMgr::getInstance()->getSelection(); } BOOL LLToolSelect::handleMouseUp(S32 x, S32 y, MASK mask) { mIgnoreGroup = gSavedSettings.getBOOL("EditLinkedParts"); - LLViewerObject* object = gObjectList.findObject(mSelectObjectID); - LLToolSelect::handleObjectSelection(object, mask, mIgnoreGroup, FALSE); + handleObjectSelection(mPick, mIgnoreGroup, FALSE); return LLTool::handleMouseUp(x, y, mask); } @@ -268,7 +252,7 @@ void LLToolSelect::onMouseCaptureLost() { // Finish drag - gSelectMgr->enableSilhouette(TRUE); + LLSelectMgr::getInstance()->enableSilhouette(TRUE); // Clean up drag-specific variables mIgnoreGroup = FALSE; @@ -276,3 +260,4 @@ void LLToolSelect::onMouseCaptureLost() + |