aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolselect.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolselect.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltoolselect.cpp263
1 files changed, 263 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolselect.cpp b/linden/indra/newview/lltoolselect.cpp
new file mode 100644
index 0000000..a557136
--- /dev/null
+++ b/linden/indra/newview/lltoolselect.cpp
@@ -0,0 +1,263 @@
1/**
2 * @file lltoolselect.cpp
3 * @brief LLToolSelect class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "lltoolselect.h"
31
32#include "llagent.h"
33#include "llviewercontrol.h"
34#include "lldrawable.h"
35#include "llmanip.h"
36#include "llmenugl.h"
37#include "llselectmgr.h"
38#include "lltoolmgr.h"
39#include "llfloaterscriptdebug.h"
40#include "llviewercamera.h"
41#include "llviewermenu.h"
42#include "llviewerobject.h"
43#include "llviewerobjectlist.h"
44#include "llviewerregion.h"
45#include "llviewerwindow.h"
46#include "llvoavatar.h"
47#include "llworld.h"
48#include "viewer.h" // for gFPSClamped, pie menus
49
50// Globals
51LLToolSelect *gToolSelect = NULL;
52extern BOOL gAllowSelectAvatar;
53
54const F32 SELECTION_ROTATION_TRESHOLD = 0.1f;
55
56LLToolSelect::LLToolSelect( LLToolComposite* composite )
57: LLTool( "Select", composite ),
58 mIgnoreGroup( FALSE )
59{
60 }
61
62// True if you selected an object.
63BOOL LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask)
64{
65 BOOL handled = FALSE;
66
67 // didn't click in any UI object, so must have clicked in the world
68 LLViewerObject* object = NULL;
69
70 // You must hit the body for this tool to think you hit the object.
71 object = gObjectList.findObject( gLastHitObjectID );
72
73 if (object)
74 {
75 mSelectObjectID = object->getID();
76 handled = TRUE;
77 }
78 else
79 {
80 mSelectObjectID.setNull();
81 }
82
83 // Pass mousedown to agent
84 LLTool::handleMouseDown(x, y, mask);
85
86 return handled;
87}
88
89BOOL LLToolSelect::handleDoubleClick(S32 x, S32 y, MASK mask)
90{
91 //RN: double click to toggle individual/linked picking???
92 return LLTool::handleDoubleClick(x, y, mask);
93}
94
95// static
96void LLToolSelect::handleObjectSelection(LLViewerObject *object, MASK mask, BOOL ignore_group, BOOL temp_select)
97{
98 BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly");
99 BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly");
100
101 // *NOTE: These settings must be cleaned up at bottom of function.
102 if (temp_select || gAllowSelectAvatar)
103 {
104 gSavedSettings.setBOOL("SelectOwnedOnly", FALSE);
105 gSavedSettings.setBOOL("SelectMovableOnly", FALSE);
106 gSelectMgr->setForceSelection(TRUE);
107 }
108
109 BOOL extend_select = (mask == MASK_SHIFT) || (mask == MASK_CONTROL);
110
111 // If no object, check for icon, then just deselect
112 if (!object)
113 {
114 if (gLastHitHUDIcon && gLastHitHUDIcon->getSourceObject())
115 {
116 LLFloaterScriptDebug::show(gLastHitHUDIcon->getSourceObject()->getID());
117 }
118 else if (!extend_select)
119 {
120 gSelectMgr->deselectAll();
121 }
122 }
123 else
124 {
125 BOOL already_selected = object->isSelected();
126
127 if ( extend_select )
128 {
129 if ( already_selected )
130 {
131 if ( ignore_group )
132 {
133 gSelectMgr->deselectObjectOnly(object);
134 }
135 else
136 {
137 gSelectMgr->deselectObjectAndFamily(object);
138 }
139 }
140 else
141 {
142 if ( ignore_group )
143 {
144 gSelectMgr->selectObjectOnly(object, SELECT_ALL_TES);
145 }
146 else
147 {
148 gSelectMgr->selectObjectAndFamily(object);
149 }
150 }
151 }
152 else
153 {
154 // JC - Change behavior to make it easier to select children
155 // of linked sets. 9/3/2002
156 if( !already_selected || ignore_group)
157 {
158 // ...lose current selection in favor of just this object
159 gSelectMgr->deselectAll();
160 }
161
162 if ( ignore_group )
163 {
164 gSelectMgr->selectObjectOnly(object, SELECT_ALL_TES);
165 }
166 else
167 {
168 gSelectMgr->selectObjectAndFamily(object);
169 }
170 }
171
172 if (!gAgent.getFocusOnAvatar() && // if camera not glued to avatar
173 LLVOAvatar::findAvatarFromAttachment(object) != gAgent.getAvatarObject() && // and it's not one of your attachments
174 object != gAgent.getAvatarObject()) // and it's not you
175 {
176 // have avatar turn to face the selected object(s)
177 LLVector3d selection_center = gSelectMgr->getSelectionCenterGlobal();
178 selection_center = selection_center - gAgent.getPositionGlobal();
179 LLVector3 selection_dir;
180 selection_dir.setVec(selection_center);
181 selection_dir.mV[VZ] = 0.f;
182 selection_dir.normVec();
183 if (!object->isAvatar() && gAgent.getAtAxis() * selection_dir < 0.6f)
184 {
185 LLQuaternion target_rot;
186 target_rot.shortestArc(LLVector3::x_axis, selection_dir);
187 gAgent.startAutoPilotGlobal(gAgent.getPositionGlobal(), "", &target_rot, NULL, NULL, 1.f, SELECTION_ROTATION_TRESHOLD);
188 }
189 }
190
191 if (temp_select)
192 {
193 if (!already_selected)
194 {
195 LLViewerObject* root_object = (LLViewerObject*)object->getRootEdit();
196
197 // this is just a temporary selection
198 LLSelectNode* select_node = gSelectMgr->findSelectNode(root_object);
199 if (select_node)
200 {
201 select_node->setTransient(TRUE);
202 }
203
204 for (S32 i = 0; i < (S32)root_object->mChildList.size(); i++)
205 {
206 select_node = gSelectMgr->findSelectNode(root_object->mChildList[i]);
207 if (select_node)
208 {
209 select_node->setTransient(TRUE);
210 }
211 }
212
213 }
214 } //if(temp_select)
215 } //if(!object)
216
217 // Cleanup temp select settings above.
218 if (temp_select || gAllowSelectAvatar)
219 {
220 gSavedSettings.setBOOL("SelectOwnedOnly", select_owned);
221 gSavedSettings.setBOOL("SelectMovableOnly", select_movable);
222 gSelectMgr->setForceSelection(FALSE);
223 }
224}
225
226BOOL LLToolSelect::handleMouseUp(S32 x, S32 y, MASK mask)
227{
228 mIgnoreGroup = !gSavedSettings.getBOOL("SelectLinkedSet");
229
230 LLViewerObject* object = gObjectList.findObject(mSelectObjectID);
231 LLToolSelect::handleObjectSelection(object, mask, mIgnoreGroup, FALSE);
232
233 return LLTool::handleMouseUp(x, y, mask);
234}
235
236void LLToolSelect::handleDeselect()
237{
238 if( hasMouseCapture() )
239 {
240 setMouseCapture( FALSE ); // Calls onMouseCaptureLost() indirectly
241 }
242}
243
244
245void LLToolSelect::stopEditing()
246{
247 if( hasMouseCapture() )
248 {
249 setMouseCapture( FALSE ); // Calls onMouseCaptureLost() indirectly
250 }
251}
252
253void LLToolSelect::onMouseCaptureLost()
254{
255 // Finish drag
256
257 gSelectMgr->enableSilhouette(TRUE);
258
259 // Clean up drag-specific variables
260 mIgnoreGroup = FALSE;
261}
262
263